100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.6 TrustPilot
logo-home
Exam (elaborations)

CSCI 1301 MIDTERM PRACTICE (PYTHON) QUESTIONS WITH 100% CORRECT ANSWERS

Rating
-
Sold
-
Pages
60
Grade
A+
Uploaded on
05-12-2025
Written in
2025/2026

CSCI 1301 MIDTERM PRACTICE (PYTHON) QUESTIONS WITH 100% CORRECT ANSWERS

Institution
CSCI 1301
Course
CSCI 1301











Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
CSCI 1301
Course
CSCI 1301

Document information

Uploaded on
December 5, 2025
Number of pages
60
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Content preview

What will be the output of the following Python code?


my_dict={1:"A", 2:"B", 3:"C"}
for i, j in my_dict.items():
print( i, j, end=" " )


Give this one a try later!

, 1A2 B3C




What will be the output of the following Python code?


def foo():
try:
print( x + 4)
finally:
print('print finally block')
print('print after finally block')
foo( )


Give this one a try later!


NameError: name 'x' is not defined




What will be the value of 'result' in following Python program?


list1 = [1,2,3,4]
list2 = [2,4,5,6]
list3 = [2,6,7,8]
result = list()


result.extend( i for i in list1 if i not in (list2+list3) and i not in result )
result.extend( i for i in list2 if i not in (list1+list3) and i not in result )
result.extend( i for i in list3 if i not in (list1+list2) and i not in result )


print(result)


Give this one a try later!

, [1, 3, 5, 7, 8]




Which code can output "we will go to mountain" ?


Give this one a try later!


class Foo:
a = "mountain"
def __init__(self, a):
self.a = a
def someday(self):
return "we will go to " + Foo.a


f1 = Foo("Hi, Jack")
print(f1.someday())




Which of these about a dictionary is false?


Give this one a try later!


The keys of a dictionary can be accessed using values




What output of result in following Python program?
list1 = [1,2,3,4]
list2 = [2,4,5,6]
result1 = list1 + list2
result2 = list1 * 2
print( result1 )
print( result2 )

, Give this one a try later!


12342456
12341234




What is the list comprehension equivalent for?


{x : x is a whole number less than 20, x is even} (including zero)


Give this one a try later!


[x for x in range(0, 20) if (x%2 ==0)]




What will be the output of the following Python code?


Give this one a try later!


ABCD




To read file's contents as a list of lines from a file object myfile, we use____


Give this one a try later!


myfile.readlines()




Which of the following is a legal Python identifier?

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
TestITandFixIT Johns Hopkins University
View profile
Follow You need to be logged in order to follow users or courses
Sold
36
Member since
1 year
Number of followers
0
Documents
4737
Last sold
4 days ago

3.5

8 reviews

5
3
4
2
3
1
2
0
1
2

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions