Question

Please Use Python and provide explanations!!!! 1. Write a function called multiply_and_print that takes two numbers,...

Please Use Python and provide explanations!!!!

1. Write a function called multiply_and_print that takes two numbers, multiplies them together, and prints out the sentence '____ times ____ is ____'. Ask the user for two numbers, and call multiply_and_print with their two numbers as arguments.

2.Write a function called roll_dice that rolls two six-sided dice and prints out the result of each die. Call it three times. (Remember, you can import the random module with the statement import random, and then use the function random.randint to get a random integer between the first and second argument, inclusive.)

0 0
Add a comment Improve this question Transcribed image text
Answer #1


\color{blue}\underline{1:}

def multiply_and_print(n1, n2):
    print("{} times {} is {}".format(n1, n2, n1 * n2))


n1 = int(input("Enter a number: "))
n2 = int(input("Enter another number: "))
multiply_and_print(n1, n2)

\color{blue}\underline{2:}

import random


def roll_dice():
    print(random.randint(1, 6), 'and', random.randint(1, 6))


roll_dice()
roll_dice()
roll_dice()
Add a comment
Know the answer?
Add Answer to:
Please Use Python and provide explanations!!!! 1. Write a function called multiply_and_print that takes two numbers,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • How to write python code that is a dice rolling function that generates random numbers. The...

    How to write python code that is a dice rolling function that generates random numbers. The dice rolling function takes two arguments: the first argument is the number of sides on the dice and the second argument is the number of dice. The function returns the sum of the random dice rolls. For example, if I call roll dice(6,2) it might return 7, which is the sum of randomly chosen numbers 4 and 3. It somewhere along the lines of:...

  • This problem investigates how you can use random numbers to simulate a computer dice game write a function called twooice that simulates the rolling of two sik-sided dice. The function takes no input...

    This problem investigates how you can use random numbers to simulate a computer dice game write a function called twooice that simulates the rolling of two sik-sided dice. The function takes no inputs. Instead, it generates two random integers between 1 and 6, and output their sum. You may submit your work as many times as you want Try to get 100%) Your Function MATLAB Documentation Reset Code to call your function C Reset 1s-tuoDice ss-twoDice This problem investigates how...

  • "PYTHON" 1. a. Create a file (module) named camera_picture.py. b. Write a function, take_picture_effect, that takes...

    "PYTHON" 1. a. Create a file (module) named camera_picture.py. b. Write a function, take_picture_effect, that takes two parameters, the filename and an effect. c. Take a picture with the filename and effect. Use camera.effect to set the effect. Use help(PiCamera) to find the effects which you can apply. d. Create a second file use_camera.py. e. Import the take_picture_effect function from the camera_picture module. f. Prompt the user for the filename. g. Prompt the user for the image_effect. help(PiCamera) to see...

  • Write a Python function, called counting, that takes two arguments (a string and an integer), and...

    Write a Python function, called counting, that takes two arguments (a string and an integer), and returns the number of digits in the string argument that are not the same as the integer argument. Include a main function that inputs the two values (string and integer) and outputs the result, with appropriate labelling. You are not permitted to use the Python string methods (such as count(), etc.). Sample input/output: Please enter a string of digits: 34598205 Please enter a 1-digit...

  • Create a Dice Game: PYTHON This game is between two people. They will roll a pair...

    Create a Dice Game: PYTHON This game is between two people. They will roll a pair of dice each 10 times. Each roll will be added to a total, and after 10 rolls the player with the highest total will be the Winner! You will use the RANDOM class RANDRANGE to create a random number from 1 to 6. You'll need a function for "rollDice" to roll a pair of dice and return a total of the dice. You must...

  • PYTHON 4. Define a function that takes two arguments: a string called strText and a number...

    PYTHON 4. Define a function that takes two arguments: a string called strText and a number called intNumber. This function will use a repetition structure (a While or For loop) to print strText intNumber of times. Call this function. 5. Get an input from the user that is a file name with an extension (e.g., "myfile.ipynb" or "myfile.txt"). Print only the characters that follow the "." in the file name (e.g., "ipynb" and "txt"). 6. Ask the user for 5...

  • USE PYTHON PLEASE Write a function called is prime which takes a single integer argument and...

    USE PYTHON PLEASE Write a function called is prime which takes a single integer argument and returns a single Boolean value representing whether the given argument is prime (True) or not (False). After writing the function, test it by using a loop to print out all the prime numbers from 1-100. To check your results, the prime numbers from 1-100 are: 2, 3, 5, 7, 11. 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67,...

  • question 2 in C programming please PE-05b-01 (Six-sider) write a counter-controlled program that prompts the user...

    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...

  • in python Write a function, named max_of_two, that takes two numbers as arguments and returns the...

    in python Write a function, named max_of_two, that takes two numbers as arguments and returns the largest of the two values. (Note, this function is actually already provided in Python as max. Do not use the provided function; reason through the logic yourself).

  • Task 5 Write a function called “earring_iter” that takes two integer arguments, size and count. This...

    Task 5 Write a function called “earring_iter” that takes two integer arguments, size and count. This function should use a (for or while) loop to draw a Hawaiian earring containingcount-manycircles,wherethefirstcircledrawnhassizesize,andeachsubsequent circle has size earring_ratio times the size of the previous circle. Here is a recursive specification for drawing a Hawaiian earring of a given size: • To draw a Hawaiian earring of a given size with zero hoops, do nothing. • To draw a Hawaiian earring of a given size...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT