Python Basics (Learn python right away now)

Python is considered as a base or startup language for new programmers because of its simplicity, ease to write English sentence like syntax. Syntax is basically structure and set of rules for programming language such as we have English, Hindi, or Urdu. Each programming language has a different syntax. In this article we will go through some basics of python and we will write our first code

Print Function(Output)

So, we will start with the first code to print hello python on the screen. To tell computer In python to write some text to the screen we have to use keyword print like this

Print(“Hello Python”)

Print() is a built-in function in Python to display things on screen. Built-in function is predefined in the language and can be used directly. Now let us run this on the IDE or CMD whatever your preference is. Remember whatever you want to display remains in quotes “ “.

Congratulations we have written our first python program. Give it a try yourself!


Now the next thing is comments. Comments are basically written so that the function performed could be understood easily. For example, you multiplied two numbers in your code, so you write that here I multiplied some numbers for some other function I want to perform   to remind yourself when you open your code again. Comments are optional but an important part and good programming practice. How to write comments in python? Well let us see here.

Any sentence followed by a “ # ” is comment. Comments do not affect program flow as they are ignored by compiler.

Data types

Data type is attribute of data that defines which type of value(s) data possess or what is the type of data on which we will perform functions. Is it a number, sentence or characters?

Python has various data types like other languages. That provide support to different types to data. Most used data types are

    1. Floating number
    2. Character
    3. String
    4. Long INT
    5. Boolean (True or False)
    6. Integer (int)


Next thing is variables. In programming variables are used to store some values such as a bottle is used to store water, or a box is used to store something just like that. These values can be either numbers, alphabets, sentence, characters etc. Python is smart enough to understand what type your variable does store when it is declared despite other languages in which you must mention for example in C++to store integer in variable you have to mention int. To store a value in variable in python we use

Variable name = value to be stored

Let us do this. Here a is variable name and 60 is value stored in it.

Another example

NOTE: to store string we must write inside double quotes such as “c” variable value as in the example

User input

Let us consider you are writing a program to multiply two numbers; how will you know those two numbers? Either you will assign two numbers yourself or you will ask user of your program to assign two number to get data from user . So how you can do that? Let us understand this with an example.

Note: Remember while programming you must keep in mind that you are developing the program for user so think from user perspective

In this example we asked user to input First number and second number for which he want multiplication. Then simply multiplied two variables in which user input was taken by using Input() function as explained earlier

Remember while using the variables we must define their type such as we defined integer type in above example. It is python language rule to define the type while using variables unlike other languages which require to define type while declaration of variable

(Visited 194 times, 1 visits today)

0 0 votes
Article Rating
Notify of
Inline Feedbacks
View all comments
Ask ChatGPT
Set ChatGPT API key
Find your Secret API key in your ChatGPT User settings and paste it here to connect ChatGPT with your Tutor LMS website.
Would love your thoughts, please comment.x