Python tunnis tehtud näited

From ICO wiki
Revision as of 13:48, 19 March 2013 by Mernits (talk | contribs) (Created page with '<source lang="python"> #!/usr/bin/python # -*- coding: utf-8 -*- # Tere täpiline kommentaar import os a = 5 print 'Tere maailm!', a b = 2.0 c = a/b print 'c väärtus on',c…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Tere täpiline kommentaar
import os
a = 5

print 'Tere maailm!', a

b = 2.0

c = a/b 

print 'c väärtus on',c

for i in range(1, 9999):
    print 'i =', i
    if i%2==0:
        print 'i on paarisarv'
    else:
        print 'i on paaritu arv'
        
while True:        
    vastus = raw_input()
    print 'vastus oli', vastus    
    if vastus == 'c':
        break

print 'programm lõpetas töö'