elz (
elz) wrote in
intro_to_cs2009-11-11 05:21 pm
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
![[community profile]](https://www.dreamwidth.org/img/silk/identity/community.png)
Entry tags:
Lecture 2
Problem set 1: Computing prime numbers, product of primes
This one's a little trickier, so feel free to comment if you run into any problems or want to brainstorm with other people!
(eta: having issues with poll, alas)
no subject
(no subject)
NASnMmOJgL
(Anonymous) - 2012-01-06 22:20 (UTC) - Expandno subject
[x]
(no subject)
(no subject)
(no subject)
aqgHeNVyWCUz
(Anonymous) - 2012-01-07 05:23 (UTC) - Expandno subject
Anybody else make a pretty ugly program? I'm gonna go try it again at some point tonight. How'd your approach differ from mine?
(no subject)
(no subject)
pXWMiprUPTOVcxLS
(Anonymous) - 2012-01-07 09:28 (UTC) - ExpandMoDeXpCzNyFKFCSvSS
(Anonymous) - 2011-08-14 05:14 (UTC) - ExpandvqiwThxRBr
(Anonymous) - 2012-01-09 05:19 (UTC) - Expandno subject
(no subject)
(no subject)
(no subject)
(no subject)
(no subject)
(no subject)
(no subject)
(no subject)
(no subject)
yvixSJkxBtcbHfBLqiT
(Anonymous) - 2012-01-09 04:22 (UTC) - Expand(no subject)
(no subject)
(no subject)
LjdywZEBondMs
(Anonymous) - 2011-08-14 05:08 (UTC) - Expand(no subject)
JQGKyQUiLhGaNrGPR
(Anonymous) - 2011-08-14 06:59 (UTC) - ExpandjBLQAbcTXgxeuAast
(Anonymous) - 2012-01-07 08:24 (UTC) - Expand(no subject)
BbJLPbCRReuw
(Anonymous) - 2012-01-06 22:05 (UTC) - Expandno subject
(no subject)
(no subject)
(no subject)
Examples used in Lecture
ETA or you can just go to the lecture video at the MIT website and they have the handout right there.
Examples of overloading
3*4
3*'ab'
'a' + 'bcd'
3 + 'ab'
str(3)+'ab'
'a'<3
4<'3'
'4'<'3'
The code he used
##x=3 #create variable x and assign value 3 to it
##x=x*x # bind x to value 9
##print x
##n = raw_input('Enter a number; ')
##print n
##print n/n
##x=15
##if (x/2)*2 == x:
## print 'Even'
##else: print 'Odd'
##x=15
##if (x/2)*2 == x: print 'Even'
##else: print 'Odd'
##z='b'
##if 'x' < z :
## print 'Hello'
## print 'Mom'
##if 'x'< z :
## print 'Hello'
##print 'Mom'
##x=15
##y=5
##z=11
##print x,y,z
###Is this right?
##if x< y:
## if x< z : print 'x is least'
## else: print 'z is least'
##else: print 'y is least'
##
##if x < y and x < z : print 'x is least'
##elif y < z : print 'y is least'
##else: print 'z is least'
##y=0
##x=3
##itersLeft = x
##while (itersLeft>0):
## y= y+x
## itersLeft = itersLeft -1
###print 'y =',y,',intersLeft=',intersLeft
##print y
##x=10
##i=1
##while(i<x): ## if x%i == 0: ## print 'divisor ',i ## i = i+1 ##x = 10 ##for i in range(1,x): ## if x%i == 0: ## print 'divisor ',i
hqFbGesiTVFUz
(Anonymous) - 2012-01-09 03:48 (UTC) - Expand