Must Know High School Computer Programming by Julie Sway

Must Know High School Computer Programming by Julie Sway

Author:Julie Sway
Language: eng
Format: epub
Publisher: McGraw-Hill Education
Published: 2020-02-01T16:00:00+00:00


8. Create a list of five of your favorite songs.

Process the list using a for loop.

Print the song titles that have an even number of letters in the

song name.

At the end of the loop, print “Play it again!”

9. The Fibonacci sequence is a well-known series where a number is the sum of the two numbers preceding it. For example: 8 is the sum of 3 + 5.

fibonacci = [0, 1, 1, 2, 3, 5, 8, 13]

a. Append the next two values in the Fibonacci series to the list.

b. Print your Fibonacci list to confirm the values.

10. How would you write the code to insert “John Quincy Adams” after “Monroe” and print the list, roster? roster = [“Washington”, “Adams”, “Jefferson”, “Madison”, “Monroe”, “Jackson”, “Van Buren”]

Use this list for the following three questions. How would you write the following lines of code? Remember to test your code in Python to confirm your answer.

pets = [“dog”, “cat”, “bird”, “turtle”,

“horse”, “fish”, “snake”]

11. Write the line of code to remove “horse” from the list of pets.

12. Write the code to remove the current 4th element from the list.

13. Write the code to delete “snake” from the list.

Use the following list for questions 14-18.

14. Write the code to find and print the largest number in the list weights?

weights = [2, 4, 6, 7.5, 9.8, 42, 19]

What is produced after each of the following blocks of code?

weights = [2, 4, 6, 7.5, 9.8, 42, 19]

15. print(sum(weights))

16. print(sum(weights) * 2)

17. print(sum(weights) / 2)

18. print(sum(weights) - 2)

19. What is printed after the following lines of code?

nums = [42, 256, 1023]

print(nums * 3)



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.