Monday 4 October 2021

Python Project [ Digital Clock]


This script create a digital clock as per the system's current time.

Input:



import tkinter as tk
from time import strftime
def light_theme():
frame = tk.Frame(root, bg="white")
frame.place(relx=0.1, rely=0.1, relwidth=0.8, relheight=0.8)
lbl_1 = tk.Label(frame, font=('calibri', 40, 'bold'),
background='White', foreground='black')
lbl_1.pack(anchor="s")
def time():
string = strftime('%I:%M:%S %p')
lbl_1.config(text=string)
lbl_1.after(1000, time)
time()
def dark_theme():
frame = tk.Frame(root, bg="#22478a")
frame.place(relx=0.1, rely=0.1, relwidth=0.8, relheight=0.8)
lbl_2 = tk.Label(frame, font=('calibri', 40, 'bold'),
background='#22478a', foreground='black')
lbl_2.pack(anchor="s")
def time():
string = strftime('%I:%M:%S %p')
lbl_2.config(text=string)
lbl_2.after(1000, time)
time()
root = tk.Tk()
root.title("Digital-Clock")
canvas = tk.Canvas(root, height=140, width=400)
canvas.pack()
frame = tk.Frame(root, bg='#22478a')
frame.place(relx=0.1, rely=0.1, relwidth=0.8, relheight=0.8)
lbl = tk.Label(frame, font=('calibri', 40, 'bold'),
background='#22478a', foreground='black')
lbl.pack(anchor="s")
def time():
string = strftime('%I:%M:%S %p')
lbl.config(text=string)
lbl.after(1000, time)
time()
menubar = tk.Menu(root)
theme_menu = tk.Menu(menubar, tearoff=0)
theme_menu.add_command(label="Light", command=light_theme)
theme_menu.add_command(label="Dark", command=dark_theme)
menubar.add_cascade(label="Theme", menu=theme_menu)
root.config(menu=menubar)
root.mainloop()

Output :







Join us: https://t.me/jupyter_python

Python Project [An application to save any random article from Wikipedia to a text file].


An application to save any random article from Wikipedia to a text file.



Output of the project






Source Code: 


from bs4 import BeautifulSoup
import requests

# Trying to open a random wikipedia article
# Special:Random opens random articles
res = requests.get("https://en.wikipedia.org/wiki/Special:Random")
res.raise_for_status()

# pip install htmlparser
wiki = BeautifulSoup(res.text, "html.parser")

r = open("random_wiki.txt", "w+", encoding='utf-8')

# Adding the heading to the text file
heading = wiki.find("h1").text

r.write(heading + "\n")
for i in wiki.select("p"):
    # Optional Printing of text
    # print(i.getText())
    r.write(i.getText())

r.close()
print("File Saved as random_wiki.txt")










Join us: https://t.me/jupyter_python

Program that converts arrays into a list, loops through the list to form a string using the chr() function




Input :


#Program that converts arrays into a list, loops through the list to form a string using the chr() function
#clcoding.com
import numpy as np
def ord_to_character(words = ""):
    
    x = np.array([112,121,134,123,32,96,34,56,67,111,98,97,119,105,113])
    
    y = np.array([78,90,104,123,132,53,34,56,97,116,98,27,119,77,117,12])
    
    z = np.array([111,112,134,123,21,32,108,106,89,70,80,103,103,120,121])
    
    letters = x.tolist() + y.tolist()  + z.tolist()
    
    for letter in letters:
        words += chr(letter)
        
        
    return words 


sentence = ord_to_character()
print(sentence)
    
Output :


py†{ `"8CobawiqNZh{„5"8atbwMuop†{ ljYFPggxy



Join us: https://t.me/jupyter_python

Plotting a colourful Scatter Plot using Matplotlib








from matplotlib import pyplot as plt

x = [10,20,30,40,50]
y = [200,300,100,400,500]
colors=[70,20,80,10,50]
sizes=[100,50,300,250,150]

plt.scatter(x,y,c=colors,s=sizes,cmap="Accent",alpha=1.0)
plt.colorbar()
plt.show





Join us: https://t.me/jupyter_python

Plotting Histogram using Pyplot







from matplotlib import pyplot as plt 

marks=[90,50,40,60,55,44,30,10,34,84]
grade_intervals=[0,35,70,100]
plt.title("Student Grades")
plt.hist(marks,grade_intervals,histtype="bar",rwidth=0.5,facecolor="blue")
plt.xticks([0,35,70,100])
plt.xlabel("Percentage")
plt.ylabel("No. of Students")
plt.show()


Join us: https://t.me/jupyter_python

Plotting Colourful Pie Chart In MatPlotlib




from matplotlib import pyplot as plt 

student_performance = ["Excellent","Good","Average","Poor"]
student_values = [15,25,12,8]
plt.figure(figsize=(7,10))
plt.pie(student_values,labels=student_performance,startangle=90,
        explode=[0.2,0,0,0],shadow=True,colors=["black","blue","yellow","red"],autopct="%2.1f%%")


plt.legend(title="Perfomances")
plt.show




Wednesday 23 June 2021

HANDLING MISSING DATA (FillNa) IN PANDAS



Firstly, we are importing an excel sheet as a DataFrame,
 

import pandas as pd
ds = pd.read_excel("C:\\Users\\mahes\\OneDrive\\Documents\\Students.xlsx")
dt = pd.DataFrame(ds)
print(dt)








Now, Let's perform some operations related to FillNa()











Join us: https://t.me/jupyter_python

HANDLING MISSING DATA (dropna) IN PANDAS


Firstly, we are importing an excel sheet as a DataFrame,
 

import pandas as pd
ds = pd.read_excel("C:\\Users\\mahes\\OneDrive\\Documents\\Students.xlsx")
dt = pd.DataFrame(ds)
print(dt)






Now, Let's perform some operations related to DROPNA


















Join us: https://t.me/jupyter_python

ILOC[ ] IN PANDAS - PYTHON

Firstly, we are importing an excel sheet as a DataFrame,
 
import pandas as pd

ds = pd.read_excel("C:\\Users\\mahes\\OneDrive\\Documents\\Students.xlsx")

dt = pd.DataFrame(ds)






Now, Let's perform some operations related to ILOC 












Join us: https://t.me/jupyter_python

LOC[ ] IN PANDAS - PYTHON



LOC[ ] IN PANDAS

Firstly, we are importing an excel sheet as a DataFrame,
 
import pandas as pd

ds = pd.read_excel("C:\\Users\\mahes\\OneDrive\\Documents\\Students.xlsx")

dt = pd.DataFrame(ds)







Now, Let's perform some operations related to LOC and ILOC 














Join us: https://t.me/jupyter_python

Tuesday 22 June 2021

EXPORT DATAFRAME TO EXCEL, CSV & TEXT FILE IN PANDAS || SAVE DATAFRAME IN PANDAS

EXPORT DATAFRAME TO EXCEL, CSV & TEXT FILE IN PANDAS 

Firstly, we are importing an excel sheet as a DataFrame,
 
import pandas as pd

st = pd.read_excel("C:\\Users\\mahes\\OneDrive\\Documents\\Students.xlsx")

sd = pd.DataFrame(st)

print(st)



Making some changes in the dataframe


st['Total']=st['Hindi']+st['English'] +st['Science'] +st['History']+st['Mathematics']






Now, exporting the DataFrame as Excel, CSV and Text File


sd.to_excel("C:\\Users\\mahes\\OneDrive\\Desktop\\StudentsNew.xlsx")

sd.to_csv("C:\\Users\\mahes\\OneDrive\\Desktop\\StudentsNew.csv")

sd.to_csv("C:\\Users\\mahes\\OneDrive\\Desktop\\StudentsNew.txt" ,sep = "\t")





As you can see we have created three new files.






Join us: https://t.me/jupyter_python

SORTING DATAFRAME (BY COLUMN) IN PANDAS (Part-2) - PYTHON PROGRAMMING


#SORTING DATAFRAME (BY COLUMN) IN PANDAS (Part-2) - PYTHON PROGRAMMING

Listing Two Rows


df[['Name','Total_Marks']]





df = df.drop(columns = "Total_Marks")
print(df)









Join us: https://t.me/jupyter_python 

MANIPULATING DATAFRAME IN PANDAS (ADD COLUMN , DROP COLUMN) || DATAFRAME MANIPULATIONS


import pandas as pd 
dt = pd.read_excel("C:\\Users\\mahes\\OneDrive\\Documents\\Students.xlsx")
df = pd.DataFrame(dt)
print(df)




df['Total_Marks'] = 0
print(df)




df['Total_Marks'] = df['Hindi']+df['English']
df







Join us: https://t.me/jupyter_python

SORTING DATAFRAME (BY COLUMN) IN PANDAS - PYTHON PROGRAMMING

#SORTING DATAFRAME (BY COLUMN) IN PANDAS 


#clcoding

import pandas as pd

dt = pd.read_excel("FILE_NAME")

print(dt)

df = pd.DataFrame(dt)

df.sort_values("MAXMTEMPERATURE", ascending = False)










Join us: https://t.me/jupyter_python 

Monday 21 June 2021

How do you reverse the string without take another string?



#How do you reverse the string without take another string?
#clcoding
s = 'hello'
n = -1
for x in s:
    n += 1
while n >= 0:
    print(s[n], end = '')
    n -= 1








Join us: https://t.me/jupyter_python

Sunday 20 June 2021

Popular Posts

Categories

AI (31) Android (24) AngularJS (1) Assembly Language (2) aws (17) Azure (7) BI (10) book (4) Books (146) C (77) C# (12) C++ (82) Course (67) Coursera (198) Cybersecurity (24) data management (11) Data Science (106) Data Strucures (8) Deep Learning (13) Django (14) Downloads (3) edx (2) Engineering (14) Excel (13) Factorial (1) Finance (6) flask (3) flutter (1) FPL (17) Google (20) Hadoop (3) HTML&CSS (47) IBM (25) IoT (1) IS (25) Java (93) Leet Code (4) Machine Learning (46) Meta (18) MICHIGAN (5) microsoft (4) Nvidia (1) Pandas (3) PHP (20) Projects (29) Python (882) Python Coding Challenge (281) Questions (2) R (70) React (6) Scripting (1) security (3) Selenium Webdriver (2) Software (17) SQL (42) UX Research (1) web application (8)

Followers

Person climbing a staircase. Learn Data Science from Scratch: online program with 21 courses