This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
numbers=range(5) | |
for i in numbers: | |
print("Value:", i) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print(customer1) | |
if customer1['age']<18: | |
print("Customer is under 18") | |
paymentOpt=(['cash'] if customer1['age']<18 else ['cash','checks','debit cards','credit cards','mobile payments','electronic bank transfers']) | |
print("The only available paymentoption for this customer is",paymentOpt) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if customer2['age']<18: | |
print("Customer is under 18") | |
paymentOpt=['cash'] | |
elif customer2['sales']<10: | |
print("Weak customer sales") | |
else: | |
paymentOpt=['cash','checks','debit cards','credit cards','mobile payments','electronic bank transfers'] | |
print("The only available paymentoption for this customer is",paymentOpt) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if customer1['age']<18: | |
print("Customer is under 18") | |
paymentOpt=['cash'] | |
else: | |
paymentOpt=['cash','checks','debit cards','credit cards','mobile payments','electronic bank transfers'] | |
print("The only available paymentoption for this customer is",paymentOpt) | |
if customer2['age']<18: | |
print("Customer is under 18") | |
paymentOpt=['cash'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
paymentOpt=['cash','checks','debit cards','credit cards','mobile payments','electronic bank transfers'] | |
customer1={'firstname':'Max','lastname':'Power','gender':'male','age':17,'sales':1} | |
customer2={'firstname':'Jane','lastname':'Doe','gender':'female','age':45,'sales':8} | |
if customer2['age']<18: | |
print("Customer is under 18") | |
paymentOpt=['cash'] | |
print("The only available paymentoption for this customer is",paymentOpt) | |
if customer1['age']<18: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with open("03_carFile.json","r") as f: | |
mycar=json.load(f) | |
print(mycar) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
with open("03_carFile.json","w") as f: | |
json.dump(car3,f) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print(car3) | |
print(len(car3)) | |
del car3['colors'] | |
print("colors deleted") | |
print(car3) | |
print(len(car3)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
car3 = {"brand": "VW", | |
"model": "ID.4", | |
"fueltype": "ELECTRIC", | |
"year": 2019, | |
"year": 2021, | |
"colors": ["yellow", "black", "purple"]} | |
print(car3) | |
type(car3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
car1['model'] |