Thursday, September 28, 2017

Here is the code for the chaos program with the addition of user input for the number of loops.

#This program is chaos program
#in chapter 1
#It shows how chaotic results
#can arise from simple starts
#Steve Conger
#9/28/2017

def main(): #start of the main function block
    print("This program illustrates a chaotic function")
    x=eval(input("Enter a number between 0 and 1 "))
    y=eval(input("Enter the number of loops to do "))
    for i in range(y):
        x = 3.9 * x * (1-x)
        print(i,"\t", x)

main()

Here is the code for the loop variations

for i in range(10,0,-1):
    print(i)


x=5
for i in range(1,x):
    print(i)

Here is the code for the Temperature conversion

#Converts Celsius to Fahrenheit
#Steve Conger
#9/28/2017
#Three things take place in every program
#input--celsius temp
#processing, execution, Algorithm -9/5 * celsius + 32
#output--Fahrenheit

def main():
    celsius = eval(input("Enter a Celsius temperature "))
    fahrenheit = 9/5 * celsius + 32
    print("Your farhenheit temperature for ", celsius, "is " ,fahrenheit)

    

main()




    

No comments:

Post a Comment