# Day 71 : Gif Creation in Python

import imageio

filenames = ["1.png","3.png","4.png"]

#you can add any type of image

images = []

for filename in filenames:

imageio.mimsave('ritesh1.gif', images,'GIF',duration=1)

#clcoding.com

# Day 70 : Program to swap first and last element of a list

# 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]```

# Day 69 : Function to find permutations of a given string

# 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```

# Day 68 : Python program to find compound interest

# 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```

# Day 67 : Python program to add two numbers

# Python program to add two numbers

number1 = input("First number: ")

number2 = input("Second number: ")

# 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

# Day 66 : Floyd's Triangle in Python using for loop

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 ```

# Day 65 : Python program to find the factorial of a number

# To take input from the user

num = int(input("Enter a number : "))

factorial = 1

# check if the number is negative, positive or zero

if num < 0:

print("Sorry, factorial does not exist for negative numbers")

elif num == 0:

print("The factorial of 0 is 1")

else:

for i in range(1,num + 1):

factorial = factorial*i

print("The factorial of",num,"is",factorial)

#clcoding.com

```Enter a number : 6
The factorial of 6 is 720```

# Day 64 : Program to Create a Countdown Timer

import time

def countdown(time_sec):

while time_sec:

mins, secs = divmod(time_sec, 60)

timeformat = '{:02d}:{:02d}'.format(mins, secs)

print(timeformat, end='\r')

time.sleep(1)

time_sec -= 1

print("stop")

num=int(input("Set Your Timer in Sec : "))

countdown(num)

#clcoding.com

```Set Your Timer in Sec : 10
stop1```

# Day 63 : Python Program to Remove Punctuations From a String

# define punctuation

punctuations = '''!()-[]{};:'"\,<>./?@#\$%^&*_~'''

# To take input from the user

my_str = input("Enter Your String : ")

# remove punctuation from the string

no_punct = ""

for char in my_str:

if char not in punctuations:

no_punct = no_punct + char

#clcoding.com

# display the unpunctuated string

print(no_punct)

```Enter Your String : " I love Python"!
I love Python```

# Day 62 : Python Program to find the factors of a number

# Python Program to find the factors of a number

# This function computes the factor of the argument passed

def print_factors(x):

print("The factors of",x,"are:")

for i in range(1, x + 1):

if x % i == 0:

print(i)

num=int(input("Enter a Number to find the Fators : "))

print_factors(num)

#clcoding.com

```Enter a Number to find the Fators : 26
The factors of 26 are:
1
2
13
26```

# Day 61 : Python Program to Print the Fibonacci sequence

# Program to display the Fibonacci sequence up to n-th term

nterms = int(input("How many terms? "))

# first two terms

n1, n2 = 0, 1

count = 0

# check if the number of terms is valid

if nterms <= 0:

# if there is only one term, return n1

elif nterms == 1:

print("Fibonacci sequence upto",nterms,":")

print(n1)

# generate fibonacci sequence

else:

print("Fibonacci sequence:")

while count < nterms:

print(n1)

nth = n1 + n2

# update values

n1 = n2

n2 = nth

count += 1  #clcoding.com

```How many terms? 7
Fibonacci sequence:
0
1
1
2
3
5
8```

# Day 60 : Python Program to Check Armstrong Number

# take input from the user

num = int(input("Enter a number: "))

# initialize sum

sum = 0

# find the sum of the cube of each digit

temp = num

while temp > 0:

digit = temp % 10

sum += digit ** 3

temp //= 10

# display the result

if num == sum:

print(num,"is an Armstrong number")

else:

print(num,"is not an Armstrong number")

#clcoding.com

```Enter a number: 477
477 is not an Armstrong number```

# Day 59 : PDF file protection using password

#pip install PyPDF2

import getpass

pdfwriter=PdfFileWriter()

for page_num in range(pdf.numPages):

with open('E:\\clcoding.pdf','wb') as f:

pdfwriter.write(f)

#clcoding.com

```Enter Password: ········

# Day 58 : Scatter Plot using Matplotlib in Python

import matplotlib.pyplot as pyplot

# Create data

riding = ((17, 18, 21, 22, 19, 21, 25, 22, 25, 24),(3, 6, 3.5, 4, 5, 6.3, 4.5, 5, 4.5, 4))

swimming = ((17, 18, 20, 19, 22, 21, 23, 19, 21, 24),(8, 9, 7, 10, 7.5, 9, 8, 7, 8.5, 9))

sailing = ((31, 28, 29, 36, 27, 32, 34, 35, 33, 39),(4, 6.3, 6, 3, 5, 7.5, 2, 5, 7, 4))

# Plot the data

pyplot.scatter(x=riding[0], y=riding[1], c='red', marker='s',label='riding')

pyplot.scatter(x=swimming[0], y=swimming[1], c='green',marker='o', label='swimming')

pyplot.scatter(x=sailing[0], y=sailing[1], c='blue',marker='*', label='sailing')

# Configure graph

pyplot.xlabel('Age')

pyplot.ylabel('Hours')

pyplot.title('Activities Scatter Graph')

pyplot.legend()

pyplot.show()

#clcoding.com

# Day 57 : Number guessing game in Python

import random

import math

lower = int(input("Enter Lower bound:- "))

upper = int(input("Enter Upper bound:- "))

# generating random number between the lower and upper

x = random.randint(lower, upper)

print("\n\tYou've only ",round(math.log(upper - lower + 1, 2)),

" chances to guess the integer!\n")

# Initializing the number of guesses.

count = 0                              #clcoding.com

# for calculation of minimum number of guesses depends upon range

while count < math.log(upper - lower + 1, 2):

count += 1

# taking guessing number as input

guess = int(input("Guess a number:- "))

# Condition testing

if x == guess:

print("Congratulations you did it in ",count, " try")

break

elif x > guess:

print("You guessed too small!")

elif x < guess:

print("You Guessed too high!")

# shows this output.

if count >= math.log(upper - lower + 1, 2):

print("\nThe number is %d" % x)

print("\tBetter Luck Next time!")

```Enter Lower bound:- 1
Enter Upper bound:- 10

You've only  3  chances to guess the integer!

Guess a number:- 6
Congratulations you did it in  1  try```

# Day 55 : Assign a value to a key in Python

d={'a':1,'b':2,'c':4}

# d is a dictionary

d['c']=3

#to modify the existing vlaue

d['d']=4

#to create a key value pair in the dictionary

print(d)

#clcoding.com

{'a': 1, 'b': 2, 'c': 3, 'd': 4}

# Day 54 : Calculate a hash of a file

import hashlib

BLOCKSIZE = 65536

# Block read size if file is big enough

fileToOpen = 'E:\\new_python\\new_doc2.txt'

hasher = hashlib.md5()

with open(fileToOpen, 'rb') as afile:

while len(buf) > 0:

hasher.update(buf)

print(hasher.hexdigest())

#clcoding.com

`d41d8cd98f00b204e9800998ecf8427e`

# Day 53 : Count number of files and directories

import os

# Path IN which we have to count files and directories

PATH = 'E:\elements'   # Give your path here

fileCount = 0

dirCount = 0

for root, dirs, files in os.walk(PATH):

print('Looking in:',root)

for directories in dirs:

dirCount += 1

for Files in files:

fileCount += 1

#clcoding.com

print('Number of files',fileCount)

print('Number of Directories',dirCount)

print('Total:',(dirCount + fileCount))

```Looking in: E:\elements
Looking in: E:\elements\New folder
Number of files 8
Number of Directories 1
Total: 9```

# Day 52 : Primes Numbers smaller than or equal to the Number

def SieveOfEratosthenes(n):

primes = [True] * (n + 1)

p = 2             # because p is the smallest prime

while(p * p <= n):

# if p is not marked as False, this it is a prime

if(primes[p]) == True:

# mark all the multiples of number as False

for i in range(p * 2, n + 1, p):

primes[i] = False

p += 1

# printing all primes

for i in range(2, n):

if primes[i]:

print(i)

if __name__ == '__main__':

n=int(input("Enter a no to check all smaller prime numbers :"))

SieveOfEratosthenes(n)

#clcoding.com

```Enter a no to check all smaller prime numbers :20
2
3
5
7
11
13
17
19```

# Day 51 : Perfect number verification in Python

def perfectNumber(number):

sum = 0

for x in range(1, number):

if number % x == 0:

sum += x

return sum == number

if __name__ == '__main__':

n=int(input("Enter a number to check : "))

print(perfectNumber(n))

#clcoding.com

```Enter a number to check : 6
True```

# Day 50 : Progress Bar in Python

import sys, time

def progressBar(count, total, suffix=''):

barLength = 60

filledLength = int(round(barLength * count / float(total)))

percent = round(100.0 * count / float(total), 1)

bar = '=' * filledLength + '-' * (barLength - filledLength)

sys.stdout.write('[%s] %s%s ...%s\r' % (bar, percent, '%', suffix))

sys.stdout.flush()

for i in range(10):

time.sleep(1)

progressBar(i, 10)

#clcoding.com

[======================================================------] 90.0% ...

# Day 49 : Insertion sort using Python

def insertionSort(List):

for i in range(1, len(List)):

currentNumber = List[i]

for j in range(i - 1, -1, -1):

if List[j] > currentNumber :

List[j], List[j + 1] = List[j + 1], List[j]

else:

List[j + 1] = currentNumber

break

return List

if __name__ == '__main__':

List = [3,7,2,8,4,1,9,5]

print('Sorted List:',insertionSort(List))

#clcoding.com

Sorted List: [1, 2, 3, 4, 5, 7, 8, 9]

# Day 48 : Bubble sort using Python

def bubbleSort(List):

for i in range(len(List)):

for j in range(len(List) - 1, i, -1):

if List[j] < List[j - 1]:

List[j], List[j - 1] = List[j - 1], List[j]

return List

if __name__ == '__main__':

List = [7,1,8,2,9,4,6,5]

print('Sorted List:',bubbleSort(List))

#clcoding.com

Sorted List: [1, 2, 4, 5, 6, 7, 8, 9]

# Day 47 : Selection sort in Python

def selectionSort(List):

for i in range(len(List) - 1): #For iterating n - 1 times

minimum = i

for j in range( i + 1, len(List)): # Compare i and i + 1 element

if(List[j] < List[minimum]):

minimum = j

if(minimum != i):

List[i], List[minimum] = List[minimum], List[i]

return List

if __name__ == '__main__':

List = [4,6,9,8,1,7,3]

print('Sorted List:',selectionSort(List))

#clcoding.com

Sorted List: [1, 3, 4, 6, 7, 8, 9]

# Day 46 : Get Zip Code with given location using GeoPy in Python

from geopy.geocoders import Nominatim

geolocator = Nominatim(user_agent="geoapiExercises")

place=input("Enter City Name: ")

location = geolocator.geocode(place)

print(location)

#clcoding.com

Enter City Name: Aundh

Aundh, Pune City, Pune, Maharashtra, 411027, India

import pytube

#Ask for the url of video

url = input("Enter video url: ")

#specify the starage path of video

path="E:"

#clcoding.com

# Day 44 : Voice Recorder in Python

#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

Enter the Recording Time in second: 11

Recording....

Recording is done Please check you folder to listen recording

# Day 43 : Search anything in Python

pip install pywhatkit

import pywhatkit as kit

searchitem=(input("Enter the topic : "))

kit.info(searchitem,100)

#clcoding.com

```Enter the topic : Python Coding
Python is a high-level, interpreted, general-purpose programming language. Its design philosophy emphasizes code readability with the use of significant indentation.Python is dynamically-typed and garbage-collected. It supports multiple programming paradigms, including structured (particularly procedural), object-oriented and functional programming. It is often described as a "batteries included" language due to its comprehensive standard library.Guido van Rossum began working on Python in the late 1980s as a successor to the ABC programming language and first released it in 1991 as Python 0.9.0. Python 2.0 was released in 2000 and introduced new features such as list comprehensions, cycle-detecting garbage collection, reference counting, and Unicode support. Python 3.0, released in 2008, was a major revision that is not completely backward-compatible with earlier versions. Python 2 was discontinued with version 2.7.18 in 2020.Python consistently ranks as one of the most popular programming languages.

== History ==

Python was conceived in the late 1980s by Guido van Rossum at Centrum Wiskunde & Informatica (CWI) in the Netherlands as a successor to  the ABC programming language, which was inspired by SETL, capable of exception handling and interfacing with the Amoeba operating system. Its implementation began in December 1989. Van Rossum shouldered sole responsibility for the project, as the lead developer, until 12 July 2018, when he announced his "permanent vacation" from his responsibilities as Python's "benevolent dictator for life", a title the Python community bestowed upon him to reflect his long-term commitment as the project's chief decision-maker.
```
In [ ]:

# Day 42 : Email Slicer in Python

email = input("Enter Your Email: ")

#remove any unnecessary white spaces

email=email.strip()

#Get the index of @

slicer_index=email.index("@")

#fetch the user name by string slicing

#fetch the domain name by string slicing

domain_name = email[slicer_index+1:]

#print the result separatly

#clcoding.com

```Enter Your Email: pythonclcoding@gmail.com

# Day 41: Image to Pencil Sketch in Python

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

import cv2

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

# 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)

#clcoding.com

#closing all open windows

cv2.destroyAllWindows()

# Day 40 : Calculation of Execution Time of a Python Program

from time import time

start = time()

#code start

email = input("Enter Your Email: ")

email=email.strip()

slicer_index=email.index("@")

domain_name = email[slicer_index+1:]

#code end

#clcoding.com

end = time()

execution_time = end - start

print("Execution Time (s) : ", execution_time)

```Enter Your Email: avc@123
Execution Time (s) :  7.258544206619263```

# Day 39 : Code and Decode QR in Python

import pyqrcode

import png

qr_code.png("instagram1.png", scale=5)

#clcoding.com

from pyzbar.pyzbar import decode

from PIL import Image

decocdeQR = decode(Image.open('instagram1.png'))

print(decocdeQR[0].data.decode('ascii'))

#clcoding.com

# Day 38 : Scrape Table from a Website using Python

import urllib.request

import pandas as pd

#List of publicly listed ITES companies of India

url = "https://en.wikipedia.org/wiki/List_of_publicly_listed_ITES_companies_of_India"

with urllib.request.urlopen(url) as i:

#clcoding.com

```               Company       Listed  Founded            Revenue  \
0  3i Infotech Limited  BSE: 532628     1993     US\$239 million
1     HCL Technologies  BSE: 532281     1976    US\$5.36 billion
2              Infosys  BSE: 500209     1981    US\$8.24 billion
3    KPIT Technologies  BSE: 532400     1990  US\$444.32 million
4               Mastek  BSE: 523704     1982  US\$150.43 million

0  US\$84 million (2014)      9000       [1]
1                   NaN    197777       [2]
2       US\$1.75 billion    169638       [3]
3                   NaN     10291       [4]
4       US\$8.37 million      3352       [5]  ```

# Day 37 : Sequence Matcher in Python

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

```Enter 1st sentence : I love Python
Enter 2nd sentence : Python is easy
Both are 44.44444444444444 % similar```

# Day 36 : Remove Cuss Words using Python

pip install better_profanity

from better_profanity import profanity

text = input("Enter your sentence to check : ")

censored = profanity.censor(text)

print(censored)

#clcoding.com

```Enter your sentence to check : go to hell
go to ****```

# Day 35 : Create Font Art using Python

pip install pyfiglet

import pyfiglet

font = pyfiglet.figlet_format('Python Coding')

print(font)

#clcoding.com

``` ____        _   _                    ____          _ _
|  _ \ _   _| |_| |__   ___  _ __    / ___|___   __| (_)_ __   __ _
| |_) | | | | __| '_ \ / _ \| '_ \  | |   / _ \ / _` | | '_ \ / _` |
|  __/| |_| | |_| | | | (_) | | | | | |__| (_) | (_| | | | | | (_| |
|_|    \__, |\__|_| |_|\___/|_| |_|  \____\___/ \__,_|_|_| |_|\__, |
|___/                                                  |___/ ```

# Day 34 : Full Diamond Pattern in Python

rows = int(input("Enter Diamond Pattern Rows = "))

print("Diamond Star Pattern")

for i in range(1, rows + 1):

for j in range(1, rows - i + 1):

print(end = ' ')

for k in range(0, 2 * i - 1):

print('*', end = '')

print()

for i in range(1, rows):

for j in range(1, i + 1):

print(end = ' ')

for l in range(1, (2 * (rows - i) )):

print('*', end = '')

print()

#clcoding.com

```Enter Diamond Pattern Rows = 6
Diamond Star Pattern
*
***
*****
*******
*********
***********
*********
*******
*****
***
*```

# Day 33 : Python code for Pascal's Triangle

def printPascal(N):

arr = [1]

temp = []

print("pascal's triangle of", N, "Rows...")

for i in range(N):

print("rows", i+1, end=" : ")

for j in range(len(arr)):

print(arr[j], end=' ')

print()        #clcoding.com

temp.append(1)

for j in range(len(arr)-1):

temp.append(arr[j] + arr[j + 1])

temp.append(1)

arr = temp

temp = []

N=int(input("Enter the Number for the pascal triangle :"))

printPascal(N)

```Enter the Number for the pascal triangle :4
pascal's triangle of 4 Rows...
rows 1 : 1
rows 2 : 1 1
rows 3 : 1 2 1
rows 4 : 1 3 3 1 ```

# Day 32 : Resistor Color Code detection using Python

color=["black","brown","red","orange","yellow"

,"green","blue","violet","grey","white"]

n=color.index((input("Enter the 1st color :")))

m=color.index((input("Enter the 2nd color :")))

p=color.index((input("Enter the 3rd color :")))

q=int(((n*10)+(m))*(10**(p)))

z=q/1000

#clcoding.com

print("\nThe Resister Value Is :")

print(f"{q}Ω  and in Kiloohm :  {z}kΩ")

```Enter the 1st color :green
Enter the 2nd color :grey
Enter the 3rd color :blue

The Resister Value Is :
58000000Ω  and in Kiloohm :  58000.0kΩ```

# Day 31 : Radar Plot using Python

import plotly.express as px

import pandas as pd

data = pd.DataFrame(dict(keys=[10, 20, 30, 40],

values=["Labour Cost", "Manufacturing Cost", "Promotion Cost", "Selling Cost"]))

figure = px.line_polar(data, r='keys', theta='values', line_close=True)

figure.update_traces(fill="toself")

figure.show() #clcoding.com

## Categories

Android (23) AngularJS (1) Books (10) C (75) C# (12) C++ (81) Course (1) Downloads (1) Engineering (13) flutter (1) FPL (17) Hadoop (1) HTML&CSS (38) IS (25) Java (89) Leet Code (4) Pandas (1) PHP (20) Projects (19) Python (401) R (69) Software (14) SQL (27)