Practice More Questions From: Quiz 1 – Loading, Querying, & Filtering Data
Q:
Which of the following can be used to open a file “MOOC.csv” in read-mode only?
Q:
Which of the following statements is false?
Q:
Which of the following can be used to open a file “MOOC.csv” in append-mode only?
Q:
Which of the statements below is false for the following script? import csv with open(‘MOOC.csv’, ‘r’) as csvfile: reader = csv.DictReader(csvfile)
Q:
There is a MOOC.csv file containing the following content. id,name,height,weight,age 1,Melanie,72,130.6,30 2,Keenan,84,197.6,31 3,Tom,78,180.0,27 Which of the statements below is true for the following script? import csv youngest_student = None min_age = None with open(‘MOOC.csv’, ‘r’) as csvfile: reader = csv.DictReader(csvfile) for row in reader: age = int(row[“age”]) if min_age == None or min_age > age: youngest_student = row[“name”] min_age = age if min_age == None: print(“The file does not contain any students.”) else: print(“The youngest student is ” + str(youngest_student) + ” who is ” + str(min_age) + ” years old.”)
Q:
There is a MOOC.csv file containing the following content. id,name,height,weight,age 1,Melanie,72,130.6,30 2,Keenan,84,197.6,31 3,Tom,78,180.0,27 Which of the statements below is true for the following script? import csv students = [] with open(‘MOOC.csv’, ‘r’) as csvfile: reader = csv.DictReader(csvfile) for row in reader: students.append(row) filtered_students = [row for row in students if (int(row[“age”]) < 30 and float(row["weight"]) < 190)] for student in filtered_students: print(student["name"], student["age"], student["weight"])
Subscribe
0 Comments
Oldest