Question

In: Computer Science

Question Objectives: The objectives of this lab exercise are to: Demonstrate an understanding of the concept...

Question Objectives: The objectives of this lab exercise are to: Demonstrate an understanding of the concept of operator precedence in Python expressions and statements. Take simple problem descriptions and produce small but complete Python programs that solve these problems. Give you some practice in using simple Python interactive input and output capabilities. Give you some practice in the simplest Python decision statement (if). Give you some practice in the simplest Python loop statement (while). Specifications: This is a four-part exercise. For the three assignment statements listed below, label the operators according to the order they will be evaluated, i.e., label the first evaluated operator with a 1, the second with a 2, and so on. Then fill in the blank with the result assigned to variable x in each part. i. x = 7 + 3 * 6 / 2 – 1 x = ________ ii. x = 2 % 2 + 2 * 2 – 2 / 2 x = ________ iii. x = ( 3 * 9 * ( 3 + ( 9 * 3 / 3 ) ) ) x = ________ Write a Python program that inputs three (3) integers to IDLE from the keyboard and prints the sum, average, product, smallest and largest of these numbers. For this exercise you may assume the user does NOT enter any duplicate values. The interactive screen dialogue should look something like this (user input is shown in bold): Input three different integers separated by : 13 27 14 Sum is 54 Average is 18 Product is 4914 Smallest is 13 Largest is 27 Write a Python program in IDLE that asks for the radius of a circle and prints the circle’s diameter, circumference, and area. Import the math library for p. Do the calculations for diameter, circumference and area in the output statements. You do NOT need variables for holding your calculated values of diameter, circumference, or area. Just place the appropriate expression as an argument to the print() function. Write a Python program in IDLE that asks for an integer and determines and prints whether it is odd or even. (Hint: Use the modulus operator (%). An even number is a multiple of 2 and any multiple of 2 leaves a remainder of zero (0) when divided by 2). Discussion: In addition to the documentation requirements specified in lab 1, first write the entire program in pseudocode as comments. When necessary place a comment to the right of complicated lines to clarify your code to the reader. Further, comments should not merely repeat what is obvious from a program statement. For example, avoid what follows. This statement below adds nothing to understanding what the statement does or what its purpose is within the program: Sum = Sum + 1 # Add 1 to Sum ß A totally worthless comment! Deliverable(s): Your deliverable should be a Word document with screenshots showing the sample code you have created, and discuss the issues that you had for this project related to AWS and/or Python IDE and how you solved them. Turn in your source code listings for the programs developed above. Include screen shots of the results from running the programs you developed for three (3) sets of test data (for each program). Choose your test cases carefully so they reflect good values to test all aspects of your solutions.

Solutions

Expert Solution

x = 7 + 3 * 6 / 2 - 1
3 * 6 -> 1st
18 / 2 -> 2nd
7 + 9 -> 3rd
16 - 1 ->4th
final result x = 15

x = 2 % 2 + 2 * 2 – 2 / 2
2 % 2 -> 1st
2 * 2 ->2nd
2 / 2 ->3rd
0 + 4 -> 4th
4 - 1 -> 5th
final result x = 3

x = ( 3 * 9 * ( 3 + ( 9 * 3 / 3 ) ) )

(9 * 3 / 3) -> 1st
9 * 3 -> 2nd
(27 / 3) -> 3rd
(3 + 9) ->4th
3 * 9 ->5th
27 * 12 -> 6th
final value x = 324

#prompting the three number as input from the user

a = int(input("enter the first number:"))
b = int(input("enter the second number:"))
c = int(input("enter the third number:"))

#finding the greatest of the three using if condition

def greater(a, b, c):
   if(a > b and a > c):
       return a
   elif(b > a and b > c):
       return b
   elif(c > a and c > b):
       return c
   else:
       return 0

#finding the smallest of the three using if conditions
def smaller(a, b, c):
   if(a < b and a < c):
       return a
   elif(b < a and b < c):
       return b
   elif(c < a and c < b):
       return c
   else:

        return 0

#finding the sum of the three

def sum_all(a, b, c):
   total = a + b + c
   return total

#finding the average of the three

def Average(a, b, c):
   return sum_all(a, b, c) / 3

print("{} {} {} Sum is {} Average is {} smaller is {} greater is {}".format(a, b, c, sum_all(a, b, c), Average(a, b, c),smaller(a, b, c), greater(a, b, c)))

If you have any doubts please comment and please don't dislike.


Related Solutions

Objectives:         The objectives of this lab exercise are to: Demonstrate an understanding of the concept...
Objectives:         The objectives of this lab exercise are to: Demonstrate an understanding of the concept of operator precedence in Python expressions and statements. Take simple problem descriptions and produce small but complete Python programs that solve these problems. Give you some practice in using simple Python interactive input and output capabilities. Give you some practice in the simplest Python decision statement (if). Give you some practice in the simplest Python loop statement (while). Specifications: This is a four-part exercise....
The goal of this exercise is to demonstrate your understanding of the characteristics that influence the...
The goal of this exercise is to demonstrate your understanding of the characteristics that influence the choice of business ownership formation. RT Taxes: After years of preparing taxes for his extended family, Ronald began a tax consultant business from his home office. He hires assistants as needed but does all of the management and main services himself. Pet Perfect: John with an expertise in sales, and Francine, with an expertise in management, opened a pet shop together, sharing profits and...
How Much Iron is in Total Cereal?        The following at home lab exercise will demonstrate...
How Much Iron is in Total Cereal?        The following at home lab exercise will demonstrate that iron is actually in iron fortified cereal such as Total.        Materials: 1 cup iron fortified cereal (Total) 2 cups of hot water (from the sink)   1 clear glass large enough to hold the cereal and the water. Magnet- The magnet can be from an inexpensive refrigerator magnet. You will be able to see the results better if you paint the magnet white...
In response to question 4.2 from the textbook, demonstrate your understanding of the differences in the...
In response to question 4.2 from the textbook, demonstrate your understanding of the differences in the design, applications, and usage of the relational database as compared to the use of spreadsheets. Question 4.2 Most DBMS packages contain data definition, data manipulation, and data query languages. For each of the following, indicate which language would be used and why. A database administrator defines the logical structure of the database. The controller requests a cost accounting report containing a list of all...
Que: This question asks you to demonstrate an understanding of the work of Karl Marx as...
Que: This question asks you to demonstrate an understanding of the work of Karl Marx as covered You are to take the side of the proletariat and argue the reason(s) why a fast-food worker SHOULD be paid $15.00 per hour and You are to take the side of the bourgeoisie and argue the reason(s) why a fast food worker SHOULD NOT be paid $15.00 per hour. (The Answer need to be in soft copy only)
Using examples, demonstrate your understanding of the concept of ‘risk management’ in financial markets contexts. How...
Using examples, demonstrate your understanding of the concept of ‘risk management’ in financial markets contexts. How can options be used to manage risk?
This discussion question will have you demonstrate your knowledge of the medical terms, understanding of the...
This discussion question will have you demonstrate your knowledge of the medical terms, understanding of the use of nouns, pronouns, and verbs, by creating a scenario of a patient. Research a medical disease and write 2-3 paragraphs to your classmates describing your patient’s condition using 20 of the words in Section 1, 2, and 3 of the textbook under “Medical Spelling.” You must highlight these words in yellow. You will also need to highlight at least ten nouns, ten pronouns,...
1) Information for this question: You are required to demonstrate your understanding of risk and how...
1) Information for this question: You are required to demonstrate your understanding of risk and how these impact companies and therefore returns for investing in these companies. You will demonstrate your understanding of systematic and unsystematic, business and financial risks in this question. Tasks: Write your discussions in the text box provided and address the following questions. • Contrast the difference between systematic and unsystematic risks and provide an example for each. You can use a company you are familiar...
Demonstrate an understanding of the product development process?
Demonstrate an understanding of the product development process?
Answer each question by defining the term in your own words to demonstrate an understanding. Cite...
Answer each question by defining the term in your own words to demonstrate an understanding. Cite any pertinent Internal Revenue Code sections or Regulations when possible. 1. Applicable Credit Amount 2. Crummey Power 3. Unified Credit 4. Annual Exclusion 5. Net Gift 6. Disclaimer 7. Marital Deduction
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT