Ace - AI Tutor
Ask Our Educators
Textbooks
My Library
Flashcards
Scribe - AI Notes
Notes & Exams
Download App
Purity Njoroge

Purity N.

Divider

Questions asked

ANSWERED

Shu Naito verified

Numerade educator

Which XXX is used to write data in the file? import csv row1 = ['1', '2', '3'] row2 = ['Tina', 'Rita', 'Harry'] XXX students_writer = csv.writer(csvfile) students_writer.writerow(row1) students_writer.writerow(row2) students_writer.writerows([row1, row2]) with open('students.csv', 'r') as csvfile:

View Answer
divider
ANSWERED

Shu Naito verified

Numerade educator

Consider the following my_script.py. Which statement should replace XXX in the script for the command-line argument python my_script.py input.txt? import sys import os if len(sys.argv) != 2: print('Usage: {} inputfile '.format(sys.argv[0])) sys.exit(1) print('Opening file {}...'.format(sys.argv[1])) XXX print('Oh No! The file does not exist.') sys.exit(1)

View Answer
divider
ANSWERED

Shu Naito verified

Numerade educator

What code replaces XXX to make the program output the number 10? multiplier = 1 def do_multiplication(x): return x * multiplier def set_multiplier(x): XXX multiplier = x user_value = 5 set_multiplier(2) print(do_multiplication(user_value))

View Answer
divider
ANSWERED

Jenny Wu verified

Numerade educator

What is the output? my_list=[3,7,0,2,-1,8] index = 0 while my_list[index] : print(my_list[index], end=" ") index += 1

View Answer
divider
ANSWERED

Jenny Wu verified

Numerade educator

Which input for variable c causes "Done" to be output next? c = 'y' while c == 'y': # Do something print('Enter y to continue, n to quit: ', end=' ') c = input() print('Done');

View Answer
divider
ANSWERED

Jenny Wu verified

Numerade educator

What should XXX and YYY be so that the final output shows how many negative values are input? n = 0 val = Get next input While val is not 0 If XXX YYY val = Get next input put n to output XXX: val > 0, YYY: n = n + 1

View Answer
divider
ANSWERED

Jenny Wu verified

Numerade educator

What is x's final value? x = 10 y = 20 if y <= 2 * x: x = x + 5 else: x = x * 2

View Answer
divider
ANSWERED

Jenny Wu verified

Numerade educator

Given year is positive, which expressions for XXX, YYY, and ZZZ will output the correct range? Choices are in the form XXX / YYY / ZZZ. If XXX: Output "1-100" Else If YYY: Output "101-200" Else If ZZZ: Output "201-300" Else: Output "Other"

View Answer
divider
ANSWERED

Shu Naito verified

Numerade educator

Three strings are read from input and stored into list fruits. Then, three more strings are read from input and stored into list quality. Lastly, string separator_char is read from input. Use five print(f' ') statements to output the following five lines: "Fruits", with a field width of 25, centered, and followed by '|'. Then "Quality", with a field width of 25, centered. 50 instances of separator_char. fruits[0], with a field width of 25, centered, and followed by '|'. Then, quality[0] with a field width of 25, centered. fruits[1], with a field width of 25, centered, and followed by '|'. Then, quality[1] with a field width of 25, centered. fruits[2], with a field width of 25, centered, and followed by '|'. Then, quality[2] with a field width of 25, centered.

View Answer
divider
ANSWERED

Shu Naito verified

Numerade educator

Floating-point number walk_length is read from input. Use one print(f' ') statement to output 'Km: ', followed by walk_length to 2 decimal places.

View Answer
divider