input():
input() in Python takes input from a user and returns it as a string by default
name = input("Enter your name: ")
print("Welcome to Python", name)
print(type(name))
Enter your name: RAJA
Welcome to Python RAJA
return statement :
return statement is used to end the execution of the function call and “returns” the result (value of the expression following the return keyword) to the caller
*Example : *
def display():
print("hello")
display()
output:
hello
In this program it displays only hello as output.
*Example 2 : *
def display():
print("hello")
print(display())
output:
hello
none
In this case the function has been terminated after the print statement. no more values has returned to the function so when we asked to display the (display()) function. It gives the output as none.
example 3 :
def display():
print("hello")
return 10+20
print(display())
output:
hello
30
In this case the function is like restarted. when we asked to return some values by putting return statement it starts functioning. it displays the value as 30.
sslc mark calculator
tamil = input("Tamil Mark please: ")
english = input("English Mark please: ")
maths = input("Maths Mark please: ")
science = input("Science Mark please: ")
social = input("Social Mark please: ")
total = (int(tamil) + int(english) + int(maths) + int(science) + int(social))
print("total mark : ",total)
print('average =', (total)*(100/500))
output:
tamil = input("Tamil Mark please: ")
english = input("English Mark please: ")
maths = input("Maths Mark please: ")
science = input("Science Mark please: ")
social = input("Social Mark please: ")
total = (int(tamil) + int(english) + int(maths) + int(science) + int(social))
print("total mark : ",total)
print('average =', (total)*(100/500))
in this program we are getting the marks from the users and printing the total marks and calculating the percentage of the candidate.
EB bill calculator:
consumer = int(input("enter the electricity unit: "))
print("your electricity bill is:", (consumer)*(0.40))
output:
enter the electricity unit: 100
your electricity bill is: 40.0
*EMI calculator : *
P = int(input("Enter the principal amount : "))
N = int(input("Enter the number of months : "))
R = int(input("Enter the monthly interest rate : "))
print("YOUR EMI IS",(P*R*(1+R)**N) / ((1+R)**N-1))
output:
Enter the principal amount : 500000
Enter the number of months : 10
Enter the monthly interest rate : 3.5
YOUR EMI IS 1750000.5139407318
BMI CALCULATOR :
weight = float(input("enter your weight in kgs : ")
height = float(input("enter your height : )
print("YOUR BMI IS : ", weight/h(height**2))
output:
enter your weight in kgs : 104
enter your height : 1.73
YOUR BMI IS : 34.74890574359317
Top comments (0)