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
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)
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
Prompt the user to enter an integer Then, prompt the user to enter a positive integer...
Prompt the user to enter an integer Then, prompt the user to enter a positive integer n2. Print out all the numbers that are entered after the last occurrence of n1 and whether each one is even or odd If n1 does not occur or there are no values after the last occurrence of n1, print out the message as indicated in the sample runs below. Sample: Enter n1: -2 Enter n2: 7 Enter 7 values: -2 3 3 -2...
PYTHON 1. Write a for loop to iterate across a user entered string in reverse order...
PYTHON 1. Write a for loop to iterate across a user entered string in reverse order Use an input statement to ask the user for a string using the prompt: Cheer? [space after the ?] and assign to a variable Start the for loop to iterate across the elements in the string in reverse order Display each element of the string on screen After the for loop ends, display the entire string 2. Write a for loop with a range...
In C code format please! 4.16 LAB: Checker for integer string Forms often allow a user...
In C code format please! 4.16 LAB: Checker for integer string Forms often allow a user to enter an integer. Write a program that takes in a string representing an integer as input, and outputs yes if every character is a digit 0-9. You may assume that the string does not contain spaces and will always contain less than 50 characters. Ex: If the input is: 1995 the output is: yes Ex: If the input is: 42,000 or 1995! the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT