Python Shell and Files Working with Python construct a program that interacts wi
ID: 3887719 • Letter: P
Question
Python Shell and Files Working with Python construct a program that interacts with the user while exploring basic data types The objective of this project is to become familiar with the Python programming language at an elementary level through both trial and error and a group effort The program should perform, at least, the following tasks. Using an interface explain what the program does to the user. Ask the user to enter their name. Respond to the user. State the data types used. Perform some basic arithmetic. Discuss data types, integer, float, complex Explore other basic mathematical operations.Explanation / Answer
Below is the python code:
import sys
name = raw_input("What's your name? ") #Asking For your name
print("Nice to meet you " + name + "!, Basically we are here to explain you the mathematical operations done in python ")
##Additon Function for Integers
def int_addition():
print ("This is for Integer Mathematical Operations ")
num1=raw_input("Enter first number: ")
num2=raw_input("Enter Second number: ")
sum = int(num1) + int(num2)
print('The sum of Integers {0} and {1} is {2}'.format(num1, num2, sum))
print (' ')
##Additon Function for Float
def float_addition():
print ("This is for Float Mathematical Operations ")
num1=raw_input("Enter first number: ")
num2=raw_input("Enter Second number: ")
sum = float(num1) + float(num2)
print('The sum of Integers {0} and {1} is {2}'.format(num1, num2, sum))
print (' ')
##Additon Function for Complex Numbers
def complex_num():
print ("This is for Complex Mathematical Operations ")
x=complex(3,4)
print (x)
##Calling the Functions defined above
int_addition()
float_addition()
complex_num()
###Similarly You can replace the mathematical operations with the "-","*" & "/" for subtraction, multiplication and division
Thanks for the question, Please let me know if you have any queries, will be glad to help.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.