Font size
WorksheetsPython Programming EndTerm
Total questions: 61
Worksheet time: 34mins
Which of the following are all basic parts of a desktop computer?
Computer case, monitor, printer
Keyboard, headphones, monitor
Mouse, speakers, computer case
Keyboard, mouse, computer case
The _____________ works with a video card to display images and text.
computer case
keyboard
monitor
printer
___________________ are devices that plug into the extra ports on your computer.
Peripherals
Servers
Software
Laptops
Python is an example of a:
Text-based programming language
Visual-based programming language
Block-based programming language
Language written in JavaScript
A data type consisting of numbers letters and symbols:
String
Integer
Float
Boolean
What does term ‘debug’ mean:
looking at the code
a set of instructions
Identify errors and fix them
Making a calculation
To repeat until a particular condition is true use:
While loop
For loop
If loop
Indentation
What does an if statement do?
Close the program
Ask a question
Make a decision
Write a comment
A statement in programming
Expresses an action to be carried out
Always returns results like expressions
Rules controlling how components in a program are combined
An instruction to perform a task, usually one word
_____ data type contain integer values with no decimal such as 1, 200, 999 etc.
int
float
char
String
Which if the values below is an integer data type?
1
1.0
1/2
"1"
Which value is a Boolean?
64
"cat"
True
0.5
What is a variable?
A storage location of memory which can change
A random area to store things in.
Something that changes
Something that can only store numbers
What is a program?
A series of a step-by-step instructions that tell a computer how to solve a task
A video that is watched on a computer
A flowchart written on a computer
The make and model of a computer
What is the output of the following list operation
aList = [10, 20, 30, 40, 50, 60, 70, 80]
print(aList[2:5])
print(aList[:4])
print(aList[3:])
[20, 30, 40, 50]
[10, 20, 30, 40]
[30, 40, 50, 60, 70, 80]
[30, 40, 50]
[10, 20, 30, 40]
[40, 50, 60, 70, 80]
None of these
Suppose list1 is [1, 3, 2], What is list1 * 2 ?
[2, 6, 4].
[1, 3, 2, 1, 3]
[1, 3, 2, 1, 3, 2]
[1, 3, 2, 3, 2, 1]
The code snippet above outputs
error
None
NaN
-1
The output of the code above is
[101, 102, 103, 104]
[3.6, 3.7, 3.8, 4]
Which of the following code deletes the key 103 and its value
del grades[103]
grades.pop(103)
del grades["103"]
grades.pop("103")
What will be the output of the following Python code?
nums = set([1,1,2,3,3,3,4,4])
print(len(nums))
7
Error, invalid syntax for formation of set
4
8
Which of the following statements is used to create an empty set?
{ }
set()
[ ]
( )
What will be the output of the following Python code?
>>> a={3,4,5}
>>> a.update([1,2,3])
>>> a
Error, no method called update for set data type
{1, 2, 3, 4, 5}
Error, list can’t be added to set
Error, duplicate item present in list
What will be the output of the following Python code?
>>> a={1,2,3}
>>> b=a
>>> b.remove(3)
>>> a
{1,2,3}
Error, copying of sets isn’t allowed
{1,2}
Error, invalid syntax for remove
What will be the output of the following Python code?
>>> a={1,2,3}
>>> b=a.copy()
>>> b.add(4)
>>> a
{1,2,3}
Error, invalid syntax for add
{1,2,3,4}
Error, copying of sets isn’t allowed
What will be the output of the following Python code?
s=set()
type(s)
<’set’>
<class ‘set’>
set
class set
What’s the main difference between Python lists and tuples?
Lists can hold any data type and tuples can only contain int and str objects.
Lists are immutable and tuples are mutable.
Lists are mutable and tuples are immutable.
Lists are faster and tuples are slower.
Check Your Answer »
Write the Python code that prints out Captain Kirk’s email address from the employee dictionary below:
employee = { "id": 1701, "name": "James T Kirk",
"email": "jtkirk@starfleet.com","position": "captain"}
(a)
What would this out put? print(users[0][0])
smith
ben
sam
james
A Python dictionary stores ...
value - key pairs
key - value pairs
A dictionary is an example of a sequence ...
True
False
Which of the following create an empty dictionary (D)?
D = dict()
D = ()
D = []
D = {}
quiz = ("Do you help out at home? ":"yes" }
File extension of Python program is ______
.py
.p
.pyx
.pyy
List index begins with _________.
0
1
-1
-2
_________________is an anonymous function.
User Defined
Default
Lambda
Reserved
What will be the anser for this code?
120
650
225
400
_______is used as a dummy place holder whenever a syntactical requirement of a certain programming element is to be fulfilled without assigning any operation
Pass
Break
While
Goto
What is the default return value for a function that does not return a value explicitly?
None
int
double
null
Which of the following items are present in the function header?
Function name only
Both function name and parameter list
parameter list only
Return value
Which of the following keywords marks the begining of the function block?
Func
define
def
function
When defining a function, the definition must occur before it is called.
true
false
Leo wants to create a subroutine that will roll a dice. Which syntax is correct?
def dice roll ():
def diceroll ()
def diceroll ():
def diceroll []:
This program will produce
a random number between 10 and 100 (including 10 but not 100) always in increments of 10
a random number between 10 and 100 (including 10 and 100) always in increments of 10
10 random numbers between 10 and 100 (including 10 and 100)
10 random numbers between 10 and 100 (including 10 and not 100)
Which operator is used in python to import all modules from packages?
. operator
* operator
-> symbol
, operator
What is the extension of python library modules?
.mod
.lib
.code
.py
A _______________ allows you to logically organize your Python code.
packages
module
method
class
Grouping related code into a module makes the ___________________ and use.
access code
remove code
access to understand
code easier to understand
Module can contain ____________ and ____________ .
functions, variables
class,method
object,syntax
expression,file
Re-naming the module as _______________ keyword.
as
re
ar
rn
Bundle multiple modules together to form a
________________ .
package
module
class
method
random
statistics
math
built-in
from math,random import *
import math.sqrt
import random as r
from math import * as m
A condition is
a statement that is either True or False
a string
an integer
a list
