Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9168feb

Browse files
Python Basic Concepts
1 parent 7f10648 commit 9168feb

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

‎basic concepts/statements.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
""" This file is create and managed by Tahir Iqbal
2+
----------------------------------------------
3+
It can be use only for education purpose
4+
"""
5+
6+
# Python Statements
7+
8+
# - if-else statement
9+
# Logical conditions used in statements
10+
# - Equals: a == b
11+
# - Not Equals: a != b
12+
# - Less than: a < b
13+
# - Less than or equal to: a <= b
14+
# - Greater than: a > b
15+
# - Greater than or equal to: a >= b
16+
17+
# if statement - it is a statement that uses logical condition, if conidition is True then the statement block will run otherwise not
18+
a = 33
19+
b = 55
20+
if b > a: # after colon sign next line will written with a tab to show that the next line is in statements block
21+
print("b is greater than a")
22+
23+
# raise an error the statement given below
24+
"""
25+
if b > a:
26+
print("b is greater than a")
27+
"""
28+
29+
# if-else statement - same as above but in this case 'if' condition False then run the code given in 'else' block
30+
if b < a:
31+
print("b is less than a")
32+
else:
33+
print("a is less than b")
34+
35+
# if-else if-else statement - it works same as if-else but after if block write statement 'else if' or 'elif' in short-form, if 'if' coniditon False then check the 'elif' condition if it is true then run 'elif' block and stop the program
36+
if a == b:
37+
print("a is equal to b")
38+
elif b > a:
39+
print("b is greater than a")
40+
else:
41+
print("a is greater than b")

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /