יום שני, 13 בפברואר 2012

Programming in Python Chapters 3+4

3.2 Exercises

1. r=5
p=3.141592
area=p*r**2
2.10
3.name, d7, 2x, first_name, lastName, Amt
4.firstName='Tal'
lastName='Zilkha'
print (firstName+' '+lastName)
5.5 and 3
6.5, error, 'five', 4
7.
def pow4(x):
    return**4
8.+++++len = 5


3.3 Exercises

1. Local variables are for functions and global are variables which are not just for one function
2.??? how???
3.not sure?
4.one returns 50 the other returns 25


3.4 Exercises

1.
def f(x,y):
 return (x+' '+y)
2.I can do this.
3.
def rightJustify(s,w):
 return ((w-len(s))*' '+s)
4. dont get it
5. returns 2
6.21?, nothing
7.???
8.len(0), len((0))


3.5 Exercises

1.
def mystery(x,y):
  return x//y
2.
def mystery(x,y):
  return x/y
gives you division
3.
def test(a,b):
  return (a+b)/2
4.b=1 a=2
5.nope
6.don't get it
7.
from math import sqrt
def quadtratic(a,b,c):
  return (((-b+sqrt(b**2-4*a*c))/(2*a), ((-b-sqrt(b**2-4*a*c))/(2*a))
8.
9.


4.2 Exercises

1.add 2 starting from 1. 1+2n
2.1 over 2 times 3n
3.1,2,4,8,16 (1*2n), 1,4,16 (1*4n)
4.36
5.1:3
6.1+11k=1024
k=93
93(21)+1=1954
7. the difference is the same...
8. does it want me to give an example or prove it? not sure how to prove it
9.they can be. multiplication by 1 (addition by 0)
10. limit is 1
11. at 1?
12.1


4.3 Exercises

1. the middle term
2.what?
3.1
4.okay.
5.huh?
6.6543210
7.2^n-n
8.?


4.4 Exercises

1.1
2.yes? to 1/100?
3.??
4.less than 1 but greater than 0
5.2, i think, guessing here
6.i think at 2, not sure
7.there is a limit on the area and the perimeter i believe


4.5 Exercises

1.

אין תגובות:

הוסף רשומת תגובה