ITE 119 Qz 10 Module 10 Flashcards
Write a function in python that prints “This is a Quiz”
def quiz_function():
print(“This is a Quiz”)
Write a function in python that takes in two numbers and returns the difference.
def calcDiff(a,b):
return a-b
Call your function that prints “This is a Quiz”
print_quiz() OR. print_quiz(‘This is a Quiz’)
Call your function that returns the difference of two numbers, pass into the function the numbers 6 and 3. Store the result in y.
y = calcDiff(6,3)
With the following function:
def print_message(username, greeting): print("Hello %s, I wish you %s!"%(username, greeting))
What will the following function call print?
print_message(“Abe Honest”, “a happy holiday”)
Hello Abe Honest, I wish you a happy holiday!
shirt = { "brand":"Gucci", "size":"Large", "price": 200.00 }
how do you print the above dictionary?
print(shirt)
shirt = { "brand":"Gucci", "size":"Large", "price": 200.00 }
How do you print the value of the “brand” key using get?
print(shirt.get(“brand”))
shirt = { "brand":"Gucci", "size":"Large", "price": 200.00 }
How do you change the “price” of the dictionary to 1000.00?
shirt[“price”] = 1000.00
shirt = { "brand":"Gucci", "size":"Large", "price": 200.00 }
How do you remove the “size” key name using pop()?
shirt.pop(“size”)
shirt = { "brand":"Gucci", "size":"Large", "price": 200.00 }
Add an item to the above dictionary called “color”, set it to yellow.
shirt[“color”] = “yellow”