Python is an object-oriented programming language.
Python is becoming a popular language because it is widely used in Artificial Intelligence, Machine Learning, Natural Language Generation, Neural Network and various other advanced fields of Data Science.
Fun Fact Of Python Programming
Python is named after the comedy television show Monty Python’s Flying Circus. It is not named after the Python snake.
Readable: Python language is a readable.
Language Should Be Easy to Learn: Learning python is easy as this is a expressive and high level programming language, which means it is easy to understand the language and thus easy to learn.
Cross Platform Programing: Python is available and can run on various operating systems such as Mac, Windows, Linux, Unix etc. This makes it a cross platform and portable language.
Open Source: Python is a open source programming language.
Large Standard Library: Python comes with a large standard library that has some handy codes and functions which we can use while writing code in Python.
Python Supports Exception Handling:Python language supports exception handling which means coders can write less error prone code and can test various scenarios that can cause an exception later on.
Automatic memory management: Python supports automatic memory management which means the memory is cleared and freed automatically. You do not have to bother clearing the memory.
Python For Web Development: Advanced framework like Django and Flask are based on Python. With these framework you can write server side code and help in the management of databases, write backend programming or mapping urls.
Machine Learning: One of the reason of python's popularity i s also due to its application in machine learning.Machine learning is a way to write a logic so that a machine can learn and solve a particular problem on its own.
Data Analysis: Python is used for data analysis and data visualization in the form of charts.
Scripting – Scripting is writing small programs to automate simple tasks such as sending automated response emails etc. Such type of applications can also be written in Python programming language.
Game development – You can develop games using Python.
Desktop applications – You can develop desktop application in Python using library like TKinter or QT.
Example 1: To print the Welcome to CoderzColumn, use the print () function as follows:
print ("Welcome to CoderzColumn")
What would you do ifyou wish to print if you want to print the name of five cities, you can write:
print("Delhi")
print("Mumbai")
print("Chennai")
print("Kolkatta")
print("Ahmedabad")
If ou want to have multiple blank lines in your code.
print (3 * "\n")
Python language makes use of two built in functions to perform the basic input/ outpit tasks.
Moreover, you would be learning about the 'import'module and its application.
Python's Output use print() function We use the print() function to output data to the standard output device.
Example 1 - Print Function
print('This sentence is output to the screen')
Example 2 - Print Function
a = 5
print('The value of a is', a)
Sometimes we would like to format our output to make it look attractive. This can be done by using the str.format() method.
This method is visible to any string object.
x = 5; y = 10
print('The value of x is {} and y is {}'.format(x,y))
What to do when you want the user to enter the values? The value of variables was defined or hard coded into the source code.
To allow flexibility, we might want to take the input from the user. In Python, we have the input() function to allow this.
The syntax for input() is: input([values])
Note: You must try this on your own and then you'll understand how it lets you to enter the values.
num = input('Enter a number: ')
# This program adds two numbers
num1 = 1.5
num2 = 6.3
# Add two numbers
sum = float(num1) + float(num2)
# Display the sum
print('OUTPUT: The sum of {0} and {1} is {2}'.format(num1, num2, sum))
# Store input numbers
num1 = input('Enter first number: ')
num2 = input('Enter second number: ')
# Add two numbers
sum = float(num1) + float(num2)
# Display the sum
print('The sum of {0} and {1} is {2}'.format(num1, num2, sum))
# Python Program to calculate the square root
# Note: change this value for a different result
num = 8
# To take the input from the user
#num = float(input('Enter a number: '))
num_sqrt = num ** 0.5
print('The square root of %0.3f is %0.3f'%(num ,num_sqrt))
# Find square root of real or complex numbers
# Importing the complex math module
import cmath
num = 1+2j
# To take input from the user
#num = eval(input('Enter a number: '))
num_sqrt = cmath.sqrt(num)
print('The square root of {0} is {1:0.3f}+{2:0.3f}j'.format(num ,num_sqrt.real,num_sqrt.imag))
CoderzColumn will bring some more interesting and simple python program in the next part. Till then Stay TUned
If you are more comfortable learning through video tutorials then we would recommend that you subscribe to our YouTube channel.
When going through coding examples, it's quite common to have doubts and errors.
If you have doubts about some code examples or are stuck somewhere when trying our code, send us an email at coderzcolumn07@gmail.com. We'll help you or point you in the direction where you can find a solution to your problem.
You can even send us a mail if you are trying something new and need guidance regarding coding. We'll try to respond as soon as possible.
If you want to