Uploaded by Aaron Westley

pythonexamfinal

advertisement
Python Exam
Study online at https://quizlet.com/_blhk9e
1. Which of the following demonstrates a dictionary
structure?
A: x = {"David, "Cooper", 35}
B: X = ("David", "Cooper, 35)
C: X = {"firstname"; "David", "lastname", "Cooper,
"age"; 35}
D: None of these choices
C: X = {"firstname";
"David", "lastname", "Cooper,
"age"; 35}
2. When accepting data in client-server communication, B: The limit for the
what is the meaning of recv(2048)
amount of byte to
accept
A the length of the encryption key used in the meetings
B: The limit for the amount of bytes to accept
C: Receiving time in miliseconds
D:The limit for the amount of words to accept
3. What would you use to convert one Python Data type A: Casting
to another?
A: Casting
B: Melting
C: Moving
D: Jumping
4. What would be the output of the following code?
names = ['Dave', 'john' 'Ben', 'Jud']
for the name in names;
print(name)
if name = = 'ben'
break
else: print ("All names were printed!")
A: Dave, john, ben, jud, all names were printed
B: Dave, John, Ben,All names were printed
1/4
D: Dave, john, Ben
Python Exam
Study online at https://quizlet.com/_blhk9e
C: Dave, John
D: Dave, john, Ben
5. While performing the Echo Communication home pro- A: The accept()
ject, the command socket.accept() crashed the script. command was not
assigned with two
What could be the problem?
variables
6. You wrote a calculator script that accepts user input
from input().
In order to make the code work properly, which of the
following must be done to get mathematical results?
A: input() should
be converted to int
for create mathematical operators
7. What did the programmer forget in the following
code?
import dateline
Myfile = open("myfile.txt", "r")
print(Myfile.read())
Date = datetime.datetime.now()
print("\n", Date.time())
The file needs to
be closed to remove the security
risk
8. for I in range (1, 10, 4):
if i = = 9:
word = Bla"
print(word)
What is the output of this code?
Bla
9. what is the purpose of the None keyword in python? Define a null variable or object
10. you installed PyCharm and started writing a little
script that prints out "I love hacking with Python".
however, PyCharm won't alllow running the script,
what can be the solution to the problem?
Setting an interpreter
11. num_list = 1, 2, 3, 4
for num in num_list:
num_list.append(num)
print(num)
infinite loop
2/4
Python Exam
Study online at https://quizlet.com/_blhk9e
what is the output of this code?
12. What happens when running the following code?
hllo world is written
inside myfile.txt
with open("Myfile.txt", "w") as file:
file.write("Hello world")
13. dictionary = {"list": 1,2,3,4}
dictionary[list]. append ([4, 5, 6])
for value in dictionary:
print(value)
"list"
14. Which commands would you use to gracefully exit in Catch and Exit
case of an error?
15. Which of the following operators in python will produce a modulo of two provided numbers?
%
16. of the following, which is not an advantage of an inter- Speed
preter compared to a compiler
17. How would you assign a tuple to variable myTuble?
myTuble = (1, 2,
'name', 'time' )
18. what type of variable is the 'x' in the following code? String
x='15'
19. Which of the following is NOT a Python data structure?
Switch
20. you wrote a script that dumps pdfs files from a chosen implement a
website into your desktop, However, the code crashes try-except statewith an error.
ment
What is the most suitable approach to solve the problem?
21. Difference between Tuple and List
3/4
tuple cannot be
edited, tuples use
paranthesis() and
Python Exam
Study online at https://quizlet.com/_blhk9e
lists use square
brackets[]
4/4
Download