Python Forum
Help! Program in python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help! Program in python
#1
Sad 
Write a program that determines whether a point falls on
given coordinates into the shaded area. Points on the border
belong to the area. Obtain the necessary parameters from the figure.
Output the result of the program as a text message:
It hits, it doesn't hit. The tasks is in the files. Can anyone please explain how to do it, otherwise nothing is clear Cry Huh Confused . And if anyone can, please do at least one task. Sorry for my poor eng Cry

Description of the algorithm
1. Enter the coordinates of the point (x, y) and convert the values to float type.
2. Check to see if the point falls within the specified area.
3. Output the result in the form: "Point x, y falls within the area." and "Point"
x, y does not fall within the scope."

Description of input and output data
Input data - point coordinates entered by the user. Type
data and representation accuracy are not specified in the problem. Let's install
real type (float).
Output data - messages, in text form, about a hit or
the point does not fall within the specified area.

Program listing
from math import *
flag = 0
print('Enter the X and Y coordinates for the point:')
x = float(input('X='))
y = float(input('Y='))
if (x < -1) or (x > 4):
flag = 0 #False
if ((x>=-1) and (x<1) and (y>=2*x+2)
and (y<=x**3-4*x**2+x+6) or (x>=1)
and (x<=4) and (y>=x**3-4*x**2+x+6)and (y<=2*x+2)):
flag = 1
else:
flag = 0
print("Point X={0: 6.2f} Y={1: 6.2f}"
.format(x, y), end=" ")
if flag:
print("hits", end=" ")
else:
print("doesn't hit", end=" ")
print("to area."
buran write Oct-08-2023, 04:52 PM:
Please, use proper tags when post code, traceback, output, etc.
See BBcode help for more info.

Attached Files

Thumbnail(s)
   

.pdf   111.pdf (Size: 266.27 KB / Downloads: 103)
.pdf   222.pdf (Size: 140.72 KB / Downloads: 116)
Reply


Messages In This Thread
Help! Program in python - by lana - Oct-08-2023, 04:37 PM
RE: Help! Program in python - by Pedroski55 - Oct-08-2023, 05:52 PM
RE: Help! Program in python - by lana - Oct-08-2023, 06:00 PM
RE: Help! Program in python - by Pedroski55 - Oct-08-2023, 07:10 PM
RE: Help! Program in python - by ICanIBB - Oct-11-2023, 01:30 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020