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
1.
Python program to find the
largest number among the three input numbers
num1 = float (input ("Enter first
number: ")) num2 = float (input ("Enter second number: ")) num3 = float (input ("Enter third number: "))
if (num1 >= num2) and (num1 >= num3):
largest = num1 elif (num2 >= num1) and (num2 >= num3): largest = num2 else: largest = num3
print("The largest number is", largest)
2. Code for the Sum of n numbers in Python using
for loop n = input("Enter value of n: ") n = int(n) total_sum = 0 for i in range(1, n+1): total_sum = total_sum + i print("Total sum is: ", total_sum)
3. Python program to find the
multiplication table (from 1 to 10) of a number input by the User)
num=int(input("Display multiplication table of?
")) for i in range(1,11): print(num,'x',i,'=',num*i)
4,. Program to add and subtract two numbers.
# Store the two numbers num1 = int(input("Enter the first number: ")) num2 = int(input("Enter the second number: ")) # Add the two numbers sum = num1 + num2 # Subtract the two numbers difference = num1 - num2 # Print the result print("The sum of the two numbers is:", sum) print("The difference of the two numbers is:", difference)