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:
Please enter 4 words
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.

For example, is_palindrome("radar") returns True.

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.

Academic Honesty!
It is not our intention to break the school's academic policy. Projects posted are only used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly fill out the form. Please provide a valid email address and we'll get back to you in less than 24 hours. We will be sending an invoice through PayPal upon confirmation. We are a non profit organization however we need an amount to keep this organization running, and to be able to complete our research and development.