In: Computer Science
I am new to python, and i used python 3. i have to make a new program can anyone give tell mw how to do this.
A) Write a function with the name doubler. The function should take an integer parameter and return twice the value of the integer.
Test the function with the following code:
print(“Double of 6 is”,doubler(6))
The printout should be:
Double of 6 is 12
B) Write a function with the name scoreToLetter. The function should take an integer parameter and give out a letter grade according to the following grade table:
|
Score >=90 |
A |
|
80<=score<90 |
B |
|
70<=score< 80 |
C |
Test the function with the following code:
X = 85
Print (“Your grade is”,scoreToLetter(x))
This should print:
Your grade is B
C) Write a function ‘sumOfThrows’ that takes two parameters ‘throws’ and ‘sides’. ‘sides’ should have a default values of 6. The function should return the sum from doing however many random throws specified for a die with ‘sides’ number of sides.
Test the function.
For example sumOfThrows(1,6) should show the outcome of throwing one six-sided die.
sumOfThrows(3,8) should show the outcome of throwing three dice with sides numbered 1 through 8.
sumOfThrows(2) should show the outcome of throwing two six-sided dice.
D) Move all functions to a module with name myFunctions.py. Import the myFunctions module and test all functions.
E) Submit both myFunction.py and the file with your tests named tests.py
A)
def doubler(num):
return 2*num
print("Double of 6 is",doubler(6))
========================================================================
See The Image and write it as it

============================================================================================
B)
def scoreToLetter(score):
if score>=90:
return 'A'
elif score>=80 and score<90:
return 'B'
elif score>=70 and score<80:
return 'C'
print ("Your grade is",scoreToLetter(85))
========================================================================
See The Output

Thanks, let me know if there is any concern.