ae1205 programming & scientific computing in python for aerospace engineers quiz what will this...

12
AE1205 Programming & Scientific Computing in Python for Aerospace Engineers Quiz What will this print? a = 2 b = 3 c = a/b print c 1 Answer: 0

Upload: jasmine-farmer

Post on 03-Jan-2016

221 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: AE1205 Programming & Scientific Computing in Python for Aerospace Engineers Quiz What will this print? a = 2 b = 3 c = a/b print c 1 Answer: 0

AE1205 Programming & Scientific Computing in Python for Aerospace Engineers

Quiz What will this print?

a = 2b = 3c = a/b

print c

1

Answer:0

Page 2: AE1205 Programming & Scientific Computing in Python for Aerospace Engineers Quiz What will this print? a = 2 b = 3 c = a/b print c 1 Answer: 0

AE1205 Programming & Scientific Computing in Python for Aerospace Engineers

Quiz What will this print?

a = 2b = 3.c = a/b

print c

2

Answer:0.666666666667

Page 3: AE1205 Programming & Scientific Computing in Python for Aerospace Engineers Quiz What will this print? a = 2 b = 3 c = a/b print c 1 Answer: 0

AE1205 Programming & Scientific Computing in Python for Aerospace Engineers

Quiz What will this print?

a = 2b = 3c = 10.0

d = a/b*ce = a*c/b

print d,e

3

Answer:0.0 6.66666666667

Page 4: AE1205 Programming & Scientific Computing in Python for Aerospace Engineers Quiz What will this print? a = 2 b = 3 c = a/b print c 1 Answer: 0

AE1205 Programming & Scientific Computing in Python for Aerospace Engineers

Quiz What will this print?

from math import *a = 2b = sqrt(a)

print “Square root of”,a,”is”,b

4

Answer:Square root of 2 is 1.41421356237

Page 5: AE1205 Programming & Scientific Computing in Python for Aerospace Engineers Quiz What will this print? a = 2 b = 3 c = a/b print c 1 Answer: 0

AE1205 Programming & Scientific Computing in Python for Aerospace Engineers

Quiz What will this print?

x = 10768a = x%10b = x%100c = x%1000

print a,b,c

5

Answer:8 68 768

Page 6: AE1205 Programming & Scientific Computing in Python for Aerospace Engineers Quiz What will this print? a = 2 b = 3 c = a/b print c 1 Answer: 0

AE1205 Programming & Scientific Computing in Python for Aerospace Engineers

Quiz: What will this print?x = 38.859n10 = int(x/10.)x = x%10.n5 = int(x/5.)x = x%5.n2 = int(x/2.)n1 = int(x%2)x = x - int(x)

print n10," x 10 euro"print n5," x 5 euro"print n2," x 2 euro"print n1," x 1 euro"print "and",int(100.*x)," cents"

6

Answer:3 x 10 euro1 x 5 euro1 x 2 euro1 x 1 euroand 85 cents

Page 7: AE1205 Programming & Scientific Computing in Python for Aerospace Engineers Quiz What will this print? a = 2 b = 3 c = a/b print c 1 Answer: 0

AE1205 Programming & Scientific Computing in Python for Aerospace Engineers

Quiz: Find the 3 syntax errors

7

Page 8: AE1205 Programming & Scientific Computing in Python for Aerospace Engineers Quiz What will this print? a = 2 b = 3 c = a/b print c 1 Answer: 0

AE1205 Programming & Scientific Computing in Python for Aerospace Engineers

Quiz: Find the 3 errors

8

No colon :

Missing bracket (2 x)

Missing comma (3x)

Page 9: AE1205 Programming & Scientific Computing in Python for Aerospace Engineers Quiz What will this print? a = 2 b = 3 c = a/b print c 1 Answer: 0

AE1205 Programming & Scientific Computing in Python for Aerospace Engineers

Quiz: Find the error

9

Page 10: AE1205 Programming & Scientific Computing in Python for Aerospace Engineers Quiz What will this print? a = 2 b = 3 c = a/b print c 1 Answer: 0

AE1205 Programming & Scientific Computing in Python for Aerospace Engineers

Quiz: Find the error

10

Page 11: AE1205 Programming & Scientific Computing in Python for Aerospace Engineers Quiz What will this print? a = 2 b = 3 c = a/b print c 1 Answer: 0

AE1205 Programming & Scientific Computing in Python for Aerospace Engineers

Quiz: Find the error

11

Page 12: AE1205 Programming & Scientific Computing in Python for Aerospace Engineers Quiz What will this print? a = 2 b = 3 c = a/b print c 1 Answer: 0

AE1205 Programming & Scientific Computing in Python for Aerospace Engineers

Quiz: Find the error

12