NEW
Font size
WorksheetsPython Quiz
Total questions: 16
Worksheet time: 8mins
What would be printed by the command
print('12-5')
12-5
'12-5'
7
'7'
Which of the operators do we use if we want at least one condition to be true?
and
or
else
not
print(Hello world!)
What will be the output of the following statement?
type('5')
str
int
float
Boolean
Which one is NOT a legal variable name?
my_var
myvar
_myvar
my-var
How do you create a variable with the numeric value 5?
Both are correct
x=5
x=int(5)
a = "Good Morning!"
print(len(a))
13
12
11
14
What is the purpose of the input() function in Python?
To take input from the user
To convert an object into a string
To print a message on the screen
To add a string at the end of the output
What is the output of print(5 + 2) in Python?
A. 52
B. 7
C. "5 + 2"
D. Error
What is the correct way to declare a variable in Python?
A) int x = 10
B) x := 10
C) var x = 10
D) x = 10
Which of the following is the correct way to start a for loop in Python?
A) for(int i=0; i<5; i++)
B) for i in range(5):
C) for(i=0; i<5; i++):
D) for i < 5:
How do you create a list in Python?
A) list = list(1, 2, 3, 4, 5)
B) list = [1, 2, 3, 4, 5]
C) list = (1, 2, 3, 4, 5)
D) list = {1, 2, 3, 4, 5}
Which of the following is used to define a block of code in Python?
A) Curly braces { }
B) Keywords begin and end
C) Indentation
D) Parentheses ( )
What will be the output of the following code?
x = ["apple", "banana", "cherry"]
x.append("orange")
print(x)
x = ["apple", "banana", "cherry"]
x.append("orange")
print(x)
B) ["orange", "apple", "banana", "cherry"]
C) ["apple", "orange", "banana", "cherry"]
C) ["apple", "orange", "banana", "cherry"]
Which method is used to remove the last item from a list?
A) pop()
B) push()
C) delete()
D) remove()
How do you create a variable with the floating number 2.8?
x=2.8
x=float(2.8)
both are correct
