What is the output of: 11.0//2 - Answers 5.0
Floor division to the nearest whole number
Returns a float
What is the output of: 11//2 - Answers 5
Return an int
What is the output of: 11/2 - Answers 5.5
Returns a float
What is the output of: 11/2.0 - Answers 5.0
What is the output of: 20%2 - Answers 0
What is the output of: 21%2 - Answers 1
What is the output of: 11%3 - Answers 2
x = 'Texas A&M University'
x [-3] = ? - Answers i
x = 'Texas A&M University'
x [3] = ? - Answers a
x = 'Texas A&M University'
len(x) = ? - Answers 20
x = 'Texas A&M University'
x [0:5:2] = ? - Answers Txs
It starts at 0 and ends at 5, incremented by 2
x = 'Texas A&M University'
x [4:] = ? - Answers s A&M University
x = 'Texas A&M University'
x [:4] = ? - Answers Texa
,x = 'Texas A&M University'
'A' in x = ? - Answers True
Acts as a Boolean, determines if it is in the string
x = 'Texas A&M University'
't' in x = ? - Answers True
x = 'Texas A&M University'
'A&M' in x = ? - Answers True
x = 'Texas A&M University'
' ' in x = ? - Answers True
x = 'Texas A&M University'
' ' in x = ? - Answers False
2**1+1 - Answers 3
3* 1**3 - Answers 3
2*(3+1) - Answers 4
6+4/2 - Answers 8.0
Returns a float due to the division
len('Hello world') = ? - Answers 11
Be sure to count the spaces as values
int(-2.3) = ? - Answers -2
float(32) = ? - Answers 32.0
str(3.14159) = ? - Answers 3.14159
[0] * 4 = ? - Answers [0, 0, 0, 0]
[1, 2, 3] * 3 = ? - Answers [ 1, 2, 3, 1, 2, 3, 1, 2, 3]
x=1
y=0
, x >= 2 and (x/y) >2 = ? - Answers False
x=6
y=2
x >= 2 and (x/y) >2 = ? - Answers True
x=1
y=0
x >= 2 and y != 0 and (x/y) >2 = ? - Answers False
What is the purpose of the "def" keyword in Python? - Answers It indicates that start of a function
It indicates that the follow indented section of code id to be stored for later
What will the following Python program print out?
def fred():
-> print ("Zap")
def jane():
-> print ("ABC")
jane()
fred()
jane() - Answers ABC Zap ABC
What will the following Python program print out?
count = 0
for number in [3, 41, 12, 9, 74, 15]:
-> count = count + 1