Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Team Quiz 1

Total questions: 50

Worksheet time: 1hrs 20mins

Name
Class
Date
1.

What will the following code segment print?


print(“Career”) print(“Labs”)

a)

CareerLabs

b)

Career Labs

c)

Career Labs(in next line)

d)

"Career" "Labs"

2.

What will be the output of the given code segment?

a = 10
b = 20 
multiple = a*b
print("multiple")
a)

20

b)

200

c)

multiple

d)

none

3.

Select correct variable name(s) which are allowed in python language.

One or more options may be correct

a)

var1

b)

var_1

c)

1var

d)

_var1

4.

Consider the python code below -

x = "abcd"
x = 10

What is the type of x after the code executes ?

a)

str

b)

int

5.

What will be the output of following statement?

print(17//10)
a)

1.7

b)

1

c)

2

d)

none

6.

What will be the output of the code if the input provided is 40 and 57 ?

a = input()
b = input()
C = a+b
print(C)

Note that the double quotes given in the options is to denote that it is a string. It wouldn't appear in the final output.

a)

90

b)

"40+57"

c)

"4057"

d)

none

7.

What will be the output of the code if input provided is 40 and 57 ?

a =int (input())
b= int (input())
C = a+b
print(C)
a)

90

b)

"40+57"

c)

"4057"

d)

none

8.

What is the type of the following number: 3.12323

a)

float

b)

int

9.

What is the result of the following: int(3.99)

a)

3

b)

3.99

10.

What is the value of x after the following is run:

x=4

x=x/2

a)

2.0

b)

4.0

11.

What is the result of the following: Name[0]

a)

"M"

b)

"n"

c)

"i"

12.

What is returned by the following function?

a)

4

b)

5

c)

false

d)

3.14

13.

What is returned by the following function?

a)

56

b)

c

c)

cat

d)

Error, you cannot have two index values unless you are using slicing.

14.

What is returned by the following function?

a)

[4, 2, 8, 999, 5, 4, 2, 8, 999, 5]

b)

[[4, 2, 8, 999, 5], [4, 2, 8, 999, 5]]

c)

[4, 2, 8, 6, 5]

d)

[[4, 2, 8, 999, 5], [4, 2, 8, 6, 5]]

15.
a)

6

b)

0

c)

120

d)

Error

16.

Suppose list1 is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after list1.pop(1)?

a)

[3, 4, 5, 20, 5, 25, 1, 3]

b)

[3, 5, 20, 5, 25, 1, 3]

c)

[1, 3, 3, 4, 5, 5, 20, 25]

d)

[1, 3, 4, 5, 20, 5, 25]

17.

What is the output when we execute list(“hello”)?

a)

[‘h’, ‘e’, ‘l’, ‘l’, ‘o’]

b)

[‘hello’]

c)

[‘llo’]

d)

[‘olleh’]

18.

Suppose list1 is [4, 2, 2, 4, 5, 2, 1, 0], Which of the following is correct syntax for slicing operation?

a)

print(list1[2:])

b)

print(list1[:2])

c)

print(list1[:-2])

d)

All

19.
a)

A

b)

Daman

c)

Error

d)

n

20.

Suppose list1 is [3, 4, 5, 20, 5], what is list1.index(5)

a)

0

b)

1

c)

4

d)

2

21.
a)

2

b)

4

c)

5

d)

8

22.

The ________ function returns its argument with a modified shape, whereas the ________ method modifies the array itself.

a)

reshape, resize

b)

resize, reshape

c)

reshape2, resize

d)

all of the mentioned

23.

What is NumPy library ?

a)
library with a large collection of high-level mathematical functions
b)

is a library written for the Python programming language for data analysis.

24.

What is the default data type of NumPy arrays?

a)

int32

b)

float64

c)

object

d)

None of the above

25.

What is the output of the following code?

a)

[2, 3, 4]

b)

[0, 1, 2]

c)

[5, 6, 7]

d)

[2, 4, 6]

26.

What is the output of the following code?

a)

[1, 2, 3, 4, 5, 6]

b)

[[1, 4], [2, 5], [3, 6]]

c)

[5, 7, 9]

d)

Error

27.

What is the output of the following code?

a)

[[19, 22], [43, 50]]

b)

[[5, 6], [7, 8], [1, 2], [3, 4]]

c)

[[1, 5], [2, 6], [3, 7], [4, 8]]

d)

Error

28.

What is the output of the following code?

a)

[[1, 2, 3], [4, 5, 6]]

b)

[[1, 4], [2, 5], [3, 6]]

c)

[1, 2, 3, 4, 5, 6]

d)

Error

29.

Tuple: What will be the output of following code?

a = 5,6,7
print(a[1:])
a)

[6,7]

b)

(6,7)

c)

[5,6,7]

d)

(5,6,7)

30.

What will be the output of follwoing code?

a = 1,2
b = (4,5)
d = a+b
print(d[2])
a)

2

b)

(4,5)

c)

4

d)

Error

31.

What will be the output of following code?

d = {1:2, “abc”:5, “def”:7}
print(d[0])
a)

1:2

b)

1

c)

2

d)

Error

32.
a)

Present

b)

Not Present

c)

Error

d)

None

33.

What will be the output of following code?

a = {1:2,’list’:[1,2],3:5}
a.pop(‘list’)
a[‘list’] = [3,5]
print(a[‘list’])
a)

None

b)

[3,5]

c)

[1,2]

d)

Error

34.

What will be the output of following code?

s = {}
s.add(4)
s.add(4)
print(len(s))
a)

2

b)

1

c)

Error

d)

none

35.

Which one of the following is correct?

a)

In python, a dictionary can have two same keys with different values.

b)

In python, a dictionary can have two same values with different keys

c)

In python, a dictionary can have two same keys or same values but cannot have two same key-value pair

d)

In python, a dictionary can neither have two same keys nor two same values.

36.

What will be the output of the following Python code?

a)

7

b)

4

c)

8

d)

Error

37.

Which of the following are true of Python dictionaries:

a)

Dictionaries can be nested to any depth.

b)

Dictionaries are accessed by key.

c)

All the keys in a dictionary must be of the same type.

d)

Dictionaries are mutable.

e)

A dictionary can contain any object type except another dictionary.

38.

Which of the following is not a valid way to define this dictionary in Python:

a)

d = dict([

('foo', 100),

('bar', 200),

('baz', 300)

])

b)

d = {}

d['foo'] = 100

d['bar'] = 200

d['baz'] = 300

c)

d = dict(foo=100, bar=200, baz=300)

d)

d = {'foo': 100, 'bar': 200, 'baz': 300}

e)

d = { ('foo', 100), ('bar', 200), ('baz', 300) }

39.

Consider this dictionary:


d = {'foo': 100, 'bar': 200, 'baz': 300}


What is the result of this statement:


d['bar':'baz']

a)

It raises an exception

b)

(200, 300)

c)

200 300

d)

[200, 300]

40.

Which of these is the best description of a list in Python?

a)

A list is a collection of data that has an order and can be changed

b)

A list is a lot of variables

c)

A list is used for shopping

d)

A list is a collection of data that cannot hold duplicated data and cannot be changed

41.

Which of these is the correct code for creating a list of names?

a)

nameList = John, Harry, Jesse, John, Harry, Harry

b)

nameList = ("John", "Harry", "Jesse", "John", "Harry", "Harry")

c)

nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]

d)

nameList = [John, Harry, Jesse, John, Harry, Harry]

42.

What is used to separate elements in a list?

a)

Bracket

b)

Comma

c)

Full Stop

d)

Space

43.

Which code would i use to add an item to a list?

a)

variable.add()

b)

variable.append()

c)

append.variable()

d)

add.variable()

44.

Identify the below expressions which would result in False?

a) False and True b) 1==1 or 2==1

c) 1==1 and 2!=1 d) True and 1==1 e) False or 1>2

a)

c, d

b)

a, e

c)

b, c, d

d)

a, c

45.

What is a correct syntax to return the first character in a string?

a)

x="Hello".sub(0,1)

b)

x="Hello"[0]

c)

x=sub("Hello",0,1)

d)

x=substring("Hello",0,1)

46.

what is the output of the below code snippet?

num1=10

num2=7//2

num2*=num1

print(num2)

a)

10

b)

35.0

c)

30

d)

30.0

47.

What is the output of the below code snippet?

a)

P 9

Q 10

R 2

S 6

b)

Tuple is immutable, so it will throw an error

c)

P 9

Q 10

R 2

S 6

T 6

d)

None of the above

48.

x = ['ab', 'cd']

for i in x:

i.upper()

print(x)

a)

['ab','cd']

b)

['AB','CD']

49.

The result of this program:

Friday = False

if Friday:

print "Jeans day!"

else:

print "Uniform day"

a)

Jeans day

b)

Today is Friday

c)

Uniform day

d)

Not Friday

50.

What is the output?

a)

more than 7

b)

more than 23

c)

spam

d)

7