Updated Python Programs Shivang Updated
Updated Python Programs Shivang Updated
Class: 10th C
Roll No.: 28
Expected Outcome:
Input: 2024
Output: 2024 is a leap year.
2. WAP to input sides of a triangle and calculate its area using Heron's formula
Python Code:
Expected Outcome:
Input: a = 3, b = 4, c = 5
Output: Area of the triangle = 6.0
3. Write a program to input a number and determine whether it is a prime number or not
Python Code:
Expected Outcome:
Input: 7
Output: 7 is a prime number.
4. Write a program to input the principal, rate, and time to calculate simple interest
Python Code:
Expected Outcome:
if num % 2 == 0:
print(str(num) + " is an even number.")
else:
print(str(num) + " is an odd number.")
Expected Outcome:
Input: 4
Output: 4 is an even number.
6. Write a program to convert a temperature from Celsius to Fahrenheit
Python Code:
Expected Outcome:
Input: Celsius = 0
Output: Fahrenheit = 32.0
7. WAP to print all even numbers from 1 to 100
Python Code:
Expected Outcome:
Expected Outcome:
Input: -5
Output: The number is negative.
9. Write a program to input two numbers and swap their values
Python Code:
Expected Outcome:
Input: a = 3, b = 4
Output: a = 4, b = 3
10. Write a program to input a number and display its square
Python Code:
Expected Outcome:
Input: 5
Output: Square of 5 = 25