wb.save('transctions2.xlsx') path = Path() for file in path.glob('*.py'): print(f"files in path is: {file}") for i in range(3): print(random.randint(10, 20)) members = ["rizwan", "zaheer", "attique"] print(random.choice(members)) ecommerce.shipping.calc_shipping() # or calc_shipping() # or shipping.calc_shipping() class Dice: def roll(self): first = random.randint(1, 6) second = random.randint(1, 6) return first, second # returning touple dice = Dice() print(f"roll dice value is: {dice.roll()}") print("hello Rizwan Zaheer")
import utils from utils import find_max print(utils.find_max([1,10,5,6,3,2,0])) print(find_max([100,1234,12,1324,22])) from ecommerce import shipping shipping.calc_shipping() from ecommerce.shipping import calc_shipping,calc_tax calc_tax() calc_shipping()
numbers = [4, 10, 6, 2] print(find_max(numbers)) #a package : a folder for multiple modules #Ex2 import ecommerce.shipping ecommerce.shipping.calc_shipping() #Ex3 from ecommerce.shipping import calc_shipping #from ecommerce import shipping calc_shipping() #shipping.calc_shipping() # python built-in module import random for i in range(3): print(random.random()) for i in range(3): print(random.randint(10, 20)) members = ['John', 'Mary', 'Bob'] leader = random.choice(members) print(leader)
from ecommerce import shipping shipping.calc_shipping(2)
import ecommerce.shipping from ecommerce.shipping import calc_shipping #preferred from ecommerce import shipping # ecommerce.shipping.calc_shipping() calc_shipping() #works only because of the 2nd import statement
p1 = Person("Alice", "Agressive", False) p2 = Person("Becky", "Talkative", True) #To show that p1 owns r2 and vice versa p1.robot_owned = r2 p2.robot_owned = r1 # importing modules import random class Dice: def roll(self): first = random.randint(1, 6) second = random.randint(1, 6) return first, second dice = Dice() print(dice.roll()) from ecommerce import shipping print(shipping.calc_shipping()) from pathlib import Path path = Path() for file in path.glob("*"): print(file)
# from ecommerce import shipping # allows for simple .function import ecommerce.shipping as ship from pathlib import Path path = Path("ecommerce") if not path.exists(): raise ValueError("Path to Ecommerce does not exist") SystemExit(0) ship.calc_shipping()
import converters from converters import kg_to_lbs import utils from utils import find_max import ecommerce.shipping from ecommerce.shipping import calc_shipping, calc_tax from ecommerce import shipping kg_to_lbs(100) print(converters.kg_to_lbs(70)) # 155.55555555555554 from line 2 print(converters.lbs_to_kg(120)) # 54.0 from line 2 # utils.find_max() from line 3 numbers = [10, 3, 6, 2, 5] maximum = find_max(numbers) print(maximum) # 10 from line 4 ecommerce.shipping.calc_shipping() # calc_shipping from line 5 ecommerce.shipping.calc_tax() # calc_tax from line 5 calc_shipping() # calc_shipping from line 6 calc_tax() # calc_tax from line 6 shipping.calc_tax() # calc_tax from line 7 shipping.calc_shipping() # calc_shipping from line 7 shipping.cal_order() # calc_order from line 7