We appreciate your visit to QUESTION 10 Write statements to generate a random number between 1 and 10 inclusive QUESTION 11 Consider the following Python code Please create a drawPentagon. This page offers clear insights and highlights the essential aspects of the topic. Our goal is to provide a helpful and engaging learning experience. Explore the content and find the answers you need!
Answer :
To generate a random number between 1 and 10 (inclusive) in Python, you can use the random.randint function from the random module.
import random
random_number = random.randint(1, 10)
print(random_number)
The random.randint(a, b) function generates a random integer between a and b (inclusive). In this case, we want a random number between 1 and 10, so we use random.randint(1, 10).
QUESTION 11:
To draw a pentagon using the drawPolygon function, you can define the drawPentagon function as follows:
import turtle
def drawPolygon(t, sides, size):
for _ in range(sides):
t.forward(size)
t.left(360/sides)
def drawPentagon(t, size):
drawPolygon(t, 5, size)
# Example usage:
t = turtle.Turtle()
drawPentagon(t, 100)
turtle.done()
The drawPolygon function takes a turtle (t), the number of sides (sides), and the size of each side (size) as parameters and draws a polygon with the specified number of sides and size. The drawPentagon function calls drawPolygon with sides=5 to draw a pentagon.
QUESTION 12:
The given code can be converted to an if-elif-else statement as follows:
if number < 0:
print("It's a negative number")
elif number == 0:
print("It's zero")
else:
print("It's a positive number")
The code checks if the number is less than 0, and if so, it prints "It's a negative number". If the condition is not met, it checks if the number is equal to 0, and if so, it prints "It's zero". If neither of the conditions is met, it prints "It's a positive number".
QUESTION 13:
To define a fruitful function that converts inches to centimeters, you can use the following code:
def inches_to_centimeters(inches):
centimeters = inches * 2.54
return centimeters
The function inches_to_centimeters takes the number of inches as a parameter, multiplies it by the conversion factor (2.54), and returns the result in centimeters.
QUESTION 14:
In the given program, the local variables are height, weight, and surface. The global variables are myHeight, myWeight, and mySurfaceArea.
Local variables are declared within a function and can only be accessed within that function. In the getSurfaceArea function, height and weight are local variables.
Global variables are declared outside any function and can be accessed throughout the entire program. In this case, myHeight, myWeight, and mySurfaceArea are global variables since they are declared outside the function getSurfaceArea.
To know more about Python , visit;
https://brainly.com/question/30391554
#SPJ11
Thanks for taking the time to read QUESTION 10 Write statements to generate a random number between 1 and 10 inclusive QUESTION 11 Consider the following Python code Please create a drawPentagon. We hope the insights shared have been valuable and enhanced your understanding of the topic. Don�t hesitate to browse our website for more informative and engaging content!
- Why do Businesses Exist Why does Starbucks Exist What Service does Starbucks Provide Really what is their product.
- The pattern of numbers below is an arithmetic sequence tex 14 24 34 44 54 ldots tex Which statement describes the recursive function used to..
- Morgan felt the need to streamline Edison Electric What changes did Morgan make.
Rewritten by : Barada