Intro to Python — Lesson 4 — Answers

Pubblicato il: 10 agosto 2020
sul canale di: KPMG:Code
458
3

Lesson 4:    • Intro to Python — Lesson 4  
Next Lesson:    • Intro to Python — Lesson 5  
Previous Lesson:    • Intro to Python — Lesson 3  
Playlist for whole course:    • Introduction to Python  
Course Material: https://github.com/ihf-code/python

Questions:
Section A
1. Create the following list of items: Apples, Cherries, Pears, Pineapple, Peaches, Mango. Then print the list
2. Add "Grapes" to the list and print the list
3. Change "Pears" to "Strawberries" and print the list
4. Remove "Apples" from the list and print the list
5. Print out the current length of the list
6. Order the list alphabetically
7. Print out the list again

Section B
1. Loop through the list you created in section A and print each item out
2. Print the numbers 1 to 100 (including the number 100)
3. Print all odd numbers from 1 to 100
4. The modern olympics started in 1896, print the years they have been held (bonus points to skip 1916, 1940, 1944)
5. Create a list of ten random numbers. Loop through your list and count the number of even numbers and the number of odd numbers.
6. Create a list of five names. Write a loop that will print "Hello" plus each name in the list.
7. Create a loop to go through each letter of the word "supercalifragilisticexpialidocious".
8. Create a list of 5 numbers. Write a for loop which appends the square of each number to the new list.
9. Create a list with five names in. Write a for loop which appends Dr. to each name in the new list.
10. FizzBuzz – Write a program that prints the numbers from 1 to 100. For multiples of three, print "Fizz" instead of the number and for multiples of five, print "Buzz". For numbers which are multiples of both three and five, print "FizzBuzz". E.g:

1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz


In questa pagina del sito puoi guardare il video online Intro to Python — Lesson 4 — Answers della durata di ore minuti seconda in buona qualità , che l'utente ha caricato KPMG:Code 10 agosto 2020, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 458 volte e gli è piaciuto 3 spettatori. Buona visione!