Please Subscribe My YouTube Channel

Tuesday, January 24, 2023

Python program for swapping two numbers:-


Python program for swapping two numbers:-


P = int( input("Please enter value for P: "))  

Q = int( input("Please enter value for Q: "))  


# To Swap the values of two variables  

P, Q = Q, P  

   

print ("The Value of P is after swapping: ", P)  

print ("The Value of Q is after swapping: ", Q)  


Python Calender Program  Python odd and even program


 

Python program for display calendar:-

Python program for display calendar:- 



# First import the calendar module  
import calendar  
# ask of month and year  
yy = int(input("Enter year: "))  
mm = int(input("Enter month: "))  

# display the calendar  
print(calendar.month(yy,mm))

#output:-

'''Enter year: 2021
Enter month: 02
   February 2021
Mo Tu We Th Fr Sa Su
 1  2  3  4  5  6  7
 8  9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28'''

Python Program for find Odd, Even, sum,min and max value.

1. Program for find Odd and Even number in python


num = int(input("Enter a number: "))  
if (num % 2) == 0:  
   print("{0} is Even number".format(num))  
else:  
   print("{0} is Odd number".format(num)) 


#Output:-
#Enter a number: 12
#12 is Even number

2. Program for find sum, max and min value of given any two digit number in python

a=int(input("Enter any Number:"))
sum=0
max=0
min=99
while a>0:
      n=a%10
      sum=min+max
      a=a//10
      if n>max:
            max=n
      if n<min:
            min=a
print("sum",sum,"min",min,"max",max)
 
#Output:-           
#Enter any Number:56
#('sum', 11, 'min', 5, 'max', 6)