Question

In: Computer Science

On Python a) Use format() method to print an integer value entered by the user and...

On Python

a) Use format() method to print an integer value entered by the user and its cube root with two decimal places.

b) Print the same values as part (a) using format() function with keyword arguments and labels number and cubeRoot as in: format(number=n,cubeRoot=cr)

c) Switch the order of keyword arguments and show that this has no effect on the output.

Solutions

Expert Solution

Answer for the above question:

code:


#Input from user
n=int(input("Enter Number :"))
#Calculating cube Root
cr = pow(n,1/3)

#a Answer
#using format function to print number and cube root
print("Cube Root of {} is {:.2f}".format(n,cr))

#b Answer
#Keyword arguments and labels
print("Cube Root of {number} is {cubeRoot:.2f}".format(number=n,cubeRoot=cr))

#c Answer
#Switcing keyword arguments
print("Cube Root of {number} is {cubeRoot:.2f}".format(cubeRoot=cr,number=n))

OUTPUT:

PS: If you have any doubt please mention in the comment section. I will solve it as soon as possible.


Related Solutions

PYTHON Let n denote an integer entered by the user. Write a program to print n...
PYTHON Let n denote an integer entered by the user. Write a program to print n multiples of 5 in the descending order, with the last number being 5. Print the average of those n multiples
Write a C++ program that accepts a single integer value entered by user. If the value...
Write a C++ program that accepts a single integer value entered by user. If the value entered is less than one the program prints nothing. If the user enters a positive integer n. The program prints n x n box drawn with * characters. If the user enters 1 , for example the program prints *. If the user enter a 2, it prints ** ** that is , a 2x2 box of * symbols.
1. Use the get() method to print the value of the "name" key and the value...
1. Use the get() method to print the value of the "name" key and the value of the "age" key of the stuInfo dictionary. Use the variable given below: stuInfo = {'name': 'John Smith', "gpa": 3.456, "age": 20} 2. Use the dict() function to make a copy of the NY dictionary to NewYorkState dictionary. 3. Change the "name" value from "John Smith" to "James Bond" of the stuInfo dictionary. Use the variable given below: stuInfo = {'name': 'John Smith', "gpa":...
Create a program that will calculate the factorial of any user entered integer. For any positive integer, the factorial is given as
Create a program that will calculate the factorial of any user entered integer. For any positive integer, the factorial is given as: n! = n·(n-1)·(n-2)·.……·3·2·1. The factorial of 0 is 1. If a number is negative, factorial does not exist and this program should display error message. Sample output dialogues should look like these:  Enter an integer: -5 ERROR!!! Tactorial of a negative number doesn't exist  Enter an integer: 10  Factorial = 3628800
Flowchart + Python. Ask the user for a value. Then, ask the user for the number...
Flowchart + Python. Ask the user for a value. Then, ask the user for the number of expressions of that value. Use While Loops to make a program. So then, it should be so that 5 expressions for the value 9 would be: 9 * 1 = 9 9 * 2 = 18 9 * 3 = 27 9 * 4 = 36 9 * 5 = 45 Flowcharts and Python Code. Not just Python code. I cannot read handwriting....
Write a Python program which prompts the user to input a string. Then, print the string...
Write a Python program which prompts the user to input a string. Then, print the string in reverse to the terminal Sample output Please enter a word: "zeus" The reverse of zeus is suez Hint: There are several ways to accomplish this. Recall that a string is an itterable object and therefore can be used with a for loop
Python A program which prompts the user to enter an number which is a integer n...
Python A program which prompts the user to enter an number which is a integer n and creates a tuple where the values are all numbers between 1 and n (both inclusive). Note: you can assume that the integer will always be > 1. Input Result 3 Enter an integer: 3 (1, 2, 3)
PYTHON: Write a program to continuously asks the user an score given as integer percentages in...
PYTHON: Write a program to continuously asks the user an score given as integer percentages in the range 0 to 100. Calculate the total number of grades in each letter-grade category as follows: 90 to 100 is an A, 80 to 89 is a B, 70 to 79 is a C, 60 to 69 is a D, and 0 to 59 is an F. Use a negative score as a sentinel value to indicate the end of the input. (The...
using python without external libaries Using integer arithmetic operators '+' and '-', print all combinations that...
using python without external libaries Using integer arithmetic operators '+' and '-', print all combinations that sum up to 'sum' by inserting the operators between digits in 'number'. example for 'number=123456789' and 'sum = 0' Print the output using the terminal: Output should be exactly like this from 1 - 22 1 : +1+2-34-56+78+9=0 2 : +1-2-34+5+6+7+8+9=0 3 : +1-23-4-56-7+89=0 ... 12 : -1+2+34-5-6-7-8-9=0 13 : -1+23+4+56+7-89=0 14 : -1-2+34+56-78-9=0 ... 22 : -12-34+56+7-8-9=0
(PYTHON) prompt the user to enter a single-digit num and print that num as follow: 1)...
(PYTHON) prompt the user to enter a single-digit num and print that num as follow: 1) use loops 2) print num in words. Example: 5 is 'five' 3) the number of spaces that go back and forth should equal the num if the user inputs 5, the program prints: five . . . . .five five . . . . . five five and 2 would be: two . .two (the periods(.) are only for demonstration purposes. Don't include it...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT