Term Paper Python Question New
Term Paper Python Question New
Instruction: Please run the following code in PyCharm and print out the output
1.
a. Using python write program to ask the user to input a character. The program checks
whether the entered character is equal to the lowercase or uppercase vowels, if it is
then the program prints a message saying that the character is a vowel else it prints that
the character is a consonant. (20 marks)
2.
a. Write a code in python with a function add() that adds two numbers passed to it as
parameters. Later after function declaration then you call the function twice in your
program to perform the addition. (10 marks)
b. Using the function above provide the default argument for the second parameter, this
default argument would be used when you do not provide the second parameter while
calling this function. (10 marks)
3.
a. Use python to write a for loop to iterate over a list of numbers from 1 to 20. In the body
of for loop you should be able to calculate the square of each number present in the list
and display the output window. (10 marks)
b. From the example above, you can iterate over a list using for loop. However used a
range() function in for loop to iterate over numbers defined by range(). (10 marks)