Question

Python Practice Sample: Question 1. Math Write a program that runs these steps three times: ...

Python Practice Sample:

Question 1. Math Write a program that runs these steps three times:

 Ask the user to enter a non-zero number (can be positive or negative).

 Find the cube of the number and subtracts 100.0 from the cube.

 Calculate the square root of the result above. If the result is negative, multiply the result by -1 so it is positive before calculating the square root.

 Print the result with two decimal places.

Homework Answers

Answer #1

CODE IN PYTHON:

number = int(input("enter a number: "))
cube=number*number*number #calculating cube
ans=cube-100 #cube-100
print("result: ",ans)
if ans<0:#if number is negative then convert it into positive before finding square root
ans=ans*(-1)
sqrt=ans**0.5 #calculating square root
print("Square root is : ","{:.2f}".format(sqrt))

OUTPUT SNIPPET:

Hope this resolves your doubt.

Please give an upvote if you liked my solution. Thank you :)

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Write a PYTHON program that displays a weekly payroll report. A loop in the program should...
Write a PYTHON program that displays a weekly payroll report. A loop in the program should ask the user for the employee number, gross pay, state tax, federal tax, and FICA withholdings. The loop will terminate when 0 is entered for the employee number. After the data is entered, the program should display totals for gross pay, state tax, federal tax, FICA withholdings, and net pay. Input Validation: ▪ Do not accept negative numbers for any of the items entered....
For each equation, write a brief program to compute and print eight steps of Newton's method...
For each equation, write a brief program to compute and print eight steps of Newton's method for finding a positive root (Preferably in Matlab or Python). a. x=2sinx b. x^3=sinx+7 c. sinx=1-x d. x^5+x^2=1+7x^3 for x>=2
1)Write a program that asks a user for a number. If (and only if) the number...
1)Write a program that asks a user for a number. If (and only if) the number is greater than zero print “The number is valid” 2)Write a program that asks a user for a grade. If (and only if) the grade is greater than zero and less than 101, print “The grade is valid” 3)Write a program that asks a user how many widgets they want to buy and prints out what the user should pay. Widgets costs 10 dollars....
Python Practice Sample: Write a program to simulate rolling a 6-sided die until the sum of...
Python Practice Sample: Write a program to simulate rolling a 6-sided die until the sum of the numbers rolled is equal to or greater than 21. If it is exactly 21, print “You won!”; if it is more than 21, print “You lost!.” Show the number rolled and the accumulated total each time. Number rolled: 6. Your total is now: 6. Number rolled: 6. Your total is now: 12. Number rolled: 4. Your total is now: 16. Number rolled: 1....
Create a Python main program which calls two functions enterNum and calcResult and accomplishes the following:...
Create a Python main program which calls two functions enterNum and calcResult and accomplishes the following: 1. The main program calls the function enterNum 3 times. The first time enterNum is called, the main program stores the returned output in the variable xx. The second time, the returned output is stored in the variable yy and the third time in zz. 2. enterNum asks the user to enter a floating point number. This function has no input arguments and returns...
Python code only! (Do not include breaks or continue functions) Write a program that asks the...
Python code only! (Do not include breaks or continue functions) Write a program that asks the user to enter the amount that they budgeted for the month. A loop should then prompt the user to enter their expenses, one at a time and to enter 0 to quit. When the loop finishes, the program should display the the amount of budget left. (a negative number indicates the user is over budget and a positive number indicates the user is under...
Python: Write a program that prompts the user to enter a positive integer value, and compute...
Python: Write a program that prompts the user to enter a positive integer value, and compute the following sequence: • If the value is even, halve it. • If it's odd, multiply by 3 and add 1. • Repeat this process until the value is 1, printing out each value. • Then print out how many of these operations you performed. If the input value is less than 1, print a message containing the word Error and exit the program....
Use C++ Write a program that first reads in how many whole numbers the user wants...
Use C++ Write a program that first reads in how many whole numbers the user wants to sum, then reads in that many whole numbers, and finally outputs the sum of all the numbers greater than zero, the sum of all the numbers less than zero (which will be a negative number or zero), and the sum of all the numbers, whether positive, negative, or zero. The user enters the numbers just once each and the user can enter them...
Write a program display the following menu: Ohms Law Calculator 1. Calculate Resistance in Ohms 2....
Write a program display the following menu: Ohms Law Calculator 1. Calculate Resistance in Ohms 2. Calculate Current in Amps 3. Calculate Voltage in volts 4. Quit Enter your choice (1-4) If the user enters 1, the program should ask for voltage in Volts and the current in Amps. Use the following formula: R= E/i Where: E= voltage in volts I= current in amps R= resistance in ohms If the user enters 2 the program should ask for the voltage...
   Dice Game – Accumulator Pattern and Conditionals (40 pts) IN PYTHON Write a program dicegame.py...
   Dice Game – Accumulator Pattern and Conditionals (40 pts) IN PYTHON Write a program dicegame.py that has the following functions in the following order: in python Write a function roll that takes an int n and returns a random number between 1 and n inclusive. Note: This function represents a n sided die so it should produce pseudo random numbers. You can accomplish this using the random module built into python.         (3 pts) Write a function scoreRound that...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT