-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsrtipt.py
More file actions
456 lines (354 loc) · 11.3 KB
/
srtipt.py
File metadata and controls
456 lines (354 loc) · 11.3 KB
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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
#!/usr/bin/python
# my_int is set to 7 below. What do you think
# will happen if we reset it to 3 and print the result?
my_int = 7
# Change the value of my_int to 3 on line 8!
my_int = 3
# Here's some code that will print my_int to the console:
# The print keyword will be covered in detail soon!
print my_int
============== new script===============
# meal.py
# Assign the variable total on line 8!
meal = 44.50
tax = 0.0675
tip = 0.15
meal = meal + meal * tax
total = meal + meal * tip
print("%.2f" % total)
======================== new script========
# string01.py
# Assign your variables below, each on its own line!
caesar = "Graham"
praline = "John"
viking = "Teresa"
# Put your variables above this line
print caesar
print praline
print viking
==================== new script ======================
"""
The string "PYTHON" has six characters,
numbered 0 to 5, as shown below:
+---+---+---+---+---+---+
| P | Y | T | H | O | N |
+---+---+---+---+---+---+
0 1 2 3 4 5
So if you wanted "Y", you could just type
"PYTHON"[1] (always start counting from 0!)
"""
WORD = "MONTY"
fifth_letter = WORD [4]
print fifth_letter
================ new script ========================
parrot = "Norwegian Blue"
len(parrot)
print len(parrot)
===================== new script ======================
parrot = "norwegian blue"
print parrot.upper()
=================== new script ========================
parrot = "norwegian blue"
print parrot.lower()
=================== new script =========================
"""Declare and assign your variable on line 4,
then call your method on line 5!"""
pi = 3.14
print str(pi)
=================== new script =========================
ministry = "The Ministry of Silly Walks"
print len(ministry)
print ministry.upper()
=================== new script =========================
"""Assign the string "Ping!" to
the variable the_machine_goes on
line 5, then print it out on line 6!"""
the_machine_goes = "Ping!"
print the_machine_goes
=================== new script =========================
# Turn 3.14 into a string on line 3!
print "The value of pi is around " + str(3.14)
=================== new script =========================
string_1 = "Camelot"
string_2 = "place"
print "Let's not go to %s. 'Tis a silly %s." % (string_1, string_2)
=================== new script =========================
name = raw_input("What is your name?")
quest = raw_input("What is your quest?")
color = raw_input("What is your favorite color?")
print "Ah, so your name is %s, your quest is %s " \
"and your favorite color is %s." % (name, quest, color)
=================== new script =========================
# Write your code below, starting on line 3!
my_string = "fuck you"
print len(my_string)
print my_string.upper()
=================== new script =========================
from datetime import datetime
now = datetime.now()
print str(now.month) +"/"+ str(now.day) +"/" + str(now.year) +" "+ str(now.hour) +":"+ str(now.minute) +":" + str(now.second)
=================== new script =========================
# this is a poker game
# Simple Blackjack game
# From Dillon by Dillon
from random import randint
from sys import exit
from time import sleep
# player starts with money
p_cash = 15
# randomly create a new card
class NewCard(object):
def __init__(self):
# card can be between 2 and 14
self.value = randint(2,14)
# Assign the card key based on its value (A = 11, J = 12, Q = 13, K = 14)
if self.value == 11:
self.key = 'A'
elif self.value == 12:
self.key = 'J'
elif self.value == 13:
self.key = 'Q'
elif self.value == 14:
self.key = 'K'
else:
self.key = self.value
# make the value of Jacks, Queens, and Kings 10
if self.value > 11:
self.value = 10
#TODO: make Aces 1 or 11
# Tell the player their cards
def print_p_cards():
print('Player: {0}: {1}'.format(p_total, p_cards))
# Tell the player the dealer's cards
def print_d_cards():
print('Dealer: {0}: {1}'.format(d_total, d_cards))
# starts a new game
def deal():
sleep(1)
p_bet = 0
# initial bet starts above maximum
if p_cash > 0:
while (p_bet > 20) or (p_bet < 1):
print('This table has a $1 minimum and $20 maximum')
p_bet = input("You have ${0}. Enter your bet or press (q) to quit $".format(p_cash))
#TODO: check if empty
if p_bet[0] == 'q':
print("Thanks for visiting Luke's Casino. Enjoy your ${0}!".format(p_cash))
exit()
else:
try:
p_bet = float(p_bet)
except:
print('Bet must be a dollar amount')
p_bet = 0
if p_bet > p_cash:
p_bet = 0
print("You don't have that much!")
else:
print('You have run out of money. Get out of here, bum!')
exit()
# dealer's hand
global d_card1
global d_card2
global d_total
global d_cards
d_card1 = NewCard()
d_card2 = NewCard()
d_total = (d_card1.value + d_card2.value)
d_cards = [str(d_card1.key), str(d_card2.key)]
# player's hand
global p_card1
global p_card2
global p_total
global p_cards
p_card1 = NewCard()
p_card2 = NewCard()
p_total = (p_card1.value + p_card2.value)
p_cards = [str(p_card1.key), str(p_card2.key)]
# tell the player the cards
print("\nLet's go")
if d_total == 21:
print_d_cards()
else:
print("Dealer: {0}: ['{1}', '?']".format(d_card1.value, d_card1.key))
print_p_cards()
#TODO: add insurance option if dealer shows Ace
# check for blackjack on initial deal
if d_total == 21 and p_total == 21:
print('You both have Blackjack! Tie!')
deal()
elif d_total == 21 and p_total != 21:
print('Dealer has Blackjack! You lost ${0}!\n'.format(p_bet))
p_cash -= p_bet
deal()
elif d_total != 21 and p_total == 21:
print('Blackjack! You won ${0}!\n'.format(p_bet * 1.5))
p_cash += p_bet * 1.5
deal()
else:
while p_total <= 21:
p_act = str(input('\nWould you like to (h)it or (s)tand? '))
#TODO: add split and double
if (p_act[0] == 's') or (p_total == 21):
print_p_cards()
print_d_cards()
while d_total < 17:
d_new_card = NewCard()
d_total += d_new_card.value
d_cards.append(str(d_new_card.key))
sleep(1)
print('The dealer hits')
print_d_cards()
global p_cash
if p_total == d_total:
print('Tie!\n')
elif p_total < d_total and d_total <= 21:
print('You lost ${0}!\n'.format(p_bet))
p_cash -= p_bet
else:
print('You won ${0}!\n'.format(p_bet))
p_cash += p_bet
deal()
elif p_act[0] == 'h':
p_new_card = NewCard()
p_total += p_new_card.value
p_cards.append(str(p_new_card.key))
print_p_cards()
print('Bust! You lost ${0}!\n'.format(p_bet))
p_cash -= p_bet
deal()
# opening statement
print("Welcome please sit at the blackjack table.")
deal()
=================== new script =========================
import this
love = "love"
what = this
this = love
love = this
raw_input = "a pity?"
love != "this"
it = "real"
inlove = "islands in the sky"
fools = "them, and now you are one of them"
reality=39
inlove=str(inlove)[0:2]
fools=str(fools[0:3])+str(fools[7])
meaning=3
it_=str(raw_input)[3:5]
life=str(meaning + reality)
print fools+" "+it_+" "+inlove+" "+"true"+" - "
print "The meaning of life is "+life
=================== new script =========================
#!/usr/bin/python
import web
urls = ('/(.*)', 'hello')
app = web.application(urls, globals())
class hello:
def GET(self, name):
if not name:
name = 'World'
return 'Hello, ' + name + '!'
if __name__ == "__main__":
app.run()
=================== new script =========================
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
class MyHandler(BaseHTTPRequestHandler):
def do_GET(self):
path=self.path
print path
ans=path
self.wfile.write(ans)
return
def log_request(self, code=None, size=None):
print('Request')
def log_message(self, format, *args):
print('Message')
if __name__ == "__main__":
try:
server = HTTPServer(("0.0.0.0", 8000), MyHandler)
print('Started http server')
server.serve_forever()
except KeyboardInterrupt:
server.socket.close()
print(' received, shutting down server')
=================== new script =========================
print "Hello this is a piglatin word translater."
print "Please enter a valid word."
print " "
ans = raw_input("what word would you like to use? ")
if ans.isalpha() == True:
print "this is not a word please try again"
elif ans.isalpha() == False:
print "you typed a word thats so great."
=================== new script =========================
def pyglatin():
print " "
print "Hello this is a piglatin word translater."
print "Please enter a valid word."
print " "
ans = raw_input("what word would you like to use? ")
if ans.isalpha() and ans > 1:
a = ans[0:1]
b = ans + a + "ay"
print a
else:
print "Thats not a word"
pyglatin()
=================== new script =========================
#!/usr/bin/python
#pyglatin game
def pyglatin():
print "Welcome to the English to Pig Latin translator!"
print "Please enter a valid word."
print " "
original = raw_input("what word would you like to use? ")
if original.isalpha() and original > 1:
a = original[0:1]
b = original + a + "ay"
c = b[1:len(b)]
print c
else:
print "Thats not a word"
pyglatin()
=================== new script =========================
def tax(bill):
"""Adds 8% tax to a restaurant bill."""
bill *= 1.08
print "With tax: %f" % bill
return bill
def tip(bill):
"""Adds 15% tip to a restaurant bill."""
bill *= 1.15
print "With tip: %f" % bill
return bill
meal_cost = 100
meal_with_tax = tax(meal_cost)
meal_with_tip = tip(meal_with_tax)
========================================================
=================== new script =========================
original = raw_input('Enter a word:')
word = original.lower()
first = original[0]
if condition:
if other_condition:
# Do something
else:
# Do something else!
else:
# Do yet another thing
=================== new script =========================
def shut_down():
s = input('would you like to shutdown?')
if s = "Yes" or "YES" or "yes" or "y" or "Y":
print("Shutting down...")
elif s = "No" or "no" or "NO" or "n" or "N":
print("Shutdown aborted!")
else:
print("Sorry, I didn't understand you.")
return shut_down()
shut_down()
=================== new script =========================
=================== new script =========================
=================== new script =========================
=================== new script =========================