WorksheetsMSTIP-Python-FinalExam
Total questions: 71
Worksheet time: 1hrs 11mins
How many variables are there in this program?
2
3
4
5
What would be the output of this program if the user input was 10?
22.04
220.4
2204
Error wrong data type
What operator is being used in this program?
less than
greater than
less than or equal to
greater than or equal to
What type of list is being used in this example?
Dictionary
List
Tuple
2d Array
Which of the following statements apply to tuples?
They are created using square brackets
They are created using curved brackets
They can be amended when the program is running
They can not be amended when the program is running
What would be the output of this program if the user entered "yes" then "what"?
Enjoy your day
it is too windy for an umbrella
Take an umbrella
Error
What would be the output of this program if the user entered "Alien"
Alienway
wayAlien
lienAay
ayAlien
What data type represents a whole number?
Float
Int
Boolean
String
What data type represents a decimal number?
Float
Int
Boolean
String
What data type represents characters?
Float
Int
Boolean
String
What data type represents only two possible outcomes?
Float
Int
Boolean
String
What you the output of this program be if the user guessed "h"?
Error
It was heads
It was tails
Bad luck
What shape would this code produce?
5 pointed star
Pentagon
Sqaure
Nothing it would give an error
Is the following subprogram a function or procedure?
Function
Procedure
What type of loop is being used in this program?
Count controlled
Condition Controlled
How many errors are there in this code?
1
2
3
4
How many errors are there in this piece of code?
0
1
2
3
Name of your Country
Changes every year
Always the same
I change it when I wish
Changes every month
Something that could change or vary.
Output
Input
Variable
Variable
Something that couldn't change
Something that I don't know
Something that could change
Something that always stays the same
What is a boolean type variable?
A popular song that was written by a Mr. Bull
Things expressed by words
Things expressed by numbers
Things expressed in True or False
If a = 3 and b= 8 and c=b=a. print (b)
11
8
24
3
What would be the value of the variable named count?
count = '46'
count = int(count)
print(count)
'46'
int
count
46
Symbol that you will use to check whether the two values are not the same.
and
or
then
!=
Keyword you will use to convert the user input to a number.
float
int
input
int_float
What is the output of the following piece of code when executed in Python shell?
>>> a=("Check")*3
>>> a
(‘Check’,’Check’,’Check’)
* Operator not valid for tuples
(‘CheckCheckCheck’)
Syntax error
Which are arithmetic operators?
+
-
>
<
Which of the following cannot be a variable?
_init_
in
it
on
Which one of these is floor division?
//
/
%
None of the above
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
A Relational operator is also called as ___________
Arithmetic operator
Logical operator
Assignment operator
Comparative operator
"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
________ are data items that have a fixed value
Tokens
Literals
Keyword
Operators
Examples of String Literals
"ABC1273"
nfjdlsj@@$
12638
'7e920938'
Choose the keyword from the following
IF
Else
iF
else
‘If’ is a decision making statement
TRUE
FALSE
if you receive a NameError when you run your program it means....
A variable has been assigned before it has been referred to
An incorrect name has been chosen
A variable has been referred to before it has been assigned
A language key word has been used
What will be the output?
name = "Dave"
print (name)
Dave
name
"Dave"
(name)
What is a input?
To plug in something
A function that allows us to ask the user to enter some data
Data displayed on a screen
A routine
The correct way to convert user input is:
birth_year = number(input())
birth_year = int(input())
birth_year = (input(int))
birth_year = int(input)
A variable must have been assigned (given) a value before that value is referenced (used).
True
False
To display the following on screen Hello World! the following command should be used:
print(Hello World!)
print("Hello World" + !)
print("Hello World!")
print"(Hello World!)"
You assign a value to a variable with which symbol
@
==
=
*
The code you use to receive and input from the keyboard
enter()
add()
receive()
input()
Program statements are executed in sequence, one after the other...
True
False
1. What is the output of the following code?
var1 = 1
var2 = 2
var3 = "3"
print(var + var2 + var3)
6
33
123
ERROR
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
3. What is the Output of the following code?
for x in range(0.5, 5.5, 0.5):
print(x)
[0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5]
[0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5]
The Program executed with errors
4. What is the output of the following code?
salary = 8000
def printSalary():
salary = 12000
print("Salary:", salary)
printSalary()
print("Salary:", salary)
Salary: 12000 Salary: 8000
Salary: 8000 Salary: 12000
The program failed with errors
5. What is the output of the following code?
def calculate (num1, num2=4):
res = num1 * num2
print(res)
calculate(5, 6)
20
The program executed with errors
30
6. Can we use the “else” clause for loops?
for example:
for i in range(1, 5):
print(i)
else:
print("this is else block statement" )
YES
NO
7. A string is immutable in Python?
Every time when we modify the string, Python Always creates a new String and assigns a new string to that variable.
TRUE
FALSE
8. What is the output of the following code?
sampleList = ["Jon", "Kelly", "Jessa"]
sampleList.append(2, "Scott")
print(sampleList)
The program executed with errors
[‘Jon’, ‘Scott’, ‘Kelly’, ‘Jessa’]
[‘Jon’, ‘Kelly’, ‘Scott’, ‘Jessa’]
9. What is the output of the following?
x = 36 / 4 * (3 + 2) * 4 + 2
print(x)
182.0
37
117
ERROR
10. Which operator has higher precedence in the following list?
% Modulus
& BitWise AND
**, Exponent
> Comparison
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,
12. What is the output of the following code?
listOne = [20, 40, 60, 80]
listTwo = [20, 40, 60, 80]
print(listOne == listTwo)
print(listOne is listTwo)
TRUE
TRUE
TRUE
FALSE
FALSE
TRUE
13. The ‘in’ operator is used to check if a value exists within an iterable object container such as a list. Evaluates to true if it finds a variable in the specified sequence and false otherwise.
TRUE
FALSE
14. What is the output of the following code?
str = "pynative"
print (str[1:3])
py
yn
pyn
yna
15. What is the output of the following code?
valueOne = 5 ** 2
valueTwo = 5 ** 3
print(valueOne)
print(valueTwo)
10
15
25
125
ERROR
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 would the output of this code be if the user entered the value 70?
Pass
Fail
Merit
Distinction
What would the outcome of this program be?
22
50
Nothing, it won't run due to errors in the code
38
What would the outcome of this program be?
prints 1 to 10 numbers
prints 10 to 1 numbers
prints 1 to 15 numbers
prints 1 to 14 numbers
What would the outcome of this program be?
prints 5 to 50 numbers
prints 5 to 49 numbers
prints 5 to 55 numbers
prints multiples of 5 upto 50
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
