Created
August 20, 2015 02:52
-
-
Save anhhoangta/9661114f5f9d12685663 to your computer and use it in GitHub Desktop.
Nested For Loop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__author__ = 'anhhoangta' | |
#print the title of program | |
print("\r") | |
print("Mutiplication Table".center(38)) | |
#print the first two lines | |
print("{:4}".format(""),end="") | |
for num in range(1,10): | |
print("{:2d}" .format(num), end="\t") #the first line | |
print() | |
print("-"*38) #the 2nd line | |
#print remanning lines use nested for loop | |
for i in range(1,10): | |
print("{:d}|".format(i),end="\t") #print the first column | |
for j in range(1, 10): | |
print("{:2d}" .format(i*j),end="\t") #print ixj with margin-right | |
print() | |
print() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment