wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

CS 1301 Final Exam Review

Total questions: 77

Worksheet time: 1hrs 15mins

Name
Class
Date
1.

Numeric Value? 7 % 3

(a)  

2.

Numeric value? 3//5

(a)  

3.

4 % 8

(a)  

4.

0//3

(a)  

5.

0%3

(a)  

6.

What will be printed out by the following print statement?

print(6+4   *   1 + 8)

(a)  

7.

What will be printed out by the following print statement?

print(2 * 3 + 4 ** 1+1)

(a)  

8.

Which of the following are valid identifier names?

Select all that apply!

a)

num1

b)

_num

c)

1num

d)

True

e)

true

9.

What will be printed out by the following code?

(a)  

10.

What will be printed out by the following code?

(a)  

11.

What will be printed from the following code?

(a)  

12.

What will be printed by the following code?

(a)  

13.

What will be printed by the following code?

(a)  

14.

How many lines will be printed out by the following code?

(a)  

15.

What number will be printed out by the following code?

(a)  

16.

What prints?

(a)  

17.

What prints?

(a)  

18.

What prints?

(a)  

19.

What prints?

(a)  

20.

What is the last thing that will be printed when this code runs?

(a)  

21.

What is the last thing that will be printed out when this code runs?

for num in range(1,5):
       print(num)

(a)  

22.

What is the value of variable a after the following code is executed? (Write error if you believe the code will not execute in its entirety)

(a)  

23.

What is the value of variable word after the following code is executed?

(a)  

24.

What is the value of variable num after the following code is executed?

(a)  

25.

Fill in the blanks to show what will be printed out by each of the following if text = "CS1301 is fun"

print(text[3:6:2]) 

(a)  

26.

Fill in the blanks to show what will be printed out by each of the following if text = "CS1301 is fun"

print(text[3:7] + text[2:3] * 2)

(a)  

27.

print(text.upper().lower()) 

text = "CS1301 is fun"

(a)  

28.

print(text[2].isdigit())

text = "CS1301 is fun"

(a)  

29.

print(text.replace("C","c").replace("c","X"))

text = "CS1301 is fun"

(a)  

30.

What will be printed out by the following code? Do not include quotation marks!

print("jackets"[1:3] + "win"[1:])

(a)  

31.

What will be printed out by the following code? Do not include quotation marks!

print("tomorrow"[2:3]*5)

(a)  

32.

What will be printed out by the following code? Do not include quotation marks!

(a)  

33.

Which of the following will remove the last "apple" from this list?

myList = ['apple', 'orange', 'banana', 'apple']

a)

del myList[3]

b)

 

myList.remove('apple')

c)

myList[3] = None

d)

myList.append('wrong')

34.

What is at index 2 of list b?

a = [1, 2, [3, 4]]
b = a[:]

a)

An alias of the list [3,4]

b)

A clone of the list [3,4]

35.

What is printed out by the following code?

(a)  

36.

What is printed out by the following code?

(a)  

37.

What will be printed out by the following code? Do not include quotes if a string (str) is printed.

(a)  

38.

What will be printed out by the following code? Do not include quotes if a string (str) is printed.

(a)  

39.

What would be printed out by the following code?

(a)  

40.

What would be printed out by the following code?

(a)  

41.

What would be printed out by the following code?

(a)  

42.

Which of these is a valid tuple?

a) (1,2)

b) ("cat","dog")

c) ((1))

d) (1,1)

e) (4,)

a)

a,b,d, and e

b)

a, b, and c

c)

all of the above

d)

a and b

43.

What would be printed out by the following code?

t1 = (1,2)

t2 = t1 + (5,6)

t3 =( t1 + t2) * 2

print(len(t3))

(a)  

44.

What would be printed out by the following code?

t1 = (1,2)

t2 = t1 + (5,6)

t3 = t2 + t1

print(t3.count(1))

(a)  

45.

What prints when this code is run?

(a)  

46.

What would print out when this code is run?

(a)  

47.

How many lines will print when this code is run?

(a)  

48.

How many lines will print when this code is run?

(a)  

49.

How many lines will print when this code is run?

(a)  

50.

What will be printed by the following code?

(a)  

51.

What will be printed by the following code? Separate multiple lines by a space!

(a)  

52.

What will be printed by the following code?

(a)  

53.

Assume you have created the following dictionary:

adict = {1:2, 2:3, 3:4, 5:6}

What would be printed out by the following code?

print(adict[2] + adict[3])

(a)  

54.

Assume you have created the following dictionary:

adict = {1:2, 2:3, 3:4, 5:6}

What would be printed out by the following code?

adict[2] += 1

adict[3] += 2

print(adict[2] + adict[3])

(a)  

55.

Assume you have created the following dictionary:

adict = {1:2, 2:3, 3:4, 5:6}

What would be printed out by the following code?

(a)  

56.

How many lines will be in the file "out.txt" after this code is run?

(a)  

57.

How many lines will be in the file "out.txt" after this code is run?

(a)  

58.

What will be printed out when this code is run?

(a)  

59.

Assume you have a file called letters.txt containing all the lowercase letters of the alphabet in order one letter per line. What would be printed out by the following code?

(a)  

60.

Assume you have a file called letters.txt containing all the lowercase letters of the alphabet in order one letter per line. What would be printed out by the following code?

(a)  

61.

Name,Age
Jakob,22
Caitlin,21
Enrique,21

If you have a csv file called names.csv that looks like the above, what would this code print out?

(a)  

62.

Name,Age
Jakob,22
Caitlin,21
Enrique,21

If you have a csv file called names.csv that looks like the above, what would this code print out?

(a)  

63.

What are methods that start with double underscores called?

(a)  

64.

What method is automatically called when an object is first created?

(a)  

65.

What is the first parameter of every method in a class?

(a)  

66.

What does OOP stand for?

(a)  

67.

What will be the LAST thing printed out by the following recursive code?

(a)  

68.

What will be printed out by this recursive code?

(a)  

69.

What will be the LAST thing printed out by the following recursive code?

(a)  

70.

How many lines will be printed out by the following recursive code?

(a)  

71.

How many lines will be printed out by the following recursive code?

(a)  

72.

How many lines will be printed out by the following recursive code?

(a)  

73.

How many lines will be printed out by the following recursive code?

(a)  

74.

What would be printed out when the following code is run?

(a)  

75.

What would be printed out when the following code is run?

(a)  

76.

What would be printed out when the following code is run?

(a)  

77.

What would the following code print?

word="hello"

word[0]="H"

print(word)

(a)