Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python Do all of the items below and submit a text file that is named, if your name is Harry Houdini, for example, HW2_HarryHoudini.py via

Python
image text in transcribed
Do all of the items below and submit a text file that is named, if your name is Harry Houdini, for example, HW2_HarryHoudini.py via Canvas. 1. Write Python code that does the following: (25pts) a. Assigns the values 3,4 and 5 to the variables a, b and c, respectively. b. Write an if statement that prints " OK " if a is less than b c. Write an if statement that prints " OK if c is less than b d. Write an if statement that prints " OK " if the sum of a and b is equal to c e. Write an if statement that prints " OK if the sum of a squared and b squared equals c squared. 2. Repeat the previous problem with the additional requirement that "NOT OK" (25pts) is printed if the condition is false. 3. This question practices the use of a list method. Assign to the variable grades (25pts) a list of 10 letter grades from among ' A ', 'B', 'C', 'D', and ' F '. For example: Write a Python expression that creates a list named frequency, in which the elements are the number of times each of the letters A, B, C, D and F appear in grades. For example, for the above value of grades, the following would be correct output: frequency =[4,2,2,0,2] Your expression must give the correct values for any list of grades, not just the one in your list. Hint: use the list method count. 4. This question practices list membership, list indexes and list slices. (25pts) a. Write a Python statement that creates a list named dog breeds that contains the elements 'collie', 'sheepdog', 'Chow', and 'Chihuahua' in the order given. b. Write a Python statement that uses list slicing to create a list herding_dogs that is made up of the first two elements of dog breeds. c. Write a Python statement that uses list indexing to create a list tiny dogs that is made up of the last element of dog breeds. d. Write a Python statement that tests whether 'Persian' is in the list dog_breeds and prints either True or False depending on the

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle 11G SQL

Authors: Joan Casteel

2nd Edition

1133947360, 978-1133947363

More Books

Students also viewed these Databases questions

Question

8. Provide recommendations for how to manage knowledge.

Answered: 1 week ago