Skip to content

Instantly share code, notes, and snippets.

@MustafaCoder2022
MustafaCoder2022 / mean_SP&max_interest.py
Created October 21, 2022 13:35
11.12. Chapter Assessment
with open('SP500.txt','r') as fileref:
total_sp = 0
count_sp = 0
max_interest = None
for idx,line in enumerate(fileref):
if idx == 0:
continue
@MustafaCoder2022
MustafaCoder2022 / list.py
Created June 14, 2022 08:07
Create a list of numbers 0 through 40 and assign this list to the variable numbers. Then, accumulate the total of the list’s values and assign that sum to the variable sum1.
numbers =list(range(41))
print(numbers)
sum1=0
for i in numbers:
sum1 +=i
print(sum1)
@MustafaCoder2022
MustafaCoder2022 / past_wrds.py
Created June 12, 2022 08:49
For each string in wrds, add ‘ed’ to the end of the word (to make the word past tense). Save these past tense words to a list called past_wrds.
wrds = ["end", 'work', "play", "start", "walk", "look", "open", "rain", "learn", "clean"]
past_wrds =[]
for i in wrds:
i +='ed'
if i not in past_wrds:
past_wrds.append(i)
print(past_wrds)