repl.it
@TonySiu/

@trying to use interactive shell

Python

No description

fork
loading
Files
  • main.py
  • new.py
main.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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
#import turtle

#turtle = turtle.Turtle()

#square()
#def square(length):
	#turtle.forward(length)
	#turtle.left(90)
	#turtle.forward(length)
	#turtle.left(90)
	#turtle.forward(length)
	#turtle.left(90)
	#turtle.forward(length)
	#turtle.left(90)


#square(120*2)
#square(120/2)
#is_john_killer = True
#is_bob_killer = False

#print(5 == 5) = True
#print(5 > 5) = False
#print(5 <= 5) = True

#if is_john_killer == True:
	#print("John is the killer")
	#square(100)


#### loops
#i = 100
#while i >= 0:
	#if i > 0:
		#print(i)
	#else:
		#print("Indentaion matters!")
	#i = i - 1

#for digit in range(1,100):#(start,finish)
	#if digit == 100:
		#print("boom")
	#else:
		#print(digit)



#####strings

#movie = 'hello world'
#print('hello world')

#Tony_phone_number = '98461008'
#print(Tony_phone_number)

#for i in "TheGodFather":
	#print(i)

#count = 0
#for letter in "it loops spaces too":
	#count += 1
#print(count)

#def string_length(word):
	#count = 0
	#for letter in word:
		#count += 1
	#return count

#print(string_length("Helper"))




####slicing

##0 : ... or ... : -1
#print("Orange"[:-1])

#groceries = ["a", "b", "o"]
#print (groceries)


#####lists

#movies = ["intersteler", "x men", "dark knight"]
#print(movies)

#print(len(movies))

#for movie in movies:
	#print(movie)

#movies. append("ha")
#movies.append("ho")
#print(movies)
#print(len(movies))


##### sum of numbers in list

##(sum of numbers in list option with functions (a))	
#addition = [1,2,3,4,5]

#def sum_of_number(numbers):
	#count = 0
	#for i in numbers:
		#count = count + i
	#return count

#print(sum_of_number(addition))

##can also use "sum" function

##(sum of numbers in list option simplest (b))
#imbeciles = [67,89,23,100]

#count = 0
#for i in imbeciles:
	#count = count + i

#print(count)



#####let's get max number from list

##using "max" function
#allowance = [2,7,9,1,14,13,4]

#def max_number(list):
	#print(max(list))

#max_number(allowance)

## loop through allowance[i], each incrementation through the if statement until left with if statement that cannot increment anymore
#biggest_number = allowance[0]
#for i in allowance:
	#if i > biggest_number:
		#biggest_number = i
#print(biggest_number)


#####let's filter movies with 7+ ratings ((type) - to found of datatype)

#movies = [("Intersteller", 10),("Ironman", 8.2), ("It Follows", 6.0)]
#print(type(movies))
#print(len(movies))

#for movie in movies:
	#if movie[1] > 6.0:
		#print(movie)
	#else:
		#print("not worth it")

##plural arguements ussually lists
#def rating_filter(movies):
	#for i in movies:
		#if i[1] > 6.0:
			#print(i[0])

#rating_filter(movies)

##adding movies into lists to print by defininig it in a function
#def rating_filter(movies, max_rating):
	#final_movies = []

	#for movie in movies:
		#if movie[1] > max_rating:
			#final_movies.append(movie[0])
	#return final_movies

#print(rating_filter(movies, 6))


##### Dictionaries + Contact Phone Book

#phone_book = {"John": "444-222-4444","Billy": "444-222-1111" }
#print(phone_book)

#movies = {"Shawshank Redemption": 9.7 ,"The God Father": 8.0 }



####Dictionary + Create Keys + Change Values + WOrd Frequency Counter

#sentence = "Hey there what are you doing hey what"

#final_answer = {}
#for word in sentence.split():
	#if I am finding it for the first time, reat a key with that word and set it's value to 1

	#If i have alread seen the word.. Then increment it's value by 1
	#if word not in final_answer:
		#final_answer[word] = 1
	#else:
		#final_answer[word] = final_answer[word] + 1
#print(final_answer)
#final_answer = {'Hey': 1, 'hey': 1, 'what': 2,'are': 1, 'you': 1, 'doing': 1,'there': 1}

#final = {}
#def frequency(list):
    
    
	#for word in sentence.split():
		#if word not in final:
			#final[word] = 1
		#else:
			#final[word] += 1
	#return final

#print(frequency(final))

#def word_frequency(sentence):
    #final_frequency = {}
    #for word in sentence.split():
        #if word not in final_frequency:
            #final_frequency[word] = 1
        #else:
            #final_frequency[word] += 1
    
    #return final_frequency
#print(word_frequency(sentence))



#for i in range (10):
    #for j in range(10 - i):
       	#print(end=" ")
    #for j in range(0,i):
       	#print(end='#')
    #for k in range(0,i):
        #print('#', end='')
    #print(end='\n')
#input()
import time
from datetime import datetime as DT
from datetime import timezone


UTC = timezone.utc
EPOCH = DT.fromtimestamp(0,UTC)
TEMPLATE ="{:24} {:10d} {:32} {:32} {:32}"

print("Unix epoch:",EPOCH.isoformat())
print()

def prtime(label,dt,template=TEMPLATE):
    ts = round(dt.timestamp())
    plain = dt.isoformat()
    local = dt.astimezone().isoformat()
    utc = dt.astimezone(UTC).isoformat()
    print(template.format(label,ts,plain,local,utc))

def mktime(label,func,*args,**kw):
    dt =  func(*args,**kw)
    prtime(label,dt)
    return dt

now = time.time()
rnow = round(now)
dates = [ mktime(*args) for args in
         (
             # naive. wrong unless local time is UTC
             ("DT.utcfromtimestamp(t)",DT.utcfromtimestamp,now),
             # correct, but naive
             ("DT.fromtimestamp(t)",DT.fromtimestamp,now),
             # correct and aware
             ("DT.fromtimestamp(t,UTC)",DT.fromtimestamp,now,UTC),
             # naive. wrong unless local time is UTC
             ("DT.utcnow()",DT.utcnow),
             # correct, but naive
             ("DT.now()",DT.now),
             # correct and aware
             ("DT.now(UTC)",DT.now,UTC),
         )
        ]

# these should all represent approximately the same time
for d in dates:
    print(round(d.timestamp())==rnow)