Tuesday, 3 May 2022

Day 21 : Fidget Spinner game with Python


 


#!/usr/bin/env python

# coding: utf-8


# # Fidget Spinner game with Python


# In[7]:



from turtle import *

state = {'turn': 0}

def spinner():

    clear()

    angle = state['turn']/10

    right(angle)

    forward(100)

    dot(120, 'cyan')

    back(100)

    right(120)

    forward(100)

    dot(120, 'green')

    back(100)

    right(120)

    forward(100)

    dot(120, 'blue')

    back(100)

    right(120)

    update()

def animate():

    if state['turn']>0:

        state['turn']-=1

    spinner() #clcoding.com

    ontimer(animate, 20)

def flick():

    state['turn']+=10

setup(420, 420, 370, 0)

hideturtle()

tracer(False)

width(20)

onkey(flick, 'space')

listen()

animate()

done()



# In[ ]:






# In[ ]:





Day 20 : Spelling Correction with Python





#!/usr/bin/env python
# coding: utf-8

# In[ ]:


pip install textblob


# # Spelling Correction with Python

# In[28]:


from textblob import TextBlob
def Convert(string):
    li = list(string.split())
    return li  
str1 = input("Enter your word : ")
words=Convert(str1)
corrected_words = []
for i in words:
    corrected_words.append(TextBlob(i))
print("Wrong words :", words)
print("Corrected Words are :")
for i in corrected_words:
    print(i.correct(), end=" ")
#clcoding.com


# In[ ]:




Day 19 : Chessboard using Matplotlib in Python

 


#!/usr/bin/env python

# coding: utf-8


# # Chessboard using Matplotlib in Python


# In[17]:



import matplotlib.pyplot as plt

dx, dy = 0.015, 0.015

x = np.arange(-4.0, 4.0, dx)

y = np.arange(-4.0, 4.0, dy)

X, Y = np.meshgrid(x, y)

extent = np.min(x), np.max(x), np.min(y), np.max(y)

z1 = np.add.outer(range(8), range(8)) % 2

plt.imshow(z1, cmap="binary_r", interpolation="nearest", extent=extent, alpha=1)


def chess(x, y):

    return (1 - x / 2 + x ** 5 + y ** 6) * np.exp(-(x ** 2 + y ** 2))

z2 = chess(X, Y)

plt.imshow(z2, alpha=0, interpolation="bilinear", extent=extent)

plt.title("Chess Board in Python")

plt.show()

#clcoding.com



# In[ ]:





Day 18 : Three Dimensional contour plots



#!/usr/bin/env python
# coding: utf-8

# # Three-Dimensional contour plots

# In[15]:


import numpy as np
import matplotlib.pyplot as plt
def f(x, y):
    return np.sin(np.sqrt(x ** 2 + y ** 2))
x = np.linspace(-6, 6, 30)
y = np.linspace(-6, 6, 30)
x, y = np.meshgrid(x, y)
z = f(x, y)              #clcoding.com
fig = plt.figure()
ax = plt.axes(projection='3d')
ax.contour3D(x,y,z,50, cmap='binary')
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('z')
plt.show()
fig = plt.figure()
ax = plt.axes(projection='3d')
ax.plot_wireframe(x,y,z, color='black')
ax.set_title('wireframe')
plt.show()
ax = plt.axes(projection='3d')
ax.plot_surface(x, y, z, rstride=1,
                cstride=1, cmap='viridis',
                edgecolor='none')
ax.set_title('surface')
plt.show()


# In[ ]:




Saturday, 16 April 2022

Day 16 : Live Weather Updates with Python

 



#!/usr/bin/env python

# coding: utf-8


# # Live Weather Updates with Python


# In[7]:



from bs4 import BeautifulSoup

import requests

headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)           AppleWebKit/537.36 (KHTML, like Gecko)            Chrome/58.0.3029.110 Safari/537.3'}

def weather(city):

    city=city.replace(" ","+")

    res = requests.get(f'https://www.google.com/search?q={city}    &oq={city}&aqs=chrome.0.35i39l2j0l4j46j69i60.6128j1j7&sourceid=                       chrome&ie=UTF-8',headers=headers)

    print("Searching......\n")

    soup = BeautifulSoup(res.text,'html.parser')   

    location = soup.select('#wob_loc')[0].getText().strip()  

    time = soup.select('#wob_dts')[0].getText().strip()       

    info = soup.select('#wob_dc')[0].getText().strip() 

    weather = soup.select('#wob_tm')[0].getText().strip()

    print(location)

    print(time)

    print(info)

    print(weather+"°C") 

city=input("Enter the Name of Any City >>  ")

city=city+" weather"

weather(city) 

#clcoding.com



# In[ ]:





Day 15 : Violin Plot using Python

 



#!/usr/bin/env python

# coding: utf-8


# In[ ]:



pip install seaborn



# # Violin Plot using Python


# In[9]:



import seaborn as sns

import matplotlib.pyplot as plt


data = sns.load_dataset("tips")

plt.figure(figsize=(10, 4))

sns.violinplot(x=data["total_bill"])

plt.show()


#clcoding.com



# In[6]:






# In[ ]:





Day 14 : Text wrapping in Python

 



#!/usr/bin/env python

# coding: utf-8


# # Text wrapping in Python


# In[17]:



import textwrap

value = """This function wraps the input paragraph such that each line

in the paragraph is at most width characters long. The wrap method

returns a list of output lines. The returned list

is empty if the wrapped

output has no content."""


# Wrap this text.

wrapper = textwrap.TextWrapper(width=70)


word_list = wrapper.wrap(text=value)


# Print each line.

for element in word_list:

print(element)


#clcoding.com



# In[ ]:





Day 13 : Country info in Python




#!/usr/bin/env python
# coding: utf-8

# In[ ]:


pip install countryinfo


# # Country info in Python

# In[1]:


from countryinfo import CountryInfo
#user input for Country Name
count=input("Enter your country : ")
country = CountryInfo(count)
print("Capital is : ",country.capital())
print("Currencies is :",country.currencies())
print("Lanuage is : ",country.languages())
print("Borders are : ",country.borders())
print("Others names : ",country.alt_spellings())

#clcoding.com



# In[ ]:




Saturday, 9 April 2022

Day 11 : Python Program to Generate Password


#!/usr/bin/env python
# coding: utf-8

# # Python Program to Generate Password

# In[10]:


#import random module 
import random

#User input for password length 
passlen = int(input("Enter the length of password : "))

#storing letters, numbers and special characters
s="abcdefghijklmnopqrstuvwxyz01234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()?"

#random sampling by joining the length of the password and the variable s
p = "".join(random.sample(s,passlen ))
print(p)

#clcoding.com


# In[ ]:




Day 10 : Dice Roll Simulator in Python


#!/usr/bin/env python
# coding: utf-8

# # Dice Roll Simulator

# In[ ]:


#importing module for random number generation
import random
#range of the values of a dice
min_val = 1
max_val = 6
#to loop the rolling through user input
roll_again = "yes"
#loop
while roll_again == "yes" or roll_again == "y":
    print("Rolling The Dices...")
    print("The Values are :")
    
    #generating and printing 1st random integer from 1 to 6
    print(random.randint(min_val, max_val))
    
    #asking user to roll the dice again. 
    #Any input other than yes or y will terminate the loop
    roll_again = input("Roll the Dices Again?") 
    
    #clcoding.com


# In[ ]:




Day 9 : BMI Calculator with Python

 #!/usr/bin/env python

# coding: utf-8



# # BMI Calculator with Python


# In[7]:



Height=float(input("Enter your height in centimeters: "))

Weight=float(input("Enter your Weight in Kg: "))

Height = Height/100

BMI=Weight/(Height*Height)

print("your Body Mass Index is: ",BMI)

if(BMI>0):

if(BMI<=16):

print("you are severely underweight")

elif(BMI<=18.5):

print("you are underweight")

elif(BMI<=25):

print("you are Healthy")

elif(BMI<=30):

print("you are overweight")

else: print("you are severely overweight")

else:("enter valid details")

 

    #clcoding.com 



# In[ ]:





Day 8 : Fahrenheit to Celsius in Python




#!/usr/bin/env python
# coding: utf-8

# # Fahrenheit to Celsius in Python

# In[16]:


def convert(s):
    f = float(s)    
#formula Applied below  
    c = (f - 32) * 5/9
    return c
celsius=input("Enter Values in Fahrenheit : ")
convert(celsius)

#clcoding.com


# In[ ]:





# In[ ]:




Day 7 : Treemap using Python



#!/usr/bin/env python
# coding: utf-8

# # Treemap using Python

# In[2]:


import plotly.graph_objects as go

fig = go.Figure(go.Treemap(
    labels = ["A","B", "C", "D", "E", "F", "G", "H", "I"],
    parents = ["", "A", "A", "C", "C", "A", "A", "G", "A"]
))

fig.show()

#clcoding.com


# In[ ]:




Sunday, 3 April 2022

Day 6 : Text to Handwriting using Python



#!/usr/bin/env python
# coding: utf-8

# # Text to Handwriting using Python

# In[ ]:


import pywhatkit as kit
import cv2
Handwritten=input("Enter your text to convert in Handwriting : ")
kit.text_to_handwriting(Handwritten, save_to="pythoncoding.png")
img = cv2.imread("pythoncoding.png")
cv2.imshow("Python Coding", img)
cv2.waitKey(0)
cv2.destroyAllWindows()

#clcoding.com


# In[ ]:




Day 5 : Roman Numbers to Decimals in Python


 

#!/usr/bin/env python

# coding: utf-8


# # Roman Numbers to Decimals in Python


# In[6]:



tallies = {'I': 1,'V': 5,'X': 10,'L': 50,

           'C': 100,'D': 500,'M': 1000}

def RomanNumeralToDecimal(romanNumeral):

    sum = 0

    for i in range(len(romanNumeral) - 1):

        left = romanNumeral[i]

        right = romanNumeral[i + 1]

        if tallies[left] < tallies[right]:

            sum -= tallies[left]

        else:

            sum += tallies[left]

    sum += tallies[romanNumeral[-1]]

    return sum 

roman=input("Enter Roman Numbers :")

RomanNumeralToDecimal(roman)


#clcoding.com



# In[ ]:





Day 4 : LCM using Python



#!/usr/bin/env python
# coding: utf-8

# # LCM using Python

# In[13]:


def least_common_multiple(a,b):
  
    if a > b:
        greater = a
    elif b > a:
        greater = b
    while(True):
        if ((greater % a == 0) and (greater % b == 0)):
            lcm = greater
            break
        greater = greater + 1
    return lcm
a=int(input("Enter 1st number: "))
b=int(input("Enter 2nd number: "))
print(least_common_multiple(a,b))

#clcoding.com


# In[ ]:




Day 3 : Palindrome Words using Python



#!/usr/bin/env python
# coding: utf-8

# # Palindrome Words using Python

# In[6]:


def palindrome(sentence):
    for i in (",.'?/><}{{}}'"):
        sentence = sentence.replace(i, "")
    palindrome = []
    words = sentence.split(' ')
    for word in words:
        word = word.lower()
        if word == word[::-1]:
            palindrome.append(word)
    return palindrome
sentence = input("Enter a sentence : ")
print(palindrome(sentence))

#clcoding.com


# In[ ]:




Day 2 : Count Character Occurrences using Python


 

#!/usr/bin/env python

# coding: utf-8


# # Count Character Occurrences using Python


# In[5]:



def count_characters(s):

    count = {}

    for i in s:

        if i in count:

            count[i] += 1

        else:

            count[i] = 1

    print(count)

word=input("Enter your string:")

count_characters(word)


#clcoding.com


Day 1: Line continuation characters in Python


#!/usr/bin/env python
# coding: utf-8

# # Day 1 :  Line continuation characters in Python

# In[28]:


print("I know Python and its very easy for everyone")


# In[29]:


print("I know Python and
its very easy for everyone")

#clcoding.com


# In[30]:


#In Python, a backslash ( \ ) is a continuation character.

print("I know Python and its very easy for everyone")

#clcoding.com


# In[ ]:




Tuesday, 29 March 2022

How to generate password using python?

random: 
Python has a built-in module that you can use to make random numbers.
The random module has a set of methods:

  • random(): Returns a random float number between 0 and 1
  • sample(): Returns a given sample of a sequence
  • shuffle(): Takes a sequence and returns the sequence in a random order
  • choice(): Returns a random element from the given sequence
  • choices(): Returns a list with a random selection from the given sequence
  • randint(): Returns a random number between the given range
  • uniform(): Returns a random float number between two given parameters

array:
An array is a collection of items stored at contiguous memory locations. 
This module defines an object type which can compactly represent an array of basic values: characters, integers, floating point numbers.

import random
import array

#  password length
MAX_LEN = 12


DIGITS = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
LOCASE_CHARACTERS = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
'i', 'j', 'k', 'm', 'n', 'o', 'p', 'q',
'r', 's', 't', 'u', 'v', 'w', 'x', 'y',
'z']

UPCASE_CHARACTERS = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'M', 'N', 'O', 'P', 'Q',
'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y',
'Z']

SYMBOLS = ['@', '#', '$', '%', '=', ':', '?', '.', '/', '|', '~', '>',
'*', '(', ')', '<']

# combines all the character arrays above to form one array
COMBINED_LIST = DIGITS + UPCASE_CHARACTERS + LOCASE_CHARACTERS + SYMBOLS

# randomly select at least one character from each character set above
rand_digit = random.choice(DIGITS)
rand_upper = random.choice(UPCASE_CHARACTERS)
rand_lower = random.choice(LOCASE_CHARACTERS)
rand_symbol = random.choice(SYMBOLS)

# combine the character randomly selected above

temp_pass = rand_digit + rand_upper + rand_lower + rand_symbol



# the password length by selecting randomly from the combined

for x in range(MAX_LEN - 4):
temp_pass = temp_pass + random.choice(COMBINED_LIST)

# changing the position of the elements of the sequence.

temp_pass_list = array.array('u', temp_pass)
random.shuffle(temp_pass_list)

# traverse the temporary password array and append the charsto form the password
password = ""
for x in temp_pass_list:
password = password + x
# print out password
print(password)




Thank you 😊 for reading. Please read other blogs. And also share with your friends and 
family.
Please also go to following blog:   https://pythoholic.blogspot.com/

Friday, 25 March 2022

Sequence Matcher in Python

 


#!/usr/bin/env python

# coding: utf-8


# # Sequence Matcher in Python


# In[3]:



from difflib import SequenceMatcher

text1 = input("Enter 1st sentence : ") 

text2 = input("Enter 2nd sentence : ")

sequenceScore = SequenceMatcher(None, text1, text2).ratio()

print(f"Both are {sequenceScore * 100} % similar")


#clcoding.com



# In[ ]:





Age Calculator using Python

 

#!/usr/bin/env python
# coding: utf-8

# # Age Calculator using Python

# In[20]:


def ageCalculator(y, m, d):
    import datetime
    today = datetime.datetime.now().date()
    dob = datetime.date(y, m, d)
    age = int((today-dob).days / 365.25)
    print(age)

#y=year m=month d=day    
ageCalculator(2001 , 8, 1)

#clcoding.com


# In[ ]:




Saturday, 19 March 2022

Image to Pencil Sketch in Python


#!/usr/bin/env python
# coding: utf-8

# # Image to Pencil Sketch in Python 

# In[ ]:


#...........Convert image to pencil sketch......!
import cv2

#specify the path to image (Loading image image)
image1 = cv2.imread('E:\demo.png')
window_name = 'Original image'

# Displaying the original image 
cv2.imshow(window_name,image1)


# convert the image from one color space to another
grey_img = cv2.cvtColor(image1, cv2.COLOR_BGR2GRAY)
invert = cv2.bitwise_not(grey_img)

#image smoothing
blur = cv2.GaussianBlur(invert, (21, 21), 0)
invertedblur = cv2.bitwise_not(blur)
sketch = cv2.divide(grey_img, invertedblur, scale=256.0)

#save the converted image to specified path
cv2.imwrite("E:\sketch.png", sketch)
 
# Reading an image in default mode
image = cv2.imread("E:\sketch.png")
  
# Window name in which image is displayed
window_name = 'Sketch image'
  
# Displaying the sketch image 
cv2.imshow(window_name, image)
#waits for user to press any key 
#(this is necessary to avoid Python kernel form crashing)
cv2.waitKey(0) 
  
#closing all open windows 
cv2.destroyAllWindows() 


# In[ ]:




Sunday, 13 March 2022

Voice Recorder in Python




#!/usr/bin/env python
# coding: utf-8

# In[13]:


pip install sounddevice


# In[14]:


pip install scipy


# # Voice Recorder in Python

# In[15]:


#import required modules
import sounddevice
from scipy.io.wavfile import write
#sample_rate
fs=44100

#Ask to enter the recording time
second=int(input("Enter the Recording Time in second: "))
print("Recording....\n")
record_voice=sounddevice.rec(int(second * fs),samplerate=fs,channels=2)
sounddevice.wait()
write("MyRecording.wav",fs,record_voice)
print("Recording is done Please check you folder to listen recording")

#clcoding.com


# In[ ]:




Download YouTube videos in Python




#!/usr/bin/env python
# coding: utf-8

# # Download YouTube videos in Python

# In[1]:


pip install pytube


# In[1]:


#import pytube library to download the video
import pytube

#Ask for the url of video
url = input("Enter video url: ")
#we can take path as well, just uncomment the following line
#path = input("Enter path of storage")
 
#specify the starage path of video
path="E:"

#magic line to download the video
pytube.YouTube(url).streams.get_highest_resolution().download(path)

#clcoding.com


# In[ ]:





# In[ ]:




Captcha in Python




#!/usr/bin/env python
# coding: utf-8

# In[1]:


pip install captcha


# # Generate Image captcha in python:

# In[12]:


from captcha.image import ImageCaptcha
   
# Specify the image size
image = ImageCaptcha(width = 300, height = 100)
# Specify the Text for captcha
captcha_text = 'python clcoding'
   
# generate the image of the given text
data = image.generate(captcha_text)  
   
# write the image on the given file and save it
image.write(captcha_text, 'E:\CAPTCHA1.png')


# # Generate audio captcha in python:

# In[13]:


from captcha.audio import AudioCaptcha
   
# Create an audio instance
audio = AudioCaptcha()  
   
# Text for captcha
captcha_text = "1011011"
   
# generate the audio of the given text
audio_captcha = audio.generate(captcha_text)
 
# specify the file name and path
audio.write(captcha_text, 'E:\Audio_Captcha.wav')


# In[ ]:




Secrets Python module







#!/usr/bin/env python
# coding: utf-8

# # secrets.randbelow(n): This function returns a random integer in the range [0, n)


# In[1]:



import secrets
  
passwd = secrets.randbelow(100)
print(passwd)


# # secrets.randbits(k): This function returns an int with k random bits

# In[2]:


import secrets

passwd=secrets.randbits(4)
print(passwd)


# # Generate a ten-character alphanumeric password.

# In[3]:


#clcoding.com
import secrets
import string
  
alphabet = string.ascii_letters + string.digits
password = ''.join(secrets.choice(alphabet) for i in range(10))
  
print(password)


# # Generate a ten-character alphanumeric password with at least one   lowercase character, at least one uppercase character,                                      and at least three digits.

# In[4]:


#clcoding.com
import secrets
import string

alphabet = string.ascii_letters + string.digits
while True:
password = ''.join(secrets.choice(alphabet) for i in range(10))
if (any(c.islower() for c in password) and any(c.isupper()
for c in password) and sum(c.isdigit() for c in password) >= 3):
print(password)
break


# In[ ]:




Saturday, 5 March 2022

Mouse and keyboard automation using Python


#!/usr/bin/env python
# coding: utf-8

# # Mouse and keyboard automation using Python

# In[31]:


import pyautogui
print(pyautogui.size())


# In[32]:


#moveTo(): use this function to move the mouse in pyautogui module. 
pyautogui.moveTo(100, 100, duration = 5)


# In[33]:


#moveRel() function: moves the mouse pointer relative to its previous position. 
pyautogui.moveRel(0, 50, duration = 5)


# In[34]:


#position(): function to get current position of the mouse pointer. 
print(pyautogui.position())


# In[35]:


#click(): Function used for clicking and dragging the mouse. 
pyautogui.click(100, 1000)


# In[36]:


#clcoding.com

Friday, 4 March 2022

Python Secrets Module

#!/usr/bin/env python
# coding: utf-8

# # secrets.randbelow(n): This function returns a random integer in the range [0, n)

# In[16]:



import secrets
  
passwd = secrets.randbelow(100)
print(passwd)


# # secrets.randbits(k): This function returns an int with k random bits

# In[17]:


import secrets

passwd=secrets.randbits(4)
print(passwd)


# # Generate a ten-character alphanumeric password.

# In[19]:


#clcoding.com
import secrets
import string
  
alphabet = string.ascii_letters + string.digits
password = ''.join(secrets.choice(alphabet) for i in range(10))
  
print(password)


# # Generate a ten-character alphanumeric password with at least one   lowercase character, at least one uppercase character,                                      and at least three digits.

# In[21]:


#clcoding.com
import secrets
import string

alphabet = string.ascii_letters + string.digits
while True:
password = ''.join(secrets.choice(alphabet) for i in range(10))
if (any(c.islower() for c in password) and any(c.isupper()
for c in password) and sum(c.isdigit() for c in password) >= 3):
print(password)
break


# In[ ]:




Monday, 28 February 2022

Digital Watch in Python using Turtle

#Code:

#!/usr/bin/env python
# coding: utf-8

# In[ ]:


import time

import datetime as dt

import turtle

# create a turtle to display time

t = turtle.Turtle()

# create a turtle to create rectangle box

t1 = turtle.Turtle()

# create screen

s = turtle.Screen()

# set background color of the screen

s.bgcolor("cyan")

# obtain current hour, minute and second 

# from the system

sec = dt.datetime.now().second

min = dt.datetime.now().minute

hr = dt.datetime.now().hour

t1.pensize(10)

t1.color('red')

t1.penup()

# set the position of turtle

t1.goto(-20, -0)

t1.pendown()

# create rectangular box

for i in range(2):

 t1.forward(200)

 t1.left(90)

 t1.forward(70)

 t1.left(90)

#clcoding.com
# hide the turtle

t1.hideturtle()

while True:

 t.hideturtle()

 t.clear()

 # display the time

 t.write(str(hr).zfill(2)

 +":"+str(min).zfill(2)+":"

 +str(sec).zfill(2),

 font =("Arial Narrow", 35, "bold"))

 time.sleep(1)

 sec+= 1

 if sec == 60:

    sec = 0

    min+= 1

 if min == 60:

    min = 0

    hr+= 1

 if hr == 13:

    hr = 1

Saturday, 26 February 2022

Creating an Audiobook in Python






#!/usr/bin/env python
# coding: utf-8

# In[31]:


pip install PyPDF2


# In[32]:


pip install pyttsx3


# In[33]:


#pip install PyPDF2
import PyPDF2


# In[34]:


#pip install pyttsx3
import pyttsx3


# In[35]:


pdfReader=PyPDF2.PdfFileReader(open('C:\\Users\\Irawen\\Documents\\embedded\\Python\\clcoding.pdf','rb'))


# In[36]:


speaker = pyttsx3.init()


# In[37]:


for page_num in range(pdfReader.numPages):
    text =  pdfReader.getPage(page_num).extractText()
    speaker.say(text)
    speaker.runAndWait()


# In[38]:


speaker.stop()


# In[ ]:




Python module whatismyip




#!/usr/bin/env python
# coding: utf-8

# # Python module to find out your IP address:

# In[2]:


pip install whatismyip


# In[13]:


import whatismyip


# In[14]:


whatismyip.amionline()


# In[15]:


whatismyip.whatismyip()


# In[16]:


whatismyip.whatismyipv4()


# In[17]:


whatismyip.whatismyipv6()


# In[ ]:




Thursday, 17 February 2022

Collections Library in Python



#!/usr/bin/env python
# coding: utf-8

# In[9]:


import collections


# In[10]:


counter=collections.Counter([1,1,2,2,3,3,3,3,4,5,6,7])


# In[11]:


counter


# In[12]:


counter.most_common(1)


# In[13]:


counter.most_common(2)


# In[14]:


counter.most_common(3)


# In[15]:


counter=collections.Counter("clcoding")


# In[16]:


counter


# In[18]:


counter["c"]


# In[19]:


counter.most_common(1)


# In[20]:


counter.most_common(2)


# In[21]:


counter=collections.Counter("ntirawen")


# In[22]:


counter


# In[23]:


counter2=collections.Counter("ntirawen")


# In[24]:


counter2


# In[25]:


counter3=collections.Counter("irawen")


# In[26]:


counter3


# In[27]:


counter2.subtract(counter3)


# In[28]:


counter2


# In[ ]:




Saturday, 5 February 2022

Address detail through python code




#!/usr/bin/env python
# coding: utf-8

# In[22]:


#...Get address detail through python code...!
 
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)

#clcoding.com

# Displaying address details
print("Zipcode:",zipcode)
print("Details of the Zipcode:")
print(location)


# In[ ]:




Track phone number using python




#!/usr/bin/env python
# coding: utf-8

# In[1]:


#.......Track phone number using python....!

import phonenumbers

#import geocoder

from phonenumbers import geocoder

#specify then phone number

a = input("Enter the Phone Number: ")

phonenumber = phonenumbers.parse(a)

#display the location of phone number

print(geocoder.description_for_number(phonenumber,'en'))


# In[2]:


pip install phonenumbers


# In[ ]:




Formatting Dates and Time Strings in Python





#!/usr/bin/env python
# coding: utf-8

# In[1]:


import time as t


# In[2]:


now = t.time()
now


# In[3]:


gmt= t.gmtime(now)


# In[4]:


gmt


# In[5]:


t.strftime("The date is : %y-%m-%d",gmt)


# In[6]:


t.strftime("The date is : %b %d, %y",gmt)


# In[13]:


t.strftime("The time is : %H:%M:%S",gmt)


# In[14]:


t.strftime("It is now %I %M%p",gmt)


# In[15]:


t.strftime("The local time format is: %X", gmt)


# In[16]:


t.strftime("The local date format is: %x", gmt)


# In[ ]:




Python statistics module




#!/usr/bin/env python
# coding: utf-8

# In[ ]:


import statistics as s


# In[3]:


s.mean(range(3))    
#(0+1+2)/3    


# In[7]:


s.median(range(4))
#clcoding.com


# In[8]:


s.median_low(range(4))


# In[9]:


s.median_high(range(4))


# In[10]:


s.median_grouped(range(4))


# In[12]:


s.mode(list(range(4))+[2])


# In[14]:


s.pstdev(list(range(4))+[2])


# In[15]:


s.stdev(list(range(4))+[2])


# In[16]:


s.pvariance(list(range(4))+[2])


# In[17]:


s.variance(list(range(4))+[2])


# In[ ]:




Saturday, 8 January 2022

Popular Python libraries used in Data Science

 Scientific Computing and Statistics

NumPy (Numerical Python)—Python does not have a built-in array data structure. It uses lists, which are convenient but relatively slow. NumPy provides the high-performance ndarray data structure to represent lists and matrices, and it also provides routines for processing such data structures.

SciPy (Scientific Python)—Built on NumPy, SciPy adds routines for scientific processing, such as integrals, differential equations, additional matrix processing and more. scipy.org controls SciPy and NumPy.

StatsModels—Provides support for estimations of statistical models, statistical tests and statistical data exploration.

Data Manipulation and Analysis :

Pandas—An extremely popular library for data manipulations. Pandas makes abundant use of NumPy’s ndarray. Its two key data structures are Series (one dimensional) and DataFrames (two dimensional).


Visualization :

Matplotlib—A highly customizable visualization and plotting library. Supported plots include regular, scatter, bar, contour, pie, quiver, grid, polar axis, 3D and text.

Seaborn—A higher-level visualization library built on Matplotlib. Seaborn adds a
nicer look and feel, additional visualizations and enables you to create visualizations
with less code.


Machine Learning, Deep Learning, and Reinforcement Learning

scikit learn— Top machine learning library. Machine learning is a subset of AI. Deep learning is a subset of machine learning that focuses on neural networks.

TensorFlow—From Google, this is the most widely used deep learning library. TensorFlow works with GPUs (graphics processing units) or Google’s custom TPUs (Tensor processing units) for performance. TensorFlow is important in AI and big data analytics—where processing demands are huge. You’ll use the version of Keras that’s built into TensorFlow.

OpenAI Gym—A library and environment for developing, testing, and comparing reinforcement-learning algorithms.

Natural Language Processing (NLP)

NLTK (Natural Language Toolkit)—Used for natural language processing (NLP)
tasks.

TextBlob—An object-oriented NLP text-processing library built on the NLTK and pattern NLP libraries. TextBlob simplifies many NLP tasks.

Gensim—Similar to NLTK. Commonly used to build an index for a collection of documents, then determine how similar another document is to each of those in the index.

Friday, 31 December 2021

Happy New Year 2022 in Python using Turtle Library



Code:  



import turtle
turtle.setup(1000, 1000, 0, 0)
t = turtle.Turtle()
t.width(12)
t.color("maroon")
s = turtle.getscreen()
t.speed(2)
s.bgcolor("azure")
#clcoding.com
t.left(180)
t.penup()
t.forward(300)
t.right(90)
t.forward(100)
t.pendown()

t.forward(50)
t.right(90)
t.forward(50)
t.left(90)
t.forward(50)
t.left(90)
t.penup()
t.forward(50)
t.left(90)
t.pendown()
t.forward(50)
t.left(90)
t.forward(50)
t.right(90)
t.forward(50)

t.penup()
t.left(90)
t.forward(15)
t.pendown()
t.left(70)
t.forward(110)
t.right(70)
t.right(70)
t.forward(110)
t.left(180)
t.forward(55)
t.left(70)
t.forward(38)
t.left(70)
t.penup()
t.forward(55)
t.left(110)

t.forward(100)
t.left(90)
t.pendown()
t.forward(100)
t.right(90)
t.forward(50)
t.right(20)
t.forward(20)
t.right(70)
t.forward(40)
t.right(70)
t.forward(20)
t.right(20)
t.forward(50)
t.left(90)
t.forward(50)
t.left(90)
t.penup()
t.forward(100)

t.left(90)
t.pendown()
t.forward(100)
t.right(90)
t.forward(50)
t.right(20)
t.forward(20)
t.right(70)
t.forward(40)
t.right(70)
t.forward(20)
t.right(20)
t.forward(50)
t.left(90)
t.forward(50)
t.left(90)
t.penup()
t.forward(100)

t.forward(20)
t.pendown()
t.left(90)
t.forward(50)
t.left(30)
t.forward(60)
t.backward(60)
t.right(60)
t.forward(60)
t.backward(60)
t.left(30)

t.penup()
t.home()
t.color("blue")

t.backward(300)
t.right(90)
t.forward(60)
t.left(180)

t.pendown()
t.forward(100)
t.right(160)
t.forward(100)
t.left(160)
t.forward(100)

t.penup()
t.home()

t.backward(240)
t.right(90)
t.forward(10)
t.pendown()
t.forward(50)
t.left(90)
t.forward(50)
t.backward(50)
t.left(90)
t.forward(100)
t.right(90)
t.forward(50)
t.backward(50)
t.right(90)
t.forward(50)
t.left(90)
t.forward(50)
t.penup()
t.home()

t.backward(150)
t.right(90)
t.forward(60)
t.pendown()
t.backward(100)
t.forward(100)
t.left(120)
t.forward(40)
t.right(60)
t.forward(40)
t.left(120)
t.forward(100)
t.penup()
t.home()

t.backward(30)
t.right(90)
t.forward(65)
t.left(90)

t.pendown()
t.left(90)
t.forward(50)
t.left(30)
t.forward(60)
t.backward(60)
t.right(60)
t.forward(60)
t.backward(60)
t.left(30)

t.penup()
t.home()

t.forward(10)
t.right(90)
t.forward(10)
t.pendown()
t.forward(50)
t.left(90)
t.forward(50)
t.backward(50)
t.left(90)
t.forward(100)
t.right(90)
t.forward(50)
t.backward(50)
t.right(90)
t.forward(50)
t.left(90)
t.forward(50)
t.penup()
t.home()

t.forward(90)
t.right(90)
t.forward(50)
t.left(90)
t.pendown()
t.left(70)
t.forward(110)
t.right(70)
t.right(70)
t.forward(110)
t.left(180)
t.forward(55)
t.left(70)
t.forward(38)
t.left(70)
t.penup()
t.forward(55)
t.left(110)

t.forward(100)
t.penup()
t.home()
t.forward(180)
t.right(90)
t.forward(50)
t.left(180)
t.pendown()
t.forward(100)
t.right(90)
t.forward(50)
t.right(20)
t.forward(20)
t.right(70)
t.forward(40)
t.right(70)
t.forward(20)
t.right(20)
t.forward(50)
t.left(180)
t.forward(50)
t.right(20)
t.forward(20)
t.right(70)
t.forward(40)
t.left(180)
t.penup()
t.home()

t.right(90)
t.forward(215)
t.right(90)
t.forward(170)
t.color("green")
t.penup()
t.home()
t.home()
t.forward(370)
t.pendown()
t.color("magenta")
t.width(3)
t.speed(0)

def squre(length, angle):
    t.forward(length)
    t.right(angle)
    t.forward(length)
    t.right(angle)

    t.forward(length)
    t.right(angle)
    t.forward(length)
    t.right(angle)
squre(80, 90)

for i in range(36):
    t.right(10)
    squre(80, 90)

t.penup()
t.home()
t.left(90)
t.forward(270)
t.left(90)
t.forward(200)
t.pendown()

t.penup()
t.setpos(-270,-120)
t.pendown()
t.pencolor('red')
t.write('Happy New Year 2022 ',font=("Algerian", 24, "normal"))
turtle.mainloop()




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

Popular Posts

Categories

100 Python Programs for Beginner (53) AI (34) Android (24) AngularJS (1) Assembly Language (2) aws (17) Azure (7) BI (10) book (4) Books (173) C (77) C# (12) C++ (82) Course (67) Coursera (226) Cybersecurity (24) data management (11) Data Science (128) Data Strucures (8) Deep Learning (20) Django (14) Downloads (3) edx (2) Engineering (14) Excel (13) Factorial (1) Finance (6) flask (3) flutter (1) FPL (17) Google (34) Hadoop (3) HTML&CSS (47) IBM (25) IoT (1) IS (25) Java (93) Leet Code (4) Machine Learning (59) Meta (22) MICHIGAN (5) microsoft (4) Nvidia (3) Pandas (4) PHP (20) Projects (29) Python (932) Python Coding Challenge (363) Python Quiz (25) Python Tips (2) Questions (2) R (70) React (6) Scripting (1) security (3) Selenium Webdriver (3) Software (17) SQL (42) UX Research (1) web application (8) Web development (2) web scraping (2)

Followers

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