Do you have to initialize variables in Python?
YES
What is the difference between the following lines:
x = 8 and x == 8
x = 8 assigns the variable to the number 8
x == 8 tests for equality
What are the two types of loops you learned? What's the difference between them?
For and While
What does the append method do in a list?
Adds new value to the end of the list
What is the NC State mascot?
Wolfpack!
True or False, this program will return PYTHON:
text = "Python"
text.upper()
print(text)
False
num % 2 checks if num is ______
EVEN
What is the term for the process of finding and resolving bugs in a program
Debugging
The process of outputting a substring from a string is called string _____.
If text = "string", how could you output the substring "ring"?
String slicing
text[2:]
What is our motto?
"Think and Do."
Initialize a variable named var that holds the number 10; then convert var to a string type.
var = 10
var = str(var)
What is the output of the following code:
x = 10
if x < 5:
print("x is greater than 5")
else:
pass
Nothing
What is the output of the following:
print(range(10))
range(0,10)
What is the output of the following:
list = [4, 5, 8, 2, 6, 9]
other = [3, 3, 3]
list.append(11)
other.insert(1, 3)
list.extend(other)
print(list)
[4, 5, 8, 2, 6, 9, 11, 3, 3, 3, 3]
How far did our men's basketball team get this past year in the NCAA?
Final Four
What is the output of the following:
x, y = 5, 8
x, y = y + 1, x
print(x)
print(y)
9
5
What is the output of the following:
height = 2.3
rain = true
time = 2
if (rain and (time > 1)):
print(height + 0.2)
else:
print("no plant growth!")
2.5
How many times will the loop run:
count = 0
for i in range(10):
if i % 2 == 0:
count += 1
if count == 3:
break
print("Loop ran", i + 1, "times.")
5 times
What is the name of NCSU's official dairy farm/ice cream brand?
Howling Cow
What is the output:
# what is this type of variable called:
a = 3
def function():
# what is this type of variable called:
a = 5
print(a)
function()
print(a)
5
3
#global
#local
Write a program to check if the given sides of a triangle is equilateral, isosceles or scalene.
x = int(input("x: "))
y = int(input("y: "))
z = int(input("z: "))
if x == y == z:
print("Equilateral triangle")
elif x == y or y == z or z == x:
print("Isosceles triangle")
else:
print("Scalene triangle")
for x in range(6):
if x == 3: break
print(x)
else:
print("Finally finished!")
0
1
2
James Goodnight is one of NCSU's most famous alumnus and is the CEO/founder of a well-known software company named _______.
SAS