Ceriwis  

Go Back   Ceriwis > HOBI > Komputer & Teknologi > Programming

Programming Share, tanya jawab, saling bantu antar programmer dengan berbagai macam bahasa pemrograman.

Reply
 
Thread Tools
  #1  
Old 11th November 2011
Braincode's Avatar
Braincode Braincode is offline
Ceriwis Addicted
 
Join Date: Nov 2011
Posts: 4,638
Rep Power: 21
Braincode mempunyai hidup yang Normal
Default [ask] optimasi kode python

buat para juragan skalian, saya minta sarannya soal optimasi kode di python. berikut saya bikin program buat menghitung umur, sudah seminggu saya otak atik nih kode, cuma rasanya masih kurang "sreg" aja, kodenya ada di bawah gan.







01 ################################################

02 #age_counter.py

03 name = raw_input("input your name")

04

05 #birth date input

06 bdate = input ("birth date")

07 bmonth = input ("brith month")

08 byear = input ("birth year")

09 birth = bdate + (bmonth * 30) + (byear * 365)

10

11 #present date input

12 tdate = input ("today date")

13 tmonth = input ("today month")

14 tyear = input ("today year")

15 today = tdate + (tmonth * 30) + (tyear * 365)

16

17 #begin processing

18 age = (today - birth) / 365 #years

19 month = ((today - birth) % 365) / 30 #month

20 day = ((today - birth) % 365) % 30 #days

21

22 #print the result

23 print "dear", name, "your age is"

24 print day, " days", month, " months", age, " years old"

25

26 #age commentation

27 if age
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Terkait
Thread Thread Starter Forum Replies Last Post
JUAL Ball Python, Dipong aka Blood Python, dan AST aka Alligator Snapping Turtle JualPetsFood Fauna (Hewan) 0 19th October 2012 08:04 PM
JUAL Dori Reptile - Ball python/ Bp/ Bol piton/ Python regius babies <100 gram AnjingRas Fauna (Hewan) 0 19th October 2012 09:05 AM
JUAL WTS Ular molurus dwarf python, condro , albertisi , carpet python, patola, Jogja GuineaPig Fauna (Hewan) 0 19th October 2012 08:38 AM
JUAL Jual Ball Python, Baby Buaya, Iguana, Dipong(Blood Python), Jogja PersianCat Fauna (Hewan) 0 18th October 2012 03:36 PM
JUAL Jual Ball Python, Baby Buaya, Iguana, Dipong(Blood Python), Jogja CatLoverz Fauna (Hewan) 0 18th October 2012 02:04 PM

 


All times are GMT +7. The time now is 04:56 AM.