Skip to content

added some projects #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions calculator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# python to use calculator
while True:
print("enter the operation you want to perform.\npress + for addition\npress - for subtraction\npress * for multilication\npress / for division\npress ^ for powering")
comp1 = input()
print("Enter first value")
val1 = int(input())
print("Enter second value")
val2 = int(input())
if comp1 == "+":
print("your result is")
print(val1 + val2 )
elif comp1 =="-":
print("your result is")
print(val1 - val2 )
elif comp1 == "*":
print("your result is")
print(val1 * val2 )
elif comp1 == "/":
print("your result is")
print(val1/val2 )
elif comp1 == "^":
print("your result is")
print(val1 ** val2 )

else:
print("enter correct operation")
print("thanks for using our calculator")
24 changes: 24 additions & 0 deletions guess-number.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# guess a number and play a game
import random
n = random.randrange(100)
number_of_guesses=1
print("Number of guesses is limited to only 6 times: ")
print("guess the number below 100")
while (number_of_guesses<=6):
guess_number = int(input("Guess the number :\n"))
if guess_number<n:
print("you enter less number please enter greater number.")
elif guess_number>n:
print("you enter greater number please enter smaller number.")
else:
print("Game Over")
print("you won")
print("no of guesses you took to finish the game is", number_of_guesses)
break
print(6-number_of_guesses,"no. of guesses left")
number_of_guesses = number_of_guesses + 1

if(number_of_guesses>6):
print("the number is", n,)
print("Game Over")
print("you Lose")
88 changes: 88 additions & 0 deletions snake-water-gun-game.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Snake water gun
#
# Snake Water Gun Game in Python
# The snake drinks the water, the gun shoots the snake, and gun has no effect on water.
#

import random
lst = ['s','w','g']
print("how many chance you wants to play:")

chance = int(input())
no_of_chance = 0
computer_point = 0
human_point = 0

print(" \t \t \t \t Snake,Water,Gun Game\n \n")


# making the game in while
while no_of_chance < chance:
print("s for snake \nw for water \ng for gun \n")
_input = input('Snake,Water,Gun:')
_random = random.choice(lst)

if _input == _random:
print("tie, both enter same key.")
print("both get 0 point")

# if user enter s
elif _input == "s" and _random == "g":
computer_point = computer_point + 1
print(f"your guess is {_input} and computer guess is {_random} \n")
print("computer wins 1 point \n")
print(f"computer_point is {computer_point} and your point is {human_point} \n ")

elif _input == "s" and _random == "w":
human_point = human_point + 1
print(f"your guess is {_input} and computer guess is {_random} \n")
print("You wins 1 point \n")
print(f"computer_point is {computer_point} and your point is {human_point} \n")

# if user enter w
elif _input == "w" and _random == "s":
computer_point = computer_point + 1
print(f"your guess is {_input} and computer guess is {_random} \n")
print("computer wins 1 point \n")
print(f"computer_point is {computer_point} and your point is {human_point} \n ")

elif _input == "w" and _random == "g":
human_point = human_point + 1
print(f"your guess is {_input} and computer guess is {_random} \n")
print("You wins 1 point \n")
print(f"computer_point is {computer_point} and your point is {human_point} \n")

# if user enter g

elif _input == "g" and _random == "s":
human_point = human_point + 1
print(f"your guess is {_input} and computer guess is {_random} \n")
print("You wins 1 point \n")
print(f"computer_point is {computer_point} and your point is {human_point} \n")


elif _input == "g" and _random == "w":
computer_point = computer_point + 1
print(f"your guess is {_input} and computer guess is {_random} \n")
print("computer wins 1 point \n")
print(f"computer_point is {computer_point} and your point is {human_point} \n ")

else:
print("you enter wrong key \n")

no_of_chance = no_of_chance + 1
print(f"{chance - no_of_chance} is left out of {chance} \n")

print("Game over")

if computer_point==human_point:
print("Tie")

elif computer_point > human_point:
print("Computer wins and you loose")

else:
print("you win and computer loose")

print(f"your point is {human_point} and computer point is {computer_point}")