$ - - PDF document

1
SMART_READER_LITE
LIVE PREVIEW

$ - - PDF document

1/27/2010 2 ) !!(!(%#' 78 ( 9 ((%:


slide-1
SLIDE 1

1/27/2010 1

  • !"#$%

&# '

($( $$$) $()*+,+ (-*. )/%##&(0"1

2 (%#'

(* (" +)!(3 "0 ($( $)!(2( $") %##1,%! !(") 1! !(") (,($( $"",%#4 5( /6!" 6 !6!(62# 6"1

2 ) !!(!(%#'

78( 9((%: )!*( 9!/(-!

%,)/.!(%# $, /

/ ; !" 2 #) $ /(( ((% ) "(6 "%#$)#,)" ,( "%<,(0=>#)%%,

$ $#+,(",%!1

?)#+ % )(%15(%"1

,",( ")

#! (,($(20) 2,( (

/!" 1@#%9 /1

+ 2") )%#! ( #22)")#(/,(/

( 9, %# )1

from math import * def printRootTable(n): for i in range(1,n): print " %2d %7.3f" % (i, sqrt(i)) def main(): printRootTable(10) main() #include <stdio.h> #include <math.h> void printRootTable(int n) { int i; for (i=1; i<=n; i++) { printf(" %2d %7.3f\n", i, sqrt(i)); } } int main() { printRootTable(10); return 0; }

slide-2
SLIDE 2

1/27/2010 2

(/

% for comments First set of them used as the help message Functions For loops; try typing 1:10 Familiar?

!

  • !-A.

97 ) #+:)B // $ !(0%

  • .()")

!

!-A. 97 !-C. 97

  • 97

) ! ) !-2().

2# ,

07 2# -0C. 070; ) (# ! #:/(0B9 (% ! ))

!(,

!( 71 D)!! )

,(($ %# !( ($-661.-2# "#)@2(0. E)!! !(,607! ( "(

  • ") "()!6 0%#.

Your turn: Program now: code to print multiples of 5 up to 50. Then print only those not divisible by 3.

"

%(( ,+6:((B )) (! (!" 62# "##)#+ 1!

slide-3
SLIDE 3

1/27/2010 3

,),(,

!" " ,(, !" F9G7" %,")9 !" " -. % ,") !" F%G7" H-6/6". ,6/6"),%

!#,( (%!" # ,6"!(") 6 ! ,))6%""-(>.

"( ,+!"

"( , !" $( 6I") +( /+ / 2(0," /!" < !" ( !") !" F,G7- ,. /!" -#,(!" .2) 1! 5( /", )!" + 9,!(1

)!" 1!

!#! (!" 2) %#2

!"( !" 1

0,($(##! ")

:!"( /1B

0/!" ")"""( -.#

((#<+#!"( / !"

#,#/!"

!" F(G7"""( -. (7 4

Example output on next slide:

!"( / ,

$!"( / #),()"# , 1! = 1 2! = 2 3! = 6 4! = 24 5! = 120 6! = 720 7! = 5040 8! = 40320 9! = 362880 10! = 3628800 >>

*/$$(

# "6 ( 0" ,#* #%)/$$( ))/(0, #(!%(!"( /

")-! ( #!"( / !" .

, #")/%( $!" # ,#&(0,"2 )2-,,(!/.

+

3 "00%J#("-#).

?,((2 ; (" +)) (%

; (0

?"

; (

"J) ;

((

1!

; >

",

; /

+

; (

)()",%6"6,

slide-4
SLIDE 4

1/27/2010 4

; !"

@(/#, %, :#,,()B "0:)",()B!(#:#,,()B91 (%, :)",()B 9"#,)" )/,() &#),()-H.)' &#/,()-.!(%(!"( !" ' #( "%/ !"( !" 1

,

K##,;C()", #("#/60!(# $ 2# !" 2#% 2#L #2#" /"# "0#/;CK $()

( 9,(

0( 9,%2 # 97F

H>M NOPG

( ) !!(%9!(#( 97FQH>MQNOPG 97F66QH6>6MQN6O6PG 97F66QH6>6MQN6O6PG 97FQ

H>MQ NOPG

KJ#( 9

K#!9 (2" 9-6. #!9(2" 9-6.7N K#! ("!-(26". 9-6. "#( 9$#/%,,(!"(( 9-6. (%# " $//1

#$ $# R!#( 9

))2"(/%69( 9 9-6H.7FQQG ))2(2(/%H69( 9 9-H6.7FH>MG

*@#(2S((%!/)@(((6I 2(0)9,)#( 9!(#2 )9

K# R!#( 9 F6G7 R-9.

5"(,(

,+"(%9 7 71 K#! (>!

  • >.

K#>!

  • );H).

K#+"($# $#-.

slide-5
SLIDE 5

1/27/2010 5

$

,(/), 6 0, 0+"(!9+ 0+"(!%+ 9+% , 97;, 1, Q %7 -9.Q ,-96%. 2(%,-96%6@/1@.

#$ $#, R

(%2(( 97;, 1>, Q %7 -9.Q ,-96%6@/1@. (%/(( 97;, 1, Q %7 -9.Q ,-96%6@/1@. ? 0"0*#)

,(I" (/

,,2#+/#2(#(2 $)

22,#, !#/1

&02# +" %!#/6#$!

# +" %1

&2,!#/626# )

9+2##/# #$()1

("# , ( 9 2L 2L T, 2L U, )2()2 #%$(+ %

20 )$#(%!!

K$))2)")$%

()1

)(I" (/

E1+!(#)!"! ( ,)7>J $!#(27)$( E1+!(%" 0!" %,(I" #02 ,

  • ,)6"#$.6,#/6)((

# !#! $#F! $# G

!( /

#,JJ2221(;#1)JJ