100 Days of Code: The Complete Python Pro Bootcamp for 2022 - Day 5 (FizzBuzz)
Published: 2023-04-02 09:21:14

Exercise 5.1 - Average Height
```python
#🚨 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
```python
#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
```python
#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
```python
# 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)

```
Project 5 Password Generator
```python
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 = ['!', '#', '$', '%', '&', '(', ')', '*', '+']

print("Welcome to the PyPassword Generator!")
nr_letters= int(input("How many letters would you like in your password?\n")) 
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**

password = ""

for char in range(1, nr_letters + 1):
  password += random.choice(letters)

for char in range(1, nr_symbols + 1):
  password += random.choice(symbols)

for char in range(1, nr_numbers + 1):
  password += random.choice(numbers)

print(password)

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

password_list = []

for char in range(1, nr_letters + 1):
  password_list.append(random.choice(letters))

for char in range(1, nr_symbols + 1):
  password_list += random.choice(symbols)

for char in range(1, nr_numbers + 1):
  password_list += random.choice(numbers)

random.shuffle(password_list)

password = ""

for char in password_list:
  password += char

print(f"Your new password is: {password} ")
```