PYTHON MULTI CHOICE URGENT 1) Consider the following code segment. It is suppose
ID: 3738433 • Letter: P
Question
PYTHON MULTI CHOICE URGENT
1)
Consider the following code segment. It is supposed to count the number of digits (0 - 9) in a string, text.
What line of code should be placed in the blank to achieve this goal?
2)
Consider the following code fragment (assumed to be in an otherwise correct program):
Assume there are no omitted statements within this fragment -- you see everything. Check the true statements (may be more than one):
Both methods refer to an instance attribute, self.shared_max.
Both methods refer to the static attribute, MyClass.shared_max.
The mutator refers to an instance attribute, self.shared_max, while the accessor refers to the static attribute, MyClass.shared_max.
3)Which for loop prints data across each row in the following code snippet?
for i in range(1, 4):
for j in range(1, 4):
print("x", end="")
print("")
4) What value is printed by the code snippet
name="John R. Johnson"
first_name="John"
location=name.find(first_name)
print(location)
5) Given the following code snippet:
MIN_SPEED=45
MAX_SPEED=60
speed=55
if not(speed <MAX_SPEED):
speed = speed-10
if not(speed>MIN_SPEED):
speed=speed+10
print(speed)
what output is produced?
45
55
65
50
6) What does the following code segment do?
x=0
for i in range(1, len(values)):
if values[i] < values[x]:
x=i
It finds the largest item in values and stores it in x
It finds the position of the largest item in values and stores it in x.
It finds the smallest item in values and stores it in x
It finds the position of the smallest item in values and stores it in x
7) You are creating a program that includes a dictionary where the keys are people's namesand the values are their favorite foods.
Which of the following statements adds an entry to the dictionary that indicates that Ravi's favorite food is chocolate?
if text[char] >= "0" and text[char] <= "9":
Explanation / Answer
1. C. if char >= "0" and char <= "9":
2. A. Both methods refer to an instance attribute, self.shared_max.
3. B. The outer for loop
4. 0
5. B. 55
6. C. It finds the smallest item in values and stores it in x
7. D. favorite_foods["Ravi"] = "chocolate"
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.