Unit 1 - Introduction To Python
Unit 1 - Introduction To Python
Reference textbook :
An introduction to Python programming
Author: Gowrishankar S
"""
this is also a multline comment
wow is this possible
"""
example:
print("Hello", "how are you?")
print("Hello", "how are you?", sep="---")
x = ("apple", "banana", "cherry")
print(x)
print(x is not y)
# returns True because x is not the same object as y, even if they
have the same content
print("steve" in x)
# returns True because a sequence with the
value "steve" is in the list
print("mark" in x)
# returns False because a sequence with the
value "mark" is not in the list
if True:
print("true")
else:
print("false")
print("Done")
• The while loop starts with the while keyword and ends with a colon. First
the Boolean expression is evaluated. If the Boolean expression evaluates
to False, then the statements in the while loop block are never executed.
• If the Boolean expression evaluates to True, then the while loop block is
executed. After each iteration of the loop block, the Boolean expression is
again checked, and if it is True, the loop is iterated again.
• Each repetition of the loop block is called an iteration of the loop.
• This process continues until the Boolean expression evaluates to False and
at this point the while statement exits.
• Execution then continues with the first statement after the while loop.
start → value indicates the beginning of the sequence. If the start argument is not
specified, then the sequence of numbers start from zero by default.
stop → Generates numbers up to this value but not including the number itself.
step → indicates the difference between every two consecu^ve numbers in the sequence.
The step value can be both negative and positive but not zero