Skip to content

Instantly share code, notes, and snippets.

View alexanderawwagner's full-sized avatar

alexanderawwagner

View GitHub Profile
@alexanderawwagner
alexanderawwagner / def_medalScore
Last active June 25, 2021 14:18
Medium_05_Python Course-Part 05-Functions
athlets = pd.DataFrame({"Name" : ["John","Kate","Julia"],
"medal" : ["gold","silver","bronze"]})
def medalScore(df):
if df['medal'] == "gold":
score = 3
elif df['medal'] == "silver":
score = 2
elif df['medal'] == "bronze":
score = 1
@alexanderawwagner
alexanderawwagner / def_dateTimeText
Last active June 25, 2021 14:19
Medium_05_Python Course-Part 05-Functions
def DateTimeText(text):
from datetime import datetime
crawlDate=datetime.now().strftime('%Y-%m-%d')
crawlTime=datetime.now().strftime('%H:%M:%S')
print("date: ",crawlDate, " time: ", crawlTime, " ",text)
DateTimeText("Hello")
@alexanderawwagner
alexanderawwagner / while_loop
Created March 5, 2021 14:48
Medium_04_Python Course-Part 04- Control Structures
from numpy import random
n=0
while n < 5:
n=random.randint(10)
print("Random number is:", n)
print("Line after While Loop")
@alexanderawwagner
alexanderawwagner / list_comprehension_for_loop
Created March 5, 2021 14:41
Medium_04_Python Course-Part 04- Control Structures
s = []
for i in range(10):
s.append(i * i)
print("Value with for loop: ", s)
@alexanderawwagner
alexanderawwagner / list_comprehension
Created March 5, 2021 14:39
Medium_04_Python Course-Part 04- Control Structures
sList = [i * i for i in range(10)]
print("Value with List comprehension: ", sList)
@alexanderawwagner
alexanderawwagner / iterating_dictionary_values
Created March 5, 2021 14:26
Medium_04_Python Course-Part 04- Control Structures
for i in dic:
print(dic[i])
for i in dic.values():
print(i)
@alexanderawwagner
alexanderawwagner / iterating_dictionary_keys
Created March 5, 2021 13:15
Medium_04_Python Course-Part 04- Control Structures
dic = {'a': 1, 'b': 2, 'c': 3}
print(type(dic))
for i in dic:
print(i)
for i in dic.keys():
print(i)
@alexanderawwagner
alexanderawwagner / for_loop_iterating_list
Last active March 5, 2021 13:14
Medium_04_Python Course-Part 04- Control Structures
l = ['a', 'b', 'c']
print(type(l))
for i in l:
print(i)
@alexanderawwagner
alexanderawwagner / loop_break
Created March 5, 2021 12:48
Medium_04_Python Course-Part 04- Control Structures
count = 0
while True:
print("Value: ", count)
count += 1
if count >= 5:
break
@alexanderawwagner
alexanderawwagner / for_loop_continue
Created March 5, 2021 12:48
Medium_04_Python Course-Part 04- Control Structures
for i in numbers:
# check if x is even
if i % 3 == 0:
continue
print("Value: ",i)