Updated On : Apr-30,2020 Tags python, basics
Python Programming Guide For Beginners - Part 1

What Is Python?

Python is an object-oriented programming language.

  • It was created by Guido Rossum in the year 1989.
  • The language is designed for the rapid prototyping of the complex real life applications.
  • Python has several interfaces to the OS systems and makes use of libraries.
  • Many tech giants such as NASA, Google, Facebook, BitTorrent etc. makes use of python for designing sophisticated programs.
  • Python langauge promotes code readbility.

Trend Of Python Programming

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.

Features Of Python Language

  1. Readable: Python language is a readable.

  2. 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.

  3. 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.

  4. Open Source: Python is a open source programming language.

  5. 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.

  6. 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.

  7. 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.

Application Of Python Language

  1. 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.

  2. 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.

  3. Data Analysis: Python is used for data analysis and data visualization in the form of charts.

  4. 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.

  5. Game development – You can develop games using Python.

  6. Desktop applications – You can develop desktop application in Python using library like TKinter or QT.

Learning About Python Basics

How To Print In Python With Example:

Example 1: To print the Welcome to CoderzColumn, use the print () function as follows:

In [1]:
print ("Welcome to CoderzColumn")
Welcome to CoderzColumn

What would you do ifyou wish to print if you want to print the name of five cities, you can write:

In [2]:

How to print blank lines

If ou want to have multiple blank lines in your code.

In [3]:
print (3 * "\n")

Understanding The Basics Of Python Input | Output | Import Statement

Python language makes use of two built in functions to perform the basic input/ outpit tasks.

  • print()
  • input()

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

In [4]:
print('This sentence is output to the screen')
This sentence is output to the screen

Example 2 - Print Function

In [5]:
a = 5
print('The value of a is', a)
The value of a is 5

Output Formatting

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.

In [6]:
x = 5; y = 10
print('The value of x is {} and y is {}'.format(x,y))
The value of x is 5 and y is 10

Python Input

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.

In [7]:
num = input('Enter a number: ')
Enter a number: 24

List Of Simple Python Programs

Python Program to Add Two Numbers

In [1]:
# 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))
OUTPUT: The sum of 1.5 and 6.3 is 7.8

Add Two Numbers Provided by The User

In [2]:
# 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))
Enter first number: 23
Enter second number: 34
The sum of 23 and 34 is 57.0

Program To Calculate The Squareroot Of A Positive Number

In [8]:
# 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))
The square root of 8.000 is 2.828

Program To Calculate The Squareroot Of Real or Complex numbers

In [9]:
# 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))
The square root of (1+2j) is 1.272+0.786j

CoderzColumn will bring some more interesting and simple python program in the next part. Till then Stay TUned

Dolly Solanki  Dolly Solanki