Font size
Worksheetspython
Total questions: 73
Worksheet time: 1hrs 13mins
A store your program must use as an identifier to keep track of a value is called a
Algorithm
Variable
Program
Assignment
Which symbol assigns a value to a variable?
(a)
Which of the following would be an example of a string variable:
ValidInput = False
GuessCount = 100
Name = "Bilbo"
Pi = 3.14159265359
To execute a Python program, you need a Python interpreter.
True
False
Which of the following would be an example of a float variable:
ValidInput = False
GuessCount = 100
Name = "Bilbo"
Pi = 3.14159265359
The rules for how programming languages statements can be assembled is known as
Variable
Algorithm
Syntax
Debugging
Which of the following would be an example of an integer variable:
ValidInput = False
GuessCount = 100
Name = "Bilbo"
Pi = 3.14159265359
What is the greater than symbol:
(a)
Python is the fastest growing programming language:
True
False
What would be the result of 3 ** 3
(a)
What would be the result of 9 // 7
(a)
What would be the reult of 9 % 7
(a)
Text to be output to the screen should be enclosed by " "
True
False
The Python IDE colour codes sections of your code to make it easier to debug
True
False
A: Strings can be changed during execution
B. Strings can be enclosed within single, double or even triple quotes
C. Strings are immutable
A,B & C are True
A,B are True but C is False
B, C are True but A is False
A,C are True but B is False
Find the output of the following code:
>>>str1='Save Soil'
>>>str1.isalnum( )
Save Soil
True
False
Identify the string membership operators of Python
in, not in
like, not like
as, not as
between, not between
Which is the powerful function used for formatting strings?
chr( )
format( )
title( )
capitalize( )
The title( ) function
assigns title
returns the title of the file
returns string in title case
Predict the output:
>>>str1="Rajathi Raja"
>>>print(str1.count('Raja'))
1
2
Error
Raja
Match the following:
1. \n A) Carriage return
2. \v B) BackSpace
3. \b C) new line
4. \r D) Vertical tab
1-C, 2-D, 3-B, 4-A
1-A, 2-C, 3-B, 4-D
1-C, 2-D, 3-A, 4-B
1-C, 2-A, 3-B, 4-D
Predict the output:
>>>saint="Thiruvalluvar"
>>>print(saint[5:])
valluvar
Thiruvalluvar
uvalluvar
Thiru
MATCH THE FOLLOWING:
1. concatenation A) +=
2. Append B) [ ]
3. String Slicing C) *
4. Repeating D) +
1-B. 2-A, 3-C, 4-D
1-D. 2-A, 3-B, 4-C
1-A,2-B,3-C,4-D
1-A,2-D,3-C,4-B
s="welcome"
print( s. center (15,'*'))
***welcome***
****welcome****
****welcome***
undefine function center
The unexpected event happened during program execution should be handled by
EXCEPTION
EXPERIMENT
ASSERTION
EXTRAORDINARY
try:
a=int(input("\n Enter a Value"))
b=int(input("\n Enter a Value "))
c=a/b
print (c)
except:
print("\n Something Went Wrong")
Assume a = 10 and b = 5, then the output will be
5.0
Something Went Wrong
Arithmetic Error
2.0
Exception disrupts the
Normal flow of the program
Abnornal flow of the program
Hard Disk
None of the Above
The suspicious code is put inside the
Try Block
Finally Block
Else Block
Except Block
________ statement can also be used without specifying Exception.
Try
Finally
Except
Else
try:
a=10/5
print (a)
except ArithmeticError:
print ("This statement is raising an exception" )
finally:
print (" final block executed " )
2.0
final block executed
This statement is raising an exception
final block executed
final block executed
2.0
An exception can be manually triggered by the command
raise
try
except
trigger
User defined Exceptions are created from the _________ Parent Class
Exception
Except
Handler
User Defined Exception
How many except statements can a try-except block have?
zero
one
more than one
more than zero
When will the else part of try-except-else be executed?
a) always
b) when an exception occurs
c) when no exception occurs
d) when an exception occurs in to except block
Is the following Python code valid?
try:
# Do something
except:
# Do something
else:
# Do something
no, there is no such thing as else
no, else cannot be used with except
no, else must come before except
yes
What will be the output of the following Python code?
lst = [1, 2, 3]
lst[3]
a) NameError
b) ValueError
c) IndexError
d) TypeError
What will be the output of the following Python code?
lst = [1, 2, 3]
lst[3]
a) NameError
b) ValueError
c) IndexError
d) TypeError
Which keyword is used for function?*
define
fun
def
function
Which of the following items are present in the function header?
function name
parameter list
return value
Both A and B
If the return statement is not used inside the function, the function will return:
0
None
Null
Arbitary value
What is a recursive function?
A function that calls other function.
A function which calls itself.
Both A and B
None of the above
Which of the following function headers is correct?*
def fun(a = 2, b = 3, c)
def fun(a = 2, b, c = 3)
def fun(a, b = 2, c = 3)
def fun(a, b, c = 3, d)
In which part of memory does the system store the parameter and local variables of a function call?
heap
stack
Uninitialized data segment
None of the above
How is a function declared in Python?*
def function function_name():
declare function function_name():
def function_name():
declare function_name():
Which one of the following is the correct way of calling a function?
function_name()
call function_name()
ret function_name()
function function_name()
Which of the following functions is a built-in function in python?
array()
sqrt()
factorial()
print()
What will be the output of the following Python expression? round(4.576)
4.5
5
4
4.6
What will be the output of the following Python expression? round(4.5676,2)
4.5
4.6
4.57
4.56
A Python module is a file with the _____ file extension that contains valid Python code.
.pym
.pymodule
.module
.py
What is returned by math.ceil(3.4)?
3
4
4.0
3.0
Which statement is correct to import all modules from the package
from package import all
from package import *
from package include all
from package include *
(a) is a string literal denoted by triple quotes for providing the specifications of certain program elements.
Which of the following is not a valid namespace?
Global namespace
Public namespace
Built-in namespace
Local namespace
What is the order of namespaces in which Python looks for an identifier?
Python first searches the global namespace, then the local namespace and finally the built-in namespace
Python first searches the local namespace, then the global namespace and finally the built-in namespace
Python first searches the built-in namespace, then the global namespace and finally the local namespace
Python first searches the built-in namespace, then the local namespace and finally the global namespace
The collection of modules and packages that together cater to a specific type of applications or requirements, is called______
module
library
classes
documentation
The help statement display ___ from a module.
constants
functions
classes
docstrings
10#40#70#
30#40#50#
50#60#70#
40#50#70#
a=10
a=20
syntax error
value error
What will be the output?
name = "Dave"
print (name)
Dave
'Dave'
name
(name)
It displays an output
What is the output from the following code?
print ("hello world")
What is the Python built-in function used to display numbers and text on the screen?
input
output
command
The punctuation requirements for printing a string in Python are:
( ) , ! and " "
( ) and !
( ) and " "
" " and !
What will be the output?
name = "Dave"
print ("name")
Dave
"Dave"
name
"name"
