0% found this document useful (0 votes)
20 views

Assignment3 62e15ed2f2576

Uploaded by

mindfuse65
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Assignment3 62e15ed2f2576

Uploaded by

mindfuse65
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

# 1.

Addition
def add():
a=int(input("enter value of a:"))
b=int(input("enter value of b:"))
c=a+b
print("Addition value is:",c)
add()
print("\n")

# 2.Subtraction
def sub():
a=int(input("enter value of a:"))
b=int(input("enter value of b:"))
c=a-b
print("subtraction value is",c)
sub()
print("\n")

# 3.Multiplication
def mul():
a=int(input("enter value of a:"))
b=int(input("enter value of b:"))
c=a*b
print("The Multliplication value:",c)
mul()
print("\n")

# 4.Division()
def div():
a=int(input("enter value of a:"))
b=int(input("enter value of b:"))
c=a/b
print("The Division value:",c)
div()
print("\n")

# 5.Evenodd()
def evenodd():
a=int(input("enter value of a:"))
if(a%2==0):
print(a,"is even number:")
else:
print(a,"is odd number:")
evenodd()
print("\n")

# 6.sqrt()
def sqrt():
a=int(input("enter value of a:"))
c=a*a
print("square of a is:",c)
sqrt()
print("\n")

# 7.cuberoot()
def cbrt():
a=int(input("enter value of a:"))
c=a*a*a
print("cuberoot of a is:",c)
cbrt()
print("\n")

# 8. power
def pow():
a=int(input("enter value of a:"))
b=int(input("enter value of b:"))
c=a^b
print("power is:",c)
pow()
print("\n")

# 9.swap()
def temp():
a=int(input("enter value of a:"))
b=int(input("enter value of b:"))
temp= a
a= b
b= temp
print(a)
print(b)
temp()
print("\n")

# 10.increment
def inc():
x=int(input("enter value of x:"))
x+=1
print("increment value",x)
inc()
print("\n")

# 11.decrement
def dec():
a=int(input("enter value of a:"))
a=a-2
print("decrement value is",a)
dec()
print("\n")

# 12.randnumbers
import random
def rand():
a=random.randint(0,200)
print("random number is:",a)
rand()
print("\n")

# 13.assignment operator
def assign():
a=int(input("enter value of a:"))
b=a
print("assigned value is",b)
assign()
print("\n")
# 14.Greeting()
def greet(name):
print("hello",name)
print(name)
greet("python")
print("\n")

# 15.list
def list():
a=["hai","hello",15,59]
print(a)
list()
print("\n")

# 16.append
def append():
a=["hai","hello",15,59]
a.append("python")
print(a)
append()
print("\n")

# 17.remove
def remove():
a=["hai","hello",15,59]
a.remove("hello")
print(a)
remove()
print("\n")
# 18.greater than
def greater():
a=int(input("enter a value:"))
b=int(input("enter b value:"))
if(a>b):
print("a value is greater")
else:
print("not greater")
greater()
print("\n")

# 19.less than
def lesser():
a=int(input("enter a value:"))
b=int(input("enter b value:"))
if(a<b):
print("a value is lessthan b")
else:
print("a is not lesser")
lesser()
print("\n")

# 20.equal
def equal():
a=int(input("enter a value:"))
b=int(input("enter b value:"))
if(a==b):
print("a is equal to b")
else:
print("a is not equal to b")
equal()
print("\n")

# 21.percentage
def marks():
che=int(input("enter chemistry marks:"))
eng=int(input("enter english marks:"))
phy=int(input("enter physics:"))
tot=che+eng+phy
avg=tot/3
print("total marks:",tot)
print("average marks",avg)
marks()
print("\n")

# 22.default
def default(a,b=10):
print(a)
print(b)
default(5)
print("\n")

# 23.repeat
def repeat():
x= 10
while x>2:
print(x)
x=x+1
repeat()
print("\n")

# 24.upper,lower,capital
def upper():
a="python program"
print(a.upper())
upper()
def lower():
b="PROGRAMMING LANGUAGE"
print(b.lower())
lower()
def capital():
c="Python Language"
print(c.capitalize())
capital()
print("\n")

# 25.pass|fail
def marks():
marks= int(input("enter ur marks:"))
if (marks>=0 and marks<=50):
print("you are failed")
elif (marks>=50 and marks<=80):
print("you got medium marks")
elif (marks>=80 and marks<=100):
print("you are passed")
else:
print("marks are not valid")
marks()
print("\n")
# 26. (a+b)2
def square():
a=int(input("enter a value:"))
b=int(input("enter b value:"))
c=a*a+ 2*a*b+ b*b
print(c)
square()
print("\n")

# 27. (a+b)3
def cube():
a=int(input("enter a value:"))
b=int(input("enter b value:"))
c=(a*a*a)+ (b*b*b)+ 3*(a*a)*b+ 3*a*(b*b)
print(c)
cube()
print("\n")

# 28.for loop
def fruits():
fruits= "apple", "banana", "mango", "guava"
for x in fruits:
print(x)
if x=="mango":
break
fruits()
print("\n")

# 29.while loop
def whilel():
x= 10
while x>2:
print(x)
x+=1
if x== 30:
break
else:
print("not elgible")
whilel()
print("\n")

# 30.reverse
def reverse():
num= int(input("enter a number:"))
rev=0
while(num>0):
rem=num%10
rev=(rev*10)+rem
num=num//10
print("reverse value",rev)
reverse()
print("\n")

output:

enter value of a:56


enter value of b:78
Addition value is: 134
enter value of a:34
enter value of b:5
subtraction value is 29

enter value of a:23


enter value of b:54
The Multliplication value: 1242

enter value of a:29


enter value of b:7
The Division value: 4.142857142857143

enter value of a:5


5 is odd number:

enter value of a:87


square of a is: 7569

enter value of a:3


cuberoot of a is: 27

enter value of a:45


enter value of b:6
power is: 43
enter value of a:3
enter value of b:5
5
3

enter value of x:45


increment value 46

enter value of a:87


decrement value is 85

random number is: 138

enter value of a:34


assigned value is 34

hello python
python

['hai', 'hello', 15, 59]

['hai', 'hello', 15, 59, 'python']


['hai', 15, 59]

enter a value:78
enter b value:43
a value is greater

enter a value:55
enter b value:55
a is not lesser

enter a value:89
enter b value:43
a is not equal to b

enter chemistry marks:45


enter english marks:70
enter physics:43
total marks: 158
average marks 52.666666666666664

5
10

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

PYTHON PROGRAM
programming language
Python language

enter ur marks:45
you are failed

enter a value:76
enter b value:34
12100

enter a value:9
enter b value:8
4913

apple
banana
mango

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29

enter a number:215259
reverse value 9
reverse value 95
reverse value 952
reverse value 9525
reverse value 95251
reverse value 952512

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy