Class 11 Assignment
Class 11 Assignment
Without function:
# Display the welcome message
message = "Welcome, to jnv Gomati"
print(message)
output:
Welcome, to jnv Gomati
With function:
# Welcome message in Python
def display_welcome_message():
message = "Welcome, to jnv Gomati"
print(message)
output:
Welcome, to jnv Gomati
# write a python program to Input two numbers from the user and display the larger one
explanation:
1. The input() function takes user input.
2. The float() function is used to convert the input into a floating-point number (to handle both
integers and decimals).
3. A simple if-elif-else block compares the two numbers and prints the larger one (or states if they
are equal).
out put:
1. Enter the first number: 8
Enter the second number: 5
The larger number is: 8.0
2. Enter the first number: 3
Enter the second number: 10
The larger number is: 10.0
3. Enter the first number: 7
Enter the second number: 7
Both numbers are equal.
# write a Python Program to Input three numbers from the user and display the biggest
number.
num1 = float(input("Enter the first number: "))
num2 = float(input("Enter the second number: "))
num3 = float(input("Enter the third number: "))
Explanation:
It prompts the user to enter three numbers.
It compares the three numbers using if-elif-else statements to determine which
one is the largest.
It then prints the largest number.
Output: 1
Enter the first number: 5
Enter the second number: 8
Enter the third number: 3
The largest number is: 8.0
Output: 2
Enter the first number: 4
Enter the second number: 2
Enter the third number: 9
The largest number is: 9.0
Output: 2
Enter the first number: 7
Enter the second number: 7
Enter the third number: 7
The largest number is: 7.0