0% found this document useful (0 votes)
17 views2 pages

Class 11 Assignment

Uploaded by

itnvsjnv
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views2 pages

Class 11 Assignment

Uploaded by

itnvsjnv
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

# Write a welcome message in python using with and without the function.

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)

# Call the function to display the message


display_welcome_message()

output:
Welcome, to jnv Gomati
# write a python program to Input two numbers from the user and display the larger one

num1 = float(input("Enter the first number: "))


num2 = float(input("Enter the second number: "))

if num1 > num2:


print(f"The larger number is: {num1}")
elif num2 > num1:
print(f"The larger number is: {num2}")
else:
print("Both numbers are equal.")

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: "))

if num1 >= num2 and num1 >= num3:


print(f"The largest number is: {num1}")
elif num2 >= num1 and num2 >= num3:
print(f"The largest number is: {num2}")
else:
print(f"The largest number is: {num3}")

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

You might also like