wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Programming - I B.Sc CS quiz

Total questions: 50

Worksheet time: 24mins

Name
Class
Date
1.

What will be the output?

name = "Dave"

print (name)

a)

Dave

b)

name

c)

"Dave"

d)

(name)

2.

What will be the output?

name = "Dave"

print (name)

a)

Dave

b)

name

c)

"Dave"

d)

(name)

3.

What is a input?

a)

To plug in something

b)

A function that allows us to ask the user to enter some data

c)

Data displayed on a screen

d)

A routine

4.

A variable must have been assigned (given) a value before that value is referenced (used).

a)

True

b)

False

5.

The correct way to convert user input is:

a)

birth_year = number(input())

b)

birth_year = int(input())

c)

birth_year = (input(int))

d)

birth_year = int(input)

6.

To display the following on screen Hello World! the following command should be used:

a)

print(Hello World!)

b)

print("Hello World" + !)

c)

print("Hello World!")

d)

print"(Hello World!)"

7.

You assign a value to a variable with which symbol

a)

@

b)

==

c)

=

d)

*

8.

The code you use to receive and input from the keyboard

a)

enter()

b)

add()

c)

receive()

d)

input()

9.

Program statements are executed in sequence, one after the other...

a)

True

b)

False

10.

if you receive a NameError when you run your program it means....

a)

A variable has been assigned before it has been referred to

b)

An incorrect name has been chosen

c)

A variable has been referred to before it has been assigned

d)

A language key word has been used

11.

If the coding steps are in the incorrect order, the computer can still execute the program.

a)

True

b)

False

12.
What is another word for 'iteration'?
a)
Selection
b)
Variable Assignment
c)
Repetition
d)
Sequencing
13.
Which python operator means 'less than or equal to'?
a)
>
b)
<
c)
>=
d)
<=
14.
How many times will this loop run?
a)
10
b)
9
c)
4
d)
5
15.
I want to allow the program to repeatedly ask the user to enter their guess if it does not equal the answer...Which option do I use?
a)
while guess == answer:
    guess=input()
b)
while answer != guess:
guess=input()
c)
while answer =! guess:
guess=input()
d)
while guess != answer:
guess=input()
16.

Which word completes this sentence: "Iteration makes code more ___________"

a)

Complex

b)

Efficient

c)

Simple

d)

Straightforward

17.

A FOR loop is....

a)

A COUNT controlled loop

b)

A CONDITION controlled loop

18.

A WHILE loop is....

a)

A COUNT controlled loop

b)

A CONDITION controlled loop

19.

What will the output be for the code shown here?

a)

3,2,1,0

b)

0,1,2,3

c)

3,2,1

d)

1,2,3

20.

What would the output be for the code shown here?

a)

0,1,2,3,4,5,6,7,8,9

b)

1,2,3,4,5,6,7,8,9,10

c)

0,2,4,6,8,10

d)

0,2,4,6,8

21.

Anil is writing a "rock, scissors, paper" program. He wants the game to repeat until the user doesn't want to play anymore. What loop should he use?

a)

a FOR loop

b)

a WHILE loop

22.

Clara is writing a program that will print out the first ten numbers of a times table (chosen by the user). Should she use....

a)

a FOR loop

b)

a WHILE loop

23.

Tara has written a "Hide and Seek Simulator" - what will happen when she runs it?

a)

It will print "1,2,3,4,5,6,7,8,9,10 Coming ready or not!"

b)

The program will not run

c)

It will print "1,2,3,4,5,6,7,8,9,11 Coming ready or not!"

d)

It will print ("10 Coming ready or not!")

24.
What will be the output?
name = 'Dave'
print (name)
a)
Dave
b)
'Dave'
c)
name
d)
(name)
25.
What symbol is used in python to assign values to a variable?
a)
equals =
b)
plus + 
c)
forward slash /
d)
asterisk *
26.

Returns the remainder from division.

a)

DIV

b)

MOD

27.

A data type consisting of numbers with decimals.

a)

integer

b)

float / real

c)

string

d)

boolean

28.

What function is used to output a message in python?

a)

print ("")

b)

print = ("")

c)

print

d)

Print ("")

29.

What is the word (command) used to display output within Python?

a)

print

b)

input

c)

output

d)

display

30.

What is a variable?

a)

A box(memory location) where you store values

b)

A box(memory location) where you store multiple values

c)

Data type

d)

A static memory value

31.

Which of these would work as a piece of code in Python?

a)

IF answer == "Yes":

b)

if answer == "Yes"

c)

if answer == "Yes":

d)

if answer = "yes":

32.

What syntax would you use to create a name variable in Python?

a)

name=input()

b)

input=name

c)

name=input{}

d)

name=INPUT

33.

If you want multiple options for your code, what should you use (after if)?

a)

elif

b)

else

c)

if

34.

A data type consisting of whole numbers.

a)

integer

b)

float / real

c)

string

d)

boolean

35.

A data type consisting of a single character.

a)

integer

b)

character

c)

string

d)

boolean

36.

Why was Python (TM) developed?

a)

To go back to the old way of programming

b)

To create a programming language for students in grade school

c)

To make it easier to learn Java

d)

Python was developed by accident

37.

Python (TM) is owned and managed by

a)

Microsoft (c)

b)

Sun Microsystems (c)

c)

Python (TM) is open source and free to use

d)

Google (c)

38.

Python is ___________ level programming language and is ___________.

a)

High, compiled

b)

High, interpreted

c)

Low, compiled

d)

Low, interpreted

39.

Generally speaking, a low level programming language is easier to read, write and maintain over a high level programming language

a)

True

b)

False

40.

The syntax in Python (TM) is one of the main advantages over other high level programming languages.

a)

True

b)

False

41.

A string

a)

carries out an action

b)

the elements of a command

c)

a collection of characters

d)

how elements in a commad are arranged

42.

A block is

a)

a statement including elements of a command

b)

the structure and form of the code

c)

source code that is grouped together

d)

meaning assigned to symbols, characters and words

43.

What symbol comes before a comment?

a)

$

b)

>>

c)

#

d)

!

44.

An exception is

a)

the structure of form of the code

b)

the meaning of the characters and words in the code

c)

the statement that is missing from the instructions

d)

an event occurring during execution of a program which disrupts the flow of the program's instructions

45.

Debugging is

a)

how characters are arranged in a statement

b)

detecting or removing errors from a program

c)

removing viruses from a computer

d)

the meaning of each of the characters and symbols in the program

46.

A disadvantage of Python is it is harder to debug than other higher level programming languages.

a)

True

b)

False

47.

In programming, a (n) _______________ is a value that can change, depending on conditions or on information passed to the program

a)

string

b)

block

c)

instruction

d)

variable

48.

Generally speaking Python (TM) would run _____________ than C++ and take ____________ time to create

a)

faster, less

b)

faster, more

c)

slower, less

d)

slower, more

49.

Since Python (TM) is open source,

a)

Support for using Python (TM) is easy to find

b)

It is free

c)

There is a large catalog of supporting documents

d)

it is a less powerful programming languange

50.

A statement in programming

a)

Expresses an action to be carried out

b)

Always returns results like expressions

c)

Rules controlling how components in a program are combined

d)

An instruction to perform a task, usually one word