From 17d414674c68ffe760a8f7dc4838ceb03efb6f32 Mon Sep 17 00:00:00 2001 From: "Anna.Agafonova" Date: Thu, 29 Nov 2018 14:22:49 +0300 Subject: [PATCH 1/3] Comment: first --- game.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 game.py diff --git a/game.py b/game.py new file mode 100644 index 0000000..255ac7d --- /dev/null +++ b/game.py @@ -0,0 +1,18 @@ +import random + +world_list = ('way', 'oil', 'cosmic', 'plan', 'library', 'washer', 'olimpia') + + +def print_users_word(arg): + print(''.join(arg)) + #return True + + +secret_word = random.choice(world_list) +print(secret_word) + +users_word = ['*'] * len(secret_word) +print_users_word(users_word) + +users_word[1] = 's' +print_users_word(users_word) From bc2fc9393e1776dcf436ad8f260d5838ffb811ec Mon Sep 17 00:00:00 2001 From: "Anna.Agafonova" Date: Thu, 29 Nov 2018 15:40:15 +0300 Subject: [PATCH 2/3] Merge branch 'three' # Conflicts: # tale --- game.py | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/game.py b/game.py index 255ac7d..0e3e1a7 100644 --- a/game.py +++ b/game.py @@ -1,5 +1,7 @@ import random +MAX_ERRORS = 8 + world_list = ('way', 'oil', 'cosmic', 'plan', 'library', 'washer', 'olimpia') @@ -14,5 +16,35 @@ def print_users_word(arg): users_word = ['*'] * len(secret_word) print_users_word(users_word) -users_word[1] = 's' -print_users_word(users_word) +#users_word[1] = 's' +#print_users_word(users_word) + + +errors_counter = 0 +while True: + letter = raw_input("vvedi bukvu ") + + if len(letter) != 1 or not letter.isalpha(): + continue + + if letter in secret_word: + idx = 0 + for char in secret_word: + if char == letter: + users_word[idx] = letter + idx += 1 + if '*' not in users_word: + print('win ;)') + break + + else: + errors_counter += 1 + print('mistakes are ', errors_counter) + if errors_counter == MAX_ERRORS: + print('loser') + break + print_users_word(users_word) +print('Bye!') + + #print(letter) + From 1f876a6653f922b993180584cd382a3e2aebad19 Mon Sep 17 00:00:00 2001 From: "Anna.Agafonova" Date: Thu, 6 Dec 2018 18:28:57 +0300 Subject: [PATCH 3/3] hs --- .idea/vcs.xml | 6 ++++++ Example.py | 24 ++++++++++++++++++++++++ HTTP_server.py | 23 +++++++++++++++++++++++ file.py | 6 ++++++ game.py | 3 +-- 5 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 .idea/vcs.xml create mode 100644 Example.py create mode 100644 HTTP_server.py diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Example.py b/Example.py new file mode 100644 index 0000000..81963a4 --- /dev/null +++ b/Example.py @@ -0,0 +1,24 @@ +class Vehicle(object): + + + def __init__(self, color, doors, tires): + # Constructor + self.color = color + self.doors = doors + self.tires = tires + + def brake(self): + + return "Braking" + + def drive(self): + + return "I'm driving!" + + +if __name__ == "__main__": + car = Vehicle("blue", 5, 4) + print(car.color) + + truck = Vehicle("red", 3, 6) + print(truck.color) \ No newline at end of file diff --git a/HTTP_server.py b/HTTP_server.py new file mode 100644 index 0000000..d9d01a2 --- /dev/null +++ b/HTTP_server.py @@ -0,0 +1,23 @@ +#!/usr/bin/python + +from BaseHTTPServer import BaseHTTPRequestHandler,HTTPServer + +# This class will handles any incoming request from the browser +class myHandler(BaseHTTPRequestHandler): + + # Handler for the GET requests + def do_GET(self): + self.send_response(200) + self.send_header('content-type', 'text/html') + self.end_headers() + self.wfile.write('Hello World!') # Send the html message + return + +try: + # Create a web server and define the handler to manage the incoming request + server = HTTPServer(("localhost", 8081), myHandler) + print 'Started http server on port ', 8081 + server.serve_forever() +except KeyboardInterrupt: + print '^C received, shutting down the web server' + server.socket.close() diff --git a/file.py b/file.py index e69de29..1794509 100644 --- a/file.py +++ b/file.py @@ -0,0 +1,6 @@ + +a = 2 +b = int(raw_input()) + +print(a + b) + diff --git a/game.py b/game.py index 0e3e1a7..ddba0b1 100644 --- a/game.py +++ b/game.py @@ -28,8 +28,7 @@ def print_users_word(arg): continue if letter in secret_word: - idx = 0 - for char in secret_word: + for idx, char in enumerate(secret_word): if char == letter: users_word[idx] = letter idx += 1