Question

This problem demonstrates the use of import module. The Python programming language has many strengths, but...

This problem demonstrates the use of import module. The Python programming language has many strengths, but one of its best is the availability to use many existing modules for various tasks, and you do not need to be an experienced computer programmer to start using these modules.

We have given you some incomplete code; note that the very first line of that code contains an import statement as follows:

import math

This statement enables your program to use a math module. A module is a collection of instructions saved together as a whole. So, in this lab you are using the math module. Any time we choose to use a module, we must use an import statement to bring this module into the program. When we import the math module, all the computer instructions contained in the math module are made available to our program, including any functions that have been defined.

If you are interested in finding out what is in the math module you can always go to the Python docs and take a look: Python Docs

Example of using the math module:
print(math.floor(5.4))
will use the floor() function as defined in the math module, and in this case with the argument 5.4, will result in printing the value 5.

Below is the definition of your problem that we are asking you to solve using the math module.

Prompt the user for floating point numbers x, y and z. For the x value your you will the use the following prompt Enter x value:inside of your input statement. Using the same approach you will prompt the user for y and z.

- Given three floating-point numbers x, y, and z, 
your job is to output
     - the **square root** of x,
     - the **absolute value** of (y minus z) , and 
     - the **factorial** of (the **ceiling** of z).  

Example of a sample run:

Enter x value:5

Enter y value:6.5

Enter z value:3.2

Then the expected output from these entries is:

2.23606797749979 3.3 24

Hint: For finding out the square root you will need to use math.sqrt(), you need to use the website recommended above to find out which functions to use in order to solve the rest of the lab problem.

Please help, getting stuck on this program! This is python!

0 0
Add a comment Improve this question Transcribed image text
Answer #1
import math

x = float(input("Enter x value:"))
y = float(input("Enter y value:"))
z = float(input("Enter z value:"))

print(math.sqrt(x), abs(y - z), math.factorial(math.ceil(z)))

Add a comment
Know the answer?
Add Answer to:
This problem demonstrates the use of import module. The Python programming language has many strengths, but...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Select the Python math module function that give you the Euclidean norm, square root of x*x...

    Select the Python math module function that give you the Euclidean norm, square root of x*x + y*y. This is the length of the vector from the origin to point (x, y). sin hypot cos sqrt radians What would be the value printed from the code below? import math print(math.ceil(math.e)) 7 2.718281 3.141592 2 3 What would be the value printed from the code below? import math print(math.floor(math.pi)) 2.718281 3.141592 2 3 6 ex is e raised to the power...

  • Write a Python program to prompt the user for an integer number. Assign this integer to...

    Write a Python program to prompt the user for an integer number. Assign this integer to a variable X. Then assign a variable Y to the X**3 (X to the power 3). Finally, assign the variable Z to the square root of Y and print the values of X, Y, and Z as shown in the example below. Use main() function to define and call the program. Example: Enter an integer number: 3 X = 3 if Y=X**3 then Y...

  • python Question 4: (Textbook Page 82, Q38) Python comes with hundreds of modules. Here is a...

    python Question 4: (Textbook Page 82, Q38) Python comes with hundreds of modules. Here is a challenge for you: find a module that you can import that will generate today's date so you can print it. Use your favorite search engine for help in finding which module you need and how to use it. In the end, write a program that prints today's date. For example, an execution could look like this: The date today is: 2015-09-18 Question 5: Suppose...

  • Python 3, fill out the table (just type) Fill in the table below just like you...

    Python 3, fill out the table (just type) Fill in the table below just like you did in last week's lab. For each expression, we would like you to first compute the expression in your head, without Python. You should that down in the second column, or "" if you have no idea. Next you should use Python to compute the expression. If the answers are different, try to explain why in the last column. Expected Calculated Reason for Expression...

  • Python Programming (Just need the Code) Index.py #Python 3.0 import re import os import collections import...

    Python Programming (Just need the Code) Index.py #Python 3.0 import re import os import collections import time #import other modules as needed class index:    def __init__(self,path):    def buildIndex(self):        #function to read documents from collection, tokenize and build the index with tokens        # implement additional functionality to support methods 1 - 4        #use unique document integer IDs    def exact_query(self, query_terms, k):    #function for exact top K retrieval (method 1)    #Returns...

  • Using Python Version 1. Write a program that uses a "while" loop to print the first...

    Using Python Version 1. Write a program that uses a "while" loop to print the first 10 positive integers and to compute their sum. Print the sum after it is computed. Do the same with a "for" loop. Version 2. Write a program to approximate the square root of a number. Recall that the square root of a number x is a number r such that r*r = x. Newton discovered that if one initial estimate of r is z...

  • Write this program using python. In your program, when you prompt users for values, only prompt...

    Write this program using python. In your program, when you prompt users for values, only prompt them to enter one value at a time. Here is a sample of what your program should look like. Sample Program Run (User input in bold) What is the length of the room (in feet)? 50 What is the width of the room (in feet)? 30 What is the length of the table (in feet)? 8 What is the width of the table (in...

  • Im posting a python program and need to convert it to C++ language. import Tkinter import...

    Im posting a python program and need to convert it to C++ language. import Tkinter import Tkinter as tk from Tkinter import * import time def current_iso8601():     """Get current date and time in ISO8601"""     # https://en.wikipedia.org/wiki/ISO_8601     # https://xkcd.com/1179/     return time.strftime("%m.%d.%Y DATE %H:%M:%S TIME") class Application(tk.Frame):     def __init__(self, master=None):                 tk.Frame.__init__(self, master)         self.pack()         self.createWidgets()         def tstampIn(self):                 clockFile = open("clockTracker.txt","w")         print "You have successfuly Clocked In \n"         clockIn...

  • Part 1: Using Idle Write a Python Script that Does the Following 1. At the top...

    Part 1: Using Idle Write a Python Script that Does the Following 1. At the top of your program, import the math library as in from math import * to make the functions in the math module available. Create a variable and assign into it a constant positive integer number of your choice. The number should be at most 10. 1 Suppose we call this variable x for this writeup document Try something like x = 4 2. Create another...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT