PY4E: Intro to Capstone

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

The following Python code causes a traceback: a = "123" b = 456 c = a + b print(c) Which line fails with a traceback?

3

What would the following Python code print out? abc = "With three words" stuff = abc.split() print(len(stuff))

3

What will the following Python program print out? total = 0 for abc in range(5): total = total + abc print(total)

10

Which of the following lines of Python code contains a syntax error? x = 12 if x < 5: print("smaller") else: print("bigger") print("all done")

3 (Hint: wrong indentation)

What is the decimal (Base-10) numeric value for the upper case letter "G" in the ASCII character set?

71

What will the following Python program print out? def fred(): print("Zap") def jane(): print("ABC") jane() fred() jane()

ABC Zap ABC

In the following XML, what is "type"? <person> <name>Chuck</name> <phone type="intl"> +1 734 303 4456 </phone> <email hide="yes" /> </person>

An attribute

Which programming language serves as the basis for the JSON syntax?

JavaScript

Where in the computer is a variable such as "X" stored? x = 123

Main Memory

Which of the following lines will never print out regardless fo the value of "x"? if x < 2 : print("Below 2") elif x < 0 : print("Negative") else : print("Something else")

Negative

What will the following Python program print out? (This is a bit tricky so look carefully). def hello(): print("Hello") print("There") x = 10 x = x + 1

Nothing will print

What is the primary use of the Python dictionary?

To store key / value pairs

What does the following Python code print out? stuff = ['joseph', 'sally', 'walter', 'tim'] print(stuff[2])

walter

What will the following Python program print out? x = -1 for value in [3, 41, 12, 9, 74, 15] : if value > x : x = value print(x)

74

Which of the following lines will never print out regardless of the value for x? if x < 2 : print("Below 2") elif x < 20 : print("Below 20") elif x < 10 : print("Below 10") else : print("Something else")

Below 10

What is "self" typically used in a Python method within a class?

To refer to the instance in which the method is being called

What is the most common Unicode encoding when moving data between systems?

UTF-8

How are strings stored internally in Python 3?

Unicode

How is a Python socket different than a Python file handle?

You can read and write using the same socket

What would the following Python code print out? abc = "With three words" stuff = abc.split() print(stuff)

['With', 'three' ,'words']

When reading data across the network (i.e. from a URL) in Python 3, what method must be used to convert it to the internal format used by strings?

decode()

Which of the following is not a good synonym for "class" in Python?

direction

In the following example, an error occurs in "line3" that normally causes a traceback if it were not in a try/except. line1 try: line2 line3 line4 except: line5 line6 What is the sequence of lines executed in this program?

line1, line2, line3, line5, line6

What word does the following sequence of numbers represent in ASCII: 108, 105, 115, 116

list

What would the following Python code sequence print out? zap = "hello there bob" print(zap[4])

o

What is the answer to this question?

42 (Hint: API key)


Kaugnay na mga set ng pag-aaral

Chemical and Physical properties and changes

View Set

QUIZ 8 MS2 Chapter 14-18 Drugs Used for Parkinsons and SEIzure Dis0rder

View Set

Brunner Chapter 68 Neurologic Trauma Questions

View Set

CITI COI, CITI RCR, CITI social and behavioral research, clinical ethics exam 1

View Set

MS3, Exam 2: Ch 34 (up to p. 750)

View Set

Chapter 3: Properties of Numbers

View Set