Question: Working with Math and the Math Module in Python 1. Enter a new program using the editor. (Python is case-sensitive, so type caps when you
Working with Math and the Math Module in Python
1. Enter a new program using the editor.
(Python is case-sensitive, so type caps when you see caps and lower-case letters when you see lower-case letters.)
a. From the File menu, select New File. Type in the following exactly as you see it there, except replace
## SimpleAddition.py
##
## This program calculates the sum of 2 numbers
def main():
num1 = 7
num2 = 5
answer = num1 + num2
print ("Sum = "+str(answer))
main()
b. Once you have typed the complete program, save the program as SimpleAddition.py. Run it by pressing F5. If you see an error message, you typed something incorrectly. Compare the printout above with your program and fix any discrepancies found. If you cannot find the error, ask the instructor for assistance. (Computers are very picky about how programmers express things, and do not tolerate typos.) Continue this process until the program runs successfully.
2. Writing your own programs.
Write a program similar to the one above that subtracts two numbers and prints the difference. Call this program SimpleDifference.py.
3. User Input.
In order to get input from the user, you should use Pythons input() function. Type the following code. Once you have typed the program, save it using the instructions from 1b above naming the file RectangleArea.py.
## RectangleArea.py
##
def main():
length = int(input("Enter the length: "))
width = int(input("Enter the width: "))
area = length * width
print ("Area = " +str(area))
main()
4. Prompt user for Month of Year.
Write a short program that asks the user to enter a month & prints a message based on the month. (i.e. if the user enters July, the output might print Independence Day Celebration or Summer Time)
Save file as: month.py and upload it to the dropbox.
Hey this is my assignment i actually do not know what to do can you please help me what to do and give me the answers of this.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
