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
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 |
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
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") |
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
from numpy import random | |
n=0 | |
while n < 5: | |
n=random.randint(10) | |
print("Random number is:", n) | |
print("Line after While Loop") |
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
s = [] | |
for i in range(10): | |
s.append(i * i) | |
print("Value with for loop: ", s) |
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
sList = [i * i for i in range(10)] | |
print("Value with List comprehension: ", sList) |
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
for i in dic: | |
print(dic[i]) | |
for i in dic.values(): | |
print(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
dic = {'a': 1, 'b': 2, 'c': 3} | |
print(type(dic)) | |
for i in dic: | |
print(i) | |
for i in dic.keys(): | |
print(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
l = ['a', 'b', 'c'] | |
print(type(l)) | |
for i in l: | |
print(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
count = 0 | |
while True: | |
print("Value: ", count) | |
count += 1 | |
if count >= 5: | |
break |
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
for i in numbers: | |
# check if x is even | |
if i % 3 == 0: | |
continue | |
print("Value: ",i) |
NewerOlder