0% found this document useful (0 votes)
87 views2 pages

Exercise 2: There Were 20 People On A Bus. 10 Got Off. 3 Came On. 15

The document contains 3 coding exercises with sample solutions. The first exercise asks the user to create lists of favorite songs and movies, combine the lists, and append a favorite book. The second calculates the total number of people on buses after some get on and off. The third gets user input for a first and last name and prints a greeting using those values.

Uploaded by

amit34521
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)
87 views2 pages

Exercise 2: There Were 20 People On A Bus. 10 Got Off. 3 Came On. 15

The document contains 3 coding exercises with sample solutions. The first exercise asks the user to create lists of favorite songs and movies, combine the lists, and append a favorite book. The second calculates the total number of people on buses after some get on and off. The third gets user input for a first and last name and prints a greeting using those values.

Uploaded by

amit34521
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/ 2

Exercise 1: Create a List of your favorite songs.

Then create a list of your


favorite movies. Join the two lists together (Hint: List1 + List2). Finally,
append your favorite book to the end of the list and print it.
Exercise 2: There were 20 people on a bus. 10 got off. 3 came on. 15
came on. 5 came off. If there were 3 more buses, and each had 15 people
throughout the bus ride, how many people were on all the buses at the last
stop? (Should be done via one equation in Python Shell)
Exercise 3: Create a small program that will take in a Users name and last
name (Hint: varName = input(Enter your name)), store both in two
variables. And then print out a message saying (Hello there, FirstName
LastName) (Using the %s symbols)
____________________________________________________________
Answer 1:
favSongs = [LA Story, Lost Stars, Grenade]
favMovies = [Avengers, Iron Man, Hulk]
favorites = favSongs + favMovies
favorites.append(NYPD Red) #Amazing Book ;)
print(favorites)

Answer 2:
>>> 20-10+3+15-5 + (3 * 15)
68
Answer 3:
First = input(Enter your first name: )
Last = input(Enter your last name: )
greeting = (Hello there, %s %s)
print(greeting %(First,Last))

You might also like