1. Write a program that uses a function to calculate the double value of a number:
--Write a DOUBLE function that: 1) takes an input parameter and 2) returns the 2 * input parameter (the double)
--Then calls the DOUBLE function with parameter 3.1415 and then prints the return value
2. The program to write now is: "Guess a number between 1 and 100"
-The Python program should produce a secret number.
-The user may guess again and again until the guess is the same as the secret speech.
-Every time the user guesses, the python program should print "Guessing is too small", "Guessing is too big" or "You guessed right"
Random number tips:
from random import radint
number = radint (1,100)
3.
The program to write now is "draw a triangle".
-The Python program should first ask for the width (positive integer, 0 or greater) and then draw a triangle.
-First row should be one star, second row two **, then *** until the number of stars is what was stated as width.
- Then the triangle ends by printing in the opposite way.
-The Python program must use for-loops.
- (Check out some multi-checks of the input, but do not need to make error checks as the user is considered to be kind)
-If the program only manages widths> = 2 stars, two points are deducted.
What a program run looks like:
Enter maximum width: 5
*
**
***
****
*****
****
***
**
*
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
27 | 28 | 29 | 30 | 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |