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

Post on 03-Jan-2016

221 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

AE1205 Programming & Scientific Computing in Python for Aerospace Engineers

Quiz What will this print?

a = 2b = 3c = 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

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

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

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

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

AE1205 Programming & Scientific Computing in Python for Aerospace Engineers

Quiz: Find the 3 syntax errors

7

AE1205 Programming & Scientific Computing in Python for Aerospace Engineers

Quiz: Find the 3 errors

8

No colon :

Missing bracket (2 x)

Missing comma (3x)

AE1205 Programming & Scientific Computing in Python for Aerospace Engineers

Quiz: Find the error

9

AE1205 Programming & Scientific Computing in Python for Aerospace Engineers

Quiz: Find the error

10

AE1205 Programming & Scientific Computing in Python for Aerospace Engineers

Quiz: Find the error

11

AE1205 Programming & Scientific Computing in Python for Aerospace Engineers

Quiz: Find the error

12

top related