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

Monday 29 November 2021

Numpy In Python

Introduction to NumPy

•   NumPy is a Python package and it stands for numerical python
•   Fundamental package for numerical computations in Python
•   Supports N-dimensional array objects that can be used for processing multidimensional data
•   Supports different data-types

Array

•   An array is a data structure that stores values of same data type
•   Lists can contain values corresponding to different data types,
•   Arrays in python can only contain values corresponding to same data type


NumPy Array


•   A numpy array is a grid of values, all of the same type, and is indexed by a tuple of 
nonnegative integers
•   The number of dimensions is the rank of the array
•   The shape of an array is a tuple of integers giving the size of the array along each dimension

Creation of array


To create numpy array, we first need to import the numpy package:




Some Operations on Numpy array











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

Saturday 27 November 2021

Sequence Data Part 5 | Day 9 | General Sequence Data Methods | Part I


General Sequence Data Methods | Part I


Some of the methods that we can apply on any sequential data.

So basically Python methods are like a Python function, but it must be called on an object.
And Python also has a set of built in methods that you can use on sequential data, but note that the method is going to written new values, but they are not going to change the original data at all. So we are going to look at few examples on how we can call the methods on the given sequential data
.





First I am creating a string for strsample which has a string to with that is learning is fun. So let
me first print and show you. So, the strsample contains string learning is fun.

String Methods


1) .capitalize() - So let us try to call some of the methods on the string but note here all string method returns new value. We do not change the original string. First we are going to look here is method capitalise and it is going to return the string with the first character capitalise. So let us just try this. So initially it was learning is fun and lowercase and now it is learning is fun with the upper case L.





2) .title() - Next one is title, basically capitalise the first character of each word. So if you have a sequence of values, if you have a string if you have set of strings in your data and if you want to do some of the operations like this then you can use all these methods on your string. So for example now, if you want to capitalise the first character of each word, then you can use title method in that case. So, it is going to written the values by capitalising the first character alone.





3) .swapcase() - And thus a method calls what case which is going to swap the
case of strings. So if it is a lowercase string then it is going to swap it to make it as uppercase string. So the original string had the learning is fun in all lowercase letters, but just what all the characters to uppercase.



4) .find()
And you can also find the index of a given letter, for example, if you want to particularly know the index of a given character then you can give that inside the find method. So that should be given the single quote. So the index of n is 4.




5) .count() - So if you want to count the total number of particular letter in a given string then you can use the count method. And inside the count method you can just give the desired string value. So that is one because a is present only ones. For example here is there in the word learning only once



6) .replace() - Using the method replace you will be able to replace any word with the given word. For example, you can apply or you can call that on the string and that is strsample and inside method you can just give string to be searched that is fun. So we are searching for the word fun in the strsample string and I am going to replace fun with joyful. So let me just try this. So you are getting learn is joyful. Instead of getting learn is fun which was the original string.




The below code will show all the functions that we can use for the particular variable:




len(object) returns number of elements in the object











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

Friday 26 November 2021

Java Oops Concept

Java Oops Concept:

1.       Objects

2.       Class

3.       Inheritance

4.       Polymorphism

5.       Abstraction

6.       Encapsulation

Object :

Any entity that has state and behaviour is known as an Object.

An object can be defined as an instance of a class.

Example :

Object = {property 1: value1, property 2: value 2……property n: value n}

Class :

  • Collection of object is called class.
  • It is a logical entity
  • Class doesn’t consume any space.
  • A class can also be defined as a blueprint from which you can create an individual object.

 

 

Inheritance :

When one object acquires all the properties and behaviours of a parent object, it is known as inheritance.

It provides code reusability.

It is a used to achieve runtime polymorphism.

 

Polymorphism :

If one task is performed in different way, it is known as polymorphism.

In java we use method overloading and method overriding.

 

Abstraction :

Hinding internal details and showing functionality is known as abstraction.

 

Encapsulation :

Binding or wrapping code and data together into a single unit are known as encapsulation.

Naming Convention :

1.     Class

    . It should start with the uppercase letter.

  It should be a noun such as Color, Button, System, Thread, etc.
Use appropriate words, instead of acronyms.

Example :

Public class Employee {

//code snippet

}

 

2.     Interface

It should start with the uppercase letter.

It should be an adjective such as Runnable, Remote, ActionListener.

Use appropriate words, instead of acronyms.

 

Example :

 

Interface Printable

{

//code snippet

}

3.     Method

It should start with lowercase letter.
It should be a verb such as main(), print(), println().
If the name contains multiple words, start it with a lowercase letter followed by an uppercase letter such as actionPerformed().

Example :

Class Employee

{

//method

Void get( )

{

//code snippet

}

}

4.     Variables

It should start with a lowercase letter such as id, name.

It should not start with the special characters like & (ampersand), $ (dollar), _ (underscore).

If the name contains multiple words, start it with the lowercase letter followed by an uppercase letter such as firstName, lastName.

Avoid using one-character variables such as x, y, z.

Example :

Class Employee

{

// variables

Int id;

Char name;

}

5.     Package

It should be a lowercase letter such as java, lang.
If the name contains multiple words, it should be separated by dots (.) such as java.util, java.lang.

Example :

Package com.abc.xyz;

Class employee

{

//code

}

 

6.     Constant

It should be in uppercase letters such as RED, YELLOW.

If the name contains multiple words, it should be separated by an underscore(_) such as MAX_PRIORITY.

It may contain digits but not as the first letter.

Example :

Class Employee

{

//constant

Static final int MIN_Age = 18;

//code

}

Object and class Example:

Public class Student {

Int id ;

String name;

Public static void main (String[] args)

{

Student s1 = new Student();

System.out.println(s1.id);

System.out.println(s1.name);

}

}

Syntax of class :

Class <class_name>{

Field;

Method;

}

 

Class Student {

Int rollno;

String name;

Void insertRecord(int r, String n)

{

Rollno = r;

Name = n;

}

Void display()

{

System.out.println(rollno+ “ “ +name);

}

Class StudentTest {

Public static void main (String[] args)

{

Student s1 = new student();

Student s2 = new Student();

S1.insertRecord(101, “Ram”);

S2.insertRecord(102, “Sita”);

S1.display();

S2.display();

}

}

 

Class Student {

Int id;

String name;

}

Class StudentTest {

Public static void main (String arg[])

{

Student s1 = new Student();

Student s2 = new student();

S1.id = 101;

S1.name = “Ram”;

S2.id = 102;

S2.name = “Sita”;

System.out.println(s1.id+ “ “ s1.name);

System.out.println(s2.id+ “ “ s2.name);

}

}

Popular Posts

Categories

AI (27) Android (24) AngularJS (1) Assembly Language (2) aws (17) Azure (7) BI (10) book (4) Books (120) C (77) C# (12) C++ (82) Course (64) Coursera (182) Cybersecurity (24) data management (11) Data Science (98) Data Strucures (6) Deep Learning (10) Django (6) Downloads (3) edx (2) Engineering (14) Excel (13) Factorial (1) Finance (6) flutter (1) FPL (17) Google (19) Hadoop (3) HTML&CSS (46) IBM (25) IoT (1) IS (25) Java (92) Leet Code (4) Machine Learning (46) Meta (18) MICHIGAN (5) microsoft (4) Pandas (3) PHP (20) Projects (29) Python (772) Python Coding Challenge (256) 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