Python is one of the most easiest language, why because,It allows humans to think naturally and write code almost like English. That is the real reason Python became powerful also it removes unnecessary complexity.
Today, Python is used in:
Artificial Intelligence
Cybersecurity
NASA projects
Automation
Data Science
Web Development
Robotics
Condition statement;
Conditional statements help Python decide which code should execute and which code should not execute.
#1. conditional statements:
Programs cannot make decisions
Every line of code would execute in the same order
Applications would not become interactive or smart
2.Conditional statements make programs:
Intelligent
Dynamic
Interactive
Flexible
Loop Statement
Looping statements are used in Python to execute a block of code repeatedly without writing the same code again and again.
Without loops, programmers would need to write repetitive code manually, which makes programs lengthy.
program:
EXAMPLE 1;
count = 1
while count<=5:
print(count*2, end=' ')
count=count+1
print(count)
print(count*2)
end is parameter
In default python put \n in end parameter ,
\n - this means print next line.
Here remove that default \n that's why output is like sequences but 8 have \n so 10 was added that sequences but 10 in default end='\n' that why 12 was gone to next line.
OUTPUT;
2 4 6 8 10 6
12
\n - this means print next line.
Here remove that default \n that's why output is like sequences but 8 have \n so 10 was added that sequences but 10 in default end='\n' that why 12 was gone to next line.
EXAMPLE -2
count = 1
while count<=5:
print(count*2 ) #print(1, end='\n')
count=count+1
print(count)
print(count*2)
I already told you in default end = '\n"
OUTPUT:
2
4
6
8
10
6
12
sep(separate parameter):
print(1, 2, 3, sep='-')
OUTPUT;
1-2-3
Refferal link;
https://dev.to/hariharan_sj_2003/the-backbone-of-python-conditions-and-loops-182j
Top comments (0)