What is the data type of x?
x = 3
int, integer
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 library to import for math functions in python
math
import math
n = 5
print ('n')
n
What is the data type of num?
num = "five"
str, string
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 is the math function for finding the absolute value of a number
math.fabs()
something = input("enter something: ")
x = something * 2
print("you entered " + x)
#user inputs 10
1010
What is the line of code to convert doorNo to an integer named x
doorNo = "5"
x = int(doorNo)
n = 5+2/2
print(n)
6
#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 to find the square root of a number
math.sqrt()
x = 3.6
y = x/2
print (y)
1.8
what is type casting?
converting from one data type to another
eg.
int(3.14)
str(2)
import math
f = math.sqrt(25)
print (f)
5.0
#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 for for random number functions
import random
name = "ben"
class ="python"
print("name" + " is in my " + class + " class")
name is in my python class
What data type does the input() command return
string
Always a string
import math
n = -4
n = n * n
n = math.fabs(n)
print(n)
16.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 acceptable
0 is inclusive, 1 is not inclusive
print("this is a poem\nit has many lines/nlike these")
this is a poem
it has many lines/nlike these