Science and Sensitivity Science - PowerPoint PPT Presentation

1 / 11
About This Presentation
Title:

Science and Sensitivity Science

Description:

Science and Sensitivity Science – PowerPoint PPT presentation

Number of Views:41
Avg rating:3.0/5.0
Slides: 12
Provided by: SUPhy4
Category:

less

Transcript and Presenter's Notes

Title: Science and Sensitivity Science


1
Science and SensitivityScience
ComputersPHY307/PHY607Sept. 24, 2002
2
Exams, projects
  • Midterm is Oct. 22. types of problems
  • Project proposal is due Oct. 10.
  • Will skip quizzes.

Homework
  • Fireworks.

3
Homework
  • Fireworks.

4
from mymodule import from random import
scene.autoscale 0 sparks for i in
range(100) sparks.append(sphere(radius0.2))
  for s in sparks s.vel vector(random()-0.5,
random()-0.5,random()-0.5)
s.vel s.vel/mag(s.vel) grav
vector(0,-0.1,0) dt 0.05 while 1
rate(20) for s in sparks for each
sphere, fall(s, grav, dt) have sphere
fall
5
Arrays, lists, vectors
  • Lists can be of any type, but dont support math.
  • Arrays are usually numbers and do support math
    operations on the elements.
  • Vectors are arrays of length 3 (like x,y,z
    coordinates.)

6
Arrays, lists, vectors sample
  • a arange(0,5,1)
  • l range(5)
  • v vector(0,1,2)
  • print a
  • print l
  • print v
  • print a a
  • print a a
  • print a / 2.
  • print l l
  • print l l
  • print v v
  • print v v

7
Loops
  • for loops
  • Repeats actions (block statement)
  • For each item in a list
  • while loops
  • Repeats actions while some condition is true
    (not zero.)
  • A condition is an expression, likea lt 10 a is
    less than 10b 3 b is equal to 3a lt 10 and
    b 3 both conditions holda gt 10 or a lt 5 one
    of the conditions hold1 true0 false

8
while examples
  • a0
  • while a lt 10
  • print a
  • aa3

9
while examples
  • from visual import
  • a box()
  • while a.x lt 10 and a.y lt 64
  • rate(5)
  • a.x a.x 0.5
  • a.y a.y 10

10
Problems with for
  • from visual import
  • sphlist
  • for j in range(0,20,4)
  • sphlist.append(sphere(xj))
  • for s in sphlist
  • s sphere()
  • s.color color.red

11
if else examples
  • a 3.9
  • x 0.26
  • for j in range(20)
  • x a x (1.-x)
  • if x gt 0.8
  • print x is larger than 0.8 at step, j
Write a Comment
User Comments (0)
About PowerShow.com