-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTUTO.py
More file actions
31 lines (31 loc) · 1.05 KB
/
Copy pathTUTO.py
File metadata and controls
31 lines (31 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# *A little Python Tutorial*
# A comment starts with #
# This tutorial is mostly about the syntax of the loops
for i in {"blub", "blab", "blib"}:
print(i)
# for-loops in Python are called with a list and not
# with an incremented variable.
# The loop walks through the list right to the in and i gets the value of the
# variable in the list. After the list is a ':' and the commands
# which are in the loop must be intended.
for i in range(1,11):
print(i)
# If you want to make a for-loop with a counter variable,
# you must use "range(start,stop)".
# IMPORTANT: i will never get the value of the stop argument!
while i < 20:
i += 1
print(i)
# The syntax of while is easier: while [condition]:
# If you thought "Why not using i++?", here's the answer:
# In Python are not incrementing or decrementing operators,
# but +=, -=, *=, /=, ^= and %= exists.
if input("Number please: ") == 20:
print("The number equals 20.")
else:
print("The number doesn't equal 20")
# I think this syntax is pretty easy.
#if [condition]:
# commands
#else:
# commands