Conditional STMT Cs

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 13

PYTHON

CONDITIONAL
STATEMENTS
Conditional
statement

( decision
making )
If
statement
If
statement
If…else
statement
If…else
example
elif
statements
elif
statements
1) Write a program in python to check whether
person is eligible to vote or not

2) Write a program to check given number is


positive, negative or zero
Programs
3) Write a program to accept two integers and
based on print the largest.

if_else
4) Write a program to accept three integers and
print the smallest. (smallest.py)
5) Program that inputs three numbers and calculate
two sums as per this:

Sum1 as the sum of all input numbers


Sum2 as the sum of non-duplicate numbers;if there are
duplicate numbers in the input ,ignores them

e.g

Programs for input 2,3,4 sum1=9 sum2=9


For inputs 3,2,3 sum1=8 ,sum2=2(3’s ignored)
For inputs 4,4,4 sum1=12 and sum2=0

based on (twosums.py)

if_else

6)Program to calculate the amount payable after sales


discount,which is 10% up to the sales amount of 20000 and
17.5% on amounts above that. (discount.py)
7) Program that asks the user to enter a
length in cm.if the user enters a negative
length,the program should tell the user that
the entry is invalid.otherwise the program
should convert the length to inches and print
Programs out the result

(1 inch =2.54 cm)

based on
8)A store charges 120rs per item if you buy
if_else less than 10 items. if you buy between 10 and
99 items , the cost is 100 rs per item. If you
buy 100 or more items , the cost is 70 rs.write
a program that asks the user how many items
they are buying and prints the total cost. \
9) Program that reads three
numbers(integers) and print them in
Programs ascending order (ascending.py)

based on 10)Write a program to input length of


three sides of a triangle .then check if
if_else these sides will form a triangle or
not(Rule : a+b> c ;b+c>a ;c+a >b)

You might also like