0% found this document useful (0 votes)
10 views6 pages

CSE039 Lab 2

Uploaded by

niyaelsalaiji
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)
10 views6 pages

CSE039 Lab 2

Uploaded by

niyaelsalaiji
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/ 6

QUESTION 1

print(2+8/2*3)

14.0

print(2+8//2**3)

print((6+3)-8//4*2+3)

print(2**(2+3)-4//2*2+2)

30

print(5<6<8)

True

print(5*3>10 and 4+6==11)

False

x=4
print("ABC"*x)

ABCABCABCABC

print(int(2**3/5))

x,y=7,2
x,y,x=x+1,y+3,x+10
print(x,y)

17 5

name = "Krishna"
age = 21
print("Hello",name,"Your age is:",age,end="")
print("You will be",age+1,"Nextyear")

Hello Krishna Your age is: 21You will be 22 Nextyear

name = "Krishna"
age = 21
print("Hello",name,"Your age is:",age)
print("You will be",age+1,"Nextyear")
Hello Krishna Your age is: 21
You will be 22 Nextyear

QUESTION 2

b=int(input("enter the breadth:"))


h=int(input("enter the height:"))
x=b*(h**2)
print("Area of the triangle:",(1/2)*x)

enter the breadth: 1


enter the height: 2

Area of the triangle: 2.0

x=int(input("Enter the the square root should be found:"))


print("square root:",x**(1/2))

Enter the the square root should be found: 81

square root: 9.0

r=int(input("enter the radius for finding perimeter:"))


print("perimeter:",2*3.14*r)

enter the radius for finding perimeter: 1

perimeter: 6.28

r=int(input("enter the radius for finding area:"))


print("area:",3.14*r**2)

enter the radius for finding area: 9

area: 254.34

print("To find distance")


x1=int(input("enter the x coordinate of 1 st point:"))
x2=int(input("enter the x coordinate of 2 nd point:"))
y1=int(input("enter the y coordinate of 1 st point:"))
y2=int(input("enter the y coordinate of 2 nd point:"))
print("Distance:",((x2-x1)**2+(y2-y1)**2)**(1/2))

To find distance

enter the x coordinate of 1 st point: 5


enter the x coordinate of 2 nd point: 5
enter the y coordinate of 1 st point: 8
enter the y coordinate of 2 nd point: 4

Distance: 4.0
print("finding quadratic eqn")
a=int(input("enter the coefficient of x^2"))
b=int(input("enter the coefficient of x:"))
c=int(input("enter the constant term:"))
x=(b**2-4*a*c)**(1/2)/4*a
print("solutions are:",-b+x,-b-x)

finding quadratic eqn

enter the coefficient of x^2 1


enter the coefficient of x: 2
enter the constant term: 1

solutions are: -2.0 -2.0

QUESTION 3

output writing

Enter a value: 4 4

Enter a value: 5 Enter a value: 8 58

Enter a value: 3 Enter a value: 4 7

Enter your name: niya Enter your age: 17 Enter your marks: 90.0 The name is: niya The age is: 17
The marks is: 90.0

QUESTION 4

q=input('Enter a value: ')


x=int(q)
print(x+1)

Enter a value: 3

QUESTION 5

s=0
for i in range(5):
x=int(input("Enter a no:"))
s+=x
print("Total:",s)

Enter a no: 10
Enter a no: 20
Enter a no: 30
Enter a no: 40
Enter a no: 50
Total: 150

s=''
for i in range(5):
x=input("Enter a no:")
s+=x
print(s)

Enter a no: 10
Enter a no: 20
Enter a no: 30
Enter a no: 40
Enter a no: 50

1020304050

r=int(input("enter the radius of the circle for finding area:"))


print("area of the circle with radius {} is:".format(r),3.14*r**2)

enter the radius of the circle for finding area: 5

area of the circle with radius 5 is: 78.5

a=int(input("Enter the side of the equilateral triangle:"))


print("The area of the equilateral triangle:",3**(1/2)*a**2/4)

Enter the side of the equilateral triangle: 1

The area of the equilateral triangle: 0.4330127018922193

print("To find the simple interest")


p=int(input("Enter the principal amount:"))
r=int(input("Enter the rate of interest:"))
t=int(input("enter the time period:"))
print('Simple interest:',(p*r*t)/100)

To find the simple interest

Enter the principal amount: 100000


Enter the rate of interest: 2
enter the time period: 10

Simple interest: 20000.0

min=0
hour=0
s=int(input("Enter the no of seconds:"))
if s%60==0:
min=s//60
s=0
else:
min=s//60
s=s%60

if min%60==0:
hour=min//60
min=0
else:
hour=min//60

print(hour,":",min,":",s)

Enter the no of seconds: 3652

1 : 0 : 52

print("Swapping the nos")


print("USING A THIRD VARIABLE")
c=0
a=int(input("enter the first no:"))
b=int(input("enter the second no:"))
print("the nos before swapping:",a,b)
c=a
a,b=b,c
print("the nos after swapping:",a,b)

print("WITHOUT USING A THIRD VARIABLE")


x=int(input("enter the first no:"))
y=int(input("enter the second no:"))
print("the nos before swapping:",x,y)
x=x+y
y=x-y
x=x-y
print("the nos after swapping:",x,y)

Swapping the nos


USING A THIRD VARIABLE

enter the first no: 4


enter the second no: 5

the nos before swapping: 4 5


the nos after swapping: 5 4
WITHOUT USING A THIRD VARIABLE

enter the first no: 4


enter the second no: 5

the nos before swapping: 4 5


the nos after swapping: 5 4

QUESTION 12
a=int(input("enter the no of units it jumps right in a single jump:"))
k=int(input("enter the no of jumps:"))
print("the position of the frog is at:",k*a)

enter the no of units it jumps right in a single jump: 8


enter the no of jumps: 1

the position of the frog is at: 8

QUESTION 13

a=int(input("enter the no of units it jumps right in a single jump:"))


b=int(input("enter the no of units it jumps left in a single jump:"))
k=int(input("enter the no of jumps:"))
print("the position of the frog is at:",(a-b)*k)

enter the no of units it jumps right in a single jump: 4


enter the no of units it jumps left in a single jump: 5
enter the no of jumps: 3

the position of the frog is at: -3

You might also like