You can type python download the google search engine
It is derived from many languages like C, C++, ABC, Algorithm68 and some other languages. The source code for Python is available under the GNU General Public License (GPL).
Let us try to look at some of the reasons which helped python in gaining such popularity and that too so fast.
Let us have a look at the features that are provided by python.
It is very easy to learn as it has fewer keywords, the structure is simple which makes it easy to learn the language.
It enables the user to create GUI based applications which could be ported into libraries like windows MFC or the windows X system for Unix.
In the coming tutorials, we shall be focusing more onto Python, its uses and learn how to write our code in Python. It is advisable that you should have some knowledge about programming, for that you can refer to our tutorial on computer programming. We will try to make it an easy and fun experience.
Let us look at some ways which we can use in order to operate Python in our system.
First, you need to install python on your computer. For that, you need to download Python. You can type python download in the google search engine. You will see an option by the name python.org which is the site where you can get information like codes, documentations, news etc. in short, you can get each and everything related to python on this website.
Let us see how we can set the path for Python.
For windows:
Open the bash shell
Over their type, export PATH =” $PATH:/usr/files/program/bin/python”. After that press enter.
After following the above steps, this is the result that you will get (for windows).
Visual studio code
Anaconda
In this tutorial we shall be looking at the syntax of how to code in Python.
It is one of the easiest ways in which one can compile a program.
After this, let us see what we need to type in order to achieve our target that is, to print Hello World on the screen.
It is very simple; all you need to do is just type:
This is the output that you will see after a successful execution of your program.
If you have studied our tutorial on computer programming, there we mentioned some of the key words that were used in Python. But incase you missed it, we will mention them in this tutorial as well.
if one:
print(“one”)
the code would have shown an error saying indentation error.
The statement inside the if block will shift towards the right. This is called indentation.
if e == 5.4:
count+=1
if f == 2880:
count+=1
if g == 2:
count+=1
elif c =="gk":
h = int(input(print('How Many Union Territories Are There In India ?')))
count -= 1
i= input(print('What is The Capital Of Arunachal Pradesh ?'))
count -= 1
j = input(print('What Is The State Flower Of Haryana ? '))
count -= 1
k = input(print('Which State Has Almond As Its State Tree ?'))
count -= 1
print('Total Marks Obtained Are:',count)
if c =='mathematics':
e = float(input(print('What Is 3 * 4 / 5 + 3 ?')))
count -= 1
f = int(input(print('What Is 5! * 4! ?')))
I hope that you guys enjoyed this tutorial and learned something from it.
We shall be talking more about such interesting features of python in the coming tutorials. I will recommend you try these concepts by your self as it will help you in learning things faster. See you guys in the next one.
Numbers: this type includes the integer type, float type, long type and complex numbers. In float type, there are decimal numbers, in integer as the name suggests are integer numbers, long is used to increase the range of these number types that is, float and integer. Complex numbers consist of combination of real numbers and imaginary numbers.
We can simply assign the value to any variable with the help of the assignment operator (=).
s = g = h = 34
Here, we are assigning the value 34 to the variables s, g, h.
Let us look at some of them.
In the last print statement, we are concatenating the string that is, adding a string to the present string. So, we get the output as “Python Programming is the best”
Lists is one of the most versatile features that is provided by python. It is like arrays in C++, the only difference between them is that that lists can hold multiple types values, but arrays can only hold a single type value of value.
Let us look at an example and try to understand the concepts of tuples.
That is, it for this tutorial, I hope you learned something from it. See you in the next one.
------------------------------------------------------------------------------------------------------------
Logical
Arithmetic
The comparison operators are used to compare the values of two or more values or statements. These are binary operators that is can only be used in case of two variables.
The signs included are:
Double equal to (==): it is used when we want to check whether the two elements are equal by value. Example 17==17. It will return true when both the values are equal.
Not equal to (! =): used when we want to check the inequality of two numbers that is, if the numbers are equal by value or not. Example 43! =43. It will return true when the two numbers are not equal by value.
In the above program, we have used and, or, not operators.
Let us now have a look at the arithmetic operators.
Let us now jump onto assignment operator.
“=” assigns the value of the right-side values to the left side value (r = t - y)
Let us look at the bitwise operator.
The bitwise operator works on the bits and perform operations bit by bit that is, binary operations.
There are three types of key words which are used in Python.
If : it works in that same fashion as we use it in English. Like if we win this match, the treat is on me. Let us look at an example.
print(“not wrong”)
Output: correct
Let us look at an example to have a better understanding.
e = 24
Output: wrong
In the above code we compared the value of e with 22 if these values match the program will print correct but if it does not, the it prints wrong as we have given an alternative of else to it.
if u == 50:
print(‘True value is 50’)
Do not forget to practice as it is an important part of your learning.
See you in the next one!
print(“Welcome”)
print(“Welcome”)
but what if you want to write welcome 100 times or 1000 times, using the print statement is not possible. So, we do it in a programmer’s way that is, a smarter way by using loops, we let them work and save our time.
Let us look at some of the loops that we can use in Python.
For loop, in this loop we execute the statements multiple times or the number of times you will tell it to do. It also increments the loop variable by itself.
for x in range(3, 6):
print(x)
While loop, in this loop the statement will be executed if the given condition is true. Before running the loop, the condition is checked and then the loop is executed. We need to give a statement in order to increment or decrement the loop variable.
# Prints out 0,1,2,3,4
output : 0 1 2 3 4
We can also use both the loops one inside the other, it is called nested loops.
Pass: the pass statement is used when we do not want a statement or command to execute. As soon as the interpreter encounters pass, it would not execute the statement.
That is all for this tutorial, hope you are clear with the topic. Try some of the statements by yourself and see the results. See you in the next one!
count += 1
if count >= 5:
if x % 2 == 0:
continue
Functions are a collection of different operations that are to be performed on an object, or anything that you want to do. Instead of writing it again and again you can just write it in a function and call that function whenever you want to execute that task.
Let us see how we can write a function in python.
Let us look at an example to get a clear understanding of the topic.
def one() :
print('-------------WELCOME------------')
a = input(print('Enter your Name:'))
b = input(print('Enter Your roll number'))
c = input(print('Enter Examination name'))
d = input(print('Enter Date of Examination'))
f1 = open('efile','w+')
f1.write(a+'\n')
f1.write(b+'\n')
f1.write(c+'\n')
f1.write(d+'\n')
f1.close()
f1 = open('efile','r')
print('Name Is :')
print(f1.readline())
print('Roll No Is:')
print(f1.readline())
print('Name Of The Examination Is:')
print(f1.readline())
print('Date Of Examination Is:')
print(f1.read())
f1.close()
one ()
As the interpreter encounters the function call, it will jump to the function definition and execute it.