Skip to content

Commit 64f4431

Browse files
authored
Add files via upload
0 parents  commit 64f4431

3 files changed

+79
-0
lines changed
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import numpy as np
2+
import pandas as pd
3+
from sklearn.neighbors import KNeighborsClassifier
4+
from sklearn import tree
5+
myInp = pd.DataFrame()
6+
size= pd.DataFrame()
7+
type_= pd.DataFrame()
8+
small = 0
9+
medium = 1
10+
large = 2
11+
size = np.array([small, small, small, medium, medium, medium, large, large, large])
12+
type_['Height (in Cms)']= [150, 155, 160, 165, 170, 175, 180, 185, 190]
13+
type_['Weight (in Kgs)']= [65, 70, 75, 80, 85, 90, 95, 100, 105]
14+
print("\n",type_,"\n\n")
15+
types= np.array(type_)
16+
classifier = KNeighborsClassifier(5)
17+
classifier = classifier.fit(types, size)
18+
h=float(input("Enter Height (in Cms): "))
19+
w=float(input("Enter Weight (in Kgs): "))
20+
myInp['Height (in Cms)']= [h]
21+
myInp['Weight (in Kgs)']= [w]
22+
myInp = np.array(myInp)
23+
prediction = classifier.predict(myInp)
24+
print("\nPredicted Shirt Size:")
25+
if prediction == 0:
26+
print('Small!')
27+
elif prediction == 1:
28+
print('Medium')
29+
elif prediction == 2:
30+
print('Large')

Guess Number Game.py

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import time
2+
import os
3+
import random
4+
num = random.randint (1,10)
5+
life = 5
6+
flag = 0
7+
8+
print("\n\t*** GUESS THE NUMBER GAME ***\n")
9+
player = input("Welcome player!\nEnter your name: \n")
10+
11+
print ("\t\tWelcome ",player,"!")
12+
13+
while (life != 0):
14+
print("Life Remaining: ",life)
15+
print("Guess a number between 1 to 10: ")
16+
inp = int(input())
17+
if inp != num:
18+
if inp > num:
19+
life-=1
20+
print("Your Guess is High,\nTry again! \n\t Remaining life: ",life)
21+
else:
22+
life-=1
23+
print("Your Guess is Low,\nTry again! \n\t Remaining life: ",life)
24+
elif inp == num:
25+
print ("Correct! You win.")
26+
flag = 1
27+
break
28+
if flag != 1:
29+
print ("\nSorry, you ran out of lives!")
30+
print ("The correct Answer is: ",num)
31+
32+
print("\n\n\t* SCORE CARD *\n")
33+
print("Player's Name: ", player, "\nLife Remaining: ",life)

Word,Sentence_Tokenizer.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from nltk import word_tokenize, sent_tokenize
2+
selection = int(input("1. Word Tokenizer\n2. Sentence Tokenizer\nSelect..?? "))
3+
4+
if(selection == 1):
5+
para = input("Enter a Sentence: ")
6+
print("Before Replacing:\n",para)
7+
result = word_tokenize(para)
8+
print("\nTokenize Words:\n"*result, sep=", ")
9+
10+
11+
if(selection == 2):
12+
para = input("Enter a Sentence: ")
13+
print("Before Replacing:\n",para)
14+
result = sent_tokenize(para)
15+
print("\nTokenize Sentence:\n"*result, sep=", ")
16+

0 commit comments

Comments
 (0)