0% found this document useful (0 votes)
0 views5 pages

Cse039 Lab 2B

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)
0 views5 pages

Cse039 Lab 2B

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/ 5

sentence="This is a sample sentence"

words=sentence.split()
print(words)

['This', 'is', 'a', 'sample', 'sentence']

sentence = "apple,banana,orange"
fruits = sentence.split(",")
print(fruits)

['apple', 'banana', 'orange']

x, y = input().split()
x = float(x)
print(x)

1 2

1.0

x = "123"
ix = int(x)
print(ix)

123

QUESTION 1

n=int(input("enter the no to be checked odd or evn:"))


if n%2==0:
print("the entered no is an even no")
else:
print("the entered no is an odd no")

enter the no to be checked odd or evn: 5

the entered no is an odd no

QUESTION 2

x=input("enter the character to be checked:")


x.lower()
if x in ['a','e','i','o','u']:
print('The entered character is a vowel')
else:
print("the entered character is a consonant")

enter the character to be checked: e

The entered character is a vowel


QUESTION 3(A)

a=int(input("enter the first no:"))


b=int(input("enter the second no:"))
if a>b:
print("the greater no among", a ,"and", b ,"is:",a)
else:
print("the greater no among", a ,"and", b ,"is:",b)

enter the first no: 2


enter the second no: 3

the greater no among 2 and 3 is: 3

QUESTION 3(B)

a=int(input("enter the first no:"))


b=int(input("enter the second no:"))
c=int(input("enter the third no:"))
if a>b and a>c:
print("the greater no among", a , b, "and", c ,"is:",a)
elif b>a and b>c:
print("the greater no among", a , b, "and", c ,"is:",b)
else:
print("the greater no among", a , b, "and", c ,"is:",c)

enter the first no: 2


enter the second no: 3
enter the third no: 4

the greater no among 2 3 and 4 is: 4

QUESTION 4

print("To check whether the entered year is leap year or not")


y=int(input("enter the year:"))
if y%4==0 and y%100!=0:
print(y,"is a leap year")
elif y%100==0 and y%400!=0:
print(y, "is not a leap year")
elif y%400==0:
print(y, "is a leap year")
else:
print(y, "is not a leap year")

To check whether the entered year is leap year or not

enter the year: 2020

2020 is a leap year


QUESION 5

print("GRADIING OF FINAL EXAM")


marks=int(input("enter your marks scored:"))
if marks>=90:
print("YOU HAVE SCORED GRADE A")
elif marks>=80:
print("YOU HAVE SCORED GRADE B")
elif marks>=70:
print("YOU HAVE SCORED GRADE C")
elif marks>=60:
print("YOU HAVE SCORED GRADE D")
else:
print("YOU HAVE SCORED GRADE F")

GRADIING OF FINAL EXAM

enter your marks scored: 56

YOU HAVE SCORED GRADE F

QUESTION 6

base_cost=0
additional_charge=0
weight=int(input("enter the weight of the package(in pounds):"))
distance=int(input("enter the distance it needs to be shipped(in
miles):"))
if weight<=2:
base_cost=5
elif weight>2 and weight<=10:
base_cost=10
else:
base_cost=20
if distance<=100:
additional_charge=0
elif distance>100 and distance<=500:
additional_charge=5
else:
additional_charge=10
print("TOTAL AMOUNT")
total=base_cost+additional_charge
print("$",total)

enter the weight of the package(in pounds): 23


enter the distance it needs to be shipped(in miles): 500

TOTAL AMOUNT
$ 25

QUESTION 7 (PROBLRM SOLVING 1)


n=int(input("enter the no of test cases:"))
for i in range(n):
x=int(input("enter the amount to be paid for renting the cooler
per month:"))
y=int(input("enter the amount to be paid for purchasing a
cooler:"))
m=int(input("enter the months the summer will be lasting:"))
if m*x>=y:
print("NO")
else:
print("YES")

enter the no of test cases: 3


enter the amount to be paid for renting the cooler per month: 5
enter the amount to be paid for purchasing a cooler: 10
enter the months the summer will be lasting: 1

YES

enter the amount to be paid for renting the cooler per month: 5
enter the amount to be paid for purchasing a cooler: 10
enter the months the summer will be lasting: 2

NO

enter the amount to be paid for renting the cooler per month: 5
enter the amount to be paid for purchasing a cooler: 10
enter the months the summer will be lasting: 3

NO

PROBLEM SOLVING 2

n=int(input("enter the no of test cases:"))


for i in range(n):
x=int(input("enter the amount to be paid for double rooms:"))
y=int(input("enter the amount to be paid for triple rooms:"))
if 3*x>2*y:
print("the minimum amount you have to pay is:",2*y)
print("accodomate triple rooms")
else:
print("the minimum amount you have to pay is:",3*x)
print("accodomate double rooms")

enter the no of test cases: 3


enter the amount to be paid for double rooms: 10
enter the amount to be paid for triple rooms: 15

the minimum amount you have to pay is: 30


accodomate double rooms
enter the amount to be paid for double rooms: 6
enter the amount to be paid for triple rooms: 8

the minimum amount you have to pay is: 16


accodomate triple rooms

enter the amount to be paid for double rooms: 4


enter the amount to be paid for triple rooms: 8

the minimum amount you have to pay is: 12


accodomate double rooms

You might also like