WorksheetsPython Assessment Quiz 1
Total questions: 40
Worksheet time: 20mins
Which command will correctly ask the user for their age?
age = input("How old are you?")
age = input(How old are you?)
input("How old are you?") = age
How old are you = input()
Which of these tests whether the variable x is the same as 'Hello'?
x = "Hello"
x != "Hello"
x == "Hello"
x <> "Hello"
What is the output of the following program?
Yes
No
Error
No output
What is the output of the following program?
Yes
No
Error
No output
What is the output of the following program?
1 to 10 numbers
1 to 5 numbers
1
5
What is the output of the following program?
for i in range(0, 5):
print(i)
i=i+1
1 to 5 numbers
1 to 4 numbers
0 to 4 numbers
0 to 5 numbers
Which of the following cannot be a variable?
_init_
in
it
on
Python is a general purpose programming language created by
Dennis M. Ritchie
Guido Van Rossum
James Gosling
Bjarne Stroustrup
Expand IDLE
Internal Development Learning Environment
Integrated Development Learning Enforcement
Interactive Development Learning Environment
Integrated Development Learning Environment
Example of valid identifiers
12Name
name$
total-mark
total_marks
"and, or and not" are ___________________
Arithmetic operator
Logical operators
Assignment operator
Comparative operator
__________are special words that are used by Python interpreter to recognize the
structure of program.
Tokens
Identifiers
Keywords
Operators
Choose the INVALID identifiers from the following
NUmbEr1
1NUMBer
A_B
A&B
2. What is the output of the following code?
p, q, r = 10, 20 ,30
print(p, q, r)
10 20
10 20 30
Error: invalid syntax
1. What is the output of the following code?
var1 = 1
var2 = 2
var3 = "3"
print(var + var2 + var3)
6
33
123
ERROR
11. What is the output of the following code?
for i in range(10, 15, 1):
print( i, end=', ')
10, 11, 12, 13, 14,
10, 11, 12, 13, 14, 15,
WHICH ONE OF THE FOLLOWING IS THE CORRECT EXTENSION OF THE PYTHON FILE ?
.py
.python
.p
None of these
WHICH ONE OF THESE IS NOT A PYTHON KEYWORD ?
and
or
scanf
is
WHICH ONE OF THESE IS USED TO TAKE INPUT FROM THE USERS ?
input
system
What is the word (command) used to display numbers and text on the screen?
Input
Output
Command
What symbol is used in python to assign values to a variable?
:
*
=
==
Python is -------language
compiled
interpreted
both compiled and interpreted
none of the above
The program above
prints all the odd numbers between 1 and 20
prints all even numbers between 1 and 20
print all the odd numbers between 1 and 21
prints all the even numbers between 1 and 21
The result of this program:
Friday = False
if Friday:
print("Jeans day!")
else:
print("Uniform day")
Jeans day
Today is Friday
Uniform day
Not Friday
What is the output?
condition
True
Program has a syntax error.
3 > 2
name = 'Dave'
print (name)
What is a output?
A piece of data that is shown on the screen.
Data that the user enters
An output
A orange
What syntax would you use to create a name variable?
name=input()
input=name
name=input{}
name=INPUT
The character that must be at the end of the line for if?
:
;
.
,
The correct way to create a variable in Python?
myVariable = 10
my Variable = 10
myVariable is 10
myVariable: 10
What would the output be for the code shown here?
0,1,2,3,4,5,6,7,8,9
1,2,3,4,5,6,7,8,9,10
0,2,4,6,8,10
0,2,4,6,8
Keyword to define functions is
def
deef
no keyword
none of these
When is the finally block executed?
when there is no exception
when there is an exception
only if some condition that has been specified is satisfied
always
What will be the output of the following Python code?
def foo():
try:
print(1)
finally:
print(2)
foo()1 2
1
2
none
