Question

In: Computer Science

ANSWER IT IN PYTHON KINDLY ANSWER PROBLEM 2 AND 3. LEAVE PROBLEM 1 OUT. # General...

ANSWER IT IN PYTHON

KINDLY ANSWER PROBLEM 2 AND 3. LEAVE PROBLEM 1 OUT.

# General instructions:

'''

I suggest you to read the problem statements first and think how you can solve the problem. Think about your own way. Then check out the hints written as comments. After each hint there should be an empty line. Write your line of code in there to satisfy the comment (you may have to store the the value in a variable but that is not given as a hint).

You can use the if/else code blocks that i have given or get some idea from that. But you have to uncomment, fill the conditions, and choose the correct word if/elif/else).

Please discuss your thoughts and ideas with your group.

'''

#Keep the comments(#) and add additional comments when needed.

# Problem 1

# This problem will ask for the total grade(it should be in between 0 to 100 and an integer) and assign a letter grade for that.

# Grading scale: A: 90-100, B: 80-89, C: 70-79, D: 60-69, F: 0-59

# Ask for a grade between 0 to 100

# Convert it to integer

# if/else block

'''

if(#condition for getting A):

letterGrade = "A"

if or elif(#condition for getting B):

letterGrade = "B"

if or elif(#condition for getting C):

letterGrade = "C"

if or elif(#condition for getting D):

letterGrade = "D"

elif or else:

letterGrade = "F"

'''

#print the letter grade along with the given grade

# Problem 2

# This problem will ask for mode of operation of the calculator and two numbers(a, b). According to that it will perform a mathematical operation.

# Opertions to include addition, subtraction, multiplication, division, remainder

# Ask for the mode

# Ask for a

# Ask for b

# Convert a to float

# Convert b to float

# if/else block

'''

if(# condition for addition):

result = # operation for addition

if or elif(# condition for subtraction):

result = # operation for subtraction

if or elif(# condition for multiplication):

result = # operation for multiplication

if or elif(# condition for division):

result = # operation for division

if or elif(# condition for remainder):

result = # operation for remainder

elif or else:

assert mode == "error", "Operation not found"

'''

# Print out the mode of operation, two numbers and the result.

# Problem 3

# This problem will look ask fr three numbers: a, b, c. This will print out the largest number among them.

# Ask for a

# Ask for b

# Ask for c

# Convert a to float

# Convert b to float

# Convert c to float

# if/else block

'''

if(# condition for a being the largest):

largest = a

if or elif(# condition for b being the largest):

largest = b

elif or else:

largest = c

'''

# print out the three numbers and the largest number among them.

Solutions

Expert Solution

Problem 2

Code

mode = input("Enter the mode ") # Ask for the mode
a = int(input("Enter the value of a ")) # Ask for a
b = int(input("Enter the value of b ")) # Ask for b
a = float(a) # Convert a to float
b = float(b) # Convert b to float

# if/else block
if(mode == '+'): # condition for addition
    result = a + b # operation for addition

elif(mode == '-'): # condition for subtraction
    result = a - b # operation for subtraction

elif(mode == '*'): # condition for multiplication
    result = a * b # operation for multiplication

elif(mode == '/'): # condition for division
    result = a / b # operation for division

elif(mode == '%'): # condition for remainder
    result = a % b # operation for remainder

else:
    assert mode == "error", "Operation not found"

print("{0} {1} {2} = {3}".format(a, mode, b, result)) # Print out the mode of operation, two numbers and the result.

Screenshot

Problem 3

Code

a = input("Enter the value of a ") # Ask for a
b = input("Enter the value of b ") # Ask for b
c = input("Enter the value of c ") # Ask for c

a = float(a) # Convert a to float
b = float(b) # Convert b to float
c = float(c) # Convert c to float

# if/else block
if(a > b and a > c): # condition for a being the largest
    largest = a

elif(b > a and b > c): # condition for b being the largest
    largest = b

else:
    largest = c

print("The Largest among {0}, {1} and {2} is {3} ".format(a,b,c,largest)) # print out the three numbers and the largest number among them.

Screenshot

Comments has been filled with the code without deleting it. Also, screenshot of code as well as the output has been provided for the reference.


Related Solutions

Comprehensive Problem 12-53 (LO 12-1, LO 12-2, LO 12-3) Pratt is ready to graduate and leave...
Comprehensive Problem 12-53 (LO 12-1, LO 12-2, LO 12-3) Pratt is ready to graduate and leave College Park. His future employer (Ferndale Corp.) offers the following four compensation packages from which Pratt may choose. Pratt will start working for Ferndale on January 1, year 1.    Benefit Description Option 1 Option 2 Option 3 Option 4 Salary $60,000 $ 50,000 $ 45,000 $ 45,000 Health insurance No coverage 5,000 5,000 5,000 Restricted stock 0 0 1,000 shares 0 NQOs 0...
Kindly answer the 2 case studies below 1. A twenty five year old woman presents at...
Kindly answer the 2 case studies below 1. A twenty five year old woman presents at the OB/GYN with infertility. She has been married for approximately 5 years and has been trying to conceive for the past two years with no success. She reports having begun menses at approximately 15 years of age, but has experienced menstrual irregularity for a number of years. Her FSH levels are high, and she is mildly hirsute (has hair deposition similar to that of...
Kindly provide the functions of the following technical documents: 1. Sales Letter 2. Inquiry Letter 3....
Kindly provide the functions of the following technical documents: 1. Sales Letter 2. Inquiry Letter 3. Application Letter 4. Resume 5. Meeting Minutes
Please answer using python 3 and def functions! Lab 2 Drill 3: (function practice) create and...
Please answer using python 3 and def functions! Lab 2 Drill 3: (function practice) create and use a function named highest() that takes three inputs and returns the highest number. After you have got it working, try calling the function with inputs ‘hat’, ‘cat’, ‘rat’.
Problem 1 ✓ Problem 2 Problem 3 ✓ Problem 4 … Problem 5 … Problem 6...
Problem 1 ✓ Problem 2 Problem 3 ✓ Problem 4 … Problem 5 … Problem 6 ✓ Problem 7 Problem 8 Problem 9 close sidebar webwork / f2019stat213 / stat_213_assignment_3 / 5 STAT 213 Assignment 3: Problem 5 Previous Problem Problem List Next Problem (1 point) To examine the effectiveness of its four annual advertising promotions, a mail order company has sent a questionnaire to each of its customers, asking how many of the previous year's promotions prompted orders that...
Instruction: For this problem, you may leave your answer as as unsimplified expressions with factorials, exponents,...
Instruction: For this problem, you may leave your answer as as unsimplified expressions with factorials, exponents, binomial coefficients, etc. However, you still need to include a brief justification for your results. (40 points - parts (a)–(h): 4 points each; part (h): 8 points In a futuristic dystopian Chicago, society is divided into five factions: Abnegation, Amity, Candor, Dauntless and Erudite. At the age of 16, each person is allowed to choose any faction as their permanent social group at the...
PYTHON: This is the posted problem: General Instructions Create a function called DeterminePrice that will determine...
PYTHON: This is the posted problem: General Instructions Create a function called DeterminePrice that will determine the cost of purchased software. The price is of the software is $350 per license. However, when purchased in larger quantities a discount is given. For quantites less than 10 copies, there is no discount. For quantities greater than 10 and less than and including 20, a 10% discount is given. For quantities greater than 20 and less than and including 30, a discount...
Problem 1-20A (Algo) Product versus selling, general, and administrative (SG&A) costs LO 1-2, 1-3 Campbell Manufacturing...
Problem 1-20A (Algo) Product versus selling, general, and administrative (SG&A) costs LO 1-2, 1-3 Campbell Manufacturing Company was started on January 1, year 1, when it acquired $85,000 cash by issuing common stock. Campbell immediately purchased office furniture and manufacturing equipment costing $9,100 and $35,100, respectively. The office furniture had an eight-year useful life and a zero salvage value. The manufacturing equipment had a $3,900 salvage value and an expected useful life of four years. The company paid $11,500 for...
Problem 1-20A (Algo) Product versus selling, general, and administrative (SG&A) costs LO 1-2, 1-3 Finch Manufacturing...
Problem 1-20A (Algo) Product versus selling, general, and administrative (SG&A) costs LO 1-2, 1-3 Finch Manufacturing Company was started on January 1, year 1, when it acquired $79,000 cash by issuing common stock. Finch immediately purchased office furniture and manufacturing equipment costing $8,400 and $27,200, respectively. The office furniture had an eight-year useful life and a zero salvage value. The manufacturing equipment had a $3,200 salvage value and an expected useful life of three years. The company paid $11,700 for...
PYTHON CODING: In this problem, we will figure out if two balls are colliding. We will...
PYTHON CODING: In this problem, we will figure out if two balls are colliding. We will think in 2D to simplify things, though 3D isn’t different conceptually. For calculating collision, we only care about a ball’s position in space, as well as its size. We can store a ball’s position with the (x, y) coordinates of its center point, and we can calculate its size if we know its radius. Thus, we represent a ball in 2D space as a...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT