Functions- Basic Assignments

  1. Create a non-return type function that takes the user's name and display the message "Hello user! Welcome to Python Functions"

Solution
def greeting(user_name):
    print('Hello',user_name,'!Welcome to Python Functions')
    
name=input('Enter your name:')
greeting(name)
  1. Create a non-return type function that takes the details of user like name,age, city, company, and profile and display the message- "Hello Python, I am name. I am age years old. I am a profile in company"

Solution
def introduction(user_name,user_age,user_profile,user_company):
    print('Hello Python, I am',user_name,'.I am',user_age,'years old. I am a',user_profile,'in',user_company,'.')

name=input('Enter your name:')
age=int(input('Enter your age:'))
profile=input('Enter Your profile:')
company=input('Enter your company:')

introduction(name,age,profile,company)
  1. Create a return type function that takes the length and breadth of a rectangle and calculate area of the rectangle.

Solution
def area_of_rectangle(length,breadth):
    area=length * breadth
    return area

length=int(input('Length of the rectangle:'))
breadth=int(input('breadth of the rectangle:'))

print('Area of the rectangle is ',area_of_rectangle(length,breadth))
  1. Create a return type function that takes weight and height of a user and return the bmi of the user. Depending upon the bmi show the category that the custimer belongs to.

Solution
  1. Create a return type function that takes principle, rate, and time from the user and then return simple interest after calculation.Afterwards Calculate amount that the user has to repay.

Solution
  1. Create a return function that takes the radius and height of a cylinder and return the total surface area. TSA = 2πr*(r + h).

Solution
  1. Create a function that takes the radius and height of a cone and return the volume. V=1/3hπr²

Solution
  1. Create a function that returns the quotient and remainder after dividing two numbers.

Solution
  1. Create a return type function that takes marks of 5 subjects from a student and calculates the percentage of the student.

Solution
  1. Create a function called create_bill that takes product name,price, and qty and return the bill.

Solution

Last updated