Given that:
a=True b=True c=True d=True
Evaluate:
a and (not b) = ?
true and (not true)
= true and false
= false
x = int( 5 + 3.14)
print(x)
8
#Find the syntax error
num = 5
print("The number is: " str(num))
num = 5
print("The number is: " + str(num))
What is the math function to find the square root of a number
math.sqrt()
word = "Hi"
if word == "hi":
print ("Hi")
else:
print("Bye")
Bye
Given that:
a=True b=True c=True d=True
Evaluate:
not(a and b )
not (true and true)
= false
first = "Nothing"
last = "None"
name = first + "last"
print(name)
Nothinglast
#Find the logical error
bat = 5
#Print the value of bat after the prompt
print("value of bat: + bat")
bat = 5
print("value of bat: " + bat)
What data type does the input() command return?
String
Always a string
n = 5
if n >=10:
print ("yes")
elif n >=5:
print("maybe")
else:
print("no")
maybe
Given that:
a=True b=True c=True d=True
Evaluate:
(not a and not b) or (c)
(not true and not true) or true
= false or true
= true
n = 5 + 2 / 2
print(n)
6.0
(6 is acceptable)
#Find the syntax error
x= integer(5.2)
y = x+ 5.2
x= int(5.2)
y = x+ 5.2
What is the math function in the math library for finding the absolute value of a number
math.fabs()
x = 10
if x % 10:
print ("yes")
else:
print("no")
no
(10%10 = 0, and if 0 is false)
Given that:
a = 15 b = 20 c = -1 d = 0
Evaluate:
(not (c < 0)) and (not(c>a))
not(true) and not(false)
= false and true
=false
n = 8 * 8 / 2 + 3 - 2
33
#Find the syntax error
x = input(enter a decimal)
y = x+5
print("y")
x = input("enter a decimal")
y = x+5
print("y")
What is the library you need to import for random number functions?
import random
num = 7
if num < 10:
print("hi")
elif num < 8:
print("hello")
else:
print("bye")
hi
Given that:
a = 15 b = 20 c = -1 d = 0
Evaluate:
(c * d) >= (b * c)
0 >= -20
true
n = 51 % 3 * 10
0
#Find the syntax error
import math
n = maths.sqrt(16)
print("n")
import math
n = math.sqrt(16)
print("n")
random.random() generates a random number between ? and ?
0.0 and 1.0
(0 and 1 is an acceptable answer)
(0 inclusive, 1 not inclusive)
fav = 15
if fav < 20:
print("less")
elif fav == 15:
print("equal")
else:
print("nothing to say")
less