Professional Documents
Culture Documents
Assignment Individu MTS
Assignment Individu MTS
1. What does the following piece of code display when run — and why?
f = 0
k = 0
def f2k(f):
k = ((f-32)*(5.0/9.0)) + 273.15
return k
f2k(8)
f2k(41)
f2k(32)
print(k)
2. Write a loop that counts the number of vowels in a character string.Test it on a few individual
words and full sentences. Once you are done, compare your solution to your neighbor’s. Did you
make the same decisions about how to handle the letter ‘y’ (which some people think is a vowel, and
some do not)? Complete the following code
vowels = 'aeiouAEIOU'
sentence = 'Mary had a little lamb.'
count = 0
for char in sentence:
______________________
______________________
______________________