From Import: Math Pi, Tan Side ( ) Area ( Side ) / Tan (Pi/) (Area)
From Import: Math Pi, Tan Side ( ) Area ( Side ) / Tan (Pi/) (Area)
The area of a pentagon can be computed using the following formula (s is the length of a side):
Write a program that prompts the user to enter the side of a pentagon and displays the area
Answer:
Run:
Question 2:
Q. 2. Write a program that reads the following information and prints a payroll statement:
Employee’s name (e.g., Smith)
Number of hours worked in a week (e.g., 10)
Hourly pay rate (e.g., 9.75)
Federal tax withholding rate (e.g., 20%)
State tax withholding rate (e.g., 9%)
Answer:
Question 3:
. Write a program that prompts the user to enter an integer and checks whether the number is
divisible by both 5 and 6, divisible by 5 or 6, or just one of them (but not both)
Answer:
if num % 5 == 0 or num % 6 == 0:
print("Is num divisible by 5 or 6?",True)
else:
print("Is num divisible by 5 or 6?",False)
(Game: lottery) The program prompts the user to enter a three-digit number and determines
whether the user wins according to the following rules:
a. If the user input matches the lottery number in the exact order, the award is $10,000.
b. If all the digits in the user input match all the digits in the lottery number, the award is
$3,000.
c. If one digit in the user input matches a digit in the lottery number, the award is $1,000.
Answer:
import random
# Generate a lottery
lottery_Digit1 = lottery // 10
lottery_Digit2 = lottery % 10
guess_Digit2 = guess % 10
Question 5:
Write a program that prompts the user to enter a point (x, y) and checks whether the point is
within the circle centered at (0, 0) with radius 10. For example, (4, 5) is inside the circle and (9,
9) is outside the circle.
Answer:
import math
m , n = 0,0
m1 , n1 = eval(input("enter value of x and y co-ordinate of a point: "))
r = 10
distance = math.sqrt(((m1-m)*2)+((n1-n)*2))
if distance < r:
print("the point are inside the circle")
elif distance == r:
print("point is on the circle")
Run:
enter value of x and y co-ordinate of a point: 5,8
the point are inside the circle