-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
148 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env python3.8 | ||
|
||
class Person(): | ||
def __init__(self, name, title, children=None): | ||
self.name = name | ||
self.title = title | ||
if children is None: | ||
self.children = [] | ||
else: | ||
self.children = children | ||
|
||
def desc(self): | ||
out = [] | ||
for kid in self.children: | ||
out.append(kid) | ||
out.extend(kid.desc()) | ||
return out | ||
|
||
p1 = Person("p1", "test") | ||
p2 = Person("p2", "test", children = [p1]) | ||
p3 = Person("p3", "test") | ||
p4 = Person("p4", "test", children = [p2, p3]) | ||
p5 = Person("p5", "boss", children = [p4]) | ||
print [person.title for person in p5.desc()] | ||
print [person.name for person in p5.desc()] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/usr/bin/env python3.8 | ||
|
||
def fizzbuzz(number): | ||
if number % 3 == 0: | ||
x = print("fizz") | ||
elif number % 5 == 0: | ||
x = print("buzz") | ||
else: | ||
pass | ||
return x | ||
|
||
|
||
fizzbuzz(6) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
#!/usr/bin/env python3.8 | ||
import random | ||
import sys | ||
|
||
|
||
# lets set some variables | ||
wordList = [ | ||
"lion", "umbrella", "window", "computer", "glass", "juice", "chair", "desktop", | ||
"laptop", "dog", "cat", "lemon", "cabel", "mirror", "hat" | ||
] | ||
|
||
guess_word = [] | ||
secretWord = random.choice(wordList) # lets randomize single word from the list | ||
length_word = len(secretWord) | ||
alphabet = "abcdefghijklmnopqrstuvwxyz" | ||
letter_storage = [] | ||
|
||
|
||
|
||
def beginning(): | ||
print("Hello Mate!\n") | ||
|
||
while True: | ||
name = input("Please enter Your name\n").strip() | ||
|
||
if name == '': | ||
print("You can't do that! No blank lines") | ||
else: | ||
break | ||
|
||
beginning() | ||
|
||
|
||
|
||
def newFunc(): | ||
print("Well, that's perfect moment to play some Hangman!\n") | ||
|
||
while True: | ||
gameChoice = input("Would You?\n").upper() | ||
|
||
if gameChoice == "YES" or gameChoice == "Y": | ||
break | ||
elif gameChoice == "NO" or gameChoice == "N": | ||
sys.exit("That's a shame! Have a nice day") | ||
else: | ||
print("Please Answer only Yes or No") | ||
continue | ||
|
||
newFunc() | ||
|
||
|
||
|
||
def change(): | ||
|
||
for character in secretWord: # printing blanks for each letter in secret word | ||
guess_word.append("-") | ||
|
||
print("Ok, so the word You need to guess has", length_word, "characters") | ||
|
||
print("Be aware that You can enter only 1 letter from a-z\n\n") | ||
|
||
print(guess_word) | ||
|
||
|
||
|
||
def guessing(): | ||
guess_taken = 1 | ||
|
||
while guess_taken < 10: | ||
|
||
|
||
guess = input("Pick a letter\n").lower() | ||
|
||
if not guess in alphabet: #checking input | ||
print("Enter a letter from a-z alphabet") | ||
elif guess in letter_storage: #checking if letter has been already used | ||
print("You have already guessed that letter!") | ||
else: | ||
|
||
letter_storage.append(guess) | ||
if guess in secretWord: | ||
print("You guessed correctly!") | ||
for x in range(0, length_word): #This Part I just don't get it | ||
if secretWord[x] == guess: | ||
guess_word[x] = guess | ||
print(guess_word) | ||
|
||
if not '-' in guess_word: | ||
print("You won!") | ||
break | ||
else: | ||
print("The letter is not in the word. Try Again!") | ||
guess_taken += 1 | ||
if guess_taken == 10: | ||
print(" Sorry Mate, You lost :<! The secret word was", secretWord) | ||
|
||
|
||
change() | ||
guessing() | ||
|
||
print("Game Over!") | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env python3.8 | ||
|
||
|
||
|
||
def to_camel_case(text): | ||
return print(list(text.split("-"))) | ||
|
||
to_camel_case("the_stealth_warrior") |