0% found this document useful (0 votes)
9 views

Python Introduction

My class notes

Uploaded by

anuscrop1
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Python Introduction

My class notes

Uploaded by

anuscrop1
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Python Introduction:

Python is a high-level, general-purpose, and very popular programming language. Python


programming language (latest Python 3) is being used in web development, and Machine Learning
applications, along with all cutting-edge technology in Software Industry. Python language is being
used by almost all tech-giant companies like – Google, Amazon, Facebook, Instagram, Dropbox,
Uber… etc.

It is used for:

web development (server-side),

software development,

mathematics,

system scripting.

Installing:

Installing Python is generally easy, and nowadays many Linux and UNIX distributions include a recent
Python. Even some Windows computers (notably those from HP) now come with Python already
installed. If you do need to install Python and aren't confident about the task you can find a few
notes on the BeginnersGuide/Download wiki page, but installation is unremarkable on most
platforms.

Python Syntax:

As we learned in the previous page, Python syntax can be executed by writing directly in the
Command Line:

>>> print("Hello, World!")

Hello, World!

Basic Python Commands:

pip install command: pip is a package manager which is written in Python language. It is used to
install and manage software packages. The pip install command is used to install any software
package from an online repository of public packages, called the Python Package Index. To run this
command in windows you need to open your Windows PowerShell and then use the following syntax
to install any package.

Syntax: pip install package-name

print command: print command is used to print a message on the screen or other standard output
device. The message can be a string or any other object. The print command can be used to print any
type of object like integer, string, list, tuple, etc.

Syntax: print(object)

type command: type command is used to check the type or class of an object.
Syntax: type(object)

range command: range command is used to generate a sequence of integers starting from 0 by
default to n where n is not included in the generated numbers. We use this command in for loops
mostly.

Syntax: range(start, stop, step)

start refers to the starting of range (Optional; 0 by default )

stop refers to the number before which you want to stop (Mandatory)

step refers to the increment count (Optional; 1 by default)

round command: round command is used to round a number to a given precision in decimal digits.
That means if you have so many digits after decimal in a float point number then you can use the
round command to round off the specified number. You can mention how many digits you want after
the decimal point.

Syntax: round(number, digits)

number refers to the floating-point number.

digits refer to the count of digits you want after the decimal point. (Optional; By default 0)

input command: input command is used to take input from the user. The flow of the program will be
stopped until the user has entered any value. Whatever the user enters it will be converted into a
string by the input function. If you want to take an integer as input then you have to convert it
explicitly.

Syntax: input(message)

message refers to the text you want to display to the user. (Optional)

len command: len command or len() function is used to get the number of items in an object. If the
object is a string then len() function returns the number of characters present in it. If the object is a
list or tuple it will return the number of elements present in that list or tuple. len() gives an error if
you try to pass an integer value to it.

Syntax: len(object)

object of which you want to find the length (Required)

Loop commands: In python, we have two primitive loop commands namely while and for.
The while loop command is used to execute a set of statements as long as the given condition is
true.
Syntax of while loop: while condition:
statements
update iterator

You might also like