#Question 1
machine_0 = {'type':'compressor','operator': 'peter packer', 'motor type' : 'hydraulic'}# first library
machine_1 = {'type':'sorter','operator': 'reed richards', 'motor type' : 'pneumatic'}#second library
machine_2 = {'type':'sprayer', 'operator':'bruce banner', 'motor type' : 'electric'}#third library
machine_3 = {'type':'dryer','operator': 'tony stark', 'motor type' : 'electric'}#fourth library
machines = [machine_0, machine_1, machine_2, machine_3]#nesting dictionaries into lists
for machine in machines:#loops until the list is fully read
print(machine)#prints the contents of the list
#Question 2
favorite_tools= {
'tim hortons': ['hammer','mallet','anvil'],
'kenny rogers': ['screwdriver','wrench','pliers'],
'billy michel': ['hammer','wrench','anvil']
}#tools dictionary
for name, tools in favorite_tools.items():#loops until dictionary is empty
print(f"\n{name.title()}'s three favorite tools are:")#prints the names
for tool in tools:#loops the items in the dictionary
print(f"{tool.title()}")#prints the tools
#Question 3
machine_0 = {'type':'compressor','operator': 'peter packer', 'motor type' : 'hydraulic'}# original library
print(machine_0)#prints original library
machine_0['maintenance']='before each use'#adds new key and value
print(machine_0)#prints to prove library has been extended
operator_info = machine_0['operator']#calls for value stored in key operator
check = machine_0['maintenance']#calls for value stored in key maintenance
print(f"\n Hi {operator_info.title()}, remember to perform fluid level checks {check}.")#Prints a message to the operator
#Question 4
def tshirt_production(size, text):#creates the function and the arguments within
"""Prints the size of a t-shirt and the text message displayed on it"""
print(f"\n The t-shirt picked is a size {size.upper()}.")#prints a formated messga about the tshirt size
print(f" It will display the text: {text.upper()}")#prints a formated message about the tshirt size
tshirt_production('l', 'keep calm and carry on!')#the first argument
tshirt_production('xl', 'r2d2')#the second argument
tshirt_production('s','awesome!')#the third argument
"""Each argument send its value to the function when it is called. The function then executes with the new parameters"""
#Question 5
def tshirt_production(size='l', text='join club mec'):#creates the function and the arguments within
"""Prints the size of a t-shirt and the text message displayed on it"""
print(f"\n The t-shirt picked is a size {size.upper()}.")#prints a formated messga about the tshirt size
print(f" It will display the text: {text.upper()}")#prints a formated message about the tshirt size
tshirt_production(text='mechatronics')#the first argument wil print with the default large, L size
tshirt_production('xxl', 'straving marvin')#the second argument will print the new instuction
tshirt_production(size='m')#the third argument will print the delault JOin Club Mec
tshirt_production()#calling the empty function will print the default size and text
"""Calling the function comes with default value. The value can be changed when calling the function and placing new values to replace the default one."""
On this page of the site you can watch the video online Python Libraries, loops and function with a duration of hours minute second in good quality, which was uploaded by the user Mechatronics 101 04 November 2020, share the link with friends and acquaintances, this video has already been watched 6 times on youtube and it was liked by 0 viewers. Enjoy your viewing!