import random

# variable of type string
name = "Jishnu"
print("Name:", name, type(name))

# variable of type integer
age = 16
print("Age:", age, type(age))

# variable of type float
grade = 11
print("Grade:", grade, type(grade))

# another variable of type string
favorite_color = " Blue"
print("Favorite Color:", favorite_color, type(favorite_color))



print()

# variable of type list (many values in one variable)

langs = ["Python", "HTML", "CSS", "C", "Java", "JavaScript", "C", "R", "C++", "Bash"]
random_lang = random.choice(langs)
print("Random Language:", random_lang)

dream_cars = ["Toyota Supra", "McLaren 750", "Buggati Chiron", "Tesla Roadster"]
random_car = random.choice(dream_cars)
print("Random Dream Car:", random_car)

print()

# variable of type dictionary (a group of keys and values)
person = {
    "Name": name,
    "Age": age,
    "Grade": grade,
    "Languages": langs,
    "Favorite Color": favorite_color
}

# prints what is in the person dictionary without brackets
print(*[str(k) + ':' + str(v) for k,v in person.items()])


games = ["Valorant", "Apex Legends", "League of Legends", "Fortnite", "Minecraft", "Pokemon", "Zelda:BOTW", "GTA"]
games.reverse()
print('\nReversed List:'),
print(', '.join(games))


random.shuffle(games)
print('\nRandom Order:'),
print(', '.join(games))
Name: Jishnu <class 'str'>
Age: 16 <class 'int'>
Grade: 11 <class 'int'>
Favorite Color:  Blue <class 'str'>

Random Language: R
Random Dream Car: McLaren 750

Name:Jishnu Age:16 Grade:11 Languages:['Python', 'HTML', 'CSS', 'C', 'Java', 'JavaScript', 'C', 'R', 'C++', 'Bash'] Favorite Color: Blue

Reversed List:
GTA, Zelda:BOTW, Pokemon, Minecraft, Fortnite, League of Legends, Apex Legends, Valorant

Random Order:
League of Legends, GTA, Apex Legends, Valorant, Pokemon, Minecraft, Zelda:BOTW, Fortnite
People = []

# InfoDB is a data structure with expected Keys and Values

# Append to List a Dictionary of key/values related to a person and hobbies
People.append({
    "FirstName": "Jishnu",
    "LastName": "Singiresu",
    "DOB": "April 20",
    "Email": "broburn123@gmail.com",
    "Dream Car": ["McLaren 750"],
    "Hobbies": ["Sleeping", "Playing Games", "Hanging Out with Friends"]
})

# Append to List a 2nd Dictionary of key/values
People.append({
    "FirstName": "Luka",
    "LastName": "Van Den Boomen",
    "DOB": "September 19",
    "Email": "unknowndutch@gmail.com",
    "Dream Car": ["F1 Racing Car"],
    "Hobbies": ["Biking","Sleeping", "Playing Video Games"]
})


# Print the data structure
print(People)
[{'FirstName': 'Jishnu', 'LastName': 'Singiresu', 'DOB': 'April 20', 'Email': 'broburn123@gmail.com', 'Dream Car': ['McLaren 750'], 'Hobbies': ['Sleeping', 'Playing Games', 'Hanging Out with Friends']}, {'FirstName': 'Luka', 'LastName': 'Van Den Boomen', 'DOB': 'September 19', 'Email': 'unknowndutch@gmail.com', 'Dream Car': ['F1 Racing Car'], 'Hobbies': ['Biking', 'Sleeping', 'Playing Video Games']}]
def print_data(person): # defines the data being printed
    print("Name:", person["FirstName"], person["LastName"]) # Tells the computer to print certain things from the dictionary
    print("Birthday:", person["DOB"])
    print("Email:", person["Email"])
    print("Dream Car:", ", ".join(person["Dream Car"]))
    print("Hobbies:", ", ".join(person["Hobbies"]))
    print()

print_data(People[0]) 
print_data(People[1])
Name: Jishnu Singiresu
Birthday: April 20
Email: broburn123@gmail.com
Dream Car: McLaren 750
Hobbies: Sleeping, Playing Games, Hanging Out with Friends

Name: Luka Van Den Boomen
Birthday: September 19
Email: unknowndutch@gmail.com
Dream Car: F1 Racing Car
Hobbies: Biking, Sleeping, Playing Video Games

Loops

def for_loop():             # for every person in the InfoDB, print their data until there is nothing else to print
    for person in People:
        print_data(person)

def for_loop_with_index():      # prints out data depending on the length of the dictionary it comes from
    for p in range(len(People)):
        print_data(People[p])

for_loop()
for_loop_with_index()
Name: Jishnu Singiresu
Birthday: April 20
Email: broburn123@gmail.com
Dream Car: McLaren 750
Hobbies: Sleeping, Playing Games, Hanging Out with Friends

Name: Luka Van Den Boomen
Birthday: September 19
Email: unknowndutch@gmail.com
Dream Car: F1 Racing Car
Hobbies: Biking, Sleeping, Playing Video Games

Name: Jishnu Singiresu
Birthday: April 20
Email: broburn123@gmail.com
Dream Car: McLaren 750
Hobbies: Sleeping, Playing Games, Hanging Out with Friends

Name: Luka Van Den Boomen
Birthday: September 19
Email: unknowndutch@gmail.com
Dream Car: F1 Racing Car
Hobbies: Biking, Sleeping, Playing Video Games

While Loops

def while_loop():       # i starts at 0
    i = 0
    while i < len(People):      # while i is less than the length of the dictionary (2), keep printing the people's data
        record = People[i]
        print_data(record)
        i = i + 1
    return

while_loop()
Name: Jishnu Singiresu
Birthday: April 20
Email: broburn123@gmail.com
Dream Car: McLaren 750
Hobbies: Sleeping, Playing Games, Hanging Out with Friends

Name: Luka Van Den Boomen
Birthday: September 19
Email: unknowndutch@gmail.com
Dream Car: F1 Racing Car
Hobbies: Biking, Sleeping, Playing Video Games

Reversed While Loop

def while_loop_reverse():       
    i = len(People) - 1
    while i >= 0:
        print_data(People[i])
        i = i - 1

print("REVERSED WHILE LOOP\n")
while_loop_reverse()
REVERSED WHILE LOOP

Name: Luka Van Den Boomen
Birthday: September 19
Email: unknowndutch@gmail.com
Dream Car: F1 Racing Car
Hobbies: Biking, Sleeping, Playing Video Games

Name: Jishnu Singiresu
Birthday: April 20
Email: broburn123@gmail.com
Dream Car: McLaren 750
Hobbies: Sleeping, Playing Games, Hanging Out with Friends

Recursive Loops

def recursive(i): # the recursive loop will keep calling itself until it is greater than or equal to the length of the dictionary
    if i >= len(People):
        return          # this is where the code will end

    print_data(People[i])      # prints the data and keeps printing until it has reached the length of the dictionary
    return recursive(i + 1)

recursive(0)
Name: Jishnu Singiresu
Birthday: April 20
Email: broburn123@gmail.com
Dream Car: McLaren 750
Hobbies: Sleeping, Playing Games, Hanging Out with Friends

Name: Luka Van Den Boomen
Birthday: September 19
Email: unknowndutch@gmail.com
Dream Car: F1 Racing Car
Hobbies: Biking, Sleeping, Playing Video Games

Quiz using Lists

import getpass

Subjects = ["Math", "U.S. History", "Random"]

Quiz = []

Quiz.append({
    "What is 2+2?" : "4",
    "What is 20 x 15?" : "300",
})

Quiz.append({
    "What is the year U.S declared independence" : "1776",
    "Who is the current U.S president?" : "Joe Biden"
})

Quiz.append({
    "What color is cheese?" : "Yellow",
})


def question_with_response(prompt):
    print("Question " + ": " + prompt)
    msg = input()
    return msg

def for_loop_index():        
    scores = [0, 0, 0] 
    s = 0
    for subject in Quiz:
        print("\nSubject: " + Subjects[s])
        for ques, ans in subject.items():
            rsp = question_with_response(ques)
            if rsp == ans:
                    print("*Ding, Ding, Ding*, Correct answer! You gain 1 point!")
                    scores[s] += 1 
            else:
                print("*Buzzer sounds*, Damn nice try, better luck next time! You gain no points.")
        s += 1
    print()
    print("Correct answers in " + Subjects[0] + ": " + str(scores[0]) + " out of " + str(len(Quiz[0])))
    print("Correct answers in " + Subjects[1] + ": " + str(scores[1]) + " out of " + str(len(Quiz[1])))
    print("Correct answers in " + Subjects[2] + ": " + str(scores[2]) + " out of " + str(len(Quiz[2])))
    return

print('Hello everyone!, ' + getpass.getuser() + " is our participant for today's trivia, Ready to test your wits?")
print("Spelling counts so make sure you check your spelling and capitalize the first letter!")
for_loop_index()
Hello everyone!, jishnus is our participant for today's trivia, Ready to test your wits?
Spelling counts so make sure you check your spelling and capitalize the first letter!

Subject: Math
Question : What is 2+2?
*Ding, Ding, Ding*, Correct answer! You gain 1 point!
Question : What is 20 x 15?
*Ding, Ding, Ding*, Correct answer! You gain 1 point!

Subject: U.S. History
Question : What is the year U.S declared independence
*Ding, Ding, Ding*, Correct answer! You gain 1 point!
Question : Who is the current U.S president?
*Buzzer sounds*, Damn nice try, better luck next time! You gain no points.

Subject: Random
Question : What color is cheese?
*Ding, Ding, Ding*, Correct answer! You gain 1 point!

Correct answers in Math: 2 out of 2
Correct answers in U.S. History: 1 out of 2
Correct answers in Random: 1 out of 1