Created
June 15, 2020 16:29
-
-
Save jmangrad/8fc45678c40308a31bb7b447421b02f3 to your computer and use it in GitHub Desktop.
Python Crash Course
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
8-3. T-Shirt: Write a function called make_shirt() that accepts a size and the | |
text of a message that should be printed on the shirt. The function should print | |
a sentence summarizing the size of the shirt and the message printed on it. | |
Call the function once using positional arguments to make a shirt. Call the | |
function a second time using keyword arguments. | |
8-4. Large Shirts: Modify the make_shirt() function so that shirts are large | |
by default with a message that reads I love Python. Make a large shirt and a | |
medium shirt with the default message, and a shirt of any size with a different | |
message. | |
8-5. Cities: Write a function called describe_city() that accepts the name of | |
a city and its country. The function should print a simple sentence, such as | |
Reykjavik is in Iceland. Give the parameter for the country a default value. | |
Call your function for three different cities, at least one of which is not in the | |
default country. | |
8.3 Answer | |
def make_shirt(size, text_message="'I am a big person'"): | |
print(" I want a size {} shirt that says {}".format(size, text_message)) | |
#make_shirt(14, 'I am a big person') | |
make_shirt(14) | |
8.4 Answer | |
def make_shirt(text_message, size = 'Large'): | |
print(" I want a size {0} shirt that says {1}".format(size, text_message)) | |
make_shirt("'I love Python'") | |
make_shirt(size = 'medium', text_message = 'I love Python') | |
make_shirt(size='small', text_message='Python is fun') | |
8.5 Answer | |
def describe_city(city, country='USA'): | |
print("{} is located in {}".format(city.title(), country)) | |
describe_city('charlotte') | |
describe_city('boston') | |
describe_city('london', 'UK') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Interesting course you have, I enjoyed taking it. I like to collect such different suggestions for myself to study different topics, so recently I took a short course on writing to study. I enjoyed writing at least once a week on different paper ideas after it, I find them for example on eduzaurus about Jack Zipes and his story with Walt Disney. I think my hobby of learning new things is only going to grow and it makes me happy how it helps with distractions at work