Python in 2 minute read

Awang Trisakti
2 min readMar 25, 2023
Image from https://towardsdatascience.com/the-zen-of-python-a-guide-to-pythons-design-principles-93f3f76d088a

Python is a high level interpreted general purpose programming language that created by Guido Van Rossum and released in 1991. Python commonly used for created a server side web application with frawework such as django, data analysis and also machine learning. Python designed as emphasized code readability with the use of indentation to determine or terminate the scope of a line of code, which is different from most cases programming languages which use brackets.

Getting started
To getting started, install python and create a py file

# This is a comment. comments are ignored by the interpreter

# Declare a variable
hello = "hello world"

# It allows you to define multiple variables in one line
a, b, c = 1, 2, 3

# Print the variable
print(hello)
# Define a function
def say_hello(time):
# If statements
if time < 12:
print("Good morning!")
else:
print("Good evening!")

# Python also allow you to use a anonymous function called lambda
# This lambda takes two arguments and returns the sum of them
sum = lambda a, b: a + b
result = sum(1, 2)

print(result)
# Will print 3
say_hello(result)
# Will print "Good morning!"

Python also support creation of classes and object that will allows you to use Object Oriented Programming.

# Create class Cat
class Cat():
# Create constructor
def __init__(self, name, age):
super().__init__(name)
self.age = age
# Create method
def __str__(self):
return f"{self.name} is {self.age} years old"

# Create object
cat = Cat("Garfield", 10)
# Print object
print(cat)
# Will print "Garfield is 10 years old"

Run the py file

Thank you for read my post, please feel free to leave comments for any suggestions or questions. Share if you find this post useful. See ya

References
-
https://en.wikipedia.org/wiki/Python_(programming_language)
- https://docs.python.org/3/tutorial/datastructures.html
- https://corporatefinanceinstitute.com/resources/data-science/python-data-structures/
- https://www.youtube.com/watch?v=x7X9w_GIm1s

--

--