CSC111 Programs Created in Class 2018

From dftwiki3
Revision as of 13:30, 31 January 2018 by Thiebaut (talk | contribs) (Created page with "~~~~ ---- =1/30/18= <source lang="python"> # wedWeek1.py # D. Thiebaut # Demo program week 1 # variables age = 20 year = 2018 # compute year born print( year - age ) #...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

D. Thiebaut (talk) 12:30, 31 January 2018 (EST)


1/30/18

# wedWeek1.py
# D. Thiebaut
# Demo program week 1


# variables
age = 20
year = 2018

# compute year born
print( year - age )


# example of for loop
for name in [ "smith", 23, 3.14159, "hello" ]:
    print( name )

"""
challenge: print the following lines
***
Mae
*****
Alice
*******
Felicia
"""

for name in [ "Mae", "Alice", "Felicia" ]:
    print( '*' * len( name ) )
    print( name )


"""
new challenge: print the following lines
*
Mae
********
Alice
****
Felicia
**
"""

for name in [ "*", "Mae", "********", "Alice", "****", "Felicia", "**" ]:
    print( name )