Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
chandu1811 authored Jan 24, 2021
1 parent daa9f27 commit 47b04ee
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions random_methods.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import random
# from numpy import random
# def guess(x):
# random_number=random.randint(0, x)
# print(random_number)
# guess=0
# while guess !=random_number:
# guess=int(input(f"guess a no in between 1 and{x}:"))
# if( guess > random_number):
# print(f"Enter a no less than {guess} ")
# elif( guess < random_number):
# print(f"Enter a no greater than {guess} ")
# print(f"U hit the jack pot,random_number generated by system is {random_number} ,random no u gussed is {guess},both are equal")

#guess(10)
def computer_guess(x):
low=0
high=x
feedback=''
while feedback!="c" :
if low!=high:
guess = random.randint(low,high)
else:
guess=low #since low and both are equal guess could be equal to high
feedback=input(f"Is {guess} is too high(h),or too low(l) or correct(c):")
if (feedback=='h'):
high=guess-1
elif(feedback=='l'):
low=guess+1
print(f"U hit the jack pot, ,random no system gussed is {guess} corerct")

computer_guess(10)






# x = random.choice([3, 5, 7, 9], p=[0.1, 0.3, 0.6, 0.0], size=(100))
# '''Generate a 1-D array containing 100 values, where each value has to be 3, 5, 7 or 9.
#
# The probability for the value to be 3 is set to be 0.1
#
# The probability for the value to be 5 is set to be 0.3
#
# The probability for the value to be 7 is set to be 0.6
#
# The probability for the value to be 9 is set to be 0'''
# x = random.rand() #Generate a random float from 0 to 1:
# x=random.randint(100, size=(5))#Generate a 1-D array containing 5 random integers from 0 to 100
# x = random.randint(100, size=(3, 5))#Generate a 2-D array with 3 rows, each row containing 5 random integers from 0 to 100:
# x = random.rand(5)#Generate a 1-D array containing 5 random floats:
# x = random.rand(3, 5)#Generate a 2-D array with 3 rows, each row containing 5 random numbers
# x = random.choice([3, 5, 7, 9])#Return one of the values in an array
# x = random.choice([3, 5, 7, 9], size=(3, 5))#Generate a 2-D array that consists of the values in the array parameter (3, 5, 7, and 9):
# import numpy as np
#
# arr = np.array([1, 2, 3, 4, 5])#o/p=[2 4 5 3 1]
# arr=[1,2,3,4,5]#o/p =[2,1,3,5,4]
#
# random.shuffle(arr)#Rando mly shuffle elements of following array ,The shuffle() method makes changes to the original array.
#
# print(random.permutation(arr)) #The permutation() method returns a re-arranged array (and leaves the original array un-changed).

0 comments on commit 47b04ee

Please sign in to comment.