Python Exam c1

Ace your homework & exams now with Quizwiz!

What would you use to convert one Python Data type to another? A: Casting B: Melting C: Moving D: Jumping

A: Casting

you wrote a script that dumps pdfs files from a chosen website into your desktop, However, the code crashes with an error. What is the most suitable approach to solve the problem?

implement a try-except statement

num_list = 1, 2, 3, 4 for num in num_list: num_list.append(num) print(num) what is the output of this code?

infinite loop

Which of the following operators in python will produce a modulo of two provided numbers?

%

dictionary = {"list": 1,2,3,4} dictionary[list]. append ([4, 5, 6]) for value in dictionary: print(value)

"list"

Difference between Tuple and List

tuple cannot be edited, tuples use paranthesis() and lists use square brackets[]

While performing the Echo Communication home project, the command socket.accept() crashed the script. What could be the problem?

A: The accept() command was not assigned with two variables

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

When accepting data in client-server communication, what is the meaning of recv(2048) 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

B: The limit for the amount of byte to accept

for I in range (1, 10, 4): if i = = 9: word = Bla" print(word) What is the output of this code?

Bla

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}

Which commands would you use to gracefully exit in case of an error?

Catch and Exit

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 C: Dave, John D: Dave, john, Ben

D: Dave, john, Ben

what is the purpose of the None keyword in python?

Define a null variable or object

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

of the following, which is not an advantage of an interpreter compared to a compiler

Speed

what type of variable is the 'x' in the following code? x='15'

String

Which of the following is NOT a Python data structure?

Switch

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

What happens when running the following code? with open("Myfile.txt", "w") as file: file.write("Hello world")

hllo world is written inside myfile.txt

How would you assign a tuple to variable myTuble?

myTuble = (1, 2, 'name', 'time' )


Related study sets

Chapter 6 A First Look at Classes Java

View Set

Financial Leverage and Capital Structure Policy

View Set

Genetics Ch 15 Gene Regulation in Eukaryotes via Translation and Transcription

View Set

Quiz #3: CH. 2 Cognitive Neuroscience

View Set

Managerial Cost Accounting - ch. 11

View Set