wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Basics 2

Total questions: 36

Worksheet time: 18mins

Name
Class
Date
1.

Integers in Python are designated

a)

the full word integer

b)

num

c)

number

d)

int

2.

Float in Python is designated

a)

The full word float

b)

number

c)

num

d)

flt

3.

Integers are ____________ and floats are _____________

a)

whole numbers and exponents

b)

powers and fractions

c)

fractions and whole numbers

d)

whole numbers and decimal numbers

4.

Which of the following is NOT an example of a float?

a)

7.3

b)

10.0

c)

2.0e2

d)

134

5.

In the following, type(5) , what is (5) called a(n)

a)

statement

b)

variable

c)

argument

d)

opening argument

6.

If you entered type(7.5) the answer output would be

a)

7.5

b)

integer

c)

float

d)

decimal

7.

Using type ahead of a number argument () tells you

a)

whether the number is a float or an integer

b)

what the output will be if you enter an argument

c)

whatever is inside the ()

d)

what type variable you have entered

8.

What is the result in Python when you use the / (division) operation?

a)

A fraction will result no matter what the input

b)

An integer will result no matter what the input

c)

A float will result no matter what the input

d)

Scientific notation will result no matter what the input

9.

Use // in order to yield

a)

A float when doing division with floats

b)

An integer when doing division with integers

c)

A float when doing division with integers

d)

An Integer when doing division with floats

10.

When you use the division operation with 10/3 and you want the remainder, you would use

a)

the symbols //

b)

the symbol /

c)

the symbol /r

d)

the symbol %

11.

When you enter multiple number and operations in one line, Python will

a)

perform operations left to right

b)

perform operations right to left

c)

perform addition and subtraction first

d)

perform order of operations according to PEMDAS

12.

If you wanted to override the automatic application of PEMDAS to your entry of multiple numbers and operations

a)

use {} around all multiplication of division

b)

insert ( ) to prioritize order according to desired order

c)

use [] around any exponents

d)

use [] around all multiplication and division

13.

Which of the following is NOT best practices when designating a variable? in Python

a)

The variable can be a word or words

b)

The variable can be more than one word

c)

Use _ underscore between multiple words

d)

Variables CANNOT be recalled and modified

e)

Create an understandable, relevant name

14.

Once you create the variable age = 18, age operates as a value. If you entered age + 3, it would yield

a)

3

b)

21

c)

ERROR

d)

age

15.

Once you change a variable, such as age = 5, and then enter age + 5, the variable ____________ and when you enter print (age) it would yield __________

a)

remains the same, 5

b)

remains the same, 15

c)

is changed, 10

d)

is changed, 5

16.

Examples of operations where you could use a shortcut to change the variable definition age = 18 (choose all correct answers)

a)

age -= 3 would subtract 3 from 18

b)

age += 3 would add 3 to 18

c)

age *= 3 would multiply 18 by 3

d)

age **= would cube 18

17.

Recall the operation of division using / will return a float whether working with floats or integers. Using // tells Python if there is an integer to yield an integer. However, using // in the shortcut //= with an integer does NOT yield an integer

a)

True

b)

False

18.

Which of the following are Boolean operations in Python (choose all correct answers)

a)

AND

b)

IF

c)

THAN

d)

OR

e)

NOT

19.

NOT is used

a)

if both operands are not true

b)

if any of the operands are true

c)

if any of two operands are not zero

d)

to reverse the logical state of the operand

20.

Which of the following are built in data types in Python

a)

dict

b)

set

c)

tuple

d)

list

e)

all of the above

21.

Which of the following has the most functionality of all of the built in data types in Python

a)

dicts

b)

lists

c)

sets

d)

tuples

22.

Which of the following built in data types is unordered collections of values with no duplicates?

a)

dicts

b)

lists

c)

sets

d)

tuples

23.

When creating a variable list in Python

a)

the comma should be placed before the second/closing ' between list items

b)

the comma should be placed before the first/opening ' in the list item

c)

the comma should be placed after the first/opening ' in the list item

d)

the comma should be placed after the second/closing ' in the list item

24.

Lists use which symbol in Python?

a)

{}

b)

[]

c)

()

d)

||

25.

Sets use which symbol in Python?

a)

||

b)

{}

c)

[]

d)

()

26.

Tuples use which symbol in Python

a)

()

b)

{}

c)

[]

d)

||

27.

An index always begins with

a)

1

b)

i

c)

a

d)

0

28.

The last item in an index will always be

a)

z

b)

aa

c)

2

d)

-1

29.

With regard to an index designation, ___________ is the first location, and the final location is “not including”

a)

length

b)

list

c)

range

d)

set

30.

Remove is used to

a)

remove an entry from a list

b)

delete the contents of a list

c)

remove an entry from a set

d)

delete the contents of a tuple

31.

Append

a)

will remove an entry in a list

b)

will removed an entry from a set

c)

will add an entry to a set

d)

will add an entry to a list

32.

When working with a list, pop will

a)

pop an entry where you have your cursor

b)

remove the first entry in the list

c)

remove the last entry from the list

d)

remove an entry from a set

33.

If you use pop successively on a list

a)

you will get an error message

b)

it will put the entries in a new file

c)

it will eventually remove all items from the list

d)

it will put entries in a set that cannot be changed

34.

What does len tell you when placed in front of your named list?

a)

how many characters are on the line including symbols

b)

how many alpha characters on on the line

c)

how many total list items there are

d)

the length of the name of the list

35.

A list is ____________ a tuple is ____________.

a)

mutable (can be changed once created), immutable (cannot be changed once created)

b)

immutable (can be changed once created), mutable (cannot be changed once created)

36.

Which of the following is NOT true about sets?

a)

Are optimized for testing if a value is a "member"

b)

Are optimized for testing if a value is shared or not shared with another set

c)

Do not contain duplicates

d)

Are in no certain order

e)

Are in alpha numeric order