#To swap two numbers
x=input("Enter value of x: ")
y=input("Enter value of y: ")
temp=x
x=y
y=temp
print("The value of x after swapping:{}".format(x))
print("The value of y after swapping:{}".format(y))
#To calculate the area of a triangle
a=float(input("Enter the first side: "))
b=float(input("Enter the second side: "))
c=float(input("Enter the third side: "))
s=(a+b+c)/2
area=(s*(s-a)*(s-b)*(s-c))*0.5
print("The area of triangle is : ",area)
# Program to generate a random number between 0 and 9
import random
print(random.randint(0,9))
#To convert temperature in celsius to fahrenheit
celsius=float(input("Enter the temperature in degree celcius: "))
fahrenheit = (celsius * 1.8) + 32# calculate fahrenheit
print("%0.1f degree Celsius is equal to %0.1f degree Fahrenheit" %(celsius,fahrenheit))
#To check whether the given number is positive or negative
num = float(input("Enter a number: "))
if num > 0:
print("Positive number")
elif num == 0:
print("Zero")
else:
print("Negative number")
# Multiplication table (from 1 to 10) in Python
num = int(input("Enter the table number : "))
# To take input from the user
# num = int(input("Display multiplication table of? "))
# Iterate 10 times from i = 1 to 10
for i in range(1, 11):
print(num, 'x', i, '=', num*i)
# Program to display calendar of the given month and year
import calendar
yy=int(input("Enter the year: ")) # year
mm=int(input("Enter the month: ")) # month
print(“ ******** ”)
print(calendar.month(yy, mm))
#To Reverse a number
num = 1234
reversed_num = 0
while num != 0:
digit = num % 10
reversed_num = reversed_num * 10 + digit
num //= 10
print("Reversed Number: " + str(reversed_num))
#To countdown time
import time
def countdown(time_sec):
while time_sec:
mins, secs = divmod(time_sec, 60)
timeformat = '{:02d}:{:02d}'.format(mins, secs)
print(timeformat, end='\r')
time.sleep(1)
time_sec -= 1
print("stop")
countdown(5)