Skip to content

Instantly share code, notes, and snippets.

@enseitankad0
Created March 1, 2018 20:11
Show Gist options
  • Save enseitankad0/c5cf99cf493201e70fc86b2099d44fc1 to your computer and use it in GitHub Desktop.
Save enseitankad0/c5cf99cf493201e70fc86b2099d44fc1 to your computer and use it in GitHub Desktop.
##### LOOPS IN PYTHON ###
for i in range(1,10): #1 2 3 4 5 6 7 8 9 default step is i++
print(i)
#transversal printing
string = "TRANSVERSAL"
for i in range (len(string)):
print(string[i])
for i in range(3):
for j in range(2 ):
print(j)
### 10x10 multiplication table
for i in range (1,11):
print('{:<3}|'.format(i))
#the same as transversal
for i in range (1,11):
print('{:<3}|'.format(i),end="")
for j in range (1,11):
print ('{:>4}'.format(i*j),end="")
if i == 1:
print('\n{:_^44}'.format(""),end="")
print("")
### WHILE ###
condition =10
while condition !=0:
print(condition)
condition = condition - 1
while True:
print("helllo 1 time")
break
# continue
for i in range (1,11):
if i ==5:
continue
print(i) ## no 5 in printed list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment