Skip to content

Commit 2e7308c

Browse files
committed
Try out
1 parent 7d66dd7 commit 2e7308c

File tree

7 files changed

+408
-0
lines changed

7 files changed

+408
-0
lines changed

mini_project_to_try/Morse Code

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit ed82a4541d6ff2e71e5bad5c002bd9ebbe814b83

mini_project_to_try/alarm.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from datetime import datetime
2+
from playsound import playsound
3+
import pyttsx3 as ts
4+
import time
5+
speak = ts.init()
6+
7+
def gettime():
8+
try:
9+
alarm = input("Enter the time to be alarmed(hr:min PM/AM):")
10+
return alarm
11+
except TypeError:
12+
print('Invalid')
13+
except ValueError:
14+
print("Invalid")
15+
16+
def time_based(alarm_time):
17+
alarm_hour=alarm_time[0:2]
18+
alarm_min=alarm_time[3:5]
19+
alarm_period=alarm_time[6:8].upper()
20+
print("Alarm Set")
21+
speak.say("Alarm Set")
22+
speak.runAndWait()
23+
while True:
24+
now = datetime.now()
25+
current_hour = now.strftime("%H")
26+
current_min = now.strftime("%M")
27+
current_period = now.strftime("%p")
28+
if current_hour==alarm_hour and current_min==alarm_min and current_period==alarm_period:
29+
speak.say("Wake up tarun")
30+
speak.runAndWait()
31+
time.sleep(2)
32+
playsound("/home/lucifertrj/Music/Arcade.mp3")
33+
break
34+
35+
alarm_time = gettime()
36+
time_based(alarm_time)
37+

mini_project_to_try/clock.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import tkinter as tk
2+
from time import strftime
3+
4+
root=tk.Tk()
5+
root.title("Clock")
6+
7+
timing=tk.Label(root,font=("arial",100),bg="black",fg="white")
8+
timing.pack()
9+
10+
def clock():
11+
clock_time=strftime('%X %p')
12+
timing.config(text=clock_time)
13+
timing.after(1000,clock)
14+
15+
clock()
16+
17+
root.mainloop()
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import streamlit as st
2+
import yfinance as finance
3+
4+
def get_ticker(name):
5+
company = finance.Ticker(name) #google
6+
return company
7+
8+
st.title("Build and Deploy Stock Market App Using Streamlit")
9+
st.header("A Basic Data Science Web Application")
10+
11+
st.sidebar.header("Geeksforgeeks \n TrueGeeks")
12+
13+
company1 = get_ticker("GOOGL")
14+
company2 = get_ticker("MSFT")
15+
16+
google = finance.download("GOOGL", start="2021-10-01", end="2021-10-01")
17+
microsoft = finance.download("MSFT", start="2021-10-01", end="2021-10-01")
18+
19+
data1 = company1.history(period="3mo")
20+
data2 = company2.history(period="3mo")
21+
22+
company2.history()
23+
st.write(company1.info)
24+
st.write("""
25+
### Google
26+
""")
27+
st.write(company1.info['longBusinessSummary'])
28+
st.write(google)
29+
st.line_chart(data1.values)
30+
31+
st.write("""
32+
### Microsoft
33+
""")
34+
st.write(company2.info['longBusinessSummary'],"\n",microsoft)
35+
st.line_chart(data2.values)

mini_project_to_try/hangman.py

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
import random
2+
import string
3+
4+
hangman_body = ['''
5+
------
6+
|
7+
|
8+
|
9+
|
10+
========''','''
11+
------
12+
| |
13+
|
14+
|
15+
|
16+
========''' ,'''
17+
------
18+
| |
19+
o |
20+
|
21+
|
22+
========''','''
23+
------
24+
| |
25+
o |
26+
| |
27+
|
28+
========''','''
29+
------
30+
| |
31+
o |
32+
/| |
33+
|
34+
========''','''
35+
------
36+
| |
37+
o |
38+
/|\ |
39+
|
40+
========''','''
41+
------
42+
| |
43+
o |
44+
/|\ |
45+
/ |
46+
========''','''
47+
------
48+
| |
49+
o |
50+
/|\ |
51+
/ \ |
52+
========''',
53+
]
54+
def displayhangman(wrong_guess,correct_guess,anime_character,hangman_body):
55+
if len(wrong_guess)<8:
56+
print(hangman_body[len(wrong_guess)])
57+
58+
print('Wrong guesses:',end='')
59+
for wrong in wrong_guess:
60+
print(wrong,end='')
61+
print('')
62+
63+
blanks = "_" * len(anime_character)
64+
65+
for i in range(len(anime_character)):
66+
if anime_character[i] in correct_guess:
67+
blanks = blanks[:i] + anime_character[i] + blanks[i+1:]
68+
69+
for letters in blanks:
70+
print(letters,end='')
71+
print('')
72+
73+
def guessTaken(alreadyexist):
74+
while True:
75+
guess = input('\n Start guessing:').lower()
76+
if guess not in string.ascii_lowercase:
77+
guess = input('Enter valid guess:')
78+
if not len(guess)== 1:
79+
guess=input('Enter a single character:')
80+
if guess==alreadyexist:
81+
guess=input('Guess again,guess already exist:')
82+
else:
83+
return guess
84+
85+
def playagain():
86+
again = input('Do you want to play again(Y/n)?').lower()
87+
if again.startswith('y'):
88+
return True
89+
else:
90+
return False
91+
92+
print('Anime Hangman')
93+
characters="jabamiyumeko,ishigamisenku,satomemary,darkness,nifuji,narumi,koyanagi,kabakura,megumin,sabo,sukuna,gojo,yuji" \
94+
"sakatagintoki,shinpachi,kagura,hijikata,makisekurisu,light,l,karma,kageyama," \
95+
"kazuma,okabe,hachiman,yukino,yui,orekihotaru,chitandaeru,narutouzumaki," \
96+
"monkeydLuffy,Lelouch,tatsumi,esdeath,akame,arima,kaori,fujinuma,kakeru,naho," \
97+
"suwa,ichigokurosaki,uryuishida,giyuutomika,kenkaneki,saiki,zerotwo,hiro,chizuru,shuohuma,jintan,menma,norman," \
98+
"ray,emma,sakakibara,akira,maisakurajima,sakuta,Ayanokouji,suzune,roronoazoro," \
99+
"vinsmokesanji,boahancock,hinatahyuga,sasukeuchiha,CC,tenma,johan,,suzakukururugi," \
100+
"karen,shikamarunara,kakashihatake,itachi uchiha,tanjiro,zenitsu,deku" \
101+
"inosuke,portazdace,jiraiya,minato,god yato,hiyori,yukine,leviackerman,erenyeager," \
102+
"mikasaackerman,erwinsmith,edwardelric,alphonseelric,roymustang,kenma,oikawa,bokuto,erza" \
103+
"rayleigh,shanks,trafalgarlaw,killua,gon,hisoka,komi,ginko,natsu,goku,vegeta".lower().split(',')
104+
105+
wrong_guess = ''
106+
correct_guess = ''
107+
anime_character = random.choice(characters)
108+
finish=False
109+
streaks=0
110+
111+
while True:
112+
displayhangman(wrong_guess, correct_guess,anime_character,hangman_body)
113+
guess=guessTaken(wrong_guess+correct_guess)
114+
if guess in anime_character:
115+
correct_guess = correct_guess + guess
116+
complete = True
117+
for i in range(len(anime_character)):
118+
if anime_character[i] not in correct_guess:
119+
complete = False
120+
break
121+
if complete:
122+
streaks=streaks+1
123+
print(f'The Anime character is {anime_character}, You guessed it right')
124+
print('Winning Streaks:',streaks)
125+
finish = True
126+
else:
127+
wrong_guess = wrong_guess + guess
128+
if len(wrong_guess) == len(hangman_body) - 1:
129+
displayhangman(hangman_body, wrong_guess, correct_guess,anime_character)
130+
print(f'Oops!!...You are out of guesses, the anime character was {anime_character}')
131+
streaks=0
132+
finish = True
133+
134+
if finish:
135+
if playagain():
136+
wrong_guess = ''
137+
correct_guess = ''
138+
finish = False
139+
anime_character = random.choice(characters)
140+
else:
141+
print("Thank you playing")
142+
break
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
import random
2+
import time
3+
4+
def game_rules():
5+
rules = """
6+
Rules: A simple 2 player game [Bungou Stray Dogs Season 3 Episode 4]
7+
1. Inially open one card, i.e., display one card from shuffled deck
8+
2. Now player1 takes a card from the deck
9+
3. Now it begins, the other player:[player2] should guess if the taken card is higher or lower from than the previous card
10+
**[ say the first card is 9, now one player should guess if the next card is high or low
11+
i.e., if 1-8 appears it is low, 10-12 and A appears then it is high
12+
now player1 reveals the next card, say it is 10.
13+
Now 10 is the previous card, now guess high or low based on number 10.
14+
]**
15+
4. If the player2 guessed correctly then player1 is again suppose to take another card
16+
5. Now when player2 guessed correctly, that drawn card is added in player1 penalty.
17+
6. If the player2 guess is wrong, then player2 will take the card and player1 will guess
18+
7. Since player2 guessed wrong, that card will be counted as player2 penalty.
19+
8. The game continues till all 51 cards are revealed [1 card will be opened in beginning so 51]
20+
9. At end who as more penalty cards loses, and player with less penalty cards win.
21+
***********
22+
10. Penalty card calculation:
23+
if player1 guessed wrong, player1 gets penalty, now player2 have to guess
24+
if player1 guessed correctly, player2 gets penalty, since guess is correct player1 itself should guess again
25+
***********
26+
"""
27+
return rules
28+
29+
def deck_52_cards():
30+
deck = list()
31+
deck.clear()
32+
suits = ['H','S','D','C'] #Hearts, Spades, Diamond, Club
33+
for suit in suits:
34+
for card in range(1,14):
35+
deck.append(suit+str(card))
36+
random.shuffle(deck)
37+
return deck
38+
39+
def winner(guess_cards,p1_name,p2_name):
40+
base=first_card = random.choice(guess_cards)
41+
print("First Card:",first_card)
42+
guess_cards.remove(first_card)
43+
player1_penalty_scores,player2_penalty_scores = 0,0
44+
turn = p2_name
45+
no_turn = p1_name
46+
47+
while True:
48+
if len(guess_cards)==0:
49+
print("\n\t Match Over \n")
50+
break
51+
52+
guess=input("{} guess High or Low:".format(turn)).lower()
53+
if guess not in ['high','low']:
54+
continue
55+
56+
next_card = random.choice(guess_cards)
57+
guess_cards.remove(next_card)
58+
print("Previous card:",base)
59+
print("New Card:",next_card)
60+
61+
correct = "low" if(int(base[1:])>int(next_card[1:])) else "high" #correct is low for True if condition else correct=High
62+
if guess==correct:
63+
print("{} Correct {}".format('*'*10,'*'*10))
64+
if turn==p1_name:
65+
player2_penalty_scores+=1
66+
else:
67+
player1_penalty_scores+=1
68+
else:
69+
print("{} Wrong, Next {}".format('*'*10,'*'*10))
70+
if turn==p2_name:
71+
turn=p1_name
72+
player2_penalty_scores+=1
73+
else:
74+
turn=p2_name
75+
player1_penalty_scores+=1
76+
77+
base=next_card
78+
79+
return(p1_name if(player2_penalty_scores>player1_penalty_scores) else p2_name)
80+
81+
def play_again():
82+
ask = input("Do you want to play again(Y/n)? ").lower()
83+
if ask.startswith('y'):
84+
main()
85+
return True
86+
print("Thank You ")
87+
88+
def main():
89+
#guess high or low
90+
game_details = input("Do you want to see the rules(Y/n)? ").lower()
91+
if game_details.startswith('y'):
92+
print(game_rules())
93+
time.sleep(15)
94+
print("Game will start in 5 seconds .....")
95+
time.sleep(5)
96+
97+
print("\n\n\t Let the Game Begin \n\n")
98+
cards = deck_52_cards()
99+
player1 = input("Player 1 enter your name: ")
100+
player2 = input("Player 2 enter your name: ")
101+
winner_of_the_game = winner(cards,player1,player2)
102+
print("Winner is",winner_of_the_game)
103+
play_again()
104+
105+
if __name__ == '__main__':
106+
main()

0 commit comments

Comments
 (0)