0% found this document useful (0 votes)
2 views4 pages

Untitled1.Ipynb - Colab

The document contains a series of Python programs that perform various tasks such as accepting user input for names and ages, calculating multiples of numbers, swapping values, and checking eligibility for voting. It also includes programs for basic arithmetic operations, determining maximum and minimum values, and implementing simple games like guessing and rock-paper-scissors. Each program is demonstrated with example inputs and outputs.
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)
2 views4 pages

Untitled1.Ipynb - Colab

The document contains a series of Python programs that perform various tasks such as accepting user input for names and ages, calculating multiples of numbers, swapping values, and checking eligibility for voting. It also includes programs for basic arithmetic operations, determining maximum and minimum values, and implementing simple games like guessing and rock-paper-scissors. Each program is demonstrated with example inputs and outputs.
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/ 4

23/01/2025, 18:40 Untitled1.

ipynb - Colab

write a program in python to accept name of a person and display

N=input("Name:")
A=int(input("age:"))
Rage=60-A
print("Name : ",N)
print("age : ",A)
print("retirement ; ",Rage)

wap to accept a number and display its 5 multiples

N=int(input("Number:"))
N1=N*1
N2=N*2
N3=N*3
N4=N*4
N5=N*5
print("N*1 : ",N1)
print("N*2 :",N2)
print("N*3 :",N3)
print("N*4 :",N4)
print("N*5 :",N5 )

Number:1
N*1 : 1
N*2 : 2
N*3 : 3
N*4 : 4
N*5 : 5

wap to accept 2 numbers and swap them

a=int(input("first number:"))
b=int(input("second number:" ))
a,b=b,a
print("the value of a after sw:",a)
print("the value of b",b)

first number:3
second number:4
the value of a: 4
the value of b 3

wap to accept 3 number find sum,average,and product

a=int(input("enter first number:"))


b=int(input("enter second number:"))
c=int(input("enter third number:"))
s=a+b+c
average=a+b+c/3
product=a*b*c
print("sum of ",a,b,"and", c,6s)
print("average of",a,b,c,average)
print("product of",a,b,c,product)

enter first number:9


enter second number:7
enter third number:6
sum of 9 7 and 6 22
average of 9 7 6 18.0
product of 9 7 6 378

wap to accept product name,price, quantity.calculate Gst and net cost

n=input("productname:")
p=int(input("price:"))
q=int(input("quantity:"))
g=int(input("gst:"))

https://colab.research.google.com/drive/16y2Gn3rI2i7NwtPk1zNM34V_jvb9nZTw 1/4
23/01/2025, 18:40 Untitled1.ipynb - Colab
d=int(input("discount:"))
price=p
quantity=q
amount=p*q
gst=g
discount=d
totalamount=pramount + gst/100*amount
netcost=totalamount-discount
print("totalamount=amount+gst/amount*100",totalamount)
print("netcost=totalamount-discount",netcost)

productname:a
price:1
quantity:10
gst:5
discount:0
totalamount=amount+gst/amount*100 10.5
netcost=totalamount-discount 10.5

check larger in 2 number

a=int(input("enter first number"))


b=a=int(input("enter second number"))
if a>b:
print(a,"is larger than",b)
else:
print(b,"is larger than",a)

enter first number5


enter second number3
5 is larger than 3

wap to accept age of a person and check of he is eligible to vote

n=int(input("enter age,"))
a=(18)
if n>=a :
print("You are eligible to vote")
else :
print("You are not eligible to vote")

wap to accept a number and check if positive or negative

n=int(input("enter number"))
a=1
if n>=1 :
print("number is positive")
else:
print("number is negative")

enter number-1
number is negative

wap to accept number and check it is one digit number or 2 digit

n=int(input("enter number"))
a=9
b=99
if 10<a>=1 :
print("it is one digit number")
else:
print("it is two digit number")

enter number43
it is two digit number
another number13

WAP to accept items name price and quantity.calculate value,gst and netprice

name=input("enter item name")


price=int(input("enter price"))
quantity=int(input("quantity"))

https://colab.research.google.com/drive/16y2Gn3rI2i7NwtPk1zNM34V_jvb9nZTw 2/4
23/01/2025, 18:40 Untitled1.ipynb - Colab
value=price*quantity
Gst=18/100*value
netprice=value+Gst
print("value",value)
print("Gst",Gst)
print("netprice",netprice)

enter item namea


enter price3750
quantity15
value 56250
Gst 10125.0
netprice 66375.0

wap to accept 2 numbers and find smaller among them

a=int(input("enter first number"))


b=int(input("enter second number"))
if a>b :
print(b,"smaller number",a)
else :
print(a,"smaller number",b)

wap to accept a number and check if 3 digit or not

a=int(input("enter the number"))


if 1000>a>99 :
print("the number is 3 digit number")
else:
print("the number is not 3 digit number")

wap to accept 3 number and find average and max

a=int(input("enter first number"))


b=int(input("enter second number"))
c=int(input("enter thrid number"))
average=(a+b+c)/3
print("average of number",average)
max=a
if b>max :
max=b
if c>max :
max=c
print("max number=",max)

enter first number1


enter second number2
enter thrid number3
average of number 2.0
max number= 3

wap to accept name and marks obtained of a student check pass or fail

name=input("enter name of student")


m=int(input("enter marks"))
if 50<m :
print("pass")
else :
print("fail")

wap to accept name and marks of 5 subjects find total and also display pass or fail

n=input("name of the student")


E=int(input("enter english marks"))
M=int(input("enter maths marks"))
H=int(input("enter hindi marks"))
S=int(input("enter science marks"))
SC=int(input("enter sst marks"))
totalmarks=E+M+H+S+SC
print("total marks88",totalmarks)
if 150<totalmarks :
print("pass")
else :
print("fail")

https://colab.research.google.com/drive/16y2Gn3rI2i7NwtPk1zNM34V_jvb9nZTw 3/4
23/01/2025, 18:40 Untitled1.ipynb - Colab

wap to make a guese game .generate a random number between 1 to 9 ask user to enter a number if it matches the random number

import random
R=random.randint(1,9)
N=int(input("enter number"))
if R==N :
print("win")
else :
print("loss")

WAP to play rock ,paper,scissor accpet input from user $play

import random
L=["rock", "paper", "scissor"]
N=input("enter your choice")
x=random.randint(0,2)

if N==L[x]:
print("tie")
elif N=="rock" and L[x]=="paper":
print("you win")
elif N=="paper" and L[x]=="scissor":
print("you win ")
elif N=="scissor" and L[x]=="rock":
print("you win")
elif N=="paper" and L[x]=="rock":
print("you lose")
elif N=="scissor" and L[x]=="paper":
print("you lose")
elif N=="rock" and L[x]=="scissor":
print("you lose")
else:
print("invalid choice")

enter your choicerock


tie

https://colab.research.google.com/drive/16y2Gn3rI2i7NwtPk1zNM34V_jvb9nZTw 4/4

You might also like