Commit a28c8c29 by Sergey.Kolodchenko

Upload New File

parent 45a8c9c2
Showing with 102 additions and 0 deletions
# input / output (print + format, input)
print('See kuvatakse ekraanile')
print('See {}{}{}'.format(23,'uus',55))
print('See {t}{x}{t}'.format(t='uus',x=24))
# variables
# datatypes (int, float, string)
muutuja = 14
print(muutuja)
print('muutuja: {}'.format(muutuja))
'''
#muutuja = 'string on nyyd'
print('muutuja: ' + str(muutuja))
'''
email = 'sergey.tthk@gmail.com
# conditionals (if, elif, else)
# operators (==, is, !=, not, and, or, in)
if muutuja > 5:
print('suurem kui 5')
elif 'gmail.com' in email:
print("uhke v2rk")
else:
print("muu")
#print('v2iksem kui 20')
'''
# loops (for + range, while)
while True:
print("true")
break
# 1 parameeter (kui mitu tsyklit)
# 2 parameeter (algus, l6pp)
# 3 parameeter (algus, l6pp, samm)
for i in range(2,6,2):
print("tsykkel: {}".format(i))
'''
#for i in "sergey.tthk@gmail.com":
# print(i)
print("sergey.tthk@gmail.com"[::-1])
# strings
# string methods( upper, find, replace, split), indexing
# generic function len()
muutuja = ' v2ike kiisu Marta'
print(muutuja.find('v2ike'))
s6nad = muutuja.split(' ')
print(s6nad[0].capitalize())
print(s6nad[0].upper())
print(s6nad[0].replace('i','SIIN ASENDAMINE'))
# esimene s6na, esimene t2ht
print(s6nad[0][-1:4])
print(s6nad[1][1:4:-1])
print(s6nad[-1])
print(len(muutuja))
'''
# list
# list methods (append, insert, pop, extend, sort)
# advanced: list comprehension
l = []
l.appent("uus element")
l.appent(5)
l.insert(1, 'keskel')
l.extend(['uued elemendid',1,2,3])
l.pop(1)
l2 = [25,2, -254, 677, 362, -25]
print(l2)
#kasvav
l2.sort()
#kahanev
l2.sort(reverse=True)
print(l2)
l3 = [x ** 2 for x in range(1, 5)]
l4 = [x for x in l2 if x > 20]
print(l4)
l5 = []
for x in l2:
if x > 20:
l5.append(x)
'''
# math and importing + docs, importing selected methods
# cos, sqrt, pow
#import math
from math import sqrt as mysqrt
print(sqrt(16))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment