Font size
WorksheetsPython Quiz
Total questions: 62
Worksheet time: 31mins
What does the following code do? myAge = int (myAge)
Converts the var (variable) myAge to a string
Converts the var (variable) myAge to a integer
Converts the var (variable) myAge from a integer to a string
Converts the var (variable) myAge to if statement
people = ["John", "Rob", "Bob"]
print (people[4])
what would this result be?
people = ["John", "Rob", "Bob"]
print (people[-1])
what would this result be?
What output will the console show, if 15 and 30 are entered by the user?
Syntax error
The sum of the two numbers - 45
The concatenation of the two numbers - 1530
Complier error
5.This symbol is used to print more than one item on a single line.
semicolon (;)
dollar ($)
comma (,)
colon(:)
7.Which of the following is not a keyword in python?
break
while
continue
operator
8.Which operator is also called comparative operator?
arithmetic operator
relational operator
logical operator
assignment operator
9.Which of the following is not logical operator?
and
or
assignment
not
What is missing from this program – print(hello)?
‘‘ ’’
::
??
*** ***
It is possible to execute both the statements under if and else at the same time.
TRUE
FALSE
There can be an else statement without an if statement
FALSE
TRUE
What is does this code display?
You are in primary school.
You are in secondary school.
You are not in school.
Nothing.
Which logic operator is used when only one condition has to be true?
and
or
not
What does the 'not' logic operator do?
Nothing.
Changes an if statement so that the condition needs to be true.
Changes an if statement so that the condition needs to be false.
Changes a value.
What is the difference between complex and simple conditions?
Complex conditions have more than one condition.
Simple conditions have more than one condition.
Complex conditions use the 'not' operator.
Only simple conditions can use logic operators.
What will this code output?
Fizz
Buzz
True
False
In input/process/output, what is process?
The whole program.
What information comes out of the program.
What the user types in to the program.
How the program modifies the information it has received in order to produce the output.
What function converts a string to an integer?
float()
str()
int()
bool()
What is the type of data in the below code?
print(type(90+1j))
Float
String
Complex Numbers
None of the above
Which of the following enclose the input parameters or arguments of a function?
Curly braces
round braces
Square Braces
None of the above
Which of the following keywords marks the beginning of the function block?
Define
key
def
Fun
What is the output for the below code snippet?
def fun(message,num=3):
print(message*num)
fun('welcome')
Error
Welcome
welcomewelcomewelcome
None of the above
What is the output for the below code snippet?
def func():
num = 3
print(num)
func()
num
func
1
3
What does the min() function do?
Gives the minimum function
Gives the maximum function
Gives the minimum and the maximum function
None of the above
What is a list?
A set of integers
A set of strings
A mixed bag of datatypes
None of the above
Which of the following is the correct option for list creation?
List = [""1,""1,""3]
List = (1,2,3,4)
List = [ 1,2,3,4]
List = [1 2 3 4]
Which of the following is true for a tuple?
Tup = 1,2,3
Tup = (""1,"2)
Tup = (1,2,3,4)
None of the above
Which of the following is not true for strings?
String = [1,2,3,4]
String = "hello"
String = 'hello'
String = ''' Hello '''
Python functions can return a value?
True
False
Is python list mutable?
True
False
Choose the immutable data types
Dictionary
Tuple
List
String
Which of the following is a mutable data type ?
Dictionary
List
String
int
Name the function used for finding the data type of a variable.
(a)
15%3
(a)
Choose the operator that calculates the quotient
&
**
%
/
Which operator has the highest precedence ?
%
//
/
**
False and True
True
False
Which of the following is a logical operator?
not
And
or
Or
a/=b is same as ?
b=a/b
a=b/a
a=a/b
b=b/a
Name the type of operator >=
Logical
Relational
Assignment
Arithmetic
_______ error occurs when the rules of the programming language is violated.
Runtime
Syntax
Logical
Which of the following gives a syntax error in Python?
100=a
a=102
print 7+3
Print 7
Is Python a Case Sensitive Language?
Yes
No
May not be
None of the above
What is answer of this expression, 22 % 3 is?
7
1
0
5
Mathematical operations can be performed on a string.
True
False
May not be
None of the above
What is the output when following statement is executed ?>>>"a"+"bc"
a
bc
ac
abc
What is the output when following code is executed ?
>>> str1 = 'hello'
>>> str2 = ','
>>> str3 = 'world'
>>> str1[-1:]
olleh
hello
h
o
What is the output of the following code ?
>>>example = "snow world"
>>>example[3] = 's'
>>>print example
snow
snow world
error
snos world
Which of the following commands will create a list?
a) list1 = list()
b) list1 = [].
c) list1 = list([1, 2, 3])
d) all of the mentioned
list1 = list()
list1 = [].
list1 = list([1, 2, 3])
all of the mentioned
Suppose list1 is [3, 5, 25, 1, 3], what is min(list1) ?
3
5
1
25
Suppose list1 is [1, 5, 9], what is sum(list1) ?
1
9
15
none
What will be the output?
names1 = ['Amir', 'Bala', 'Chales']
if 'amir' in names1:
print(1)
else: print(2)
None
1
2
error
1. Which of the following statements create a dictionary?
d = {}
d = {“john”:40, “peter”:45}
d = {40:”john”, 45:”peter”}
All of the mentioned
