1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
scoundrel [369]
3 years ago
5

You will write a program that generates random drawings that can be drawn using the shape painter.

Computers and Technology
1 answer:
DiKsa [7]3 years ago
6 0

Answer:

import random

f_name = input('Enter the drawing file name: ')

total_shapes = int(input('Enter the no. of total shapes: '))

file = open(f_name,'w')

for i in range(total_shapes):

              category = random.randint(0,1)

              if category == 0:

                             left_coordinate = [random.randint(0,499),random.randint(0,499)]

                             while left_coordinate[0] == 499 and left_coordinate[499] == 0:

                                            left_coordinate = [random.randint(0,499),random.randint(0,499)]

                                           

                             right_coordinate = [random.randint(left_coordinate[0]+1,499), random.randint(left_coordinate[1]+1,499)]

                             

                             red_intensity = random.randint(0,100)

                             green_intensity = random.randint(100,200)

                             blue_intensity = random.randint(192,255)

                             if i == total_shapes-1:      

                                            file.write('Rectange; '+str(left_coordinate[0])+', '+str(left_coordinate[1])+'; '+str(right_coordinate[0])+', '+str(right_coordinate[1])+'; '+str(red_intensity)+', '+str(green_intensity)+', '+str(blue_intensity))

                             else:

                                            file.write('Rectange; '+str(left_coordinate[0])+', '+str(left_coordinate[1])+'; '+str(right_coordinate[0])+', '+str(right_coordinate[1])+'; '+str(red_intensity)+', '+str(green_intensity)+', '+str(blue_intensity)+'\n')

              else: #Circle

                             center = [random.randint(0,499),random.randint(0,499)]

                             if center[0] > center[1]:

                                            radius = random.randint(0,499-center[0])

                             else:

                                            radius = random.randint(0,499-center[1])

                             red_intensity = random.randint(0,100)

                             green_intensity = random.randint(100,200)

                             blue_intensity = random.randint(192,255)

                                           

                             if i == total_shapes-1:    

                                            file.write('Circle; '+str(center[0])+', '+str(center[1])+'; '+str(radius)+'; '+str(red_intensity)+', '+str(blue_intensity)+', '+str(green_intensity))

                             else:

                                            file.write('Circle; '+str(center[0])+', '+str(center[1])+'; '+str(radius)+'; '+str(red_intensity)+', '+str(blue_intensity)+', '+str(green_intensity)+'\n')

                                           

file.close()                                        

Explanation:

  • Get the file name from the user.
  • Loop through to generate total shapes  .
  • Use randInt to randomly generate the category.
  • If category is zero, then that means its a rectangle.
  • Check for last record using an If statement and then display relevant information.
You might be interested in
Different between I time and E time​
Elis [28]

Answer:

On time means at a particular designated time, i.e. neither especially early nor late. The train is scheduled to arrive on time at 13:36. In time means early enough, i.e. before a deadline or another cutoff.

Explanation:

3 0
3 years ago
Mr. stevens is the principal of a high school. why might he want to export data from a database of students’ exam scores? to cre
Archy [21]

Mr. Stevens wants to export data from database of students’ exam scores to create presentation using other software on how  the scores have changed throughout a semester.

<h3>What is database?</h3>

The database is the collection of data which is arranged in proper manner generally electronically in computer system for the easy access and latter use.

The database also help to analyse the data. The data is export from database for following reasons-

  • For backing up the important data.
  • To move the data from two different program version.  

Mr. stevens is the principal of a high school. He want to export data from a database of students’ exam scores. With this data he can make presentation to analyze the scores.

Mr. Stevens wants to export data from a database of students’ exam scores to create a presentation using other software on how students’ scores have changed throughout a semester.

Learn more about the database here;

brainly.com/question/26096799

5 0
3 years ago
Read 2 more answers
Where to get industrial circuits far cry 6
Bond [772]

Answer:

Lola's Shop. They are available in the El Este, Madrugada, and Valle de Oro areas.

8 0
3 years ago
I NEED HEP QUICK
avanturin [10]

Answer:

O = (C2+C3+C4+C5)-81

Explanation:

5 0
2 years ago
Who Find the exact web server that hosted the website by looking in a huge database of internet addresses
son4ous [18]

Answer:

The Internet service provider (ISP)

Explanation:

The internet service provider provides individuals and other companies access to the internet and other web services. The internet service provider looks through a huge database of internet addresses to find the exact web server that a website is hosted on when a query is sent.

4 0
3 years ago
Other questions:
  • To resize an embedded chart, ____. select one:
    5·1 answer
  • A usability study compares the number of page visits on a web site. Half of the participants saw Version A of the home page. The
    13·1 answer
  • Conduct online research on web authentication and define what it is. Describe different authentication methods
    5·1 answer
  • Which part of the Word screen matches label A?
    13·1 answer
  • What are the ASE special certifications?
    14·2 answers
  • Type the correct answer in the box. Spell all words correctly.
    12·1 answer
  • The term "exception propagation" means:
    5·1 answer
  • In 5-10 sentences, describe the procedure for responding to an e-mail message.
    5·1 answer
  • 17.8.1: Writing a recursive math function. Write code to complete raise_to_power(). Note: This example is for practicing recursi
    10·1 answer
  • What are some of the key system-oriented trends that have fostered is-supported decision making to a new level?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!