Difference between revisions of "CSC111 Homework 1 2015b"

From dftwiki3
Jump to: navigation, search
(Created page with "--~~~~ ---- --D. Thiebaut (talk) 14:45, 25 January 2015 (EST) ---- <br /> <bluebox> In this assignment is due on 9/19/15 at 11:55 p.m....")
 
Line 5: Line 5:
 
<br />
 
<br />
 
<bluebox>
 
<bluebox>
In this assignment is due on 9/19/15 at 11:55 p.m.
+
In this assignment is due on 9/19/15 at 11:55 p.m., or 5 minutes before midnight.  Remember that no extensions are given in this class!
  
 
Each problem requires you to ''copy'' an incomplete program into IDLE, and then ''edit'' it so that the output of your edited program matches '''exactly''' the output specified in the problem.  You will submit your programs for this assignment in the CSC111 section of your Moodle account.   
 
Each problem requires you to ''copy'' an incomplete program into IDLE, and then ''edit'' it so that the output of your edited program matches '''exactly''' the output specified in the problem.  You will submit your programs for this assignment in the CSC111 section of your Moodle account.   
  
There may be many different ways to edit a program to make it output the one specified in the problem.  In general, if you have a choice between several possible modifications, pick the one that is the simplest.  Do not try to rewrite the program, but keep its structure.  It is acceptable to add new statements in some problems.  You must '''evaluate''' each program on Moodle to receive a grade for it.  Make sure you evaluate your programs before the deadline, otherwise you will not receive a grade.   Remember that no extensions are given in this class!
+
There may be many different ways to edit a program to make it output the one specified in the problem.  In general, if you have a choice between several possible modifications, pick the one that is the simplest.  Do not try to rewrite the program, but keep its structure.  It is acceptable to add new statements in some problems.  You must '''evaluate''' each program on Moodle to receive a grade for it.  Make sure you evaluate your programs before the deadline, otherwise you will not receive a grade.
  
 
'''Grading''':  The homework assignments count for a total of 40% of the final grade.  Since there will be approximately 11 assignments this semester, each one will count for roughly 40/11 or 3.9% of the final grade.  Homework 1 contains 10 problems; therefore each one counts for approximately 0.039% of the final grade.  The programs are graded 0 or 100, depending on whether its output is exactly the one required, or not.
 
'''Grading''':  The homework assignments count for a total of 40% of the final grade.  Since there will be approximately 11 assignments this semester, each one will count for roughly 40/11 or 3.9% of the final grade.  Homework 1 contains 10 problems; therefore each one counts for approximately 0.039% of the final grade.  The programs are graded 0 or 100, depending on whether its output is exactly the one required, or not.
  
You should work as a pair on this assignment, and submit your program on Moodle twice, once for each pair member.  For example, if Emily and Sarah work as a pair, they will both create  
+
You should work as a pair on this assignment, and submit your program on Moodle twice, once for each pair member.  For example, if Emily and Sarah work as a pair, they will create the program together on one computer.  When the program runs well, Sarah will connect to her Moodle account, and submit the program in the area specific to this assignment, and then Emily will connect to her Moodle account and do the same.
 
</bluebox>
 
</bluebox>
 
<br />
 
<br />
Line 20: Line 20:
 
=Problem #1=
 
=Problem #1=
 
<br />
 
<br />
Open IDLE on your computer and type in the incomplete program shown below.  Modify it until you get it to show the output shown in the second column, below.  When you are satisfied your program runs correctly, submit it to Moodle, in the HW 1 P 1 section:
+
Open IDLE on your computer and create a new program called '''hw1_1.py'''.  In the IDLE edit window, type the incomplete program shown below.  Modify it until you get it to show the output shown in the second column, below.  When you are satisfied your program runs correctly, submit it to Moodle, in the HW 1 P 1 section:
 
<br />
 
<br />
 
{| class="wikitable" width="100%"
 
{| class="wikitable" width="100%"
Line 28: Line 28:
 
|
 
|
 
<source lang="python">
 
<source lang="python">
 +
# hw1_1.py
 
# Homework 1, Problem 1
 
# Homework 1, Problem 1
 
# Name of pair partner #1
 
# Name of pair partner #1
Line 55: Line 56:
 
=Problem #2=
 
=Problem #2=
 
<br />
 
<br />
Open IDLE on your computer and type in the incomplete program shown below.  Modify it until you get it to show the output shown in the second column, below.  When you are satisfied your program runs correctly, submit it to Moodle, in the HW 1 P 2 section:<br />
+
Open IDLE on your computer and create a new program called '''hw1_2.py'''.  In the IDLE window, type in the incomplete program shown below.  Modify it until you get it to show the output shown in the second column, below.  When you are satisfied your program runs correctly, submit it to Moodle, in the HW 1 P 2 section:<br />
 
{| class="wikitable" width="100%"
 
{| class="wikitable" width="100%"
 
! style="width: 60%;" |  '''Incomplete program'''  
 
! style="width: 60%;" |  '''Incomplete program'''  
Line 62: Line 63:
 
|
 
|
 
<source lang="python">
 
<source lang="python">
 +
# hw1_2.py
 
# Homework 1, Problem 2
 
# Homework 1, Problem 2
 +
# Name of pair partner #1
 +
# Name of pair partner #2
  
 
college = "Smith College"
 
college = "Smith College"
Line 84: Line 88:
 
=Problem #3=
 
=Problem #3=
 
<br />
 
<br />
Be sure to read Chapter 1, Section 6 in Zelle before starting.  Then, open IDLE on your computer and type in the incomplete program shown below.  Modify it until you get it to show the output shown in the second column, below.  When you are satisfied your program runs correctly, submit it to Moodle, in the HW 1 PB 3 section:
+
Be sure to read Chapter 1, Section 6 in Zelle before starting.  Then, open IDLE on your computer, create a program called '''hw1_3.py''', and type in the incomplete program shown below.  Modify it until you get it to show the output shown in the second column, below.  When you are satisfied your program runs correctly, submit it to Moodle, in the HW 1 PB 3 section:
 
<br />
 
<br />
 
{| class="wikitable" width="100%"
 
{| class="wikitable" width="100%"
Line 92: Line 96:
 
|
 
|
 
<source lang="python">
 
<source lang="python">
# Homework 1, Problem 3 (read Section 1.6 in Zelle)
+
# hw1_3.py
 +
# Homework 1, Problem 3
 +
# Name of pair partner #1
 +
# Name of pair partner #2
  
 
def greet( person ):
 
def greet( person ):
     print( person )
+
     print( "bonjour", person )
     print( "How are you?" )
+
     print( "How are you today?" )
  
 
greet( "John" )
 
greet( "John" )
Line 119: Line 126:
 
=Problem #4=
 
=Problem #4=
 
<br />
 
<br />
Open IDLE on your computer and type in the incomplete program shown below.  Modify it until you get it to show the output shown in the second column, below.  When you are satisfied your program runs correctly, submit it to Moodle, in the HW 1 PB 4 section:<br />
+
Open IDLE on your computer and type in the incomplete program shown below.  Save it in a file called '''hw1_4.py'''.  Modify it until you get it to show the output shown in the second column, below.  When you are satisfied your program runs correctly, submit it to Moodle, in the HW 1 PB 4 section:<br />
 
{| class="wikitable" width="100%"
 
{| class="wikitable" width="100%"
 
! style="width: 60%;" |  '''Incomplete program'''  
 
! style="width: 60%;" |  '''Incomplete program'''  
Line 126: Line 133:
 
|
 
|
 
<source lang="python">
 
<source lang="python">
# Homework 1, Problem 4 (read Section 1.6 in Zelle)
+
# hw1_4.py
 +
# Homework 1, Problem 4
 +
# Name of pair partner #1
 +
# Name of pair partner #2
  
 
def greetBar( person ):
 
def greetBar( person ):
Line 154: Line 164:
 
<!-- ---------------------------------------------------------------------------------------------------------------------- -->
 
<!-- ---------------------------------------------------------------------------------------------------------------------- -->
  
=Problem #5=
 
<br />
 
Open IDLE on your computer and type in the incomplete program shown below.  Modify it until you get it to show the output shown in the second column, below.  When you are satisfied your program runs correctly, submit it to Moodle, in the HW 1 P 5 section.
 
  
Be careful, as the Moodle testing program counts extra spaces or extra blank lines in your output as incorrect!
+
=Problem 5=
 
 
Make sure you click on '''evaluate''' in Moodle to make sure your program receives a grade.
 
 
<br />
 
<br />
{| class="wikitable" width="100%"
+
Open IDLE on your computer and type in the incomplete program shown below.  Save it as '''hw1_5.py'''. Modify it until you get it to show the output shown in the second column, below.  When you are satisfied your program runs correctly, submit it to Moodle, in the HW 1 P 5 section.  Be careful, as the Moodle testing program counts extra spaces or extra blank lines in your output as incorrect!
! style="width: 60%;" |  '''Incomplete program'''
 
! Output
 
|-
 
|
 
<source lang="python">
 
# Homework 1, Problem 5
 
 
 
def greetLength( person ):
 
    bar = "---------------------"
 
    print( bar )
 
    noChars = len( person )
 
    print( "==>", person )
 
    print( "Your name contains", noChars)
 
 
 
greetLength( "John" )
 
greetLength( "Emily" )
 
 
 
</source>
 
|
 
<source lang="text">
 
---------------------
 
==> John <==
 
Your name contains 4 characters
 
---------------------
 
==> Emily <==
 
Your name contains 5 characters
 
---------------------
 
==> Jo <==
 
Your name contains 2 characters
 
</source>
 
|}
 
<br />
 
<!-- ---------------------------------------------------------------------------------------------------- -->
 
 
 
=Problem 6=
 
<br />
 
Open IDLE on your computer and type in the incomplete program shown below.  Modify it until you get it to show the output shown in the second column, below.  When you are satisfied your program runs correctly, submit it to Moodle, in the HW 1 P 6 section.  Be careful, as the Moodle testing program counts extra spaces or extra blank lines in your output as incorrect!
 
  
 
Make sure you click on '''evaluate''' in Moodle to make sure your program receives a grade.
 
Make sure you click on '''evaluate''' in Moodle to make sure your program receives a grade.
Line 210: Line 178:
 
|
 
|
 
<source lang="python">
 
<source lang="python">
# Homework 1, Problem 6
+
# hw1_5.py
 +
# Homework 1, Problem 5
 +
# Name of pair partner #1
 +
# Name of pair partner #2
  
 
def greetLength( person ):
 
def greetLength( person ):
Line 235: Line 206:
 
<!-- ---------------------------------------------------------------------------------------------------- -->
 
<!-- ---------------------------------------------------------------------------------------------------- -->
  
=Problem 7=
+
=Problem 6=
 
<br />
 
<br />
Open IDLE on your computer and type in the incomplete program shown below.  Modify it until you get it to show the output shown in the second column, below.  When you are satisfied your program runs correctly, submit it to Moodle, in the HW 1 P 7 section.
+
Open IDLE on your computer and type in the incomplete program shown below.  Save it as '''hw1_6.py'''.  Modify it until you get it to show the output shown in the second column, below.  When you are satisfied your program runs correctly, submit it to Moodle, in the HW 1 P 6 section.
  
 
Be careful, as the Moodle testing program counts extra spaces or extra blank lines in your output as incorrect!
 
Be careful, as the Moodle testing program counts extra spaces or extra blank lines in your output as incorrect!
Line 250: Line 221:
 
|
 
|
 
<source lang="python">
 
<source lang="python">
# Homework 1, Problem 7
+
# hw1_6.py
 +
# Homework 1, Problem 6
 +
# Name of pair partner #1
 +
# Name of pair partner #2
  
 
person1 = "Maria Callas"
 
person1 = "Maria Callas"
Line 283: Line 257:
 
<!-- ---------------------------------------------------------------------------------------------------- -->
 
<!-- ---------------------------------------------------------------------------------------------------- -->
  
=Problem 8=
 
<br />
 
Open IDLE on your computer and type in the incomplete program shown below.  Modify it until you get it to show the output shown in the second column, below.  When you are satisfied your program runs correctly, submit it to Moodle, in the HW 1 P 8 section. 
 
  
Be careful, as the Moodle testing program counts extra spaces or extra blank lines in your output as incorrect! 
 
  
Also, note that in this problem, there is a blank line printed after each non-blank output.
+
<showafterdate after="20150920 00:00" before="20151231 00:00">
 
 
Make sure you click on '''evaluate''' in Moodle to make sure your program receives a grade.
 
 
 
<br />
 
{| class="wikitable" width="100%"
 
! style="width: 60%;" |  '''Incomplete program'''
 
! Output
 
|-
 
|
 
<source lang="python">
 
# Homework 1, Problem 8
 
 
 
def greet2( person ):
 
    print( person )
 
    print()
 
 
 
for person in [ "Emily", "Jo" ]:
 
    greet2( person )
 
 
 
</source>
 
|
 
<source lang="text">
 
Lujun is a Smith College student
 
 
 
Emily is a Smith College student
 
 
 
Jo is a Smith College student
 
 
 
 
 
</source>
 
|}
 
<br /><br />
 
<!-- ---------------------------------------------------------------------------------------------------- -->
 
 
 
=Problem 9=
 
<br />
 
This problem corresponds to the HW1 P9 section on Moodle.
 
 
 
Open IDLE on your computer and type in the incomplete program shown below.  Modify it until you get it to show the output shown in the second column, below.  When you are satisfied your program runs correctly, submit it to Moodle, in the HW 1 P 9 section.
 
 
 
Make sure you click on '''evaluate''' in Moodle to make sure your program receives a grade.
 
 
 
<br />
 
{| class="wikitable" width="100%"
 
! style="width: 60%;" |  '''Incomplete program'''
 
! Output
 
|-
 
|
 
<source lang="python">
 
# Homework 1, Problem 9
 
 
 
for degreesF in [ -10, 10, 20, 30, 32, 40, 50 ]:
 
    degreesC = (degreesF - 32) * 5 / 9
 
    print( degreesF, "is", round( degreesC ) )
 
</source>
 
|
 
<source lang="text">
 
-10 Fahrenheit is -23 Celsius
 
0 Fahrenheit is -18 Celsius
 
10 Fahrenheit is -12 Celsius
 
20 Fahrenheit is -7 Celsius
 
30 Fahrenheit is -1 Celsius
 
32 Fahrenheit is 0 Celsius
 
40 Fahrenheit is 4 Celsius
 
50 Fahrenheit is 10 Celsius
 
60 Fahrenheit is 16 Celsius
 
 
 
</source>
 
|}
 
<br /><br />
 
<!-- ---------------------------------------------------------------------------------------------------- -->
 
 
 
=Problem 10=
 
<br />
 
Open IDLE on your computer and type in the incomplete program shown below.  Modify it until you get it to show the output shown in the second column, below.  When you are satisfied your program runs correctly, submit it to Moodle, in the HW 1 P 10 section.
 
 
 
Make sure you click on '''evaluate''' in Moodle to make sure your program receives a grade.
 
 
 
<br />
 
{| class="wikitable" width="100%"
 
! style="width: 60%;" |  '''Incomplete program'''
 
! Output
 
|-
 
|
 
<source lang="python">
 
# Homework 1, Problem 10
 
 
 
def printBar( length ):
 
    print( "-+" * length )
 
 
 
for length in [10,9,8,7,6,5,4,3,2,1]:
 
    printBar( length )
 
 
 
</source>
 
|
 
<source lang="text">
 
+-
 
+-+-
 
+-+-+-
 
+-+-+-+-
 
+-+-+-+-+-
 
+-+-+-+-+-+-
 
+-+-+-+-+-+-+-
 
+-+-+-+-+-+-+-+-
 
+-+-+-+-+-+-+-+-+-
 
+-+-+-+-+-+-+-+-+-+-
 
</source>
 
|}
 
<br />
 
 
 
<showafterdate after="20150204 00:00" before="20150601 00:00">
 
 
=Solution Programs=
 
=Solution Programs=
 
<br />
 
<br />
Line 456: Line 315:
 
greetBar( "Emily" )
 
greetBar( "Emily" )
 
greetBar( "Lujun" )
 
greetBar( "Lujun" )
 +
  
 
print("\n\n==================== 5 ========================\n\n" )
 
print("\n\n==================== 5 ========================\n\n" )
Line 465: Line 325:
 
     print( bar )
 
     print( bar )
 
     noChars = len( person )
 
     noChars = len( person )
     print( "==>", person, "<==" )
+
     print( "Hello", person, "how are you?" )
    print( "Your name contains", noChars, "characters" )
 
  
 
greetLength( "John" )
 
greetLength( "John" )
Line 475: Line 334:
  
 
# Homework 1, Problem 6
 
# Homework 1, Problem 6
 
def greetLength( person ):
 
    bar = "---------------------"
 
    print( bar )
 
    noChars = len( person )
 
    print( "Hello", person, "how are you?" )
 
 
greetLength( "John" )
 
greetLength( "Emily" )
 
greetLength( "Jo" )
 
 
print("\n\n==================== 7 ========================\n\n" )
 
 
# Homework 1, Problem 7
 
  
 
person1 = "Maria Callas"
 
person1 = "Maria Callas"
Line 505: Line 350:
 
greetLength( person3 )
 
greetLength( person3 )
  
print("\n\n==================== 8 ========================\n\n" )
 
 
# Homework 1, Problem 8
 
 
def greet2( person ):
 
    print( person, "is a Smith College student" )
 
    print()
 
 
for person in [ "Lujun", "Emily", "Jo" ]:
 
    greet2( person )
 
 
 
print("\n\n==================== 9 ========================\n\n" )
 
 
# Homework 1, Problem 9
 
 
for degreesF in [ -10, 0, 10, 20, 30, 32, 40, 50, 60 ]:
 
    degreesC = (degreesF - 32) * 5 / 9
 
    print( degreesF, "Fahrenheit is", round( degreesC ), "Celsius" )
 
 
print("\n\n==================== 10 ========================\n\n" )
 
 
# Homework 1, Problem 10
 
 
def printBar( length ):
 
    print( "+-" * length )
 
 
for length in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]:
 
    printBar( length )
 
 
   
 
   
 
  
 
</source>
 
</source>

Revision as of 16:32, 7 September 2015

--D. Thiebaut (talk) 16:45, 7 September 2015 (EDT)


--D. Thiebaut (talk) 14:45, 25 January 2015 (EST)



In this assignment is due on 9/19/15 at 11:55 p.m., or 5 minutes before midnight. Remember that no extensions are given in this class!

Each problem requires you to copy an incomplete program into IDLE, and then edit it so that the output of your edited program matches exactly the output specified in the problem. You will submit your programs for this assignment in the CSC111 section of your Moodle account.

There may be many different ways to edit a program to make it output the one specified in the problem. In general, if you have a choice between several possible modifications, pick the one that is the simplest. Do not try to rewrite the program, but keep its structure. It is acceptable to add new statements in some problems. You must evaluate each program on Moodle to receive a grade for it. Make sure you evaluate your programs before the deadline, otherwise you will not receive a grade.

Grading: The homework assignments count for a total of 40% of the final grade. Since there will be approximately 11 assignments this semester, each one will count for roughly 40/11 or 3.9% of the final grade. Homework 1 contains 10 problems; therefore each one counts for approximately 0.039% of the final grade. The programs are graded 0 or 100, depending on whether its output is exactly the one required, or not.

You should work as a pair on this assignment, and submit your program on Moodle twice, once for each pair member. For example, if Emily and Sarah work as a pair, they will create the program together on one computer. When the program runs well, Sarah will connect to her Moodle account, and submit the program in the area specific to this assignment, and then Emily will connect to her Moodle account and do the same.



Problem #1


Open IDLE on your computer and create a new program called hw1_1.py. In the IDLE edit window, type the incomplete program shown below. Modify it until you get it to show the output shown in the second column, below. When you are satisfied your program runs correctly, submit it to Moodle, in the HW 1 P 1 section:

Incomplete program Output
# hw1_1.py
# Homework 1, Problem 1
# Name of pair partner #1
# Name of pair partner #2

age = 1
name = "Alex"
year = 2015

print( "--", year )
print( name, "is", "and was born in" )
-- 2015 --
Alex is 20 years old, and was born in 1995
Alex will be 25 in 2020.


Make sure you evaluate the program and receive a grade for it, otherwise your work will not be counted toward the homework grade!

Problem #2


Open IDLE on your computer and create a new program called hw1_2.py. In the IDLE window, type in the incomplete program shown below. Modify it until you get it to show the output shown in the second column, below. When you are satisfied your program runs correctly, submit it to Moodle, in the HW 1 P 2 section:

Incomplete program Output
# hw1_2.py
# Homework 1, Problem 2
# Name of pair partner #1
# Name of pair partner #2

college = "Smith College"
bar = "-" * len( college )
name = "Fiona"
print( bar )
print( college )
-------------
Smith College
Fiona
-------------


Make sure you evaluate the program and receive a grade for it, otherwise your work will not be counted toward the homework grade!

Problem #3


Be sure to read Chapter 1, Section 6 in Zelle before starting. Then, open IDLE on your computer, create a program called hw1_3.py, and type in the incomplete program shown below. Modify it until you get it to show the output shown in the second column, below. When you are satisfied your program runs correctly, submit it to Moodle, in the HW 1 PB 3 section:

Incomplete program Output
# hw1_3.py
# Homework 1, Problem 3
# Name of pair partner #1
# Name of pair partner #2

def greet( person ):
    print( "bonjour", person )
    print( "How are you today?" )

greet( "John" )
greet( "Emily" )
greet( "Lujun" )
Hello John
How are you?
Hello Emily
How are you?
Hello Lujun
How are you?


Make sure you evaluate the program and receive a grade for it, otherwise your work will not be counted toward the homework grade!

Problem #4


Open IDLE on your computer and type in the incomplete program shown below. Save it in a file called hw1_4.py. Modify it until you get it to show the output shown in the second column, below. When you are satisfied your program runs correctly, submit it to Moodle, in the HW 1 PB 4 section:

Incomplete program Output
# hw1_4.py
# Homework 1, Problem 4
# Name of pair partner #1
# Name of pair partner #2

def greetBar( person ):
    bar = "---------------------"
    print( bar )
    print( person )

greetBar( "Lujun" )
greetBar( "Emily" )
greetBar( "John" )
---------------------
Hello John
How are you?
---------------------
Hello Emily
How are you?
---------------------
Hello Lujun
How are you?



Problem 5


Open IDLE on your computer and type in the incomplete program shown below. Save it as hw1_5.py. Modify it until you get it to show the output shown in the second column, below. When you are satisfied your program runs correctly, submit it to Moodle, in the HW 1 P 5 section. Be careful, as the Moodle testing program counts extra spaces or extra blank lines in your output as incorrect!

Make sure you click on evaluate in Moodle to make sure your program receives a grade.


Incomplete program Output
# hw1_5.py
# Homework 1, Problem 5
# Name of pair partner #1
# Name of pair partner #2

def greetLength( person ):
    bar = "---------------------"
    print( bar )
    print( "Hello", person )

greetLength( "John" )
greetLength( "Emily" )
greetLength( "Jo" )
---------------------
Hello John how are you?
---------------------
Hello Emily how are you?
---------------------
Hello Jo how are you?



Problem 6


Open IDLE on your computer and type in the incomplete program shown below. Save it as hw1_6.py. Modify it until you get it to show the output shown in the second column, below. When you are satisfied your program runs correctly, submit it to Moodle, in the HW 1 P 6 section.

Be careful, as the Moodle testing program counts extra spaces or extra blank lines in your output as incorrect!

Make sure you click on evaluate in Moodle to make sure your program receives a grade.


Incomplete program Output
# hw1_6.py
# Homework 1, Problem 6
# Name of pair partner #1
# Name of pair partner #2

person1 = "Maria Callas"
person2 = "Sir Elton John"
person3 = "Lady Gaga"

def greetLength( person ):
    bar = "---------------------"
    print( bar )
    noChars = len( person )
    print( person, "<==" )
    print(  noChars, "characters" )

greetLength( person2 )
greetLength( person2 )
greetLength( person2 )
---------------------
==> Maria Callas <==
Your name contains 12 characters
---------------------
==> Sir Elton John <==
Your name contains 14 characters
---------------------
==> Lady Gaga <==
Your name contains 9 characters




<showafterdate after="20150920 00:00" before="20151231 00:00">

Solution Programs


# edit the statements below (some of them are incomplete) so that the output
# is the one stated in Homework #1, Problem #1

print("\n\n==================== 1 ========================\n\n" )

age = 20
name = "Alex"
year = 2015

print( "--", year, "--" )
print( name, "is", age, "years old, and was born in", year - age )
print( name, "will be", 2020 - year + age, "in 2020." )


print("\n\n==================== 2 ========================\n\n" )

# Homework 1, Problem 2

college = "Smith College"
bar = "-" * len( college )
name = "Fiona"
print( bar )
print( college )
print( name )
print( bar )

print("\n\n==================== 3 ========================\n\n" )

# Homework 1, Problem 3 (read Section 1.6 in Zelle)

def greet( person ):
    print( "Hello", person )
    print( "How are you?" )

greet( "John" )
greet( "Emily" )
greet( "Lujun" )

print("\n\n==================== 4 ========================\n\n" )

# Homework 1, Problem 4 (read Section 1.6 in Zelle)

def greetBar( person ):
    bar = "---------------------"
    print( bar )
    print( "Hello", person )
    print( "How are you?" )

greetBar( "John" )
greetBar( "Emily" )
greetBar( "Lujun" )


print("\n\n==================== 5 ========================\n\n" )

# Homework 1, Problem 5

def greetLength( person ):
    bar = "---------------------"
    print( bar )
    noChars = len( person )
    print( "Hello", person, "how are you?" )

greetLength( "John" )
greetLength( "Emily" )
greetLength( "Jo" )

print("\n\n==================== 6 ========================\n\n" )

# Homework 1, Problem 6

person1 = "Maria Callas"
person2 = "Sir Elton John"
person3 = "Lady Gaga"

def greetLength( person ):
    bar = "---------------------"
    print( bar )
    noChars = len( person )
    print( "==>", person, "<==" )
    print( "Your name contains", noChars, "characters" )

greetLength( person1 )
greetLength( person2 )
greetLength( person3 )

</showafterdate>


...