Define "precondition" and "postcondition" as part of your description
Convert the above algorithm to a Python program to output the desired results.
1.Start
2.Initialize Sum , Count to 1 ( Sum = 1 , Count = 1 )
3.Enter a temp
4.Add Temp to sum. ( Sum = Temp + Sum )
5.Increase Counter by 1 ( Count = Count + 1)
6.Repeat step 3 through 5 , Ten times
7.Calculat average temp in Fahrenheit (Average temp = (( sum * 9 / 5 ) + 32 ) / 10 )
8.If t Average temp is more than or equal to 97 and Average temp is less than or equal to 99 then Display “Your body temperature is normal”
9.Else Average temp is more than to 100.4 then Display “You have a fever caused by an infection or illness”
10.End.
1.Start
2.Initialize Sum , Count to 1 ( Sum = 1 , Count = 1 )
3.Enter a temp
4.Add Temp to sum. ( Sum = Temp + Sum )
5.Increase Counter by 1 ( Count = Count + 1)
6.Repeat step 3 through 5 , Ten times
7.Calculat average temp in Fahrenheit (Average temp = (( sum * 9 / 5 ) + 32 ) / 10 )
8.If t Average temp is more than or equal to 97 and Average temp is less than or equal to 99 then Display “Your body temperature is normal”
9.Else Average temp is more than to 100.4 then Display “You have a fever caused by an infection or illness”
10.End.
1.Start
2.Initialize Sum , Count to 1 ( Sum = 1 , Count = 1 )
3.Enter a temp
4.Add Temp to sum. ( Sum = Temp + Sum )
5.Increase Counter by 1 ( Count = Count + 1)
6.Repeat step 3 through 5 , Ten times
7.Calculat average temp in Fahrenheit (Average temp = (( sum * 9 / 5 ) + 32 ) / 10 )
8.If t Average temp is more than or equal to 97 and Average temp is less than or equal to 99 then Display “Your body temperature is normal”
9.Else Average temp is more than to 100.4 then Display “You have a fever caused by an infection or illness”
10.End.
Given the length and breadth of a rectangle, write a program to find whether the area
of the rectangle is greater than its perimeter. For example, the area of the rectangle
with length = 5 and breadth = 4 is greater than its perimete
Write conditional expressions for
If a < 10 b =20, else b = 30
Print 'Morning' if time < 12, otherwise print 'Afternoon'
Write a nested loop program to get the following output:
Traversing through list using nested loop
Outer Loop 10
Inner Loop A
Inner Loop B
Inner Loop C
Outer Loop 20
Inner Loop A
Inner Loop B
Inner Loop C
Outer Loop 30
Inner Loop A
Inner Loop B
Inner Loop C
Invent your own function that does some useful computation of your choosing. Use incremental development, and record each stage of the development process as you go. Finally, print output that demonstrates that the function works as you intended.
Include all of the following in your Learning Journal:
Incremental development. Do the exercise at the end of that section:
As an exercise, use incremental development to write a function called hypotenuse that returns the length of the hypotenuse of a right triangle given the lengths of the other two legs as arguments. Record each stage of the development process as you go. (Downey, 2015)
After the final stage of development, print the output of hypotenuse(3, 4) and two other calls to hypotenuse with different arguments.
Include all of the following in your Learning Journal:
Using recursion and the is_divisible function from Section 6.4. Your program may assume that both arguments to is_power are positive integers. Note that the only positive integer that is a power of "1" is "1" itself.
After writing your is_power function, include the following test cases in your script to exercise the function and print the results:
print("is_power(10, 2) returns: ", is_power(10, 2))
print("is_power(27, 3) returns: ", is_power(27, 3))
print("is_power(1, 1) returns: ", is_power(1, 1))
print("is_power(10, 1) returns: ", is_power(10, 1))
print("is_power(3, 3) returns: ", is_power(3, 3))
You should submit a script file and a plain text output file (.txt) that contains the test output. Multiple file uploads are permitted. Don’t forget to include descriptive comments in your Python code.