Pythonプログラマーの進化

初心者



  1. def階乗( x ) :
  2. x == 0の 場合 :
  3. 1を 返す
  4. その他 :
  5. return x *階乗( x- 1 )
  6. 階乗の印刷 ( 6 )




1年間プログラマー(以前Pascalを勉強していた)



  1. def階乗( x ) :
  2. 結果= 1
  3. i = 2
  4. 一方、 i < = x:
  5. 結果=結果* i
  6. i = i + 1
  7. 結果を返す
  8. 階乗の印刷 ( 6 )






プログラマー1年(以前はCを勉強していた)



  1. def fact ( x ) : #{
  2. 結果= i = 1 ;
  3. while ( i < = x ) : #{
  4. 結果* = i ;
  5. i + = 1 ;
  6. #}
  7. 結果を返す ;
  8. #}
  9. 印刷 (事実( 6 ) )




1年間のプログラミング( SICPが読む)



  1. @tailcall
  2. def fact ( x、acc = 1 ) :
  3. if ( x > 1 ) : return ( fact ( ( x- 1 ) 、 ( acc * x ) ) ))
  4. その他 :accを返す
  5. 印刷 (事実( 6 ) )




Pythonでの1年間のプログラミング(以前に1Cで学習)



  1. def ObrabotkaObchisleniya ( ) :
  2. //
  3. 0を 返す
  4. def Soobschit ( TekstSoobscheniya ) :
  5. 印刷 TekstSoobscheniya
  6. def Faktorial (ザナチェニエ) :
  7. リターンザナチェニエ*ファクトリアル(ザナチェニエ-1 )
  8. Soobschit ( Faktorial ( 6 ) )
  9. ストゥキ= 84000




Pythonと時々Brainfuckを学ぶ



  1. 輸入 OS
  2. def fact ( x ) :
  3. file = open ( "code.b" 、 'w' )
  4. ファイル 。 write ( "> ++++++++++ >>> +> + [>>> + [-[<<<<< [+ <<<<<] >> [[-]> [< <+> +>-] <[> + <-] <[> + <-[> + <-[> + <-[> + <-[> + <-[> + <-[> + <- [> + <-[> + <-[> [-] >>>> +> + <<<<<<-[> + <-]]]]]]]]]]]]> [<+> -] + >>>>>] <<<<< [<<<<<] >>>>>>> [>>>>>] ++ [-<<<<<] >>>>> >-] + >>>>>] <[> ++ <-] <<<< [<[> + <-] <<<<] >> [-> [-] ++++++ [ <++++++++>-] >>>>] <<<<< [<[> +> + <<-]>。<<<<<]>。>>>>] " )
  5. ファイル 。 閉じる ( )
  6. #todo:xパラメーターの実装
  7. os 。 システム ( '/ usr / bin / bf code.b' )
  8. 事実( 6 )




Pythonでの1年間のプログラミング



  1. def階乗( x ) :
  2. res = 1
  3. xrange ( 2 、x + 1 )の iの場合:
  4. res * = i
  5. 返品
  6. 階乗の印刷 ( 6 )




レイジーパイソンの労働者



  1. def fact ( x ) :
  2. x > 1 および x * fact ( x- 1 ) または 1を 返します
  3. 印刷事実( 6 )




非常に怠zyなPythonワーカー



  1. f = lambda x:x および x * f ( x- 1 ) または 1
  2. プリント f ( 6 )




Pythonのエキスパート



  1. fact = lambda x: reduce ( int 。__mul__ 、 xrange ( 2 、x + 1 ) 、 1 )
  2. 印刷事実( 6 )




Pythonのハッカー



  1. インポートシステム
  2. @tailcall
  3. def fact ( x、acc = 1 ) :
  4. if x:ファクトを返す ( x 。__sub__ ( 1 ) 、acc 。__mul__ ( x ) )
  5. accを返す
  6. sys 標準 write ( str ( fact ( 6 ) ) + ' \ n '




エキスパートプログラマー



  1. c_math インポートファクトから
  2. 印刷事実( 6 )




英語専門プログラマー



  1. c_maths インポートファクトから
  2. 印刷事実( 6 )




Webプログラマー



  1. def階乗( x ) :
  2. #-------------------------------------------------
  3. #---階乗計算スニペット---
  4. #---ご自身の責任で使用してくださいVasily Pupkin 2010 ---
  5. #-------------------------------------------------
  6. 結果= str ( 1 )
  7. i = 1 #Ivanをハッキングしてくれてありがとう
  8. 一方、 i < = x:
  9. #result = result * i#おそらく使用した方が良い* =
  10. #result = str(結果*結果+ i)
  11. #result = int(result * = i)#??????
  12. 結果= str ( int (結果) * i )
  13. #result = int(str(result)* i)#
  14. i = i + 1
  15. 結果を返す
  16. 階乗の印刷 ( 6 )




Unixプログラマー



  1. 輸入 OS
  2. def fact ( x ) :
  3. os 。 システム ( 'factorial' + str ( x ) )
  4. 事実( 6 )




Windowsプログラマー



  1. NULL = なし
  2. def CalculateAndPrintFactorialEx ( dwNumber、
  3. hOutputDevice、
  4. lpLparam、
  5. lpWparam、
  6. lpsscSecurity、
  7. * dwReserved ) :
  8. if lpsscSecurity ! = NULL:
  9. NULLを返します#実装されていません
  10. dwResult = dwCounter = 1
  11. 一方、 dwCounter < = dwNumber:
  12. dwResult * = dwCounter
  13. dwCounter + = 1
  14. hOutputDevice。 書き込み ( str ( dwResult ) )
  15. hOutputDevice。 書き込み ( ' \ n ' )
  16. 1を 返す
  17. インポートシステム
  18. CalculateAndPrintFactorialEx ( 6 、 sys。Stdout 、NULL、NULL、NULL、NULL、NULL、NULL、NULL、NULL、NULL、NULL、NULL )




大規模オフィスプログラマー



  1. def new ( cls、 * args、 ** kwargs ) :
  2. return cls ( * args、 ** kwargs )
  3. クラス番号( オブジェクト ) :
  4. 合格する
  5. クラス IntegralNumber ( int 、Number ) :
  6. def toInt ( self ) :
  7. 新しい ( int 、 self )を 返します
  8. クラス InternalBase ( オブジェクト ) :
  9. def __init__ ( self 、base ) :
  10. 自己 。 ベース =ベース。 toInt ( )
  11. def getBase ( self ) :
  12. return new ( IntegralNumber、self。base )
  13. クラス MathematicsSystem ( オブジェクト ) :
  14. def __init__ ( self 、ibase ) :
  15. アブストラクト
  16. @ classmethod
  17. def getInstance ( cls、ibase ) :
  18. 試してください :
  19. cls .__インスタンス
  20. AttributeError を除く :
  21. cls .__ instance = new ( cls、ibase )
  22. cls .__インスタンスを返します
  23. クラス StandardMathematicsSystem ( MathematicsSystem ) :
  24. def __init__ ( self 、ibase ) :
  25. ibaseの場合 。 getBase ( ) ! = new ( IntegralNumber、 2 ) :
  26. NotImplementedErrorを発生させます
  27. 自己 。 base = ibase。 getBase ( )
  28. def calculateFactorial ( self 、target ) :
  29. 結果= 新規 ( IntegralNumber、 1 )
  30. i = new ( IntegralNumber、 2 )
  31. 一方、 i < =ターゲット:
  32. 結果=結果* i
  33. i = i + new ( IntegralNumber、 1 )
  34. 結果を返す
  35. StandardMathematicsSystemを印刷します 。 getInstance ( new ( InternalBase、 new ( IntegralNumber、 2 ) ) ) 。 CalculateFactorial ( new ( IntegralNumber、 6 ) )




あなたはどのタイプに属しますか、 %username% ?



upd。:誰がひそかにカルマに溶け込むのだろうか? 異議がある場合は、コメントでそれを表現する勇気を持ってください。



All Articles