Python Basics
Python Basics
List:
#!/usr/bin/python
Tuple:
#!/usr/bin/python
dict = {}
dict['one'] = "This is one"
If clause:
#!/usr/bin/python
var = 100
While:
#!/usr/bin/python
count = 0
count = count + 1
#!/usr/bin/python
var = 1
while var == 1 : # This constructs an infinite loop
Above example goes in an infinite loop and you need to use CTRL+C to exit the program.
While else:
#!/usr/bin/python
count = 0
while count < 5:
else:
print count, " is not less than 5"
0 is less than 5
1 is less than 5
2 is less than 5
3 is less than 5
4 is less than 5
5 is not less than 5
while clause consists only of a single statement, it may be placed on the same line as the while header.
For strings:
#!/usr/bin/python