# [ ] import https://raw.githubusercontent.com/MicrosoftLearning/intropython/master/rainbow as rainbow.txt
!curl https://raw.githubusercontent.com/MicrosoftLearning/intropython/master/rainbow -o rainbow.txt
# [ ] Open rainbow.txt in read mode & read as list with .readlines()
rainbow_file = open('rainbow.txt','r')
rainbow_colors = rainbow_file.readlines()
# [ ] sort rainbow_colors list, iterate the list to print each color
rainbow_colors.sort()
for color in rainbow_colors:
print(color)
# [ ] The Weather: import world_mean_team.csv as mean_temp.txt
!curl https://raw.githubusercontent.com/MicrosoftLearning/intropython/master/world_temp_mean.csv -o mean_temp.txt
# [ ] The Weather: open file, read/print first line, convert line to list (splitting on comma)
new_file = open('mean_temp.txt','r')
headings = new_file.readline()
print(headings)
headlist = headings.split(',')
print(headlist)
# [ ] The Weather: use while loop to print city and highest monthly average temp in celsius
!curl https://raw.githubusercontent.com/MicrosoftLearning/intropython/master/world_temp_mean.csv -o mean_temp.txt
city_temp = open('mean_temp.txt', 'a+')
city_temp.write("\nRio de Janeiro,Brazil,30.0,18.0")
city_temp.close()
new_file = open('mean_temp.txt','r')
headings = new_file.readline()
print(headings)
headlist = headings.split(',')
print(headlist)
temp = city_temp.readline()
while temp:
temp = temp.split(',')
print(new_file[0].capitalize(), "of", temp[0].title(), new_file[2], "is", temp[2], "Celsius")
temp = city_temp.readline()
city_temp.close()
# [ ] use curl to download https://raw.githubusercontent.com/MicrosoftLearning/intropython/master/digits_of_pi as pi.txt
!curl https://raw.githubusercontent.com/MicrosoftLearning/intropython/master/digits_of_pi -o pi.txt
# [ ] Set up the project files and initial values
piread = open('pi.txt','r')
name = input("Name:")
seed = len(name)
piread.seek(seed)
digit = piread.read(1)
guess = input("enter a single digit guess or q to quit")
correct = 0
wrong = 0
piread = open('pi.txt','r')
name = input("enter hi")
seed = len(name)
piread.seek(seed)
digit = piread.read(1)
guess = input("enter a single digit guess or q to quit")
correct = 0
wrong = 0
while guess.isdigit():
if digit == ".":
digit = piread.read(1)
elif digit == "\n":
seed = 1
piread.seek(seed)
digit = piread.read(1)
else:
if int(guess) == int(digit):
print(guess, ":correct")
correct += 1
else:
print("Number is", digit, "not", guess)
wrong += 1
guess = input("input a non-digit guess")
digit = piread.read(1)
print("Correct",correct,"\n Incorrect",wrong)
piread.close()