What is the difference between "=" and "=="
"=" is assignment
"==" is relational/comparison
If statement used when checking conditions sequentially
if-elif-else
When would you use a FOR LOOP
when you have a known number of iterations
Convert 5.8 to a integer
int(5.8) = 5
What list operator is used to convert a list to a string with "," as a separator
",".join(list)
What is the correct order of operations for relation and boolean operators
Relational
not
and
or
What kind of if statement is this:
if citizenship == True:
if age >= 18:
print("You are eligible to vote")
Nested if
What does "break" do
immediately stops the loop it is in
Is there an error? If so, where?
The error of the code:
(int("73.5") - float("2")) * 5
int("73.5")
Step size
Value of a in:
a = 3 b = 2 c = 7
a += c
a *= b
a = a**3
8000
Is there an error? If not, what is the output:
x = 0
if x = 5:
print("Five")
Error "x=5" needs to be "x==5"
What is the output:
i = 0
while i < 10:
print(i*2)
Infinite Loop
Would this result in an error? If no, what is the result?
mystring = "hi"
print(bool(mystring))
output: True
What is the output of:
mylist = [100,32,43,25,1,82]
num = mylist.pop(3)
print(num*4)
100
Convert this interval notation to python code:
if x is in ( - infinity, 10] U [30 , 50)
if (x <= 10) or (x>= 30 and x<50)
Output of:
a = 15
if not(a != 30 or a>15):
print("True")
else:
print("False")
False
What is the output:
for i in range(1,5,2):
value = i**2
print(value)
1
9
Output of:
(float("3.2") + int("4")) / 2
"3.6"
What is the output of this code:
newlist = ["a","b","c","d","e","f"]
newlist[1:5]=["x","y"]
print(newlist)
['a', 'x', 'y', 'f']
What is the output of this code
a = 1
b = 3
c = 5
math = int(c // 5 ** b - a * 0.5)
print(math)
0
predict the output:
GPA = 3.5
credit = 18
if GPA >=2.0:
standing = "In Good Standing"
if GPA >= 3.5 and credit >= 12:
standing = "Dean's List"
if GPA >= 3.9 and credit >= 15:
standing = "President's List"
print(standing
Dean's list
How many times does this loop run
count = 0
for i in range(5):
for j in range(i):
count += 1
print(count)
10
What is the output:
from math import*
number = float(bool("True")+15/3*e**(bool()))
print(number)
6.0
What is the output of this code
list1 = [0,1,2,3,4,5]
list2 = [6,7,8,9,10]
for i in range(len(list2)):
list1.append(list2[i])
print(list1)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]