davalend

Members
  • Content Count

    14
  • Joined

  • Last visited

Everything posted by davalend

  1. How to write the code for summation of alist of number eg ( 0, 1, 2, 3, 4) it means (0)+(0 + 1)+(0+1+2)+(0+1+2+3)+(0+1+2+3+4) tks
  2. how to write the code to display the current time ?
  3. hmm.... because i am using this number in "a" in a formula. for example: x = a * 100 so x will return me a list of difference answer with difference input of "a" get what i mean?
  4. read = open('rules.txt', 'r') a = read.readlines() arr = [] for ruleline in a: arr.append(ruleline.split()[1]) print arr ----------------------------------- ['5510/2'] ['5510/2', '2490/1'] ['5510/2', '2490/1', '4728/2'] ['5510/2', '2490/1', '4728/2', '1940/1'] ['5510/2', '2490/1', '4728/2', '1940/1', '1940/1'] ['5510/2', '2490/1', '4728/2', '1940/1', '1940/1', '5510/3'] --------------------------------------------------------------- it keeps repeating. how come?
  5. tks so much for the quick reply. ya. i done it
  6. Sorry, i dont get what u mean ... which part of my coding is wrong? and how shd it be change?
  7. read = open('sample.txt', 'r') a = read.readlines() arr = [] for ruleline in a: for ruledata in ruleline[2:9]: arr.append(ruledata) print arr, what is wrong with this code? it prints ['5'] ['5', '5'] ['5', '5', '1'] ['5', '5', '1', '0'] ['5', '5', '1', '0', '/'] ['5', '5', '1', '0', '/', '2'] ['5', '5', '1', '0', '/', '2', ' '] ..... what I want is 5510/2, not seperating them... pls guide me.
  8. 1 5510/2 if then Date = 03/17/1999 03/18/1999 2 2490/1 if DA0=100 then DA1 = 112 3 4728/2 if F2=.AP then F1 = .S .AS i have this data in a txt file. now i need to retrieve 5510/2, 2490/1, 4728/2 ONLY. how do i do that in python?
  9. now i got other problem. t = len(a) * 0.6 t will definitly be a decimal. how can i change it to the whole number without the decimal, so that i can apply to n in foo[m:n]. n has to be integer
  10. this is my python code ---------------------------------- read = open('sample.txt', 'r') a = read.readlines() for line in a : print line, ------------------------------------ the above code will print all the line in the file. but if i wan it to print only certain % of the line(for example: 50% of the line). how do i code it?
  11. i need some help with some c++ coding. i need to convert c++ coding to python. anyone can help me?