xs = [10,20,30,40,50]
ss = ["Alice","John","Raj"]
xs[0]
10
xs[2:4]
[30, 40]
xs.append(60)
xs
[10, 20, 30, 40, 50, 60]
n = int(input("enter a number: "))
if n%2 == 0:
print("EVEN")
else:
print("ODD")
EVEN
n = int(input("enter a number: "))
if n%2 == 0:
print("EVEN")
print("DONE")
EVEN DONE
n = int(input("enter a score: "))
if n >= 90:
print("A")
elif n >= 80:
print("B")
elif n >= 70:
print("C")
elif n >= 60:
print("D")
else:
print("F")
xs
[10, 20, 30, 40, 50, 60]
answer = 0
for x in xs:
if x%2 != 0:
answer = answer + x
print(answer)
0
def odd_sum(xs):
answer = 0
for x in xs:
if x%2 != 0:
answer = answer + x
return answer
odd_sum([10,21,30,43,50])
64
odd_sum([10,20,30])
0
# Reads file and returns a list of lines in string format
def read_data(fname):
with open(fname,"r") as f:
data = f.read().splitlines()
f.close()
return data
read_data("in.dat")
['# read from file data about one day ', '# format: start_time:end_time:#steps', '09.30AM:09.45AM:220', '11.45AM:12.23PM:300', '11.45AM:10.23AM:302', '2.45PM:3.23PM:202', '3.45PM:3.53PM:90', '5.45PM:5.53PM:80', '6.45PM:7.23PM:1000', '10.45PM:10.53PM:102']
"09:35am".find(":")
2