Friday, 29 June 2018

continue statement


break statement

break statement

Python Operators

Python Operators

Like all computer programming languages, python also supports following basic operators. Using these operators, we can perform mathematical operations on variables.

Basic operators in Python includes

+ for addition operation
-  for subtraction operation
*  for multiplication operation
/  for division operation
%  for modulus operation
**  for exponent operation
//  for floor division operation

Examples of Python Operators

Let’s use these operators on following two variables:

num1 = 10
num2 = 5

Addition
num1 + num2 will result in 15

Subtraction
num1 - num2 will result in 5

Multiplication
num1 * num2 will result in 50

Division
num1/num2 will result in 2

Floor Division
num1//num2 will result in 2 (rounds down the answer to the nearest whole number)

Modulus
num1%num2 will result in 0 (It’s remainder of 10 divided by 5)

Exponent
num1**num2 will result in 100000 (10 to the power of 5)

Assignment Operator (=)


Like most of the programming languages, Python uses equal sign (=) as assignment operator.

number = 5

Above statement will assign value 5 to variable number.

There are a few more ways to use assignment operators in Python; examples are +=, -= and *=.

If we want to increment value of number by 2, we can write

number = number + 2

Python will first evaluate the expression on the right side i.e. number + 2 and assign the answer to the left side. Hence execution of above statement will result in number = 7 (assuming initial value of number is 5).

The same statement can also be written as under:

number += 2

The number += 2 is actually a short form of the statement number = number + 2

Similarly, if we want to do a subtraction, we can write number = number – 2 or number -= 2. The same works for most of the python operators described above.



* * * * *

Python Installation and Setup

Python Installation and Setup

Python interpreter is needed to run Python programs. Perform following steps to install python software in your system.


Step-1 Search "Python Download in Google"


Step-2 Download latest Python version from URL https://www.python.org/downloads/


Step-3 Install Downloaded - Python 3.7.4 applications (.exe file)


Step-4 Install Python 3.7.4 - Customize your installation


Step-5 Select basic configuration to install (select your installation drive and folder)



Step-6 Wait for message "Python Setup was successful"


Step-7 Go to Windows start menu and select: IDLE Python 3.7


Step-8 Start writing your Python code in IDLE (Python Interpreter)

First Python Practical using Python Shell

* * * * *



Acknowledgement: All product names (Google, Windows, Python and others), logos, and brands are property of their respective owners. The content shown on page is for demonstration only.

Decision Making

Decision Making

Basic Syntax

Welcome to Python Practicals

Let's explore Top Python Practicals

Click your Topic of Interest to Learn

Introduction to Python

Python is an easy to learn and very powerful programming language. It has efficient data structures and a simple approach to object-oriented programming. Python’s syntax together with its interpreted nature, make it an ideal language for scripting and rapid application development. 

Basics of Python

Python is an easy to learn and very powerful programming language.

Data Types

Python is very good in String Processing. 

Numbers

Numbers are one of the fundamental building block of any programming language.


Copyright © 2021 PythonPracticals.Blogspot.Com

All rights reserved.






Python Overview

Python Overview

If you are new to the Computer Programming, Python is a great place to start. One of the key features of Python is its simplicity which makes it ideal language for beginners to learn.

Python is one of the widely used high-level programming language invented by Guido van Rossum. It can be used for solving varieties of problems. Python is known for its simplicity and code readability. Programmer can develop application very rapidly using Python.


Python code resembles the English language. To interpret the Python codes, computer needs a special program known as the Python interpreter. Python interpreter is needed to code, test and execute the  Python programs.

Most programs in Python needs very few lines of code to solve complicated programming task compared to other languages. Fewer lives of code leads to fewer programming errors and reduces the overall development time. 



Python Data types

Data types

Friday, 23 March 2018

First Python Program

My First Python Program

Start your Python Shell.

You will get command prompt like (>>>). Write following simple command to print your first message using Python Programming.

>>> print("Hello World")
Hello World

Congratulations!!! Your first python program is done....

Here, >>> print("Hello World") is the python code we need to write to generate the output Hello World.

* * * * *
#Sample Python Program
print("Hello Students..")
print("Welcome to Python Practicals.......")

Output:
Hello Students..
Welcome to Python Practicals.......


Python Practicals

Welcome to the World of Python Programming


This blog helps you to learn Python programming concepts. You can learn Python programming practicals at your own pace. One can easily learn concepts of Python programming by practicing various programs given on various pages of this blog. Enjoy the power of Self Study.

Click your Topic of Interest to Learn.....


Basics of Python
Looping
Functions
File Management
Classes
Networking
Security



Branching Statements in Python: Python language executes program statements in a sequence. Sometimes we need to alter the flow of sequence of statements. This is possible using Branching statements offered by Python language. They are also known as control statements. Branching Statements of Python are given below:
  • if statement
  • if…else statement
  • nested if statement


Looping statements in Python: In computer programming, a loop is a sequence of commands or statements that are repeated many times. Looping statements in Python language are as under:
  • for statement
  • while statement
  • nested loops

File Management in Python: We create a File for permanent storage of data. Python language provides many functions that help us to perform various file operations. 

Click here to know more about general syntax of File Management, reading content from a file, writing and appending content to a file. 


* * * * *