'''
*********************************************************
****Assignment 3 Section 1
*********************************************************
'''
#Averaging Grades with a While Loop

# Request user to enter a number of grades to be averaged.
num_grades = int(input("Enter the number of grades to average: "))

# Define variables
total = 0
count = 0

# Create a loop to get the grades
while count < num_grades:
    grade = float(input("Enter grade: "))
    total += grade
    count += 1

# Print overall total and the class average
print("Total of all grades is", total)
print("Class average is", total / num_grades)

'''
*********************************************************
****Assignment 3 Section 2
*********************************************************
'''
# Nested While Loops

# Define outer loop counter
k = 5

# Create nested while loops
while k > 0:
    i = 0
    while i <= 10:
        print(f"k = {k}, i = {i}")
        i += 2
    k -= 1

'''
*********************************************************
****Assignment 3 Section 3
*********************************************************
'''
# While Loop with Sentinel Value

# Tell the user about entering positive numbers or -1 to end
print("Enter a positive number to be added to the total or -1 to end.")

# Define the total variable
total = 0

# Create a loop to process user entered numbers
while True:
    number = int(input())
    if number == -1:
        break
    total += number

# Print the total of the numbers entered
print("The sum of all numbers entered is", total)
