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
Over time, smart phones have become _____.
-BARSIC- [3]
I think the answer is the 2nd one
7 0
3 years ago
Read 2 more answers
to create an app for a mobile device, yourself, you would use BLANK software like Swift, Corona or Scratch.
stiv31 [10]
True

All the programming languages mentioned above synchronizes best with contemporary mobile platforms. Corona, for instance, is built on the programming language LUA and is used in the creation of Android mobile apps, primarily games. 

Swift on one hand is best for an apple creation (IOS and OSX). Swift is an open source which is extremely easy to learn, and is the future of mobile app development. 

On the other hand, scratch is a programming language where children can program and is used as an introductory language. Skills learned from using scratch can be applied to other basic languages like Java and python.

7 0
3 years ago
a ____ consists of wires connecting the cpu and other parts of the computer. The _____ transfers data between CPU and memory uni
geniusboy [140]

Answer:

A power supply consists of wires connecting the cpu and other parts of the computer. The data bus transfers data between CPU and memory unit.

Explanation:

4 0
3 years ago
Which of the following information would best be displayed throughout the use of a time line
tresset_1 [31]

the best answer to me is D

7 0
4 years ago
What is the name of the port that you plug an ethernet network cable into?
IrinaVladis [17]

the answer is RJ-45

3 0
4 years ago
Other questions:
  • Define the method object inc_num_kids() for PersonInfo. inc_num_kids increments the member data num_kids.Sample output for the g
    11·1 answer
  • Collins and quillian explained the results of priming experiments by introducing the concept of _____ into their network model.
    12·1 answer
  • A formal log-on procedure is the operating system’s last line of defense against unauthorized access.
    10·1 answer
  • Apollo Couriers, a company providing international express mail services, has a proactive customer communications team. The prim
    8·1 answer
  • Create a program that will read in a Salesperson name, employment status (1=Full-time AND 2=Part-time) and the sales amount.
    5·1 answer
  • Which of the following scan only works if operating system’s TCP/IP implementation is based on RFC 793?
    12·1 answer
  • Hlo plss help.<br>.....,, ​
    7·2 answers
  • Write short cut of<br> fully justified​
    7·1 answer
  • 15. It is the process of capturing data or translating information to recording format
    12·1 answer
  • The term _____ refers to an organization of components that define and regulate the collection, storage, management and use of d
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!