Skip to content

Commit

Permalink
just save
Browse files Browse the repository at this point in the history
  • Loading branch information
rakeshlinux committed Jan 21, 2021
1 parent 19eb48c commit 1ceb70c
Show file tree
Hide file tree
Showing 26 changed files with 332 additions and 41 deletions.
1 change: 1 addition & 0 deletions Networking/Check_site.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os

hostname ="https://binarynote.com"

for i in range(2, 255):
response = os.system("ping -4t " + hostname)
Expand Down
4 changes: 2 additions & 2 deletions Projects/Hangman_game.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
9# Hangman Games
# Hangman Games
# program by : rakesh kumar
# website : https://cbsetoday.com


import random as r

# steps to select a random word from sowpods.txt file
with open("sowpods.txt") as file:
with open("c:/python/projects/sowpods.txt") as file:
data = file.read().split()
number = r.randint(0, len(data))
word = data[number]
Expand Down
13 changes: 13 additions & 0 deletions Tkinter/bindFunctionEvent.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,20 @@ def printName(event):
print("hello my name is rakesh ")

button1= Button(root,text="Print my Name")
button2= Button(root,text="Print my Name-2")
button3= Button(root,text="Print my Name-3")
button4= Button(root,text="Print my Name-4")
button5= Button(root,text="Print my Name-5")

button1.bind('<Button-1>',printName)
button2.bind('<Button-2>',printName)
button3.bind('<Button-3>',printName)
button4.bind('<Button-4>',printName)
button5.bind('<Button-5>',printName)

button1.pack()
button2.pack()
button3.pack()
button4.pack()
button5.pack()
root.mainloop()
21 changes: 16 additions & 5 deletions Tkinter/messagebox.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
from tkinter import *
import tkinter.messagebox
import tkinter.simpledialog
root = Tk()

tkinter.messagebox.showinfo('Window Title','This is the message')
answer = tkinter.messagebox.askyesno('Question',"Are you sure to delete this record ?")
if answer ==True :
print("You selected to delete record")
"""
yesno = tkinter.messagebox.askyesno('Question',"Are you sure to delete this record ?")
tkinter.messagebox.askokcancel()
tkinter.messagebox.askquestion()
tkinter.messagebox.askretrycancel()
tkinter.messagebox.askyesnocancel()
root.mainloop()
if yesno ==True :
print("You selected to delete record")
"""

no = tkinter.simpledialog.askstring('List Input','Enter number ')
no = no.split()
print(no)

root.mainloop()
3 changes: 3 additions & 0 deletions Tkinter/tempCodeRunnerFile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
yesno = tkinter.messagebox.askyesno('Question',"Are you sure to delete this record ?")
if yesno ==True :
print("You selected to delete record")
4 changes: 2 additions & 2 deletions fileHandling/Find_lines_start_with_T.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
# made on : 07/07/2018

file = open(r"abcd.txt",'r')
count=0;
count=0
for line in file.readlines():
if line[0]=='T':
count+=1
file.close()
print("Total lines that start with alphabet 'T' :",count)
print("Total lines that start with alphabet 'T' :", count)
4 changes: 2 additions & 2 deletions fileHandling/file_read.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
file = open(r"abcd.txt",'r')
data1 = file.read()
file = open("demo.txt")
data1 = file.read() #
print(data1)
file.close()
15 changes: 8 additions & 7 deletions fileHandling/file_read_linewise.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
#made by : rakesh kumar
# made on : 07/07/2018

file = open(r"abcd.txt",'r')
count=0;
for line in file.readlines():
if "Project" in line.split():
count+=1
file.close()
print("Total 'Project' term available :",count)


file = open("abcd.txt",'r')
data = file.readlines()
for line in data:
print(data)

file.close()
120 changes: 120 additions & 0 deletions fileHandling/result12_2020.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
import csv
import re
import xlwt


def write2_cell(ws, row, roll, gender, name, marks):
ws.write(row, 0, roll)
ws.write(row, 1, name)
ws.write(row, 2, gender)

for values in marks.values():
if(values[0] == '301'):
ws.write(row, 3, values[1])
if(values[0] == '302'):
ws.write(row, 4, values[1])
if(values[0] == '041'):
ws.write(row, 5, values[1])
if(values[0] == '042'):
ws.write(row, 6, values[1])
if(values[0] == '043'):
ws.write(row, 7, values[1])
if(values[0] == '283'):
ws.write(row, 8, values[1])
if(values[0] == '265'):
ws.write(row, 9, values[1])
if(values[0] == '044'): # biology
ws.write(row, 10, values[1])
if(values[0] == '048'): # physical
ws.write(row, 11, values[1])
if(values[0] == '030'): # economics
ws.write(row, 12, values[1])
if(values[0] == '055'): # Accounts
ws.write(row, 13, values[1])
if(values[0] == '054'): # BST
ws.write(row, 14, values[1])
if(values[0] == '812'): # marketing
ws.write(row, 15, values[1])
if(values[0] == '028'): # Pol science
ws.write(row, 16, values[1])
if(values[0] == '034'): # music
ws.write(row, 17, values[1])
if(values[0] == '049'): # music
ws.write(row, 18, values[1])


file = open(r'C:\Users\rakesh\Desktop\z60074.txt', 'r')
rows = csv.reader(file)
wb = xlwt.Workbook()
ws = wb.add_sheet("result")
""" ws1 = wb.add_sheet("result1") """

st = xlwt.easyxf('font: bold yes;align: horiz centre , vert centre ,wrap yes')
ws.write(0, 0, "Roll No", st)
ws.write(0, 1, "Student Name", st)
ws.write(0, 2, "Gender", st)
ws.write(0, 3, "English", st)
ws.write(0, 4, "Hindi", st)
ws.write(0, 5, "Maths", st)
ws.write(0, 6, "Physics", st)
ws.write(0, 7, "Chemistry", st)
ws.write(0, 8, "CS", st)
ws.write(0, 9, "IP", st)
ws.write(0, 10, "Bio", st)
ws.write(0, 11, "Physical", st)
ws.write(0, 12, "Eco", st)
ws.write(0, 13, "Account", st)
ws.write(0, 14, "Bst", st)
ws.write(0, 15, "marketing", st)
ws.write(0, 16, "Pol Sci", st)
ws.write(0, 17, "Music", st)
ws.write(0, 18, "ART", st)
ws.write(0, 19, "result", st)

n = 1
count = 0
for row in rows:
if(len(row) <= 0):
continue
else:
count += 1
line1 = ''.join(row)
line2 = re.sub(' +', ' ', line1)
line3 = line2.split(' ')
if(count % 2 == 1):
sub = {}
roll = line3[0]
gender = line3[1]
name = line3[2] + " " + line3[3]
number = False
try:
sub[1] = ['' . join(line3[4])]
sub[2] = ['' . join(line3[5])]
sub[3] = ['' . join(line3[6])]
sub[4] = ['' . join(line3[7])]
sub[5] = ['' . join(line3[8])]
if(line3[9][0].isdigit()):
sub[6] = ['' . join(line3[9])]
number = True
except:
continue

else:
try:
sub[1].append(line3[1])
sub[2].append(line3[3])
sub[3].append(line3[5])
sub[4].append(line3[7])
sub[5].append(line3[9])
if number:
sub[6].append(line3[11])
except:
print(roll, name, line3)
continue

if(count % 2 == 0):
write2_cell(ws, n, roll, gender, name, sub)
n = n+1

wb.save(r"C:\Users\rakesh\Desktop\result123.xls")
print('File Generated.....Please check your file')
2 changes: 1 addition & 1 deletion fileHandling/tempCodeRunnerFile.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
print(x)
print("Total lines that start with alphabet 'T' :",count)
7 changes: 7 additions & 0 deletions numpy/create_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import numpy as np
a = np.array([1, 2, 3, 4, 5, 5, 6, 7, 8])
print(a[2])
print(a[0])
print(a[:3]) # slicing example
print(a[2:6])
print(a[2::2])
5 changes: 4 additions & 1 deletion pandas/df_access_column.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@
]
heading = ["admno", "name", "marks", "fees"]
df = pd.DataFrame(data, columns=heading)
print(df[['name','fees']]
print(df['marks']+10)
print(df.marks>75)
print(df['marks'][df.marks>75])

7 changes: 6 additions & 1 deletion pandas/df_access_rows.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,9 @@
]
heading = ["admno", "name", "marks", "fees"]
df = pd.DataFrame(data, columns=heading)
print(df[1])
print(df.head())
print(df.head(2))
print(df.tail())
print(df.tail(3))
print(df[1:3])

17 changes: 17 additions & 0 deletions pandas/df_append.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# create dataframe using list of Tuple
import pandas as pd
data = [
(1101, 'rakesh', 56, 5656.56),
(1203, 'jatin jain', 56, 5666.56),
(1205, 'pushkar', 78, 5666.56),
(1206, 'arushi', 98, 4564.34),
(1208, 'mannat bhatia', 89, 4500),
(1234, 'unnati', 67, 3500.56),
(1245, 'Nikunj Tyagi', 68, 4500),
(5755, 'vishank', 89, 5000)
]
heading = ["admno", "name", "marks", "fees"]
df = pd.DataFrame(data, columns=heading)
df = df.append({'admno': 9999, 'name': 'ramji', 'marks': 99,
'fees': 9999.99}, ignore_index=True)
print(df)
26 changes: 16 additions & 10 deletions pandas/df_creation2.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
# create dataframe using list of Python Dictionary
# create dataframe using list of Tuple
import pandas as pd
df = pd.DataFrame(
[
{'admno': 1101,'name': 'rakesh','marks' :56, 'fees': 5656.56},
{'admno': 1203, 'name':'jatin jain','marks':56, 'fees': 5666.56},
{'admno': 1205, 'name':'pushkar','marks':78, 'fees': 5666.56},
{'admno': 1206, 'name':'arushi','marks':98, 'fees': 4564.34},
{'admno': 1208, 'name':'mannat bhatia','marks':89, 'fees': 4500}
]
)
data = [
(1101, 'rakesh', 56, 5656.56),
(1203, 'jatin jain', 56, 5666.56),
(1205, 'pushkar', 78, 5666.56),
(1206, 'arushi', 98, 4564.34),
(1208, 'mannat bhatia', 89, 4500),
(1234, 'unnati', 67, 3500.56),
(1245, 'Nikunj Tyagi', 68, 4500),
(5755, 'vishank', 89, 5000)
]
heading = ["admno", "name", "marks", "fees"]
df = pd.DataFrame(data, columns=heading)
print(df)
df = df.append({'admno': 9999, 'name': 'ramji', 'marks': 99,
'fees': 9999.99,'grade':'a'}, ignore_index=True)
print(df)
20 changes: 20 additions & 0 deletions pandas/df_delete_row_col.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import pandas as pd
data = [
(1101, 'rakesh', 56, 5656.56),
(1203, 'jatin jain', 56, 5666.56),
(1205, 'pushkar', 78, 5666.56),
(1206, 'arushi', 98, 4564.34),
(1208, 'mannat bhatia', 89, 4500),
(1234, 'unnati', 67, 3500.56),
(1245, 'Nikunj Tyagi', 68, 4500),
(5755, 'vishank', 89, 5000)
]
heading = ["admno", "name", "marks", "fees"]
df = pd.DataFrame(data, columns=heading)
#df = df.drop('fees',axis=1)
#df = df.drop(columns=['marks','fees'])
#df = df.drop(['marks','fees'],axis=1)
#df.drop('fees',axis=1,inplace=True)
df =df.drop([1,2,3],axis=0) # delete rows
print(df)

20 changes: 20 additions & 0 deletions pandas/df_index_label.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import pandas as pd
data = [
(1101, 'rakesh', 56, 5656.56),
(1203, 'jatin jain', 56, 5666.56),
(1205, 'pushkar', 78, 5666.56),
(1206, 'arushi', 98, 4564.34),
]
data1 = [

(1208, 'mannat bhatia', 89, 4500),
(1234, 'unnati', 67, 3500.56),
(1245, 'Nikunj Tyagi', 68, 4500),
(5755, 'vishank', 89, 5000)
]
heading = ["admno", "name", "marks", "fees"]
df = pd.DataFrame(data, columns=heading)
df1 = pd.DataFrame(data1, columns=heading)

df2 = df.append(df1) # concatenation
print(df2)
14 changes: 14 additions & 0 deletions pandas/df_merge.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import pandas as pd

right = pd.DataFrame({'admno': ['101', '102', '103', '104'],
'Game': ['Cricket', 'BasketBall', 'Badminton', 'Swimming'],
'Fee': [1200, 750, 800, 1500]})
print(right['Fee'].count())
print(right['Fee'].max())
print(right['Fee'].min())
print(right['Fee'].sum())
print(right['Fee'].mean()) #average
print(right['Fee'].median()) #average
print(right['Fee'].std()) #standard daviation
print(right['Fee'].var()) #standard variance
print(right['Fee'].quantile()) # quantile of the values
18 changes: 18 additions & 0 deletions pandas/df_rename_Columns.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import pandas as pd
data = [
(1101, 'rakesh', 56, 5656.56),
(1203, 'jatin jain', 56, 5666.56),
(1205, 'pushkar', 78, 5666.56),
(1206, 'arushi', 98, 4564.34),
(1208, 'mannat bhatia', 89, 4500),
(1234, 'unnati', 67, 3500.56),
(1245, 'Nikunj Tyagi', 68, 4500),
(5755, 'vishank', 89, 5000)
]
heading = ["admno", "name", "marks", "fees"]
df = pd.DataFrame(data, columns=heading)
#df =df.rename(columns={"fees":'Annual Fees'})
#df = df.rename({'fees':'Yealy fees'},axis=1)
df = df.rename({'fees':'yealy fees', 'marks':'ut-2'}, axis=1)
#df.rename({'fees': 'yealy fees', 'marks': 'ut-2'}, axis=1,inplace=True)
print(df)
Loading

0 comments on commit 1ceb70c

Please sign in to comment.