The goal of this course is to get you started with the Python programming language. Python is a great and easy language to learn.
The main purpose of this tutorial is to get you started with the Python programming language. Python is a great and simply to learn. It is great language for those who are new learner to programming. After doing this tutorial, You can create scripts, websites, games, or desktop applications in Python. In this tutorial , we will explain python programming language , we will consider on these topics :
Python is high level general purpose , Interpreted , interactive and object oriented programming language.It was developed by Guido Van Rossum. It is also known as dynamic and easy to use because its allows the programmer's to rich in style and it is very popular scripting language and used by big organization like google , NASA , CIA , Disney etc. The design purpose of the Python language emphasizes programmer productivity and code readability.
Python is must for beginners aspirants and working professionals engineers to became a best software developer and if you are in web domain then it is great achievement of you in this ERA.
High-level language : A programming language like Python that is designed to be easy for humans to read and write.
Interactive mode :A way of using the Python interpreter by typing commands and expressions at the prompt.
Interpret :To execute a program in a high-level language by translating it one line at a time. low-level language : A programming language that is designed to be easy for a computer to execute; also called “machine code” or “assembly language”.
Parse : To examine a program and analyze the syntactic structure.
Portability : A property of a program that can run on more than one type of computer.
Print function : An instruction that causes the Python interpreter to display a value on the console screen.
Problem solving : The process of contructing a problem, searching a solution, and expressing the solution.
Program : A sets of instructions that identify a computation.
Prompt : Whenever program show a message and pause for the user to type some input to the program.
Machine code : The lowest level programming language for software, which language that is directly executed by the central processing unit (CPU).
Main Memory : Accumulate programs and data. Main memory loses its data when the power is turned off.
Secondary memory : Accumulate programs and data and retains its information even when the power is turn off. Generally slower than main memory. Examples of Physical memory include disk drives and flash memory in USB sticks.
Semantics : The meaning of a program. semantic error An error in a program that makes it do something other than what the programmer intended.
Source code : A program in a high-level language.
A variable is a name that refers to a value The values we have seen so far are 1, 2, and “Hello, World!”. These values belong to different types: 5 is an integer, and “Hello, India!” is a string, so it is called because it contains a “string” of letters.
An expression is a combination of values, variables, and operators. A value all by itself is examine an expression, and It is a variable, so the following are all legal expressions (assuming that the variable x has been assigned a value):
19 , x
x + 19
A statement is a unit of code that the Python interpreter can execute. We have seen two type of statements: print being an expression statement and assignment. When you type a statement in interactive mode, the interpreter executes it and displays the result, if there is one.
try
block lets you test a block of code for errors. The except
block lets you handle the error. The finally
block lets you execute code, regardless of the result of the try- and except blocks.A statement that creates a new function, specifying its name, parameters, and the statements it executes. "A named sequence of statements that performs some useful operation. Functions may or may not take arguments and may or may not produce a result."
When you define a function, you specify the name and the sequence of statements. Later, you can “call” the function by name. We have define in following one example of a function call :
>>> type(32)
Python provides a number of important built-in functions that we can use without needing to provide the function definition. The creators of Python wrote a set of functions to solve common problems and included them in Python for us to use.
Python also provides built-in functions that convert values from one type to another. The int function takes any value and converts it to an integer,
Python has a math module that provides most of the familiar mathematical functions. Before we can use the module, we have to import it:
>>> import math
Function call : A statement that executes a function. It consists of the function name followed by an argument list.
Function object : A value created by a function definition. The name of the function is a variable that refers to a function object.
Function Parameter : A name used inside a function to refer to the value passed as an argument.
Repeated execution of a set of statements using either a function that calls itself or a loop.
A string is a sequence of characters. You can access the characters one at a time with the bracket operator:
>>> fruit = 'banana' >>> letter = fruit[1]
File handling is an important part of any web application.
Python has several functions for creating, reading, updating, and deleting files.
The key function for working with files in Python is the open()
function.
"r"
- Read - Open file for reading
"a"
- Append - Opens a file for appending,
"w"
- Write - Opens a file for writing,
"x"
- Create - Creates the specified file
Like a string, A sequence of values is called List. In a string, the values are characters; in a list, they can be any type. The values in list are called elements or sometimes items.
There are several ways to create a new list; the simplest is to enclose the elements in square brackets(“[" and “]”):
[10, 20, 30, 40]
['crunchy frog', 'ram bladder', 'lark vomit']
A mapping from a set of keys to their corresponding values. In a list, the index positions have to be integers; in a dictionary, the indices can be (almost) any type. You can think of a dictionary as a mapping between a set of indices (which are called keys) and a set of values. Each key maps to a value. The association of a key and a value is called a key-value pair or sometimes an item. As an example, we’ll build a dictionary that maps from English to Spanish words, so the keys and the values are all strings. The function dict creates a new dictionary with no items. Because dict is the name of a built-in function, you should avoid using it as a variable name.
>> eng2sp = dict()
>> print(eng2sp) {}
A tuple1 is a sequence of values much like a list. The values stored in a tuple can be any type, and they are indexed by integers. The important difference is that tuples are immutable. Tuples are also comparable and hashable so we can sort lists of them and use tuples as key values in Python dictionaries. Syntactically, a tuple is a comma-separated list of values:
>>> t = 'a', 'b', 'c', 'd', 'e'
A set is a collection which is unordered and unindexed. In Python sets are written with curly brackets. Like as :
A language for expressing more complex search strings. A regular expression may contain special characters that indicate that a search only matches at the beginning or end of a line or many other similar capabilities.
Write a public review