Write a function that will take in a number (from 1-6) through the parameter, and will display the appropriate ASCII depiction of a dice face with pips. Then create a program that generates a random number 1-6 and calls your Function to display the random dice face.
Using python 3.6 to solve this problem.
import random def printDice(n): print('+-----+') # second row if n == 1: print('|' + ' '*5 +'|') elif n == 2 or n == 3: print('|*' + ' '*4 +'|') else: print('|*' + ' '*3 +'*|') # third row if n == 1 or n == 3 or n == 5: print('|' + ' '*2 + '*' + ' '*2 +'|') elif n == 2 or n == 4: print('|' + ' '*5 +'|') else: print('|*' + ' '*3 +'*|') # fourth row if n == 1: print('|' + ' '*5 +'|') elif n == 2 or n == 3: print('|' + ' '*4 +'*|') else: print('|*' + ' '*3 +'*|') print('+-----+\n\n') for _ in range(10): printDice(random.randint(1, 6))
Hi. please find the answer above.. In case of any doubts, please
ask in comments. If the answer helps you, please upvote. I
am in great need of upvotes. Thanks!
Write a function that will take in a number (from 1-6) through the parameter, and will...
Write a void function that generates a random number from 0 to 1 with two decimal digits and uses a proper parameter to return it. Write a C program that calls the function and displays the return value.
Python: Write a func that will create a list of random numbers. The function will take in two parameters. The first parameter specifies how many values to generate and the second parameter is the highest random # (2 is the minimum) that the func generates. To get the random numbers, you may use this line of code: y = random.randint (2,max), where max is the highest possible random #, INCLUSIVE.
Write a python function named displayFizzBuzz that takes a number as a parameter and DISPLAYS the appropriate FizzBuzz value for that number. Test this function on all of the numbers between 1 and 100000. Submit the code and a screenshot of the program running in Linux
DATA PROGRAMMING: PYTHON Be sure to use sys.argv NOT input. Write a program and create a function called inch2cm that takes one number in inches as a parameter, converts it to the centimeters and prints the result. The program output is shown below. Input: 14 Output: 14 inches = 35.56 centimeter Write a program and create the following functions: shapes(): takes the shape name and a number as parameters, and calls the proper function to calculate the area. areaCircle(): take...
question 2 in C programming please PE-05b-01 (Six-sider) write a counter-controlled program that prompts the user to enter the number of times n to roll a six-sided die. The program should print to the screen the iteration of the loop and result for each roll 1 ) How many times would you like to roll? 3 roll 6 6 5 1 2) PE 05b 02 (Flash Cards) Write a counter-controlled program that creates addition problems for an elementary kid to...
Look at the following function definition: def my_function(x, y): return x[y] a. Write a statement that calls this function and uses keyword arguments to pass ‘testing’ into x and 2 into y. b. What will be printed when the function call executes? 6. Write a statement that generates a random number in the range I'm using python to solve this this is what i did def main(): result= my_function(x='testing', y=2) print(result) def my_function(x,y): return x[y] main()
In Python, Complete the extraCreditTotal() function to take a list of grades as a parameter and return the total number points above 100. Examples: extraCreditTotal( [101, 83, 107, 90] ) returns 8 (because 1 + 0 + 7 + 0 is 8) extraCreditTotal( [89, 113, 95] ) returns 13 extraCreditTotal( [89, 73, 96, 97, 99, 100] ) returns 0
(c++) Write a program that generates a random number between 1 and 100 and asks the user to guess what the number is. If the user’s guess is higher than the random number, the program should display “Too high, try again.” If the user’s guess is lower than the random number, the program should display “Too low, try again.” The program should use a loop that repeats until the user correctly guesses the random number. Be sure that your program...
PYTHON 1- Write a function that receives a string value as a parameter, converts its first character to uppercase and returns the first character. 2- Test your function by writing a main, which calls your function and prints its return value. 3- Save your program in a file called firstChar.py and use the following link to submit your file.
Write a function named displayFizzBuzz that takes a number as a parameter and DISPLAYS the appropriate FizzBuzz value for that number. Test this function on all of the numbers between 1 and 100000. Submit the code and a screenshot of the program running in Linux