Skip to main content

Command Palette

Search for a command to run...

Python Learn : Day 1

Updated
•4 min read•View as Markdown
V

DevOps Engg.

Hey there, my name is Vishal, and I'm a DevOps Engineer. I'm upskilling myself, so here I am documenting everything related to my Python learning journey. I hope you will enjoy this article.

Day 1 : Introduction to Python

What is Programming

Programming is a way for us to tell computers what to do. Computer is a very dumb machine and it only does what we tell it to do. Hence we learn programming and tell computers to do what we are very slow at - computation. If I ask you to calculate 5+6, you will immediately say 11. How about 23453453 X 56456?

You will start searching for a calculator or jump to a new tab to calculate the same.

Object-Oriented Programming (OOP):

OOP is a programming paradigm that models software design using objects, which have attributes (data) and methods (behaviors). It involves classes, encapsulation, inheritance, and polymorphism.

Imagine you are running a zoo. Each type of animal in your zoo can be seen as an object, and the class represents the type of animal. For instance:

  • Classes: You have classes like "Lion," "Elephant," and "Giraffe," each describing the characteristics and behaviors of that specific type of animal.

  • Encapsulation: Think of each animal being housed in its own enclosure. Encapsulation in OOP is like bundling the details about each animal (data) and their actions (methods) within their enclosure. This way, you keep the information about lions separate from that of elephants.

  • Inheritance: Now, imagine you introduce a new type of animal, say a "Zookeeper." This class can inherit some features from the "Person" class, like the ability to speak and walk. It's like creating a new Lego piece with features from an existing one.

  • Polymorphism: When you instruct all the animals in the zoo to "make a sound," each animal responds differently based on its type. The same command (method call) produces distinct results for lions, elephants, and giraffes.

Functional Programming (FP):

FP is a programming paradigm that treats computation as the evaluation of pure functions, emphasizing immutability, side-effect-free operations, and concepts like higher-order functions and recursion.

Now, think of the tasks you need to manage in the zoo as functions or procedures, each with a specific purpose.

  • Pure Functions: Each task is like a recipe that, given specific ingredients, always produces the same result. For example, feeding the animals is a pure function – the same amount of food given to the same animal always produces the same result.

  • Immutability: Once you've assigned a specific diet to an animal, you don't change it. It's like setting the rules for the zoo and not altering them once they're established.

  • Higher-Order Functions: Now, imagine you have a function that decides what food to give based on the type of animal. This function takes in another function (the specific diet for each animal) and uses it to determine the appropriate food. This is similar to a higher-order function.

  • Recursion: If you have a task like counting the total number of animals in the zoo, instead of walking through each enclosure one by one, you might have a function that counts the animals in one enclosure and calls itself for each additional enclosure.

In summary, OOP is like managing a zoo where each animal is an object with specific characteristics, while FP is like efficiently handling various tasks in the zoo using well-defined functions and rules. Both approaches have their strengths and are chosen based on the problem at hand.

What is Python?

  • Python is a dynamically typed, general purpose programming language that supports an object-oriented programming approach as well as a functional programming approach.

  • Python is an interpreted and a high-level programming language.

  • It was created by Guido Van Rossum in 1989.

Features of Python

  • Python is simple and easy to understand.

  • It is Interpreted and platform-independent which makes debugging very easy.

  • Python is an open-source programming language.

  • Python provides very big library support. Some of the popular libraries include NumPy, Tensorflow, Selenium, OpenCV, etc.

  • It is possible to integrate other programming languages within python.

What is Python used for

  • Python is used in Data Visualization to create plots and graphical representations.

  • Python helps in Data Analytics to analyze and understand raw data for insights and trends.

  • It is used in AI and Machine Learning to simulate human behavior and to learn from past data without hard coding.

  • It is used to create web applications.

  • It can be used to handle databases.

  • It is used in business and accounting to perform complex mathematical operations along with quantitative and qualitative analysis.

Lab1 :

lab1.txt

print ("hello vishalk17")

\==============

Special Thanks to ,

More from this blog

Vishalk17 DevOps

14 posts