Docsity

Introduction to Python Programming: Basic Concepts and Examples, Study notes of Physics

Partial preview of the text

Download Introduction to Python Programming: Basic Concepts and Examples and more Study notes Physics in PDF only on Docsity!

Introduction to Python

  1. Wap to calculate the sum of three no.s. Ans. a= b= c= sum=a+b+c Print (“sum of 3 numbers”,sum)
  2. Wap to calculator the cube of 4. Ans. a= cube= aaa Print (“cube of a”,cube) 3.Wap to calculate the area and perimeter of square. Ans. a= area=a*a

perimeter=4*a print (“area is”,area) print (“perimeter is”, perimeter)

  1. Wap in entermarks of 5 subjects. Calculate total and percentage. Ans. a= b= c= d= e= Sum = a+b+c+d+e Print (“sum of 5 subjects, sum”) percentage=sum 500
    5.Wap to calculate the area of rectangle,whose length is 20 and breadth is 10. Ans. length= breadth= area=l*b

enter=no. 8 Square is 64

  1. Wapt to calculate area os circle using infact functions. Ans. radius input (“enter value of radius”) area= print(“area is “, area) Run Enter value of radius Area =

Conditional and

Statements and Loops

  1. WAP to find the greatest no. out of two no. entered. Ans. a=int(input(“enter a no.”)) b=int(input(“enter another no.”)) If a>b: print(b, “is greater”) WAP to find weather s no. entered is even or odd. Ans. a=int(input(“enter value”))

elif == print (“thursday”) elif== print(“friday”) elif== print(“saturday”) else: print(“invalid input”) WAP to enter a no. and check if the no. is positive, negative and zero. Ans. a=int(input(“enter the no.”) If: a>0: Print (a,”is positive”) Elif: a== Print (a,”is zero”) Else: a< print (a, “is negative”) WAP to print a message as per entered age by user.

AGE message <=2 infant <=12 kid <=17 teenager <=59 adult Otherwise senior citizen Ans. a==int(input(“enter the no.”) If a < print (a,“infant”) If a < print (a,“kid”) If a< print (a, “teenager”) If a< print (a,“adult”) Else: (a,“a senior citizen”)

  1. Display channel name as per channel no. entered by user.

Ans. y=int (input(“enter a year”) If y to 100==0: If y to 400==0: print (“leap year”) Else: print (“not a leap year”)

  1. WAP to find the greatest number out of some numbers entered by user. Ans. a=int (input(“enter no.”)) b=int (input(“ enter no.”)) c=int )input(“enter no.”)) If a>b: print (a, “is greater”) If a>c: print (a, “ is greater”) Else: If b>c print (b, “is greater”) Else: print (c, “is greater”)
  1. WAP to print numbers from 1 to 10 using while loop. Ans. a= While a>=10i print (a) a=a+

THANK YOU MADE BY

TAJE KA

CAS- 9-A

RO NO. - 42