Skip to content
Merged
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
60 changes: 60 additions & 0 deletions bullcowgame.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import random as rand
import emoji as emo

emo_cow = emo.emojize(emo.demojize('🐄'))
emo_bull = emo.emojize(emo.demojize('🐂'))
print('\n\033[1m' + ' --: Welcome to Cows (', emo_cow, ') and Bulls (', emo_bull, ') game :--' + '\033[0m')

rand_num = rand.randrange(1000, 9999, 1)
rand_num_list = list(str(rand_num).replace("", ""))

trial = 0
error_dig = 0
error_let = 0

while True:
user_num = input('Guess the 4 digit number : ')
user_num_list = list(str(user_num).replace("", ""))

def if_contain_letter(x):
for ele in x:
if ele.isalpha():
con = True
else:
con = False
return con

if len(user_num_list) != 4:
print(' DIGIT no. Error : \n Your entered number does not contain 4 digits')
error_dig += 1
if error_dig > 3:
print('*) WARNING !! What are you doing ? Too much errors ! Be careful !')

if if_contain_letter(user_num_list):
print('DIGIT type Error :\n inputted number contains letter ')
error_let += 1

if not if_contain_letter(user_num_list):
if len(user_num_list) == 4:
a = []
b = []

for i in range(len(user_num_list)):
if rand_num_list[i] == user_num_list[i]:
a.append(user_num_list[i])

if rand_num_list[i] != user_num_list[i]:
if user_num_list[i] in rand_num_list:
b.append(user_num_list[i])

num_of_cow = len(a)
num_of_bull = len(b)
print(num_of_cow, ' cow (', emo_cow, ')')
print(num_of_bull, ' bull (', emo_bull, ')')
trial += 1

if str(user_num) == str(rand_num):
print('\n\033[1m' + '### Congratulations! , Well played ###' + '\033[0m')
print('Trials = ', trial)
print('Errors = ', error_dig + error_let)
break
29 changes: 29 additions & 0 deletions c.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
def isVowel(c):
return (c == 'A' or c == 'E' or c == 'I' or
c == 'O' or c == 'U' or c == 'a' or
c == 'e' or c == 'i' or c == 'o' or
c == 'u');


def pigLatin(s):


length = len(s);
index = -1;
for i in range(length):
if (isVowel(s[i])):
index = i;
break;


if (index == -1):
return "-1";


return s[index:] + s[0:index] + "ay";

str = pigLatin("graphic");
if (str == "-1"):
print("No vowels found. Pig Latin not possible");
else:
print(str);
32 changes: 32 additions & 0 deletions calc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
opt = int(input("enter the option you want to perform : 1.addition 2.multiplication"))
if opt==1:
s=0
n=int(input("enter how many times you want to sum up :"))
print("enter",n,"numbers : ")
for i in range(0,n):
a=int(input("enter the number"))
s=s+a
print("the result is : ",s)

elif opt==2:
m=1
n1=int(input("how many times you want to multiply : "))
print("enter",n1,"numbers :")
for i in range(0,n1):

b=int(input("enter the number :"))
m=m*b
print("the result is :",m)
elif opt==3:
n2=int(input("how many times you want to substract :"))
print("enter", n2 ,"numbers: ")
a=int(input("enter the 1st number"))
b=int(input("enter the 2nd number"))
#c=(a-b)
d=(n2-2)
print("you have to enter ", d, "numbers more")
for i in range(0,d):
c=(a-b)
e=int(input("enter the number : "))
f=c-e
print("the result is :", f)
11 changes: 11 additions & 0 deletions checkconnection.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from urllib.request import urlopen ##importing necessary library this library contains all the modules for url status checking

name=input("enter your name:") ## entering the user name

def status(): ## defining the function to check the status
try:
urlopen("https://www.youtube.com/",timeout=1) ## if the url is openable then user is connected
print(name,"you are connected to internet")
except:
print(name,"you are not connected to internet") ## otherwise not connected
status() ## calling the status function
38 changes: 38 additions & 0 deletions client-chat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import socket
import select
import sys

server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
if len(sys.argv) != 3:
print ("Correct usage: script, IP address, port number")
exit()
IP_address = str(sys.argv[1])
Port = int(sys.argv[2])
server.connect((IP_address, Port))

while True:

# maintains a list of possible input streams
sockets_list = [sys.stdin, server]

""" There are two possible input situations. Either the
user wants to give manual input to send to other people,
or the server is sending a message to be printed on the
screen. Select returns from sockets_list, the stream that
is reader for input. So for example, if the server wants
to send a message, then the if condition will hold true
below.If the user wants to send a message, the else
condition will evaluate as true"""
read_sockets,write_socket, error_socket = select.select(sockets_list,[],[])

for socks in read_sockets:
if socks == server:
message = socks.recv(2048)
print (message)
else:
message = sys.stdin.readline()
server.send(message)
sys.stdout.write("<You>")
sys.stdout.write(message)
sys.stdout.flush()
server.close()
3 changes: 3 additions & 0 deletions multiplication.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
n=int(input("Multiplication Table of:"))
for i in range(1,10+1):
print("{} X {} = {}".format(i,n,i*n))
5 changes: 5 additions & 0 deletions sum of oddno.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
n=int(input("Enter n value:"))
sum=0
for i in range(1,n+1,2):
sum+=i
print(sum)