From 5b35dfa88142f41dfaecc48e99600a917ee035c4 Mon Sep 17 00:00:00 2001
From: slayer005 <148843476+slayer005@users.noreply.github.com>
Date: Tue, 24 Oct 2023 11:34:51 +0530
Subject: [PATCH] Create Number guessing game in Python 3 and C

Create Number guessing game in Python 3 and C
---
 Number guessing game in Python 3 and C | 44 ++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
 create mode 100644 Number guessing game in Python 3 and C

diff --git a/Number guessing game in Python 3 and C b/Number guessing game in Python 3 and C
new file mode 100644
index 00000000..4483cc1a
--- /dev/null
+++ b/Number guessing game in Python 3 and C	
@@ -0,0 +1,44 @@
+import random
+import math
+# Taking Inputs
+lower = int(input("Enter Lower bound:- "))
+
+# Taking Inputs
+upper = int(input("Enter Upper bound:- "))
+
+# generating random number between
+# the lower and upper
+x = random.randint(lower, upper)
+print("\n\tYou've only ", 
+	round(math.log(upper - lower + 1, 2)),
+	" chances to guess the integer!\n")
+
+# Initializing the number of guesses.
+count = 0
+
+# for calculation of minimum number of
+# guesses depends upon range
+while count < math.log(upper - lower + 1, 2):
+	count += 1
+
+	# taking guessing number as input
+	guess = int(input("Guess a number:- "))
+
+	# Condition testing
+	if x == guess:
+		print("Congratulations you did it in ",
+			count, " try")
+		# Once guessed, loop will break
+		break
+	elif x > guess:
+		print("You guessed too small!")
+	elif x < guess:
+		print("You Guessed too high!")
+
+# If Guessing is more than required guesses,
+# shows this output.
+if count >= math.log(upper - lower + 1, 2):
+	print("\nThe number is %d" % x)
+	print("\tBetter Luck Next time!")
+
+# Better to use This source Code on pycharm!