Python Quiz on  Pandas Read CSV
There are 20 questions based on Pandas Read CSV.
Sign in to Google to save your progress. Learn more
Q1.  What does the following code print?
income = 1000
expense = 400
net = income - expense
print(f"Net income: ${net}")
*
4 points
Q2.  What will this Python code output?
revenue = 10000
expenses = 7500
profit = revenue - expenses
print("Net Profit:", profit)
*
4 points
Q3.  What does this Python dictionary access return?
patient = {"name": "Ali", "age": 35, "blood_type": "O+"}
print(patient["blood_type"])
*
4 points
Q4.  What is the time complexity of the binary search algorithm? *
4 points
Q5. What will the following Python function return?
def grade(score):
    return "Pass" if score >= 50 else "Fail"

print(grade(45))
*
4 points
Q6.  What does the following code print if industry.csv contains one industry name per line?
import csv

with open('industry.csv', newline='') as file:
    reader = csv.reader(file)
    rows = list(reader)
    print(rows[0])  
*
4 points
Q7.  What will this code output if industry.csv contains 44 industry names (one per line)?
import csv
with open('industry.csv', newline='') as file:
    reader = csv.reader(file)
    count = sum(1 for row in reader)
    print(count)

*
4 points
Q8.  What does this code do?
import csv
with open('industry.csv') as f:
    reader = csv.reader(f)
    for row in reader:
        print(row[0])
*
4 points
Q9.  What does the following code do?
import csv
with open('industry.csv') as f:
    reader = csv.reader(f)
    next(reader)  # Skip header
    for row in reader:
        print(row[0])
*
4 points
Q10.  What does this code do?
import csv
with open('industry.csv', 'a', newline='') as f:
    writer = csv.writer(f)
    writer.writerow(['AI/ML'])
*
4 points
Q11.  What will print(industry_list) display?
import csv

with open('industry.csv') as f:
    reader = csv.reader(f)
    industry_list = [row[0] for row in reader]
    print(industry_list[:3])
  
*
4 points
Q12.  What does this code assume about the CSV file?
with open('industry.csv') as f:
    reader = csv.DictReader(f)
    for row in reader:
        print(row['Industry'])
*
4 points
Q13.  What will this code do?
import csv
with open('industry.csv', 'w', newline='') as f:
    writer = csv.writer(f)
    writer.writerow(['Industry'])
    writer.writerow(['Accounting/Finance'])
*
4 points
Q14.  What will this code print?
import csv

with open('industry.csv') as f:
    reader = csv.reader(f)
    count = sum(1 for row in reader if 'Finance' in row[0])
    print(count)
*
4 points
Q15.  What does this code check?
import csv
with open('industry.csv') as f:
    reader = csv.reader(f)
    data = list(reader)
    if not data:
        print("File is empty")
*
4 points
Q16.  What will this print?
import csv
with open('industry.csv') as f:
    reader = csv.reader(f, delimiter=';')
    for row in reader:
        print(row)
*
4 points
Q17.  What is the result of this code?
import csv
with open('industry.csv') as f:
    reader = csv.reader(f)
    for i, row in enumerate(reader):
        if i >= 5:
            break
        print(row[0])
*
4 points
Q18.  Why is the with open(...) statement used when handling CSV files?   *
4 points
Q19.  What does this code do?
import csv
with open('industry.csv') as f:
    reader = csv.reader(f)
    blanks = [row for row in reader if not row or row[0].strip() == '']
    print(len(blanks))
*
4 points
Q2O.  What does this code do?
import csv
industries = [['Healthcare'], ['Education'], ['Technology']]
with open('industry.csv', 'w', newline='') as f:
    writer = csv.writer(f)
    writer.writerows(industries)
*
4 points
Submit
Clear form
This content is neither created nor endorsed by Google.