python conditional statements, Lecture notes of Programming Languages

programs and output of python programming language

Typology: Lecture notes

2023/2024

Uploaded on 08/23/2024

sandipan-ray
sandipan-ray 🇮🇳

1 document

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
pf3

Partial preview of the text

Download python conditional statements and more Lecture notes Programming Languages in PDF only on Docsity!

Python Programs on Conditional Statements In [10]: In [11]: In [16]: In [20]: #1. Write a Python Program to check whether a number is 3 digit no or not n=int(input("Enter any number=")) if(n>99 and n<100@) : print(n,"is 3 digit number") else: print(n,"is not 3 digit number") Enter any number=796 796 is 3 digit number #1. Write a Python Program to check whether a number is 3 digit no or not n=int(input("Enter any number=")) if(n>=10@ and n<=999): print(n,"is 3 digit number") else: print(n,"is not 3 digit number") Enter any number=573 573 is 3 digit number # 2. Write a Python Program to check profit and Loss of a product. #1. Write a Python Program to check whether a number is 3 digit no or not cp=int(input("Enter cost price (cp) =")) sp=int(input("Enter selling price (sp) =")) if(sp>cp): print("Profit will be",sp-cp) elif (cp==sp): print("No Profit No Loss") else: print("Loss will be",cp-sp) Enter cost price (cp) =1000 Enter selling price (sp) =1200 Profit will be 200 # 3. Write a Python Program to make a menu based calculator. a=int(input("Enter 1st number=")) b=int(input("Enter 2nd number=")) print("1 for + \t 2 for - \t 3 for X \t 4 for \ \n") ch=int(input("Enter your choice:")) if(ch==1): print("Addition will be",a+b) elif (ch==2): print("Subtraction will be",a-b) elif (ch==3): print("Multiplication will be",a*b) elif (ch==4): print("Division will be",a/b) else: print("You have entered a wrong choice!") Enter 1st numbe Enter 2nd number=2 1 for + 2 for - 3 for X 4 for \ i) Enter your choice:2 Subtraction will be 8 http://localhost:8888/nbconvert/html/Python%20Programs%200n%2... 18-10-2023, 23:07