0% found this document useful (0 votes)
21 views1 page

ISTM-6200 Assignment 4 Updated

Uploaded by

getrude.katiyo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views1 page

ISTM-6200 Assignment 4 Updated

Uploaded by

getrude.katiyo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Python Programming

Prof. Chad Ho

Individual Assignment 4
Due: Wednesday, 11/6

1. [3 pts] Write code to:


a) Create a list, celebrities, and fill in the list with 3 of your favorite celebrities (in order).
b) Use for to print their names, using the format as in the example below.
c) For full credit, you shouldn’t “hard code” the order number (1, 2, 3). Instead, use a variable index
so that the program runs properly if you have more than 3 favorite celebrities.

Favorite celebrity #1 is Stephen Curry.


Favorite celebrity #2 is Matthew Mcconaughey.
Favorite celebrity #3 is Chad Ho (=__=??).

2. [3 pts] Work on Exercise 1 from the lab exercises.

3. [4 pts]
Consider a sentence: “I love Python and Python loves me.” Write a function to print the sentence in
the reverse order (word by word). In your code, you must call the function to show the result.
Hint: You may find .split() useful.

ü You will earn half credit if your function can print the following:

ü You will earn full credit if your function can take care of the period and capitalizations. Pay
attention that the last word must be in lower case.

4. [5 pts] Write a program to meet the following requirements:


a) Request the user to enter celebrities’ name continuously (one name at a time)
i. The user can enter up to 4 names; when 4 names are entered, the prompt automatically stops.
ii. The user can quit the prompt by entering “done” anytime as long as s/he has entered at least 1
name.
iii. In other words, the user cannot quit the prompt if s/he hasn’t entered any name yet.
b) Print all the names, using the same format as in Q1.

To earn the full credit:


ü The initials of printed names must be capitalized and the rest in lower case (e.g., Chad Ho)

Hint: How to request inputs continuously? See Q3, Assignment 2. You may use .append() here.
Use break to terminate your while loop when certain conditions are met.

You might also like