Description
see the file attachment ……………………………………………………
…...............................................………………………………………………………....
Unformatted Attachment Preview
Purchase answer to see full attachment
Explanation & Answer
Both word and zip files.
Surname 1
Student’s Name
Professor’s Name
Course
Date
Python Final
Question 1
from math import factorial
number = int(input("Enter a number: "))
if number % 2 == 0: # case number is even
fact = factorial(number)
print(f"The factorial of {number} is {fact}")
else: # case number is odd
for i in range(1, 11):
product = i * number
print("{:2} x{:2} = {:2}".format(i, number, product))
Question 2
'''
0, 1, 1, 2, 3, 5, 8, 13, 21, 34 for the first 10 days
step 0: Start
step 1: Declare variables i, a, c, b
step 1.1: Initialize i to 0, a to 0, b to 1, and c to 0
step 2: Enter n (the number of days)
step 3: Display c, display b
step 4: Loop to execute the following
step 4.1: c = a + b
step 4.2: a = b
step 4.3: b = c
step 4.4: display c
Surname 2
step 4.5: increase i by 1
step 5: End
'''
i = a = c = 0
b = 1
n = int(input("Enter the number of due days: "))
print(c, end=", ")
print(b, end=", ")
while i < (n-2):
c = a + b
a = b
b = c
print(c, end=", ")
i += 1
"""
The above program is an implementation of the fibonacci series;
The first term is always 0, the next is 1, and the successive terms are a sum
of their corresponding preceding two terms.The series can go forever except when
restircted
by a specified first n terms where n is the number of required terms, like 50 in
this case,
"""
Question 3
"""
"""
current_temp = 120
required_temp = 115
while current_temp >= required_temp:
print(f"Current temp...