## Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

Name:

Roll No:

Getting credit

Complete all required blank boxes and lines on this handout. When you are done, show your written answers

to one of the TAs. The TA may ask you a few questions to make sure you understand the material.

Submission: The docx file and edited version of PaintShapes.py, zipped into a file

**1 Random Simulation Basics
**

The following script produces 4 lines of output:

# ShowRand.py

from random import randint as randi

from random import uniform as randu

N = 100000

count=0

for k in range(N):

x = randu(0,100)

if 10<=x<=20 or 45<=x<=70:

count +=1

print (float(count)/float(N))

count=0

for k in range(N):

x = randu(0,100)

if 10<=x<=45 and 20<=x<=60:

count +=1

print (float(count)/float(N))

count=0

for

k in range(N):

x = randi(1,20)

if x%3==1 or x%5==0:

count +=1

print (float(count)/float(N))

count=0

for

k in range(N):

x = randi(1,20)

if 13<=x<17:

count +=1

print (float(count)/float(N))

Cyan with probability 1/3.12).Fill in the following table: I Think the Python Expression Notes Output Is 1 First Output Line 2 Second Output Line 3 Third Output Line 4 Fourth Output Line Says 2 PaintShapes Run the module PaintShapes. 2.1 Show how to modify these assignment statements so that no painted shape is cut by the edge of the figure window? As it stands. [Make the required changes in the PaintShapes. the color is Magenta with probability 1/3.py and observe that it randomly places 500 color disks and squares in the figure window: Look at the computation of rangeR and sideRange values inside the for loop. a Cyan disk with probability 1/4.3) if rc%3==0: c = MAGENTA elif rc%3==1: c = CYAN else: c = BLUE so that we draw a Magenta disk with probability 1/3. and Blue with probability 1/3. and a Blue disk with probability 5/12? Hint: randi(1. 2.2 How could you change rc = randi(1.py] .

count('N').1 Assume that L is a positive integer and that T has been produced by the for loop. A hop is either two units North. two units South. (Hint. -L): x = 0 y = 0 T = “” for i in range 2000 : if abs(x) < L and abs(y) < L: # The robot has not reached the edge r = randi(1. two units East.y coordinates of the robot's final position are printed out. T. 3. -L).count('E').2 Add code after the Code Here comment so that the x. T = T + 'EE' elif r==3: # Hop South y = y-1. An example T would be 'NNEENNSSWWSSWWEE'. and T. Answer: 3. and ( -L. T.3 Random Walk Here is code that simulates a random walk inside a square with corners (L. Answer: . ( -L.count('W'). T = T + 'SS' else: # Hop West x = x-1. Think about T. L). L). or two units West. The string T records the itinerary. (L. Add code after the Code Here comment so that the number of hops that the robot took is assigned to the variable nSteps.4) if r==1: # Hop North y = y + 1. T = T + 'NN' elif r==2: # Hop East x = x + 1. T = T + 'WW' else: break # Code Here The robot starts at (0.count('S').0) and hops its way towards the edge of the square.

- 1 (1)jjkuploaded bySumeet ten Doeschate
- c++programsuploaded byVipin
- untitleddocumentuploaded byapi-341090482
- JF_V02_S02_L09_tryuploaded byAnggi Putra Permana
- Bk Edctn SparkCharts Computer Javauploaded byEH
- Django095 Cheat Sheetuploaded byScott Sweeney
- Jienosa54uploaded bydavidson123524
- IFEM.HW04uploaded bygman
- Codeuploaded byKresno Satrio
- 1716889 - VL148 During Inbound Delivery Creation With MIGO (HUM)uploaded bySatish Raj
- Debuguploaded bytatiana1609
- Django Cheat Sheetuploaded byNathaniel Sim
- Re_ Understanding Caffe.iouploaded byjustme8
- HW 2Skiinguploaded bymr_banny21
- (s1==s5) vs s1==s5 (Beginning Java Forum at JavaRanch)uploaded bykenni18
- Business Scenario Approver of Fi in Workflowuploaded byRicky Das
- Agenda electronica en Dev C++uploaded byOscar Llanos
- Manual Changesuploaded bySimone Orsi de Almeida
- KW_Config Testing Doc-Cash Flow Statementuploaded bysapsapfi
- Cara Instal Library TinyGA Di Arduinouploaded byHàrés Aregh BoeNdanz
- 06 THOTCON 0x1-Trolling Reverse-Engineers With Math-Frank2uploaded bypooook
- Loguploaded byLuiz Henrique
- CapaOracle_Estructuras de Controluploaded byPaolo Abraham Peralta
- Analog Clockuploaded byKevin Nightbird
- Xilinx Esd Bookuploaded byEr Anupam Datta
- JUST BASICuploaded byTivar Victor
- PROCEDURE+FOR+CREATING+WEB+SERVICES+IN+NETBEANSuploaded bycindhiya1
- Ejemplos 2 y 3 Hechos en Clase Programacion Linealuploaded byJavier
- b64 Calculatoruploaded byjavervalino
- How to Clear the Backupuploaded bymyhootz

- Basic Electronicsuploaded byRoshan Ajith
- Thevenin's Theoremuploaded byRoshan Ajith
- CS09 408(P)_ Digital_System_Design_lab.pdfuploaded byRoshan Ajith
- Working w/ JSON stringsuploaded byRoshan Ajith
- Logic Designuploaded byRoshan Ajith
- Familiarising w/ Unix and Linux commandsuploaded byRoshan Ajith
- Installing Multiple OSuploaded byRoshan Ajith
- Linear Systems-Introuploaded byRoshan Ajith
- SM-Lab1uploaded byRoshan Ajith

Read Free for 30 Days

Cancel anytime.

Close Dialog## Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

Loading