Skip to content

Commit aa1cf68

Browse files
committed
merge~2
1 parent 1654179 commit aa1cf68

File tree

24 files changed

+2334
-0
lines changed

24 files changed

+2334
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#Password Generator Project
2+
import random
3+
letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
4+
numbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
5+
symbols = ['!', '#', '$', '%', '&', '(', ')', '*', '+']
6+
7+
nr_letters = random.randint(8, 10)
8+
nr_symbols = random.randint(2, 4)
9+
nr_numbers = random.randint(2, 4)
10+
11+
password_list = []
12+
13+
for char in range(nr_letters):
14+
password_list.append(random.choice(letters))
15+
16+
for char in range(nr_symbols):
17+
password_list += random.choice(symbols)
18+
19+
for char in range(nr_numbers):
20+
password_list += random.choice(numbers)
21+
22+
random.shuffle(password_list)
23+
24+
password = ""
25+
for char in password_list:
26+
password += char
27+
28+
print(f"Your password is: {password}")
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from tkinter import *
2+
3+
Calc=Tk()
4+
Calc.title("Calculator")
5+
Calc.minsize(400,500)
6+
7+
# entry_point=Entry(width=80,)
8+
Calc.config(padx=20,pady=20)
9+
# entry_point.grid()
10+
11+
# def calc_button():
12+
# Calc.config(entry_point.get())
13+
14+
# button =Button(text="9")
15+
# button.grid(column=0,row=0)
16+
button = Button(text="Button-1", height=3, width=10)
17+
button.grid(column=0,row=0)
18+
19+
button=Button(text="Button-2", height=3, width=10)
20+
button.grid(column=1,row=0)
21+
22+
23+
24+
Calc.mainloop()
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import tkinter as tk
2+
3+
def button_click(number):
4+
current = entry.get()
5+
entry.delete(0, tk.END)
6+
entry.insert(0, str(current) + str(number))
7+
8+
def button_clear():
9+
entry.delete(0, tk.END)
10+
11+
# def button_equal():
12+
# try:
13+
# expression = entry.get()
14+
# result = eval(expression) # Use eval() cautiously in real-world applications!
15+
# entry.delete(0, tk.END)
16+
# entry.insert(0, result)
17+
# except (SyntaxError, NameError, ZeroDivisionError):
18+
# entry.delete(0, tk.END)
19+
# entry.insert(0, "Error")
20+
21+
root = tk.Tk()
22+
root.title("Calculator")
23+
24+
entry = tk.Entry(root, width=35, borderwidth=5)
25+
entry.grid(row=0, column=0, columnspan=4, padx=10, pady=10)
26+
27+
buttons = [
28+
'7', '8', '9', '/',
29+
'4', '5', '6', '*',
30+
'1', '2', '3', '-',
31+
'0', '.', '=', '+'
32+
]
33+
34+
row = 1
35+
col = 0
36+
for button_text in buttons:
37+
button = tk.Button(root, text=button_text, padx=40, pady=20, command=lambda text=button_text: button_click(text) if text != '=' else button_equal() if text != 'C' else button_clear())
38+
button.grid(row=row, column=col)
39+
col += 1
40+
if col > 3:
41+
col = 0
42+
row += 1
43+
44+
clear_button = tk.Button(root, text="C", padx=40, pady=20, command=button_clear)
45+
clear_button.grid(row=row, column=col)
46+
47+
root.mainloop()
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import csv
2+
import pandas
3+
4+
# with open("weather_data.csv") as file:
5+
# tempr= []
6+
# data = csv.reader(file)
7+
# for all_info in data:
8+
# tempr.append(all_info[1])
9+
# print(tempr)
10+
# res = [eval(i) for i in tempr[1:]]
11+
# print("Modified list is: ", res)
12+
13+
# a = pandas.read_csv("weather_data.csv")
14+
15+
# temp_list = a["temp"].to_list
16+
# print(temp_list)
17+
# average=0
18+
# for i in temp_list():
19+
# average+=i
20+
# print(average/len(temp_list()))
21+
22+
# print(a["temp"].max())
23+
# monday = a[a.Day=="Monday"]
24+
# print(monday.condition)
25+
# df = a.assign(Fahrenheit=lambda x: (9/5)*x['temp']+32)
26+
# print(df)
27+
28+
# scratch
29+
# new_file ={
30+
# "student": ["shubham", "sonali", "sonal"],
31+
# "score": [20, 10, 30]
32+
# }
33+
# data=pandas.DataFrame(new_file)
34+
# data.to_csv("trial.csv")
35+
36+
a = pandas.read_csv("2018_Central_Park_Squirrel_Census_-_Squirrel_Data.csv")
37+
cinammon_color_count = len(a[a["Primary Fur Color"]=="Cinnamon"])
38+
gray_color_count = len(a[a["Primary Fur Color"]=="Gray"])
39+
Black_color_count = len(a[a["Primary Fur Color"]=="Black"])
40+
41+
new_file = {
42+
"color": ["Cinammon", "gray", "black"],
43+
"total count": [cinammon_color_count,gray_color_count, Black_color_count]
44+
}
45+
data=pandas.DataFrame(new_file)
46+
data.to_csv("primary_fur_color.csv")
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import multiprocessing
2+
import time
3+
4+
5+
def letter():
6+
for i in "abcd":
7+
time.sleep(1)
8+
print(f"letter:{i}")
9+
10+
11+
def number():
12+
for i in range(5):
13+
time.sleep(1.5)
14+
print(f"number:{i}")
15+
16+
17+
if __name__ == "_main_":
18+
t1 = Process(target=letter)
19+
t2 = Process(target=number)
20+
21+
current_time = time.time()
22+
# start the thread
23+
t1.start()
24+
t2.start()
25+
# wait for thread to complete
26+
t1.join()
27+
t2.join()
28+
29+
used_time = time.time() - current_time
30+
print(used_time)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
question_data = [
2+
{"text": "A slug's blood is green.", "answer": "True"},
3+
{"text": "The loudest animal is the African Elephant.", "answer": "False"},
4+
{"text": "Approximately one quarter of human bones are in the feet.", "answer": "True"},
5+
{"text": "The total surface area of a human lungs is the size of a football pitch.", "answer": "True"},
6+
{"text": "In West Virginia, USA, if you accidentally hit an animal with your car, "
7+
"you are free to take it home to eat. ", "answer": "True"},
8+
{"text": "In London, UK, if you happen to die in the House of Parliament, "
9+
"you are entitled to a state funeral.", "answer": "False"},
10+
{"text": "It is illegal to pee in the Ocean in Portugal.", "answer": "True"},
11+
{"text": "You can lead a cow down stairs but not up stairs.", "answer": "False"},
12+
{"text": "Google was originally called 'Backrub'.", "answer": "True"},
13+
{"text": "Buzz Aldrin's mother's maiden name was 'Moon'.", "answer": "True"},
14+
{"text": "No piece of square dry paper can be folded in half more than 7 times.", "answer": "False"},
15+
{"text": "A few ounces of chocolate can to kill a small dog.", "answer": "True"}
16+
]
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from question_model import Question
2+
from data import question_data
3+
from quiz_brain import QuizBrain
4+
question_bank = []
5+
6+
for question in question_data:
7+
question_text = question["text"]
8+
question_answer = question["answer"]
9+
new_question = Question(question_text, question_answer)
10+
question_bank.append(new_question)
11+
12+
quiz = QuizBrain(question_bank)
13+
14+
while quiz.is_still_question:
15+
16+
quiz.next_question()
17+
18+
19+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
class Question:
2+
def __init__(self, text, answer):
3+
self.text = text
4+
self.answer = answer
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
class QuizBrain:
2+
def __init__(self, q_list):
3+
self.question_number = 0
4+
self.score=0
5+
self.question_list = q_list
6+
7+
def is_still_question(self):
8+
return len(self.question_list) > self.question_number
9+
10+
def next_question(self):
11+
current_question = self.question_list[self.question_number]
12+
self.question_number += 1
13+
a = input(f"q.{self.question_number}:{current_question.text} (True/False): ")
14+
15+
if a == current_question.answer:
16+
print("You got it right!")
17+
print(f"The correct answer is {current_question.answer}")
18+
self.score+= 1
19+
print(f"{self.score}")
20+
21+
22+
else:
23+
print("No you don't got it :")
24+
print(f"The correct answer is {current_question.answer}")
25+
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# import random
2+
3+
# print('Welcome to Snake-Water-Gun Game')
4+
# rounds = int(input('Enter number of rounds: '))
5+
# choices = {'g':'s', 's':'w', 'w':'g'}
6+
# p_score = c_score = 0
7+
# for i in range(1, rounds+1):
8+
# p = input("Choose s for Snake, w for Water, g for Gun: ").strip()
9+
# if p not in choices:
10+
# print("Invalid input, try again\n")
11+
# continue
12+
# Computer = random.choice(list(choices.keys()))
13+
# print(f'You choose: {p}, \n computer choose: {Computer}')
14+
# if choices[Computer] == p:
15+
# c_score += 1
16+
# elif choices[p] == Computer:
17+
# p_score += 1
18+
# else:
19+
# print(f"\t Round {i} is Draw")
20+
# print(f'Your score in round {i} is : {p_score}')
21+
# print(f'Computer score in round {i} is : {c_score}')
22+
23+
# print(f'Your final score is : {p_score}')
24+
# print(f'Computer final score is : {c_score}')
25+
# if p_score > c_score:
26+
# print("Congratulations!! You Won")
27+
# elif c_score > p_score:
28+
# print("You lose!!")
29+
# else:
30+
# print("Match Draw!!")
31+
32+
# import random
33+
34+
# def rec():
35+
# play=int(input("if you want to play press 1 aur pressc any key"))
36+
# if play==1:
37+
# Computer=['s','w','g']
38+
# Computer=random.choice(list(Computer))
39+
# print(Computer)
40+
41+
# rec()
42+
# d=['s','w','g']
43+
# d=random.choice(list(d))
44+
# print(d)
45+
46+
# import random
47+
48+
# win_matrix = []
49+
# choice_list = ["Snake" , "Water" , "Gun"]
50+
# win_matrix = [['D' , 'W' , 'L'],['L' , 'D' , 'W'],['W' , 'L' , 'D']]
51+
# dict_points = {'S' : 0 , 'W' :1 , 'G':2 }
52+
53+
# player_1 = input("Player1 Select your option from (Snake,Water,Gun)?")
54+
55+
# player_2 = random.choice(choice_list)
56+
# print(f"System selected :: {player_2} ")
57+
58+
# print("Player1 you : " , win_matrix[dict_points[player_1[0]]][dict_points[player_2[0]]])
59+
60+
61+
from random import choice
62+
63+
def score_func():
64+
c_score = p_score = 0
65+
total_round=int(input("how many round do you want play:"))
66+
for round in range(1,total_round):
67+
68+
computer_choice=['s','w','g']
69+
computer=choice(list(computer_choice))
70+
d={'s':0,'w':1,'g':2}
71+
72+
person=str(input("User choices between gun, snake and water is : ").strip())
73+
74+
print("Computer choices between gun, snake and water is : " , computer )
75+
76+
print(f"Computer choose {computer} and Person choose {person}")
77+
78+
if person == 'w' or person == 's' or person == 'g':
79+
if computer == person:
80+
print("match is draw")
81+
elif computer == 's' and person == 'w':
82+
c_score += 1
83+
print("computer is the winner")
84+
elif computer == 'w' and person == 'g':
85+
c_score += 1
86+
print("computer is winner")
87+
88+
elif computer == 'g' and person == 's':
89+
print("computer is the winner")
90+
c_score += 1
91+
else:
92+
print("person is winner")
93+
p_score += 1
94+
else:
95+
print("you input invalid character")
96+
print(c_score)
97+
print(p_score)
98+
again_play=input("Do you want to continue Press y for continue:")
99+
100+
if again_play=="y":
101+
return score_func()
102+
103+
104+
105+
score_func()
106+
107+
108+

0 commit comments

Comments
 (0)