├── README.md ├── program01.py ├── program02.py ├── program03.py ├── program04.py ├── program05.py └── program06.py /README.md: -------------------------------------------------------------------------------- 1 | # Python-01 2 | Assignment-4 3 | -------------------------------------------------------------------------------- /program01.py: -------------------------------------------------------------------------------- 1 | #Q 01.Write a program that takes a number n checks whether the number is even or odd. 2 | x=int(input("enter a number")) 3 | if(x%2==0): 4 | print("number is even") 5 | else: 6 | print("it is a odd number") 7 | -------------------------------------------------------------------------------- /program02.py: -------------------------------------------------------------------------------- 1 | #Q 02.Enter three integers (i)print the largest of the three. 2 | #(ii)sum of all inputs. 3 | #(iii)sum of non-duplicate number. 4 | #(i): 5 | 6 | x, y, z =input("enter three numbers\n").split(" ") 7 | print(f"{x} {y} {z}") 8 | if(x>=y and x>=z): 9 | print("x is the largest number among them",x) 10 | elif (y>=z): 11 | print("y is largest number among them",y) 12 | else: 13 | print("z is the largest number among them",z) 14 | 15 | #(ii): 16 | 17 | x=int(input("enter your 1st number")) 18 | y=int(input("enter your 2nd number")) 19 | z=int(input("enter your 3rd number")) 20 | print(f"{x} {y} {z}") 21 | k=x+y+z 22 | print(k) 23 | 24 | #(iii): 25 | x=int(input("enter your 1st number")) 26 | y=int(input("enter your 2nd number")) 27 | z=int(input("enter your 3rd number")) 28 | if(x != y and y != z and x != z): 29 | k=x+y+z 30 | print(k) 31 | elif (x==y==z): 32 | print('sum is=',0) 33 | elif (x==y): 34 | print('sum is=',z) 35 | elif (y==z): 36 | print("sum is=",x) 37 | elif (x==z): 38 | print("sum is=",y) 39 | 40 | 41 | -------------------------------------------------------------------------------- /program03.py: -------------------------------------------------------------------------------- 1 | #Q 03.Write a program to test the divisibility of a number with another number. 2 | n=int(input("enter the number")) 3 | k=int(input("enter the divisible number")) 4 | if(n%k==0): 5 | print("yes number is divisible by",k) 6 | else: 7 | print("no number is not divisible by",k) 8 | print("final answer is=",n//k) 9 | -------------------------------------------------------------------------------- /program04.py: -------------------------------------------------------------------------------- 1 | #Q 04.Write a program find the multiple of a number out of given five number. 2 | a=int(input("enter number:")) 3 | for i in range(1,6): 4 | print(a,"*",i,"=",a*i) 5 | -------------------------------------------------------------------------------- /program05.py: -------------------------------------------------------------------------------- 1 | #05.Write a program to display a menu for calculating area of a circle or preimeter. 2 | #(i)Ask for radius of a circle? 3 | #(ii)if-elif statement: 4 | 5 | import math 6 | r=float(input("enter the radius of a circle")) 7 | area=math.pi*r*r 8 | print("the area of a circle is:",area) 9 | perimeter=2*math.pi*r 10 | print("the perimeter of a circle is :",perimeter) 11 | 12 | #if-elif statement: 13 | #If >=90 A 14 | #elif >=80 <=90 B 15 | #elif >=70 <=80 C 16 | #else fail 17 | mark=float(input("enter the mark")) 18 | if(mark>=90): 19 | print("A") 20 | elif(mark>=80 and mark<=90): 21 | print("B") 22 | elif(mark>=70 and mark<=80): 23 | print("C") 24 | else: 25 | print("fail") 26 | -------------------------------------------------------------------------------- /program06.py: -------------------------------------------------------------------------------- 1 | #Q 06.Write a program that reads two numbers of an arithmetic operator & display the computed result. 2 | #(i)enter 1&2 3 | #op=input(enter operator[+ - * / %]: 4 | num1=1 5 | num2=2 6 | print("enter which operator would you like to perform") 7 | op=input("enter any of these given operator +,-,*,/,%\n") 8 | if op=='+': 9 | result=num1+num2 10 | elif op=='-': 11 | result=num1-num2 12 | elif op=='*': 13 | result=num1*num2 14 | elif op=='/': 15 | result=num1/num2 16 | elif op=='%': 17 | result=num1%num2 18 | else: 19 | print(" you press invalid operator") 20 | print(num1,op,num2,"=",result) 21 | 22 | --------------------------------------------------------------------------------