0% found this document useful (0 votes)
14 views2 pages

BA7 Notebook PDF

The document contains Python code examples that use conditional statements like if-else to check various conditions: check if a number is greater than a limit; find the largest of two numbers; check if a number is divisible by 2, 3, or both; check if a character is a vowel or consonant; check nested if statements. It also provides sample outputs for different inputs to the programs.

Uploaded by

Villa Vanitha
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)
14 views2 pages

BA7 Notebook PDF

The document contains Python code examples that use conditional statements like if-else to check various conditions: check if a number is greater than a limit; find the largest of two numbers; check if a number is divisible by 2, 3, or both; check if a character is a vowel or consonant; check nested if statements. It also provides sample outputs for different inputs to the programs.

Uploaded by

Villa Vanitha
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/ 2

1/23/23, 3:25 PM BA7-Notebook - Jupyter Notebook

In [17]:

w = int(input('Enter Weight'))
if(w <= 15):
print("Weight under limit")
else:
extraW = w - 15
amount = 500 * extraW
print("Extra amount ", amount)

Enter Weight20
Extra amount 2500

Q. find lagrest from two number.

Q. check a number is divisable by 2 and 3.

Q. check a number is divisable by 2 or 3.

Q. Q. check a number is divisable by 2 or 3 or both.

Q. Write a program to check entered character is vowel or consonant.

In [18]:

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


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

input first number5


input second number6
Second number is larger 6

In [19]:

n = int(input("input first number"))


if (n%2==0) and (n%3==0):
print("number is divisable by 2 and 3")
else:
print("number is not divisable by 2 and 3")

input first number20


number is not divisable by 2 and 3

In [20]:

n = int(input("input first number"))


if (n%2==0) or (n%3==0):
print("number is divisable by 2 or 3")
else:
print("number is not divisable by 2 or 3")

input first number20


number is divisable by 2 and 3

In [21]:

n = int(input("input first number"))


if (n%2==0) or (n%3==0) or ((n%2==0) and (n%3==0)):
print("number is divisable by 2 or 3 or both")
else:
print("number is not divisable by 2 or 3 or both")

input first number24


number is divisable by 2 or 3

In [22]:

c = input('input a letter')
if (c=='a' or c=='e' or c == 'i' or c == 'o' or c == 'u' or c=='A' or c=='E' or c == 'I' or c == 'O' or c == 'U' ):
print("Vowel")
else:
print("Consonent")

input a lettera
Vowel

Nested if-else

localhost:8888/notebooks/Term4S/scripts/BA7-Notebook.ipynb# 1/2
1/23/23, 3:25 PM BA7-Notebook - Jupyter Notebook
If :
if :
else:
else:
if :
else:

In [25]:

n = 0
if n !=0:
if n%2==0:
print("even")
else:
print("odd")
else:
print("0 is neither even nor odd")

0 is neither even nor odd

In [ ]:

w = int(input('Enter Weight'))
if w > 50:
print("not Allowed")
else:
if(w <= 15):
print("Weight under limit")
else:
extraW = w - 15
amount = 500 * extraW
print("Extra amount ", amount)

localhost:8888/notebooks/Term4S/scripts/BA7-Notebook.ipynb# 2/2

You might also like