Quick links
Latest articles
Internship
Members
New...
Algorithms
Discrete Mathematics
Big data
Languages
C
C++
C++ STL
Java
Data Structure
C#.Net
Android
Kotlin
SQL
Web
PHP
Python
JavaScript
CSS
Ajax
Node.js
Web prog.
Programs
C
C++
DS
Java
C#
Python
Aptitude
C
C++
Java
DBMS
Interview
C
Embedded C
Java
SEO
HR
CS Subjects
CS Basics
O.S.
Networks
DBMS
Embedded Systems
Cloud Computing
Machine learning
CS Organizations
Linux
DOS
More...
Articles
Puzzles
News/Updates

Home » Python programs

Python | Some of the examples of simple if else



Python | Examples of if else: Here, we will learn about simple if else by using some of the small example codes.
Submitted by Pankaj Singh, on October 04, 2018

Example1: Enter a number and check whether it is 10 or not

a=int(input("Enter A : "))

if a==10:
    print("Equal to 10")
else:
    print("Not Equal to 10")

Output

Enter A : 10
Equal to 10

Example2: Find largest of two numbers

a=int(input("Enter A: "))
b=int(input("Enter B: "))

if a>b:
    g=a
else:
    g=b

print("Greater = ",g)

Output

Enter A: 36
Enter B: 24
Greater =  36

Example3: Find largest of two numbers using single statement

a=int(input("Enter A: "))
b=int(input("Enter B: "))

c= a if a>b else b

print("Greater = ",c)

Output

Enter A: 24
Enter B: 36
Greater =  36





Quick links:
C FAQ(s) C Advance programs C/C++ Tips & Tricks Puzzles JavaScript CSS Python Linux Commands PHP Android Articles More...

Featured post:
Introduction to Linux (Its modes, Safety, Most popular Applications)
Linux Best Distribution Software (Distros) of 2018

Was this page helpful? Please share with your friends...

Are you a blogger? Join our Blogging forum.

Comments and Discussions



Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com (2015-2018), Some rights reserved.