Write a Python Program to:
1. That accepts number of employees from user as n. For each employee, it accepts the age. Program should find the total number of employees who are more than 45 years old.
2. That calculates the factorial of a number using while loop. (Factorial of 4 is 1*2*3
Use while loop in both the programs.
Answers
Answered by
2
1.
n = int(input("Enter number of employees"))
emps_morethan_45yo=0
counter = 0
while counter != n:
age = int(input("Enter age of an employee"))
if age > 45:
emps_morethan_45yo += 1
counter += 1
2.
n = float(input("Enter a number"))
ans = 1
counter = n - 1
while counter != 1
ans *= counter
counter -= 1
Answered by
12
1.
n = int(input("Enter the number of employees: "))
print()
ce = 0
i = 0
while i != n:
age = int(input("Enter the age of the employee: "))
if age > 45:
ce = ce + 1
i = i + 1
print()
print("There are", ce, "employees above the age of 45.")
2.
n = int(input("Enter a number: "))
f = 1
i = 1
while i <= n:
f = f * i
i = i + 1
print("The factorial of", n, "is", str(f) + ".")
Equestriadash:
Thanks for the Brainliest! ^_^"
Similar questions