😎
CS1.dev
  • Welcome to Computer Science 1
  • Unit 2
    • Activity 2.1
    • Activity 2.2
    • Activity 2.3
    • Activity 2.4
    • Activity 2.5
    • Activity 2.6
    • Activity 2.7
    • Activity 2.9
    • Activity 2.10
    • Project 2
    • Activity 2.8
    • Activity 2.11
    • Activity 2.12
    • Activity 2.13
    • Activity 2.14
    • Activity 2.15
    • Activity 2.16
    • Activity 2.17
    • Activity 2.18
    • Activity 2.19
    • Project 3
    • Activity 2.20
    • Activity 2.21
    • Activity 2.22
    • Activity 2.23
    • Activity 2.24
    • Project 4
    • Activity 2.25
    • Activity 2.26
    • Activity 2.27
    • Activity 2.28
    • Project 5
    • Activity 2.29
    • Activity 2.30
    • Activity 2.31
    • Activity 2.32
    • Activity 2.33
    • Activity 2.34
    • Activity 2.35
    • Activity 2.36
  • Unit 3
    • Activity 3.1
    • Activity 3.2
    • Activity 3.3
    • Activity 3.4
    • Activity 3.5
    • Activity 3.6
    • Activity 3.7
    • Activity 3.8
    • Activity 3.9
    • Activity 3.10
    • Activity 3.11
    • Project 6
    • Activity 3.12
  • Activity 3.13
  • Activity 3.14
  • Activity 3.15
  • Activity 3.16
  • Project 7
  • Activity 3.17
  • Activity 3.18
  • Activity 3.19
  • Project 8
  • Linux
    • bash
    • cat
    • cd
    • chmod
    • df
    • echo
    • find
    • grep
    • less
    • ls
    • mkdir
    • more
    • pwd
    • tar
    • touch
    • unzip
    • zip
Powered by GitBook
On this page
  • Source Code
  • scores.csv
  • students.csv
  • passaic.csv
  • professions.csv
  • financials.csv
  • books.csv
  1. Unit 2

Activity 2.34

Source Code

import math
import random
import csv

def main():
    done = False
    while not done:
        print("Menu System")
        print("E1 - Example 1")
        print("Q - Quit")
        choice = input("Choice: ").upper()
        if choice == "E1":
            example1()
        elif choice == "E2":
            example2()
        elif choice == "E3":
            example3()
        elif choice == "P1":
            problem1()
        elif choice == "P2":
            problem2()
        elif choice == "P3":
            problem3()
        elif choice == "P4":
            problem4()
        elif choice == "P5":
            problem5()
        elif choice == "Q":
            print("Quitting!")
            done = True
        else:
            print("Invalid choice")

# define Example 1 Function
def example1():
    print("Example 1")
    # open the csv file


    # create a csv reader


    # read the header


    # iterate over the remaining rows


    # close the file


# define Example 2 Function
def example2():
    print("Example 2")
    # open the csv file


    # create a csv reader


    # read the header


    # iterate over the remaining rows


    # close the file


# define Example 3 Function
def example3():
    print("Example 3")
    # open a file in write mode
    with open('people.csv', mode='w', newline='') as file:
        writer = csv.writer(file)

    # write header row
        writer.writerow(["Name", "Age", "City"])

    # write data rows
        writer.writerow(["Alice", 30, "New York"])
        writer.writerow(["Bob", 25, "Los Angeles"])
        writer.writerow(["Charlie", 35, "Chicago"])

# problem1
def problem1():
    print("Problem 1")

# problem2
def problem2():
    print("Problem 2")

# problem3
def problem3():
    print("Problem 3")

# problem4
def problem4():
    print("Problem 4")

# problem5
def problem5():
    print("Problem 5")



# call the main function, do not delete!
main()

scores.csv

Name,Math,Science,English
Devin,90,85,88
Teddi,75,80,78
Jada,85,90,92

students.csv

ID;Name;Shop
1;Alexa;Computer Science
2;Teddi;Medical Arts
3;Devin;Culinary

passaic.csv

Town,Population
Paterson,146199
Clifton,84273
Passaic,69781
Wayne,54772
West Milford,25678
Hawthorne,18597
Little Falls,14456
Totowa,10841
Pompton Lakes,11015
Ringwood,12356
Wanaque,11145
Prospect Park,5867
North Haledon,8346
Woodland Park,12039
Bloomingdale,7984

professions.csv

Profession,AverageSalary,TypicalDegree
Software Developer,105000,Bachelor's
Accountant,75000,Bachelor's
Civil Engineer,85000,Bachelor's
Nurse,70000,Associate's
Graphic Designer,65000,Bachelor's
Teacher,75000,Bachelor's
Surgeon,250000,Doctorate
Dentist,140000,Doctorate
Psychologist,85000,Doctorate
Marketing Manager,90000,Bachelor's

financials.csv

Month,Revenue,Expenses
January,10000,5000
February,15000,10000
March,20000,7000
April,22000,8000
May,24000,8500
June,26000,9000
July,28000,9500
August,30000,10000
September,32000,8500
October,34000,9000
November,36000,9500
December,38000,10000

books.csv

Title,Author,Genre,Publication Year,Available
To Kill a Mockingbird,Harper Lee,Classic,1960,Yes
1984,George Orwell,Dystopian,1949,No
The Great Gatsby,F. Scott Fitzgerald,Classic,1925,Yes
Pride and Prejudice,Jane Austen,Romance,1813,No
Harry Potter and the Sorcerer's Stone,J.K. Rowling,Fantasy,1997,Yes
The Hobbit,J.R.R. Tolkien,Fantasy,1937,No
The Da Vinci Code,Dan Brown,Thriller,2003,Yes
Sapiens,Yuval Noah Harari,Non-Fiction,2011,Yes
Beloved,Toni Morrison,Fiction,1987,No
The Catcher in the Rye,J.D. Salinger,Classic,1951,Yes
PreviousActivity 2.33NextActivity 2.35

Last updated 3 months ago