Skip to content

Commit a5348a2

Browse files
committed
2 parents 66a6373 + 5e6f2e2 commit a5348a2

11 files changed

+260
-0
lines changed

Best_game.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# We have 3 choice for selecting snake, water, function
2+
# we have selected anything from 3 choices
3+
# computer choose randomly among three choices
4+
5+
# if I choose snake and computer choose water then snake win
6+
# if I choose snake and computer choose gun then gun win
7+
# if I choose snake and computer choose snake then match draw
8+
9+
# if I choose gun and computer choose water then water win
10+
# if I choose gun and computer choose water then gun win
11+
# if I choose gun and computer choose water then gun match tie
12+
13+
# if I choose water and computer choose gun then water won
14+
# if I choose water and computer choose snake then snake won
15+
# if I choose water and computer choose water then draw
16+
17+
import random
18+
19+
score = 0
20+
i = 1
21+
22+
while i <= 5:
23+
24+
computer_guesses = ['snake', 'water', 'gun']
25+
print(f"{i}. Computer has choose value....")
26+
compChoice = random.choice(computer_guesses)
27+
28+
print("Choose any one from snake, water, gun ")
29+
myChoice = input()
30+
31+
if myChoice == "snake" or myChoice == "water" or myChoice == "gun":
32+
if myChoice == 'snake' and compChoice == 'water':
33+
print("You win!!")
34+
score += 1
35+
elif myChoice == 'snake' and compChoice == 'gun':
36+
print("You lost!!")
37+
elif myChoice == 'water' and compChoice == 'gun':
38+
print("You win!!")
39+
score += 1
40+
elif myChoice == 'water' and compChoice == 'snake':
41+
print("You lost!!")
42+
elif myChoice == 'gun' and compChoice == 'snake':
43+
print("You win!!")
44+
score += 1
45+
elif myChoice == 'gun' and compChoice == 'water':
46+
print("You lost!!")
47+
else:
48+
print("Match draw!!")
49+
i += 1
50+
else:
51+
print("Enter valid input...")
52+
print("\nYour Total score: ", score)

Contact_Book_Management/Info.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Hey!
2+
I have added Contact Management System made by me.

Contact_Book_Management/Project.py

Whitespace-only changes.

DiceRollGame/DiceRollGame.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#importing module for random number generation
2+
import random
3+
4+
#range of the values of a dice
5+
min_val = 1
6+
max_val = 6
7+
8+
#to loop the rolling through user input
9+
roll_again = "yes"
10+
11+
#loop
12+
while roll_again == "yes" or roll_again == "y":
13+
print("Rolling The Dices...")
14+
print("The Values are :")
15+
16+
#generating and printing 1st random integer from 1 to 6
17+
print(random.randint(min_val, max_val))
18+
19+
#generating and printing 2nd random integer from 1 to 6
20+
print(random.randint(min_val, max_val))
21+
22+
#asking user to roll the dice again. Any input other than yes or y will terminate the loop
23+
roll_again = input("Roll the Dices Again?")

DiceRollGame/Readme.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## Project Name : Dice Rolling Game.
2+
### Creating this project by using Python.
3+
4+
## Screen Shot :
5+
![DiceRollGame](https://user-images.githubusercontent.com/68117385/193454478-266ae1af-9e66-42b7-afaf-daa622b831b6.png)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
def kthRepeating(input,k):
2+
3+
# OrderedDict returns a dictionary data
4+
# structure having characters of input
5+
# string as keys in the same order they
6+
# were inserted and 0 as their default value
7+
dict=OrderedDict.fromkeys(input,0)
8+
9+
# now traverse input string to calculate
10+
# frequency of each character
11+
for ch in input:
12+
dict[ch]+=1
13+
14+
# now extract list of all keys whose value
15+
# is 1 from dict Ordered Dictionary
16+
nonRepeatDict = [key for (key,value) in dict.items() if value==1]
17+
18+
# now return (k-1)th character from above list
19+
if len(nonRepeatDict) < k:
20+
return 'Less than k non-repeating characters in input.'
21+
else:
22+
return nonRepeatDict[k-1]
23+
24+
# Driver function
25+
if __name__ == "__main__":
26+
input = "Ankur Ranjan"
27+
k = 3
28+
print (kthRepeating(input, k))

MathsQuiz/MathematicsQuiz.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
def check_guess(guess, answer):
2+
global score
3+
still_guessing = True
4+
attempt = 0
5+
while still_guessing and attempt < 3:
6+
if guess.lower() == answer.lower():
7+
print("Correct Answer")
8+
score = score + 1
9+
still_guessing = False
10+
else:
11+
if attempt < 2:
12+
guess = input("Sorry Wrong Answer, try again")
13+
attempt = attempt + 1
14+
if attempt == 3:
15+
print("The Correct answer is ",answer )
16+
17+
score = 0
18+
print("Mathamatics Quiz")
19+
guess1 = input("45+45+45+45 = ?\n Type your Ans. = ")
20+
check_guess(guess1, "180")
21+
guess2 = input("\n1234+0+1.23+98 = ?\n Type your Ans. = ")
22+
check_guess(guess2, "1333.23")
23+
guess3 = input("\n35x12x0-69+69 = ?\n Type your Ans. = ")
24+
check_guess(guess3, "0")
25+
print("\nYour Score is "+ str(score))

MathsQuiz/MathsQuiz.png

39 KB
Loading

MathsQuiz/Readme.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Project : Mathamatical Quiz
2+
### Mathamatical Quiz implement by using Python.
3+
4+
## Screen Shot :
5+
6+
![MathsQuiz](https://user-images.githubusercontent.com/68117385/193453481-4db1449b-1981-4d17-8372-51621c1e1ef5.png)

Python1/lavishsheth.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#My Rock Paper Scissor Game #
2+
import random
3+
4+
print("Winning Rules of the Rock paper scissor game as follows: \n"
5+
+"Rock vs paper->paper wins \n"
6+
+ "Rock vs scissor->Rock wins \n"
7+
+"paper vs scissor->scissor wins \n")
8+
9+
while True:
10+
print("Enter choice \n 1 for Rock, \n 2 for paper, and \n 3 for scissor \n")
11+
12+
13+
choice = int(input("User turn: "))
14+
15+
while choice > 3 or choice < 1:
16+
choice = int(input("enter valid input: "))
17+
18+
19+
if choice == 1:
20+
choice_name = 'Rock'
21+
elif choice == 2:
22+
choice_name = 'paper'
23+
else:
24+
choice_name = 'scissor'
25+
26+
27+
print("user choice is: " + choice_name)
28+
print("\nNow its computer turn.......")
29+
30+
31+
comp_choice = random.randint(1, 3)
32+
33+
while comp_choice == choice:
34+
comp_choice = random.randint(1, 3)
35+
36+
37+
if comp_choice == 1:
38+
comp_choice_name = 'Rock'
39+
elif comp_choice == 2:
40+
comp_choice_name = 'paper'
41+
else:
42+
comp_choice_name = 'scissor'
43+
44+
print("Computer choice is: " + comp_choice_name)
45+
46+
print(choice_name + " V/s " + comp_choice_name)
47+
48+
if choice == comp_choice:
49+
print("Draw=> ", end = "")
50+
result = Draw
51+
52+
53+
if((choice == 1 and comp_choice == 2) or
54+
(choice == 2 and comp_choice ==1 )):
55+
print("paper wins => ", end = "")
56+
result = "paper"
57+
58+
elif((choice == 1 and comp_choice == 3) or
59+
(choice == 3 and comp_choice == 1)):
60+
print("Rock wins =>", end = "")
61+
result = "Rock"
62+
else:
63+
print("scissor wins =>", end = "")
64+
result = "scissor"
65+
66+
67+
if result == Draw:
68+
print("<== Its a tie ==>")
69+
if result == choice_name:
70+
print("<== User wins ==>")
71+
else:
72+
print("<== Computer wins ==>")
73+
74+
print("Do you want to play again? (Y/N)")
75+
ans = input().lower
76+
77+
78+
79+
if ans == 'n':
80+
break
81+
82+
print("\nThanks for playing")
83+
84+
85+
86+
87+
Output:-
88+
![Screenshot (5)](https://user-images.githubusercontent.com/109017996/193450417-0c3178d7-ec41-4bef-88b1-61b39be43f5f.png)

java_inheritance_code/vss240.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Terms used in Inheritance
2+
- Class: A class is a group of objects which have common properties. It is a template or blueprint from which objects are created.
3+
Sub Class/Child Class: Subclass is a class which inherits the other class. It is also called a derived class, extended class, or child class.
4+
Super Class/Parent Class: Superclass is the class from where a subclass inherits the features. It is also called a base class or a parent class.
5+
Reusability: As the name specifies, reusability is a mechanism which facilitates you to reuse the fields and methods of the existing class when you create a new class. You can use the same fields and methods already defined in the previous class.
6+
# The syntax of Java Inheritance
7+
class Subclass-name extends Superclass-name
8+
{
9+
//methods and fields
10+
}
11+
The extends keyword indicates that you are making a new class that derives from an existing class. The meaning of "extends" is to increase the functionality.
12+
13+
# In the terminology of Java, a class which is inherited is called a parent or superclass, and the new class is called child or subclass.
14+
Java Inheritance Example
15+
# Inheritance in Java
16+
- As displayed in the above figure, Programmer is the subclass and Employee is the superclass. The relationship between the two classes is Programmer IS-A Employee. It means that Programmer is a type of Employee.
17+
class Employee{
18+
float salary=40000;
19+
}
20+
class Programmer extends Employee{
21+
int bonus=10000;
22+
public static void main(String args[]){
23+
Programmer p=new Programmer();
24+
System.out.println("Programmer salary is:"+p.salary);
25+
System.out.println("Bonus of Programmer is:"+p.bonus);
26+
27+
28+
![image](https://user-images.githubusercontent.com/100853056/193450818-6d6e463e-696a-407c-ad85-a3a9d120e38c.png)
29+
30+
}
31+
}

0 commit comments

Comments
 (0)