-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfirstFile.py
151 lines (105 loc) · 2.3 KB
/
firstFile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
from sys import argv
def funct(*args):
first, second = args
print("Arguments %s and %s are being printed!" % (first, second))
def funct2(name, surname):
print("Your name: %s and surname: %s." % (name, surname))
x = 1
y = 33
funct(x, y)
'''
print("Ypur Fisrt name:")
name = raw_input()
print("Ypur Second name:")
surname = raw_input()
funct2(name, surname)
script, f = argv
file = open(f)
def print_file(file):
print(file.read())
def rewind(file):
file.seek(0)
def print_line(line,file):
print line, file.readline()
print_file(file)
rewind(file)
cur_line = 1
print_line(cur_line, file)
print_line(cur_line + 1, file)
print_line(cur_line + 1, file)
file.close()
'''
def f(weight):
try:
float(weight)
except:
TypeError
else:
weight = float(weight)
print('Your weight is: %.2f' % weight)
#weight = float(raw_input())
#f(weight=raw_input())
list = [1,2,3,4,5]
def sum(list):
sum = 0
for i in range(0, len(list), 1):
sum += list[i]
return sum
print(sum(list))
t = ((1,2),(3,4,3),(5,6))
for tuple in t:
if tuple.__len__() < 3:
print(tuple)
tuple = (1,2,3,4)
# Dedenie od tuple a prepisanie metody __len__
class tt(tuple.__class__):
def __len__(void):
return 1
t = tt((1,2,3,4))
print(t.count(1))
d = {1:'a', 2:'b', 3:'c'}
for k,v in d.items():
print("Key is: %s, Value is: %s" % (k, v))
for n in d:
print('Keys: %s, Values: %s' % (n, d[n]))
#print("Key is: %s, Value is: %s" % (k, v))
# while loops
'''
meno = 'Pato'
while meno.__eq__('Pato'):
print('Yes!')
print('Enter name:')
meno = raw_input()
else:
print('No longer!')
'''
x = 0
while x<10:
if(x == 5):
x += 1
continue
print(x)
x += 1
x = xrange(1,6)
y = range(1,6)
if not type(x).__eq__(type(y)):
print('They are not the same!')
if type(x) is not type(y):
print('huhu')
print(type(x))
# List comprehension
l = [x**2 for x in xrange(0,4)]
print(l)
l = [x for x in xrange(0,11) if x % 2 == 0]
print(l)
l = []
for x in xrange(0,11):
if(x%2 == 0):
l.append(x)
print(l)
# convert C to F
print('Insert temperatures: ')
celsius = ['%.2f' % (float(raw_input())*(9/5.0) +32) for t in xrange(0,5)]
print(celsius)
#fahrenheit = [(float(t)*()) for t in celsius]
#print(fahrenheit)