print("What is the variable name/key?", "value?", "type?", "primitive or collection, why?")
name = "John Doe"
print("name", name, type(name))

print()


# variable of type integer
print("What is the variable name/key?", "value?", "type?", "primitive or collection, why?")
age = 18
print("age", age, type(age))

print()

# variable of type float
print("What is the variable name/key?", "value?", "type?", "primitive or collection, why?")
score = 90.0
print("score", score, type(score))

print()

# variable of type list (many values in one variable)
print("What is variable name/key?", "value?", "type?", "primitive or collection?")
print("What is different about the list output?")
langs = ["Python", "JavaScript", "Java"]
print("langs", langs, type(langs), "length", len(langs))
print("- langs[0]", langs[0], type(langs[0]))

print()

# variable of type dictionary (a group of keys and values)
print("What is the variable name/key?", "value?", "type?", "primitive or collection, why?")
print("What is different about the dictionary output?")
person = {
    "name": name,
    "age": age,
    "score": score,
    "langs": langs
}
print("person", person, type(person), "length", len(person))
print('- person["name"]', person["name"], type(person["name"]))
What is the variable name/key? value? type? primitive or collection, why?
name John Doe <class 'str'>

What is the variable name/key? value? type? primitive or collection, why?
age 18 <class 'int'>

What is the variable name/key? value? type? primitive or collection, why?
score 90.0 <class 'float'>

What is variable name/key? value? type? primitive or collection?
What is different about the list output?
langs ['Python', 'JavaScript', 'Java'] <class 'list'> length 3
- langs[0] Python <class 'str'>

What is the variable name/key? value? type? primitive or collection, why?
What is different about the dictionary output?
person {'name': 'John Doe', 'age': 18, 'score': 90.0, 'langs': ['Python', 'JavaScript', 'Java']} <class 'dict'> length 4
- person["name"] John Doe <class 'str'>
InfoDb = []

# InfoDB is a data structure with expected Keys and Values

# Append to List a Dictionary of key/values related to a person and cars
InfoDb.append({
    "FirstName": "John",
    "LastName": "Mortensen",
    "DOB": "October 21",
    "Residence": "San Diego",
    "Email": "jmortensen@powayusd.com",
    "Owns_Cars": ["2015-Fusion", "2011-Ranger", "2003-Excursion", "1997-F350", "1969-Cadillac"]
})

# Append to List a 2nd Dictionary of key/values
InfoDb.append({
    "FirstName": "Ethan",
    "LastName": "Truong",
    "DOB": "July 28",
    "Residence": "4s Ranch",
    "Email": "truong.ethan@yahoo.com",
    "Owns_Cars": ["BMW"]
})

# Print the data structure
# InfoDB is a data structure with expected Keys and Values

# Append to List a Dictionary of key/values related to a person and cars
InfoDb.append({
    "FirstName": "Liav",
    "LastName": "Bar",
    "DOB": "August 9",
    "Residence": "San Diego",
    "Email": "liavbar5@gmail.com",
    "Owns_Cars": ["2020-Camry", "2017-Sorento"]
})

# Append to List a 2nd Dictionary of key/values
InfoDb.append({
    "FirstName": "Re'em",
    "LastName": "Ben-Ishai",
    "DOB": "May 11",
    "Residence": "San Diego",
    "Email": "ReemB@powayusd.com",
    "Owns_Cars": ["2021-Kona"]
})

# Print the data structure
print(InfoDb)
[{'FirstName': 'John', 'LastName': 'Mortensen', 'DOB': 'October 21', 'Residence': 'San Diego', 'Email': 'jmortensen@powayusd.com', 'Owns_Cars': ['2015-Fusion', '2011-Ranger', '2003-Excursion', '1997-F350', '1969-Cadillac']}, {'FirstName': 'Ethan', 'LastName': 'Truong', 'DOB': 'July 28', 'Residence': '4s Ranch', 'Email': 'truong.ethan@yahoo.com', 'Owns_Cars': ['BMW']}, {'FirstName': 'Liav', 'LastName': 'Bar', 'DOB': 'August 9', 'Residence': 'San Diego', 'Email': 'liavbar5@gmail.com', 'Owns_Cars': ['2020-Camry', '2017-Sorento']}, {'FirstName': "Re'em", 'LastName': 'Ben-Ishai', 'DOB': 'May 11', 'Residence': 'San Diego', 'Email': 'ReemB@powayusd.com', 'Owns_Cars': ['2021-Kona']}]

Using Index in For Loop

list = ["Mercedes","Toyota","Tesla","Honda","Hyundai","Bugatti"] 
for i in list: 
    print(i)
Mercedes
Toyota
Tesla
Honda
Hyundai
Bugatti

Outputing In Reverse Order

list = ["Mercedes","Toyota","Tesla","Honda","Hyundai","Bugatti"] 
for i in list: 
    print(i[::-1])
    print(list[::-1])
sedecreM
['Bugatti', 'Hyundai', 'Honda', 'Tesla', 'Toyota', 'Mercedes']
atoyoT
['Bugatti', 'Hyundai', 'Honda', 'Tesla', 'Toyota', 'Mercedes']
alseT
['Bugatti', 'Hyundai', 'Honda', 'Tesla', 'Toyota', 'Mercedes']
adnoH
['Bugatti', 'Hyundai', 'Honda', 'Tesla', 'Toyota', 'Mercedes']
iadnuyH
['Bugatti', 'Hyundai', 'Honda', 'Tesla', 'Toyota', 'Mercedes']
ittaguB
['Bugatti', 'Hyundai', 'Honda', 'Tesla', 'Toyota', 'Mercedes']

Other Methods Performed By Lists

QuizThat Stores In a List of Dictionaries

def question_with_response(prompt):
    print("Question: " + prompt) 



word = " "
questions = 4 # number of questions
correct = 0


questions_answers = [{"What command is used to include other functions that were previously developed?" : "import", 
                     "What command is used to evaluate correct or incorrect response in this example?" : "if", 
                     "Each 'if' command contains an '_________' to determine a true or false condition?" : "expression",
                     "Variables for the values the function needs. Is passed as an argument when the function is called" : "parameters"}] # dictionary
# questions_answers.append = ({"What command is used to include other functions that were previously developed?" : "import", 
#                      "What command is used to evaluate correct or incorrect response in this example?" : "if", 
#                      "Each 'if' command contains an '_________' to determine a true or false condition?" : "expression",
#                      "Variables for the values the function needs. Is passed as an argument when the function is called" : "parameters"}) # dictionary

for i in questions_answers:
    for question, answer in i.items():
        question_with_response(question) # printing the questions
        word = input("Answer: ") # variable that connects to the user's input
        if word == answer:  # if the answer provided is correct
            print("You got it right!!")
            correct += 1
        else:  # if the answer provided is wrong
            print("Your answer was wrong")

print(str(correct) + "/" + str(questions)) # correct/len(questions_answers)
Question: What command is used to include other functions that were previously developed?
You got it right!!
Question: What command is used to evaluate correct or incorrect response in this example?
You got it right!!
Question: Each 'if' command contains an '_________' to determine a true or false condition?
You got it right!!
Question: Variables for the values the function needs. Is passed as an argument when the function is called
You got it right!!
4/4

New Dictionary Data Set