All you need to know about Basics of Python:

What is Python?

Python is an interpreted, object-oriented, high-level programming language, free and open source with dynamic semantics.I know it is difficult to understand these terms.So, let me break down them.So by

Interpreted: means a programming language whose instructions are exceuted directly, without compiling into machine language.

Object-oriented: means a programming language structure wherein the data and their methods are defined as self-contained entities called “objects.”Basically it uses the concept of classes and objects.

High-level programming language: means that a language in which computer instructions are written in a way that is easily understandable and close to human language.

Now, Why Python?

Let’s discuss some of the main features of python:

  1. Easy to Learn: As compared to other languages like Java, C++. Python is very easy to learn as it is straightforward and much the same as the English Language.

2.Expressive Language: As python is same as English language, it can perform tasks in very few lines of code.

As, in java, to print “Hello World”, we need to write some 4–5 lines of code, same in python we need only 1 line to print “hello World” on console.

3.Embeddable: By embeddable means, the code of the other programming language can be used in the Python source code.We can use python code in other programming languages as well.

4. Dynamic Memory Allocation: In python, there is no need to specify data type of a variable.We just need to assign variable and python automatically allocates the memory at run time.

For example: a = 23, that’s it no need of int, string, float anything.

5. Free and Open Source: python is freely available for everyone.You can contribute by downloading its source code without paying.

Python gives you huge amount of options to continue your career in different field.

Popular Python Job Profiles

  • Software Engineer
  • Python Developer
  • Research Analyst
  • Data Analyst
  • Data Scientist
  • Software Developer

There are many more.

Back To Python Basics:

What are the keywords in Python?

Keywords are reserved words that cannot be used as variable names, function names, or any other identifiers.In Python, keywords are case sensitive.

Image for post
Image for post
Keyword In Python

Let’s discuss each of them one by one.

  1. False: True and False are truth values in Python. They are the results of comparison operations or logical operations in Python. For example: You gave any condition like 5>3, it will return True. Same 4=4 return True. 4=0 returns False. True and False in python are same as 1and 0.
Image for post
Image for post

2. None: is an constant that represents that there is a null value.Void functions that do not return anything will return a None object automatically. None is also returned by functions in which the program flow does not contain any return statement.None can be assigned to a variable. For Example: x= None

Image for post
Image for post

3. and: is an logical operator in python. and will result into True only if both the operands are True.

4. not: operator is used to invert the truth value. For Example: Given A results in not A, Given True results in False.

5. or : will result into True if any of the operands is True.

Image for post
Image for post

6. as: is used to create an alias when you are importing any module to your program. It means giving a different name of your choice to a module while importing it. For example: import numpy as np

7. assert: is used to debug a program in a more convinient way. assert is followed by a condition.If the condition is true, nothing happens. But if the condition is false, AssertionError will occur.

Image for post
Image for post

8. break: will end the smallest loop it is in and control flows back to the statement immediately below the loop.

Image for post
Image for post

9. class: is used to define a new user-defined class.

10. continue: causes to end the current iteration of the loop, but not the whole loop.

17. for: is used for looping. Generally we use for when we know the number of times we want to loop.

11. in : is used to test if a sequence (list, tuple, string etc.) contains a value. It returns True if the value is present, else it returns False.

Image for post
Image for post

11. def: is used to define a user-defined function.

12. del: is used to delete the reference to an object. Everything is object in Python, can delete a variable reference using del.

13. if: when you want to test some condition and execute a block only if the condition is true, then we use if.

14. elif : is short for else if, followed by a condition

15. else : is the block which is executed if the condition is false

16. finally: ensures that the block of code inside it gets executed even if there is an unhandled exception.

17. import : keyword is used to import modules into the current namespace.

18. from: from import is used to import specific attributes or functions into the current namespace.

19. global: is used to declare that a variable inside the function is global

20. is: is used in Python for testing object identity. While the == operator is used to test if two variables are equal or not, is is used to test if the two variables refer to the same object.

21. lambda:is used to create an function with no name. It is an inline function that does not contain a return statement. It consists of an expression that is evaluated and returned.

22. nonlocal: is used to declare that a variable inside a nested function is not local to it, meaning it lies in the outside the function.

23. pass: is a null statement in Python. Nothing happens when it is executed. It is used as a placeholder. Suppose we have a function that is not implemented yet, but we want to implement it in the future, So we use pass over there.

24. raise:We can raise an exception explicitly with the raise keyword.

25. return: statement is used inside a function to exit it and return a value.

26. try, except: blocks are used to catch exceptions in Python.

27. while: is used for looping in Python.The statements inside a while loop continue to execute until the condition for the while loop evaluates to False or a break statement is encountered.

28. with: statement is used to wrap the execution of a block of code within methods.

29. yield: is used inside a function like a return statement. But yield returns a generator. Generator is an iterator that generates one item at a time. A large list of values will take up a lot of memory. Generators are useful in this situation as it generates only one value at a time instead of storing all the values in memory.

For more about python.Please visit:

Thanks for giving your valuable time.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store