mikekameta

Posted on

# 100 Days of Code: The Complete Python Pro Bootcamp for 2022 - Day 5 (FizzBuzz)

Exercise 5.1 - Average Height

``````#ðŸš¨ Don't change the code below ðŸ‘‡
student_heights = input("Input a list of student heights ").split()
for n in range(0, len(student_heights)):
student_heights[n] = int(student_heights[n])
#ðŸš¨ Don't change the code above ðŸ‘†

#Write your code below this row ðŸ‘‡

total_height = 0

for height in student_heights:
total_height += height
print(f"Total height = {total_height}")

number_of_students = 0

for student in student_heights:
number_of_students += 1
print(f"Total students = {number_of_students}")

average_height = round(total_height / number_of_students)
``````

Exercise 5.2 High Score

``````#The aim of the exercise is to use a For Loop function not a max() or min()

#ðŸš¨ Don't change the code below ðŸ‘‡
student_scores = input("Input a list of student scores ").split()
for n in range(0, len(student_scores)):
student_scores[n] = int(student_scores[n])
print(student_scores)
ðŸš¨ Don't change the code above ðŸ‘†
#Write your code below this row ðŸ‘‡
top_score = 0
for score in student_scores:
if score > top_score:
top_score = score
#print(top_score)

print(f"The highest score in the class is: {top_score}")
print(average_height)
``````

Exercise 5.3 Add even numbers from 1-100

``````#Write your code below this row ðŸ‘‡

total = 0
for number in range(1, 101):
if(number %2 == 0):
total += number
print(total)
``````

Exercise 5.4 FizzBuzz

``````# Write your code below this row ðŸ‘‡

for fizzbuzz in range(1, 101):
if fizzbuzz % 3 == 0 and fizzbuzz % 5 == 0:
print("Fizzbuzz")
continue
elif fizzbuzz % 3 == 0:
print("Fizz")
continue
elif fizzbuzz % 5 == 0:
print("Buzz")
continue
print(fizzbuzz)

``````

``````import random
letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
numbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
symbols = ['!', '#', '\$', '%', '&', '(', ')', '*', '+']

nr_symbols = int(input(f"How many symbols would you like?\n"))
nr_numbers = int(input(f"How many numbers would you like?\n"))

#Easy Level - Order not randomized:
#e.g. 4 letter, 2 symbol, 2 number = JduE&!91**

for char in range(1, nr_letters + 1):

for char in range(1, nr_symbols + 1):

for char in range(1, nr_numbers + 1):

#Hard Level - Order of characters randomized:
#e.g. 4 letter, 2 symbol, 2 number = g^2jk8&P**

for char in range(1, nr_letters + 1):

for char in range(1, nr_symbols + 1):

for char in range(1, nr_numbers + 1):