### p19: Add to and Reverse a List

Ask the user to enter 4 words. Add the words to a list (turn them all lowercase). Show the list.

Make a second list, that has the original words in reverse order

Note: use of reverse() or reversed() python functions is not permitted.

Sample Run:
Word 1: One
Word 2: Two
Word 3: Three
Word 4: Four
Original list of words = ['one', 'two', 'three', 'four']
List of words in reverse = [ 'four' , 'three', 'two', 'one' ]

### p20: Count Random Letters

Write a program that makes a list of 10 random letters from A to C.

(Hint use the ASCII table) and a loop that happens 10 times)

The program counts how many times each Letter appears in the list

Use python function count() is not permitted.

Sample Run:
Generating a list of 10 random letters A,B,C:
[A, B, C, B, A, C, A, B, C, C]
The letter A appears: 3 times
The letter B appears: 3 times
The letter C appears: 4 times

### p21: Change a Sentence

Ask the user to enter a sentence, where everything is in lower case.

Your program capitalizes the first letter of every word.

Sample Run:
Please enter a sentence: this is a sentence
Your sentence is: This Is A Sentence.

### p22: sum() , average(), min(), max(), reverse()

Write the definitions and calls for the following functions:

• sum (list_parameter) : returns the sum of numbers inside a list.
• average (list_parameter) : returns the average of numbers inside a list.
• min (list_parameter) : returns the smallest of all numbers inside a list.
• max (list_parameter) : returns the largest of all numbers inside a list.
• reverse(list_parameter) : returns the list in reverse order.
• main () : calls all the functions above.

The use of any built-in python function to aid you solve these is not permitted! You must be able to write these basic function using simple loops and selection. The sum.py program below shows you an example to get you started.

### p23: is_palindrome()

Define and test a function is_palindrome() that recognizes palindromes

Palindrome is a word that looks the same written backwards.

print ( is_palindrome("radar") ) # Shows True

### Midterm 2 Short Programs

Write the following two functions, and test them (show output):

Function 1:

Write a function which takes 2 float PARAMETERS distance and time.

The functions computes and SHOWS the speed = distance/ time rounded to 2 values to the right of the decimal point, for example: speed = 634.16

Function 2:

Write a function which takes 2 PARAMETERS num1, num2.

The function then RETURNS the bigger of the 2 numbers

### Midterm Longer Program

Write a program that accepts the lengths of three sides of a triangle as an input from the user: A, B, C

1) Validate the user input so that the user can only enter positive values for sides A, B, C. All three must be true:

• A > 0
• B > 0
• C > 0

2) The program output should first check if the shape is a triangle. A shape is a triangle if the sum of two side lengths is greater than the third side. All 3 must be true:

• a + b > c
• a + c > b
• c + b > a

3) If it is a triangle, then indicate whether or not the triangle is:

• Equilateral , all 3 sides must be equal (A = B as well as B = C) .
• Right
• A2 + B2 = C2
• A2 + C2 = B2
• C2 + B2 = A2
• Isosceles which is Not Equilateral, only two sides are Equal.
• A = B
• A = C
• B = C
• Another type of triangle, neither of the conditions above is true.

Set up the program so the user can choose to repeat the program, if desired.

Test your program for the 4 types of triangles, and submit the output with your C program.