Exercises_Answers
Exercises_Answers
Exercises - Answers
2. Write a program to add numbers between 1 and N where N is defined by the user input.
Hint: Search the documentation for range
(https://docs.python.org/3/library/stdtypes.html#typesseq)
4. Draw the art in following figure using turtle. You can use turtle.circle() function to draw
circles.
Hint: There are 30 circles in the figure
5. Create a random list of size N with integer random numbers in the rang 0-9 . N should be an
input given by the user.
Display the random number list and the same list in reverse order.
Hint: Have a quick look at the Python random module
(https://docs.python.org/3/library/random.html)
Also read following documentation on Python lists. You don’t have to read all the details. In this case
find out how you can append elements and reverse the elements of a list in place.
https://docs.python.org/3/tutorial/datastructures.html
6. Input N integers from user and store them in a List. Display the list and the average of those
N numbers.
7. The exponential function ex can be characterized in a variety of equivalent ways. In
particular, it may be defined by the following series.
Hint: Use the math module. Look for its documentation and check how you can calculate factorial of
a number.
8. Write a function which returns the value of the following function for a given x value.
9. Write a program that asks the age of the user and display the age category depending on age.
10. Analyse the following code that implements a simple game.
Improve the code to incorporate 3 players.
Please read online how you can implement a while loop in Python
11. Write a code to create an Image like this!