#Guess the output in this case?
a=(1 << 53)+1
print(a+1.0 > a)
#???
Python Coding September 10, 2022 Python No comments
Python Coding September 10, 2022 Python No comments
import pandas as pd
import csv,json
data=pd.read_csv("Instagram.csv")
print(data)
print("Converted JSON file below :")
print (json.dumps(list(csv.reader(open('Instagram.csv')))))
#clcoding.com
Impressions Home Hashtags Explore Other Saves
0 3920 2586 1028 619 56 98
1 5394 2727 1838 1174 78 194
2 4021 2085 1188 0 533 41
3 4528 2700 621 932 73 172
Converted JSON file below :
[["Impressions", "Home", "Hashtags", "Explore", "Other", "Saves"], ["3920", "2586", "1028", "619", "56", "98"], ["5394", "2727", "1838", "1174", "78", "194"], ["4021", "2085", "1188", "0", "533", "41"], ["4528", "2700", "621", "932", "73", "172"]]
Python Coding September 10, 2022 Python No comments
#import the library pyautogui
import pyautogui
#imports the time library
import time
#run the next lines of code while the state is set as “True”
while True:
#move your cursor 10 pixels
pyautogui.moveRel(0, 10)
#pauses your code from running for 2 seconds
time.sleep(2)
#clcoding.com
Python Coding September 10, 2022 Python No comments
#reading an Image
from PIL import Image
Image.open("wolf.png")
import pywhatkit
pywhatkit.image_to_ascii_art('wolf.png','MyArt')
#reading text file
read_file= open("MyArt.txt","r")
print(read_file.read()) #clcoding.com
..::.:::.:::.:::.::..::.:::.:::.:::.::..::.:::.:::.:::.::..::..::.:::.:::.:::.:: ::.:::.:::.:::.::.:::.:::.:::.:::.:::.::::::.:::.:::.::..::..::.:::.:::.:::.:::. .:::.:::.:::.:::$#S#*::.:::.:::.:::.::::::.:::.:::.::.:$SS@*:.:::.:::.:::.:::.:: ::.:::.:::.::.!#**#S*@:...:::.:::.:::.::.:::.:::.::.:*#**#**$::.:::.:::.:::.:::. .:::.:::.:::.:#**$*%S*S&%!:..::.::..::.:::..::..:.:%#**S@*$**$.::.:::.:::.:::.:: ::.:::.:::.::$**@***&##***S@*..:..!::::#@.:!..:!$&**S##&%**&**!.:::.:::.:::.:::. ::::.:::.::..#**%***%##&&#S**#**$@SSSS***#S#*%S***#&&#&****%**%::.:::.:::.:::.:: ::::::.::!@&&**S***%%*%@##&&#******S##SS$#*****#@&#&@%*%%**%**%..::.:::.:::.:::. ::::.:::.:*****#**%@*&%**$##&@S*&#%*******&S*&@&S#$**%#*&%*%S*#@@*:::.:::::::::: ::::::::::$***#$**$S***$***@*#@#@*@%***%@*$&@$#*@***@***S$**$#***$:.:::::::::::: :::::::::.*S***&%*%&****%***$*@#*S&@***%&S*S@@S$***$****#***&****$:::::::::::::: :::::::::.%***@%**$&**SS@****@%@$%*******$$&$@&****&****#$**%S***#:.:::::::::::: ::::::::::%#**@***@*##$*%**************************%*$&#*&***S***#:::::::::::::: :::::::::!&****@***%************************************%%**@****#*::::::::::::: ::::::::::&***&$%$$*******%*************************%%******$#****%!.::::::::::: ::::::::*@S***##&@%****%@@&&@%*******************%$@@@@@$****%$#****@:..:::::::: :::::::::$****S@*******%*%%$@&@$***************%@@$%%***%*******@S***#$!:::::::: ::::::::@****S$***************%$$%************$$%****************@*****@!::::::: ::::::!%S***S@%***************************************************&****#$!:::::: :::::.!@**S@*******************************************************%#**S$:.::::: ::::!$S***#%*************%%$#@*********%*********%#@%%%*************$#***S@!:::: :::.%S****#%**********%@&@@&**@**%*****@%@***%%*%S*@@@@@$%**********%#*****$:::: :::*&S***S&%**********%$&S*S&#*&*$#%**%%%%**@#%$*S&&*#$$$%***********@*****#%!:: ::!%****S&$$%%***%$$$%%***@SSS**S$$#%*$@@**@@*@**##S#$***%$@@@$***%%$$@S***S%!:: ::..%&###****&*%@@$%***%$@@&&@$$&S#$$*#$&%$%%#*&%*%$@@@@$%**%$@&$*&*****S&&%.::: ::::...:$S*#%**%%****%%$$@@$$$****$@$#&$$@%%@$%***%$@@@$$$%*****%**@S**#!...:::: :::::!$S***#&@**********************%%%%%*%%**********************$&#****@!.:::: :::!$S******#%******$##@@@$$$%*****%$@@@@@@@$%****%$$$$@@##$******%#******S@!.:: ::::!!%#***S#SS$****%$&@%%$$%@@****%$@@@@@@@$%***@@%$$%*@&$%****%#S#****#%!!:::: ::::.!$$$$&***#*****$@$@$%%@&$@****%$@@@@@@@$%**%@$&$%%@@@@$*****@****@$$$!::::: ::::::..:%S****#&$***$@@$%**$*#****%$@@@@@@@$%***&*%**%$@@$***%%S***&$!..::::::: .:::.:::*$**$&***&***%%%%***#*@****%%$$$$$$%%%***$S@***%%%%***@***SS&:.::.:::.:: ::.:::.::...!&***#@%*******#*$*****@########$****%$S@*******%$&***$::::.:::.:::. .:::.:::.::%##@#***&%$%****S*&$***$****SS****%**%$#*&*****%*$****$!::.:::.:::.:: ::.:::.::::!:...******%%***$*S#$***#********#**%@#**%*****#S#**S%!..:::.:::.:::. .:::.:::.::..::.!#@S**S@**%%S#*#%***@#&$@##@***%&*S#%***%#S**@&#*.:::.:::.:::.:: ::.:::.:::.:::.::.:SS**&@#***&&*&&@$$$$@@$$$$@&&S&#**S&$$*****..:::.:::.:::.:::. .:::.:::.:::.:::.:!*:$***S&%%*$S%:&%S#****S*$#!*#$*#*@S***S!*!.::.:::.:::.:::.:: ::.:::.:::.:::.:::.:.%*&*:.:.&S$**$#********#&!S$S**..:%#*#..::.:::.:::.:::.:::. .:::.:::.:::.:::.:::.!*..::..!*&&*@**********&S&&*@.::..:%*::.:::.:::.:::.:::.:: ::.:::.:::.:::.:::.::..::.:::.**@#*#@S&*#S#$&*S@*#::.:::.::::::.:::.:::.:::.:::. .:::.:::.:::.:::.::::::.:::.::.%*@#$!*!$%$*%$&&*#:.:::.:::.::.:::.:::.:::.:::.:: ::.:::.:::.:::.:::.::.:::.:::..!**&@@@@@&@@@@#**!.::.:::.::::::.:::.:::.:::.:::. .:::.:::.:::.:::.::::::.:::.::::&**S&$$%*%%&&#*@::.:::.:::.::.:::.:::.:::.:::.:: ::.:::.:::.:::.::::::::::.:::.:::$#*****@S****@:.:::.:::.::::::.:::.:::.:::.:::. .:::.:::.:::.:::.::::::.:::.:::.::.*###***#&@$.:::.:::.::::::::::.:::.:::.:::.:: ::::::.:::.:::.::::::::::.:::.:::.::::!$!$!...::.:::.::::::::::.:::.:::.:::.:::. ::::::::.::::::::::::::::::::::.::::::..:..:::::::.:::.::::::::::.:::.:::::::::: ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Python Coding September 10, 2022 Python No comments
# Python program to convert decimal into other number systems
dec = int(input("Enter a Decimal Number: "))
#decimal to binary
print(bin(dec), "in Binary.")
#decimal to octal
print(oct(dec), "in Octal.")
#decimal to Hexadecimal
print(hex(dec), "in Hexadecimal.")
#clcoding.com
Enter a Decimal Number: 9999 0b10011100001111 in Binary. 0o23417 in Octal. 0x270f in Hexadecimal.
Python Coding September 02, 2022 Projects, Python No comments
Python Coding September 02, 2022 Projects, Python No comments
Python Coding September 02, 2022 Python No comments
Enter the Phone Number: +447894561236 United Kingdom
Python Coding August 30, 2022 Python No comments
from PIL import Image
def Images_Pdf(filename, output):
images = []
for file in filename:
im = Image.open(file)
im = im.convert('RGB')
images.append(im)
images[0].save(output, save_all=True, append_images=images[1:])
#clcoding.com
# Images Path , output pdf
Images_Pdf(["binod_mirror.png", "binod.png", "binod.jpg"], "output.pdf")
Python Coding August 30, 2022 Python No comments
pip install pytesseract
pip install pillow
from PIL import Image
from pytesseract import pytesseract
#Define path to tessaract.exe
path_to_tesseract = r'C:\Program Files\Tesseract-OCR\tesseract.exe'
#Define path to image
path_to_image = 'texttoimage.png'
#Point tessaract_cmd to tessaract.exe
pytesseract.tesseract_cmd = path_to_tesseract
#Open image with PIL
img = Image.open(path_to_image)
#Extract text from image
text = pytesseract.image_to_string(img)
print(text)
Python Coding August 30, 2022 Python No comments
pip install python-barcode
import barcode
from barcode.writer import ImageWriter
#Define content of the barcode as a string
number = input("Enter the code to generate barcode : ") #clcoding.com
#Get the required barcode format
barcode_format = barcode.get_barcode_class('upc')
#Generate barcode and render as image
my_barcode = barcode_format(number, writer=ImageWriter())
#Save barcode as PNG
my_barcode.save("generated_barcode")
from PIL import Image #to open the barcde and show
Image.open('generated_barcode.png') #clcoding.com
Python Coding August 30, 2022 Python No comments
img=Image.open('binod.jpg')
# The file format of the source file.
print(img.format) # Output: JPEG
# The pixel format used by the image.
#Typical values are "1", "L", "RGB", or "CMYK."
print(img.mode) # Output: RGB
# Image size, in pixels.
print(img.size) # Output: (1920, 1280)
print(img.palette) # Output: None
JPEG RGB (500, 271) None
Python Coding August 26, 2022 Python No comments
from calendar import*
year = int(input('Enter Year:'))
print(calendar(year, 2, 1, 8, 4))
#2 = 2 characters for days (Mo,Tu, etc)
#1 = 1 line (row) for each week
#8 = 8 rows for each month
#4 = 4 columns for all months of the year.
#clcoding.com
2023 January February March April Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su 1 1 2 3 4 5 1 2 3 4 5 1 2 2 3 4 5 6 7 8 6 7 8 9 10 11 12 6 7 8 9 10 11 12 3 4 5 6 7 8 9 9 10 11 12 13 14 15 13 14 15 16 17 18 19 13 14 15 16 17 18 19 10 11 12 13 14 15 16 16 17 18 19 20 21 22 20 21 22 23 24 25 26 20 21 22 23 24 25 26 17 18 19 20 21 22 23 23 24 25 26 27 28 29 27 28 27 28 29 30 31 24 25 26 27 28 29 30 30 31 May June July August Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su 1 2 3 4 5 6 7 1 2 3 4 1 2 1 2 3 4 5 6 8 9 10 11 12 13 14 5 6 7 8 9 10 11 3 4 5 6 7 8 9 7 8 9 10 11 12 13 15 16 17 18 19 20 21 12 13 14 15 16 17 18 10 11 12 13 14 15 16 14 15 16 17 18 19 20 22 23 24 25 26 27 28 19 20 21 22 23 24 25 17 18 19 20 21 22 23 21 22 23 24 25 26 27 29 30 31 26 27 28 29 30 24 25 26 27 28 29 30 28 29 30 31 31 September October November December Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su 1 2 3 1 1 2 3 4 5 1 2 3 4 5 6 7 8 9 10 2 3 4 5 6 7 8 6 7 8 9 10 11 12 4 5 6 7 8 9 10 11 12 13 14 15 16 17 9 10 11 12 13 14 15 13 14 15 16 17 18 19 11 12 13 14 15 16 17 18 19 20 21 22 23 24 16 17 18 19 20 21 22 20 21 22 23 24 25 26 18 19 20 21 22 23 24 25 26 27 28 29 30 23 24 25 26 27 28 29 27 28 29 30 25 26 27 28 29 30 31 30 31
Python Coding August 26, 2022 Python No comments
import whois
domain=input("Enter your Domain : ")
domain_info = whois.whois(domain)
for key, value in domain_info.items():
print(key,':', value)
Enter your Domain : https://www.clcoding.com/ domain_name : ['CLCODING.COM', 'clcoding.com'] registrar : Google LLC whois_server : whois.google.com referral_url : None updated_date : 2022-04-12 07:43:54 creation_date : 2019-04-12 02:05:57 expiration_date : 2023-04-12 02:05:57 name_servers : ['NS-CLOUD-B1.GOOGLEDOMAINS.COM', 'NS-CLOUD-B2.GOOGLEDOMAINS.COM', 'NS-CLOUD-B3.GOOGLEDOMAINS.COM', 'NS-CLOUD-B4.GOOGLEDOMAINS.COM'] status : ['clientTransferProhibited https://icann.org/epp#clientTransferProhibited', 'clientTransferProhibited https://www.icann.org/epp#clientTransferProhibited'] emails : registrar-abuse@google.com dnssec : unsigned name : Contact Privacy Inc. Customer 7151571251 org : Contact Privacy Inc. Customer 7151571251 address : 96 Mowat Ave city : Toronto state : ON registrant_postal_code : M4K 3K1 country : CA
Python Coding August 17, 2022 Python No comments
pip install plyer
import time
from plyer import notification
if __name__ == "__main__":
while True:
notification.notify(
title = "ALERT!!!",
message = "Take a break! It has been an hour!",
timeout = 10
)
time.sleep(3600)
#clcoding.com
Python Coding August 16, 2022 Python No comments
# importing packages
from pytube import YouTube
import os
# url input from user
yt = YouTube(str(input("Enter the URL of the video you want to download: \n>> ")))
# extract only audio
video = yt.streams.filter(only_audio=True).first()
# check for destination to save file
print("Enter the destination (leave blank for current directory)")
destination = str(input(">> ")) or '.'
# download the file
out_file = video.download(output_path=destination)
# save the file
base, ext = os.path.splitext(out_file)
new_file = base + '.mp3'
os.rename(out_file, new_file) #clcoding.com
# result of success
print(yt.title + " has been successfully downloaded in .mp3 format.")
Python Coding August 15, 2022 Python No comments
from pdf2docx import Converter
pdf_file = 'clcoding.pdf'
docx_file = 'clcoding.docx'
cv = Converter(pdf_file)
cv.convert(docx_file)
cv.close()
#clcoding.com
[INFO] Start to convert clcoding.pdf [INFO] [1/4] Opening document... [INFO] [2/4] Analyzing document... [INFO] [3/4] Parsing pages... [INFO] (1/1) Page 1 [INFO] [4/4] Creating pages... [INFO] (1/1) Page 1 [INFO] Terminated in 0.16s.
Python Coding August 15, 2022 Python No comments
INDIAN Flag in Python. All dimensions are as per our INDIAN standards. Let us know if you have any suggestions.
import numpy as np
import matplotlib.pyplot as py
import matplotlib.patches as patch
#Plotting the tri colours in national flag
a = patch.Rectangle((0,1), width=9, height=2, facecolor='#138808', edgecolor='grey')
b = patch.Rectangle((0,3), width=9, height=2, facecolor='#ffffff', edgecolor='grey')
c = patch.Rectangle((0,5), width=9, height=2, facecolor='#FF6103', edgecolor='grey')
m,n = py.subplots()
n.add_patch(a)
n.add_patch(b)
n.add_patch(c)
#AshokChakra Circle
radius=0.8
py.plot(4.5,4, marker = 'o', markerfacecolor = '#000080', markersize = 9.5)
chakra = py.Circle((4.5, 4), radius, color='#000080', fill=False, linewidth=7)
n.add_artist(chakra)
#24 spokes in AshokChakra
for i in range(0,24):
p = 4.5 + radius/2 * np.cos(np.pi*i/9 + np.pi/48)
q = 4.5 + radius/2 * np.cos(np.pi*i/9 - np.pi/48)
r = 4 + radius/2 * np.sin(np.pi*i/9 + np.pi/48)
s = 4 + radius/2 * np.sin(np.pi*i/9 - np.pi/48)
t = 4.5 + radius * np.cos(np.pi*i/9)
u = 4 + radius * np.sin(np.pi*i/9)
n.add_patch(patch.Polygon([[4.5,4], [p,r], [t,u],[q,s]], fill=True, closed=True, color='#000080'))
py.axis('equal')
py.show() #clcoding.com
Python Coding August 15, 2022 Python No comments
from zipfile import ZipFile
with ZipFile('binod.zip', 'r') as zip_object:
zip_object.extractall()
#list of files that are archived in the ZIP file
print(zip_object.namelist())
#clcoding.com
['binod.jpg', 'BumBumBole.gif', 'clcoding.pdf', 'file1.pdf']
Python Coding August 15, 2022 Python No comments
import pyshorteners
long_url = input("Enter the URL to shorten: ")
##TinyURL shortener service
type_tiny = pyshorteners.Shortener()
short_url = type_tiny.tinyurl.short(long_url)
print("The Shortened URL is: " + short_url)
#clcoding.com
Enter the URL to shorten: https://www.clcoding.com/p/python.html The Shortened URL is: https://tinyurl.com/2zb6hedv
Python Coding August 15, 2022 Python No comments
import PyPDF2
import pyttsx3
engine = pyttsx3.init()
# Read the pdf by specifying the path in your computer
pdfReader = PyPDF2.PdfFileReader(open('clcoding.pdf', 'rb'))
# Get the handle to speaker
speaker = pyttsx3.init()
# split the pages and read one by one
for page_num in range(pdfReader.numPages):
text = pdfReader.getPage(page_num).extractText()
speaker.say(text) #clcoding.com
speaker.runAndWait()
# stop the speaker after completion
speaker.stop()
# save the audiobook at specified path
engine.save_to_file(text, 'E:\audio.mp3')
engine.runAndWait()
Python Coding August 15, 2022 Python No comments
from PIL import Image, ImageDraw, ImageFont
img = Image.open(r'binod.jpg')
draw = ImageDraw.Draw(img)
text = "clcoding.com"
font = ImageFont.truetype('arial.ttf', 50)
textwidth, textheight = draw.textsize(text, font)
width, height = img.size
x=width/2-textwidth/2
y=height-textheight-50
draw.text((x, y), text, font=font)
img.save(r'binod.png')
Image.open('binod.png')
Python Coding August 15, 2022 Python No comments
import emoji
print(emoji.emojize(":India:"))
print(emoji.emojize(":books:"))
print(emoji.emojize(":red_heart:"))
print(emoji.emojize(":hibiscus:"))
print(emoji.emojize(":rose:"))
print(emoji.emojize(":baby:"))
#clcoding.com
🇮🇳 📚 ❤️ 🌺 🌹 👶
Python Coding August 15, 2022 Python No comments
from captcha. Image import ImageCaptcha
# Specify the image size
image = ImageCaptcha(width = 300, height = 100)
# Specify the Text for captcha
captcha_text = input("Enter Captcha text : ")
# generate the image of the given text
data = image.generate(captcha_text)
#clcoding.com
# write the image on the given file and save it
image.write(captcha_text, 'E:\CAPTCHA1.png')
from PIL import Image
Image.open('E:\CAPTCHA1.png')
Enter Captcha text : python
Python Coding August 15, 2022 Python No comments
Number = int(input("Enter the Number to Check Disarium Number = "))
length = len(str(Number))
Temp = Number
Sum = 0
rem = 0 #clcoding.com
while Temp > 0:
rem = Temp % 10
Sum = Sum + int(rem**length)
Temp = Temp // 10
length = length - 1
print("The Sum of the Digits = %d" %Sum)
if Sum == Number:
print("\n%d is a Disarium Number." %Number)
else:
print("%d is Not a Disarium Number." %Number)
Enter the Number to Check Disarium Number = 175 The Sum of the Digits = 175 175 is a Disarium Number.
Python Coding August 15, 2022 Python No comments
from geopy.geocoders import Nominatim
# Using Nominatim Api
geolocator = Nominatim(user_agent="geoapiExercises")
# Zipocde input
a = input("Enter the zipcode : ")
zipcode = a
# Using geocode()
location = geolocator.geocode(zipcode)
# Displaying address details
print("Zipcode:",zipcode)
print("Details of the Zipcode:")
print(location)
#clcoding.com
Enter the zipcode : 411045 Zipcode: 411045 Details of the Zipcode: Pune City, Maharashtra, 411045, India
Python Coding August 15, 2022 Python No comments
import imageio
filenames = ["1.png","3.png","4.png"]
#you can add any type of image
images = []
for filename in filenames:
images.append(imageio.imread(filename))
imageio.mimsave('ritesh1.gif', images,'GIF',duration=1)
#you can add duration as per your need
#clcoding.com
Python Coding August 14, 2022 Python No comments
# Swap function
def swapList(newList):
size = len(newList)
# Swapping
temp = newList[0]
newList[0] = newList[size - 1]
newList[size - 1] = temp
return newList
# Driver code
newList = []
newList = [int(item) for item in input("Enter the list items : ").split()]
print(swapList(newList))
#clcoding.com
Enter the list items : 4 5 2 3 8 6 [6, 5, 2, 3, 8, 4]
Python Coding August 14, 2022 Python No comments
# Function to find permutations of a given string
from itertools import permutations
def allPermutations(str):
permList = permutations(str)
# print all permutations
for perm in list(permList):
print (''.join(perm))
# Driver program
if __name__ == "__main__":
str = input("Enter your string : ")
allPermutations(str)
#clcoding.com
Enter your string : CAT CAT CTA ACT ATC TCA TAC
Python Coding August 14, 2022 Python No comments
# Python program to find compound interest
def compound_interest(principle, rate, time):
# Calculates compound interest
Amount = principle * (pow((1 + rate / 100), time))
CI = Amount - principle
print("Compound interest is", CI)
P=float(input("Enter Principle Value : "))
R=float(input("Enter Rate Value : "))
T=float(input("Enter Time Value : "))
compound_interest(P,R,T)
#clcoding.com
Enter Principle Value : 1000 Enter Rate Value : 11 Enter Time Value : 3 Compound interest is 367.6310000000003
Python Coding August 14, 2022 Python No comments
# Python program to add two numbers
number1 = input("First number: ")
number2 = input("Second number: ")
# Adding two numbers
# User might also enter float numbers
sum = float(number1) + float(number2)
# Display the sum
# will print value in float
print("The sum of {0} and {1} is {2}" .format(number1, number2, sum))
#clcoding.com
First number: 21
Second number: 31
The sum of 21 and 31 is 52.0
Python Coding August 14, 2022 Python No comments
print("Enter the Number of Rows: ", end="")
row = int(input())
num = 1
for i in range(row):
for j in range(i+1):
print(num, end=" ")
num = num+1
print()
#clcoding.com
Enter the Number of Rows: 6 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
Free Books Python Programming for Beginnershttps://t.co/uzyTwE2B9O
— Python Coding (@clcoding) September 11, 2023
Top 10 Python Data Science book
— Python Coding (@clcoding) July 9, 2023
🧵:
Top 4 free Mathematics course for Data Science ! pic.twitter.com/s5qYPLm2lY
— Python Coding (@clcoding) April 26, 2024
Web Development using Python
— Python Coding (@clcoding) December 2, 2023
🧵: