Skip to content

Instantly share code, notes, and snippets.

View alexanderawwagner's full-sized avatar

alexanderawwagner

View GitHub Profile
@alexanderawwagner
alexanderawwagner / for_loop
Created March 5, 2021 12:41
Medium_04_Python Course-Part 04- Control Structures
numbers=range(5)
for i in numbers:
print("Value:", i)
@alexanderawwagner
alexanderawwagner / conditional_expressions
Last active March 4, 2021 14:25
Medium_04_Python Course-Part 04- Control Structures
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)
@alexanderawwagner
alexanderawwagner / if_elif_else_statement
Created March 4, 2021 14:14
Medium_04_Python Course-Part 04- Control Structures
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)
@alexanderawwagner
alexanderawwagner / if_else_statement
Last active March 4, 2021 13:54
Medium_04_Python Course-Part 04- Control Structures
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']
@alexanderawwagner
alexanderawwagner / if_statements
Created March 4, 2021 13:49
Medium_04_Python Course-Part 04- Control Structures
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:
@alexanderawwagner
alexanderawwagner / dictionary_read_json
Created February 26, 2021 14:53
Medium_03_Python Course-Part 03-Data Types | Data Structures
with open("03_carFile.json","r") as f:
mycar=json.load(f)
print(mycar)
@alexanderawwagner
alexanderawwagner / dictionary_save_write_json
Created February 26, 2021 14:51
Medium_03_Python Course-Part 03-Data Types | Data Structures
import json
with open("03_carFile.json","w") as f:
json.dump(car3,f)
@alexanderawwagner
alexanderawwagner / dictionary_remove
Created February 26, 2021 14:46
Medium_03_Python Course-Part 03-Data Types | Data Structures
print(car3)
print(len(car3))
del car3['colors']
print("colors deleted")
print(car3)
print(len(car3))
@alexanderawwagner
alexanderawwagner / dictionary_duplicate
Created February 26, 2021 14:43
Medium_03_Python Course-Part 03-Data Types | Data Structures
car3 = {"brand": "VW",
"model": "ID.4",
"fueltype": "ELECTRIC",
"year": 2019,
"year": 2021,
"colors": ["yellow", "black", "purple"]}
print(car3)
type(car3)
@alexanderawwagner
alexanderawwagner / dictionary_single_value
Created February 26, 2021 14:41
Medium_03_Python Course-Part 03-Data Types | Data Structures
car1['model']