Path: blob/master/02-Python Statements/08-Statements Assessment Test - Solutions.ipynb
1598 views
Kernel: Python 3
Statements Assessment Solutions
Use for
, .split(), and if
to create a Statement that will print out words that start with 's':
In [1]:
In [2]:
Out[2]:
start
s
sentence
Use range() to print all the even numbers from 0 to 10.
In [3]:
Out[3]:
[0, 2, 4, 6, 8, 10]
Use List comprehension to create a list of all numbers between 1 and 50 that are divisible by 3.
In [4]:
Out[4]:
[3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48]
Go through the string below and if the length of a word is even print "even!"
In [5]:
In [6]:
Out[6]:
word <-- has an even length!
in <-- has an even length!
this <-- has an even length!
sentence <-- has an even length!
that <-- has an even length!
an <-- has an even length!
even <-- has an even length!
number <-- has an even length!
of <-- has an even length!
Write a program that prints the integers from 1 to 100. But for multiples of three print "Fizz" instead of the number, and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz".
In [ ]:
Use a List Comprehension to create a list of the first letters of every word in the string below:
In [7]:
In [8]:
Out[8]:
['C', 'a', 'l', 'o', 't', 'f', 'l', 'o', 'e', 'w', 'i', 't', 's']