The below 2 problems are scrambled and unindented code.
Reverse engineer the code, so it works. Create a new
program that works. Write pseudocode for this code.
1. UNSCRAMBLE (AND INDENT) THE BELOW CODE:
# given Fahrenheit, calculate Celsuis, allow user to repeat process
break # exit the loop
print('The equivalent temperature in Celsuis is: ' + str(c))
repeat = input('Enter y to run the program again: ')
while True: # always start the loop
c = ((f-32)*5)/9 # calculate Celsuis temperature
print("Thank you for using this program.")
if repeat!='y':
f = float(input('Enter a temperature in Fahrenheit: '))
2. UNSCRAMBLE (AND INDENT) THE BELOW CODE:
# Find the Greatest Common Factor (GCF) of 2 positive integers
# For example, if the two numbers are 35 and 20
# The factors of 35 are 1,5,7,35
# The factors of 20 are 1,2,4,5,10,20
# The GCF is 5
# Allow the user to run the program again until ready to exit
num2 = int(input('Enter another integer: '))
print('This program finds the greatest common factor of 2 numbers.')
if num2%x==0:
num1 = int(input('Enter an integer: '))
while True:
gcf = 1
gcf=x
for x in range(1,num1+1):
if num1%x==0:
print('Thank you for using this program.')
if x>gcf:
if ans=='n':
ans = input('Enter y to run the program again, or n to exit: ')
gcf=x
print('The greatest common factor is: ' + str(gcf))
break