import pizza2 from pizza import make_pizza3 from pizza import make_pizza2 as mp2 import pizza as p pizza2.make_pizza(16, 'pepperoni') pizza2.make_pizza(18, 'mushrooms', 'green peppers', 'extra cheese') make_pizza3(22, 'mushrooms', 'green peppers', 'extra cheese') mp2('pepperoni') mp2('mushrooms', 'green peppers', 'extra cheese') p.make_pizza3(26, 'mushrooms', 'green peppers', 'extra cheese')
#importing modules --> module means group of functions or group together import pizza pizza.make_pizza(14,'olive','corn') pizza.make_pizza(16,'cheese','tomatos') import pizza2 pizza2.make_pizza(14,'olive','corn') pizza2.make_pizza(16,'cheese','tomatos')
cd = unprinted_design.pop() printed_design.append(cd) def completed(printed_design ): while printed_design: print ( "I had printed ", printed_design.pop()) unprinted_design = ['abc','def','ghi'] printed_design = [] unprinted(unprinted_design,printed_design) completed(printed_design) ### Using arbitrary number of arguments using dictionary def build_profile(fname, lname , **user_info): user_info['first_name'] = fname # append to last user_info['last_name'] = lname # Append to last return user_info user_profile = build_profile('albert','einstein', location='princeton', field = 'physics') print(user_profile) # pizza2.make_pizza(16,'abc') pizza2.make_pizza(6,'abc','def' , 'fg')
import pizza """模块导入初次""" pizza.make_pizza("mushrooms", "green peppers", "extra cheese") from pizza2 import make_pizza make_pizza(11, "mushrooms") from pizza2 import make_pizza as make make(11, "mushrooms") from pizza import * make_pizza("mushrooms", "green peppers")