wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Programming Basics 1

Total questions: 25

Worksheet time: 14mins

Name
Class
Date
1.

Is Python case sensitive when dealing with identifiers?

a)

Yes

b)

No

c)

Machine Dependent

d)

None of the mentioned

2.

What is the maximum possible length of an identifier?

a)

31 characters

b)

63 characters

c)

79 characters

d)

None of the mentioned

3.

Which of the following is an invalid variable?

a)

my_string_1

b)

1st_string

c)

foo

d)

_

4.

Which of the following is not a keyword?

a)

assert

b)

eval

c)

nonlocal

d)

pass

5.

Which of the following cannot be a variable?

a)

__init__

b)

in

c)

it

d)

on

6.

Consider the code:

a=21; b=6

print(a/b); print(a//b); print(a%b) 

What is the result?

a)

3.0

3

3

b)

3

3

3

c)

3.5

3

3

d)

3.5

3.5

3

7.

Consider the code and What is the result?

s='AB CD'

list=list(s)

list.append('EF')

print(list)

a)

('A','B',' ','C','D','EF')

b)

['A','B','C','D','E','F']

c)

{'A','B',' ','C','D','EF'}

d)

['A','B',' ','C','D','EF']

8.

Which is the correct operator for power(xy)?

a)

x^y

b)

x**y

c)

x^^y

d)

None of the above

9.

Which one of these is floor division?

a)

/

b)

//

c)

\

d)

\\

10.

What is the order of precedence in python?

i) Parentheses, ii) Exponential

iii) Multiplication, iv) Division

v) Addition, vi) Subtraction

a)

i,ii,iii,iv,vi,v

b)

ii,i,iv,iii,v,vi

c)

ii,i,iii,iv,v,vi

d)

i,ii,iii,iv,v,vi

11.

Operators with the same precedence are evaluated in which manner?

a)

Left to Right

b)

Right to Left

c)

Can’t say

d)

None of the mentioned

12.

What is the output of this expression, 3*1**3?

a)

27

b)

9

c)

3

d)

313

13.

The expression int(x) implies that the variable x is converted to integer. State whether true or false.

a)

True

b)

False

14.

Which one of the following have the highest precedence in the expression?

a)

Exponential

b)

Addition

c)

Parentheses

d)

Multiplication

15.

Exponent operator ** has ​ (a)   associativity in Python.

Choose from the below words
right-to-left
left-to-right
top-to-bottom
bottom-to-top
16.

Which of these in not a core data type?

a)

Lists

b)

Dictionary

c)

Tuples

d)

Class

17.

Given a function that does not return any value, what value is thrown by default when executed in shell.

a)

int

b)

bool

c)

void

d)

None

18.

Following set of commands are executed in shell, what will be the output? 

>>>str="hello"

>>>str[:2]

a)

he

b)

lo

c)

olleh

d)

hello

19.

What is the return type of function id?

a)

bool

b)

dict

c)

int

d)

float

20.

What error occurs when you execute?

apple = mango

a)

SyntaxError

b)

ValueError

c)

TypeError

d)

NameError

21.
a)

IndentationError

b)

cannot perform mathematical operation on string's.

c)

hello2

d)

hello2hello2

22.

What is the mutable object given below?

a)

dict

b)

str

c)

list

d)

tuple

23.

In order to store values in terms of key and value we use what core data type.

a)

list

b)

tuple

c)

set

d)

dict

24.
a)

Option A

b)

Option B

c)

Option C

d)

Option D

25.

What is the average value of the code that is executed below ?

>>>grade1 = 80

>>>grade2 = 90

>>>average = (grade1 + grade2) / 2

a)

85

b)

85.0

c)

85.1

d)

90.0