Tuesday 3 May 2022

Day 28 : Bar Graph using Matplotlib in Python




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

# # Bar Graph using Matplotlib in Python

# In[2]:


import matplotlib.pyplot as pyplot
# Set up the data
labels = ('Python', 'Scala', 'C#', 'Java', 'PHP')
index = (1, 2, 3, 4, 5) # provides locations on x axis
sizes = [45, 10, 15, 30, 22]
# Set up the bar chart
pyplot.bar(index, sizes, tick_label=labels)
# Configure the layout
pyplot.ylabel('Usage')
pyplot.xlabel('Programming Languages')
# Display the chart
pyplot.show() #clcoding.com


# In[ ]:




Day 27 : Pie Charts using Matplotlib in Python

 



#!/usr/bin/env python

# coding: utf-8


# # Pie Charts using Matplotlib in Python


# In[2]:



#Pie Charts using Matplotlib in Python

import matplotlib.pyplot as pyplot

labels = ('Python', 'Java', 'Scala', 'C#')

sizes = [45, 30, 15, 10]

pyplot.pie(sizes,

labels=labels,

autopct='%1.f%%',

counterclock=False,

startangle=105)

# Display the figure

pyplot.show() 

#clcoding.com



# In[ ]:






# In[ ]:





Day 26 : Real time Currency Converter with Python

 



#!/usr/bin/env python

# coding: utf-8


# In[ ]:



pip install forex_python



# # Real-time Currency Converter with Python


# In[7]:



from forex_python.converter import CurrencyRates

c = CurrencyRates()

amount = int(input("Enter the amount: "))

from_currency = input("From Currency: ").upper()

to_currency = input("To Currency: ").upper()

print(from_currency, " To ", to_currency, amount)

result = c.convert(from_currency, to_currency, amount)

print(result)


#clcoding.com



# In[ ]:





Day 24 : Validate Anagrams using Python




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

# # Validate Anagrams using Python

# In[4]:


def anagram(word1, word2):
    word1 = word1.lower()
    word2 = word2.lower()
    return sorted(word1) == sorted(word2)

print(anagram("cinema", "iceman"))
print(anagram("cool", "loco"))
print(anagram("men", "women"))
print(anagram("python", "pythno"))
#clcoding.com


# In[ ]:






Day 23 : Contact Book in Python


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

# # Contact Book in Python

# In[1]:


names = []
phone_numbers = []
num = int(input("Enter no of contact you want to save : "))
for i in range(num):
    name = input("Name: ")
    phone_number = input("Phone Number: ") 
    names.append(name)
    phone_numbers.append(phone_number)
print("\nName\t\t\tPhone Number\n")
for i in range(num):
    print("{}\t\t\t{}".format(names[i], phone_numbers[i]))
search_term = input("\nEnter search term: ")
print("Search result:")
if search_term in names:
    index = names.index(search_term)
    phone_number = phone_numbers[index]
    print("Name: {}, Phone Number: {}".format(search_term, phone_number))
else: #clcoding.com
    print("Name Not Found")
    
#clcoding.com    


# In[ ]:






Day 22 : Pick a Random Card using Python

 



#!/usr/bin/env python

# coding: utf-8


# # Pick a Random Card using Python


# In[8]:



import random

cards = ["Diamonds", "Spades", "Hearts", "Clubs"]

ranks = [2, 3, 4, 5, 6, 7, 8, 9, 10,

         "Jack", "Queen", "King", "Ace"]


def pick_a_card():

    card = random.choices(cards)

    rank = random.choices(ranks)

    return(f"The {rank} of {card}")


print(pick_a_card())


#clcoding.com



# In[ ]:





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[ ]:




Popular Posts

Categories

AI (27) Android (24) AngularJS (1) Assembly Language (2) aws (17) Azure (7) BI (10) book (4) Books (113) C (77) C# (12) C++ (82) Course (60) Coursera (176) coursewra (1) Cybersecurity (22) data management (11) Data Science (85) Data Strucures (6) Deep Learning (9) Django (6) Downloads (3) edx (2) Engineering (14) Excel (13) Factorial (1) Finance (5) flutter (1) FPL (17) Google (18) Hadoop (3) HTML&CSS (46) IBM (25) IoT (1) IS (25) Java (92) Leet Code (4) Machine Learning (43) Meta (18) MICHIGAN (4) microsoft (3) Pandas (3) PHP (20) Projects (29) Python (726) Python Coding Challenge (169) Questions (2) R (70) React (6) Scripting (1) security (3) Selenium Webdriver (2) Software (17) SQL (40) UX Research (1) web application (8)

Followers

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