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!
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)))

This problem demonstrates the use of import module. The Python programming language has many strengths, but...
Exercise 2: Import a Python Math Module You can find a list of all of the math functions available in the Python.org Math Functions page found in the Resources. Select any math function(s) that you would like to use in a program. Do the following: Write a program that imports the math module and uses the function that you selected. (Hint: You will need to determine the arguments that must be passed to the function, return the result, and display...
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 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...
Implement the following problem as a self-contained python module. Write a program that continually prompts the user for positive integer values and stores them in a list. You should stop prompting when the user enters a negative integer value. When the user is done entering values, you should print the list of integers they have provided in sorted order. You should then compute the mean and standard deviation of the values in the list. Recall that the mean is just...
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 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...
Rule book: 1.)Must be Python - 2.) no imported module (ie cmath) - no can do on the imports... pure code.. 3.) numbers are float - not integer. Here's the prompt: (Algebra: solve quadratic equations) The two roots of a quadratic equation ax^2 + bx + c = 0 can be obtained using the following formula: r1 = (-b + sqrt(b^2 - 4ac)) / (2a) and r2 = (-b - sqrt(b^2 - 4ac)) / (2a) b^2 - 4ac is called...
I have a program I am trying to build as homework in PYTHON. The program consists of a calculator for shopping where input asks the customer for the price of a product and then print; 1. The TOTAL of all products if the customer wishes to add it on 2. PRINTS "Do you wish to add this to your total" then 3. The TOTAL. then the program repeats as the customer continues to shop. The program must also have a...
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...