0% found this document useful (0 votes)
6 views1 page

Python

Become python master

Uploaded by

yonep73748
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views1 page

Python

Become python master

Uploaded by

yonep73748
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Identifiers An identifier is a name given to a variable, function, class or module.

rules An identifier Repetition statements or Iteration statements Exception handling is one of the most important feature
cannot start with a digit but is allowed everywhere else*eywords cannot be used as identifiers*One of Python programming language that allows us to handle the errors caused by exceptions Built-In
cannot use spaces and special symbols like !, @, #, $, % etc*Identifier can be of any length Keywords are Functions The Python interpreter has a number of functions that are built into it and are always
a list of reserved words that have predefined meaning. Keywords are spe cial vocabulary and cannot be available. You have already looked at some of the built-in functions like input(), print(), range() Modules
used by programmers as identifiers for variables, functions, constants or with any identifier in Python are reusable libraries of code having .py extension, which implements a group of methods and
name.statements is an instruction that the Python interpreter can execute. Python program consists of a statements.Function Definition and Calling the Function You can create your own functions and use
sequence of statements ex :z = 1 is an assignment statement.Variable is a named placeholder to hold them as and where it is needed. User-defined functions are reusable code blocks created by users to
any type of data which the program can use to assign and modify during the course of execution To perform some specific task in the program.default parameter has a default value as part of its function
define a new variable in Python, we simply assign a value to a name rules • Variable names can consist definition. Any calling function must provide argu ments for all required parameters in the function
of any number of letters, underscores and digits. • Variable should not start with a number. • Python definition but can omit arguments for default parameters.Keyword Arguments Until now you have seen
Keywords are not allowed as variable names. • Variable names are case-sensitive. For example, that whenever you call a function with some values as its argu ments, these values get assigned to the
computer and Computer are dif ferent variables.Operators are symbols, such as +, –, =, >, and <, that parameters in the function definition according to their position.Command Line Arguments A Python
perform certain mathematical or logical operation to manipulate data values and produce a result based program can accept any number of arguments from the command line. Command line arguments is a
on some rules types Arithmetic operators are used to execute arithmetic operations such as addition, methodology in which user will give inputs to the program through the console using commands Strings
sub traction, division, multiplication etc.Assignment operators are used for assigning the values are another basic data type available in Python. They consist of one or more char acters surrounded by
generated after evaluating the right operand to the left operand. Assignment operation always works matching quotation marks. str() function returns a string which is considered an informal or nicely
from right to left.comparison operator When the values of two operands are to be compared then printable representation of the given object. The syntax for str() function is, str(object) Basic String
comparison operators are used. The output of these is always a Boolean value logical operators are used Operations In Python, strings can also be concatenated using + sign and * operator is used to create a
for comparing or negating the logical values of their oper ands and to return the resulting logical repeated sequence of strings.String Comparison You can use (>, <, <=, >=, ==, !=) to compare two strings
value.Bitwise operators treat their operands as a sequence of bits (zeroes and ones) and perform bit by resulting in either Boolean True or False value. Python compares strings using ASCII value of the
bit operation.Operator precedence determines the way in which operators are parsed with respect to characters Built-In Functions Used on Strings There are many built-in functions for which a string can be
each other. Operators with higher precedence become the operands of operators with lower passed as an argument String Traversing Since the string is a sequence of characters, each of these
precedence.Associativity determines the way in which operators of the same pre cedence are parsed. characters can be traversed using the for loop.Formatting Strings Python supports multiple ways to
Almost all the operators have left-to-right associativity Data types specify the type of data like numbers format text strings. These include %-formatting and str.format(). Format Specifiers Format specifiers may
and characters to be stored and manipu lated within a program types *numbers Integers, floating point also contain evaluated expressions. The syntax for f-string format ting operation is, f'string_statements
numbers and complex numbers fall under Python numbers cat egory. They are defined as int, float and {variable_name [: {width}.{precision}]}’ Escape Sequences Escape Sequences are a combination of a
complex class in Python *Booleans may not seem very useful at first, but they are essential when you backslash (\) followed by either a letter or a combination of letters and digits. Escape sequences are also
start using conditional statements yes-or-no question ,either True or False*string consists of a sequence called as control sequences.A raw string is created by prefixing the character r to the string. In Python, a
of one or more characters, which can include letters, num bers, and other types of characters*None is raw string ignores all types of formatting within a string including the escape characters.Unicodes
another special data type in Python. None is frequently used to represent the absence of a value Fundamentally, computers just deal with numbers. They store letters and other characters by assigning a
Identation In Python, Programs get structured through indentation This principle makes the code look number for each one. Before Unicode was invented, there were hundreds of different systems, called
cleaner and easier to understand and read Comments are an important part of any program. A comment character encodings for assigning these numbers.
is a text that describes what the program or a particular part of the program is trying to do and is
ignored by the Python interpreter types *single line comment the hash (#) symbol to start writing a
comment. Hash (#) symbol makes all text following it on the same line into a commen multiline
comments If the comment extends multiple lines, then one way of commenting those lines is to use
hash (#) symbol at the beginning of each line reading input In Python, input() function is used to gather
data from the user. syntax = variable_name = input([prompt]) f-string is a string literal that is prefixed
with “f”. These strings may contain replacement fields, which are expressions enclosed within curly
braces {} .type conversions You can explicitly cast, or convert, a variable from one type to another
complex() function to print a complex number with the value real + imag*j or convert a string or
number to a complex number Sequential Control Flow Statements: This refers to the line by line
execution, in which the statements are executed sequentially, in the same order in which they appear in
the program. . Decision Control Flow Statements: Depending on whether a condition is True or False,
the decision structure may skip the execution of an entire block of statements or even execute one block
of statements instead of other (if, if…else and if…elif…else). Loop Control Flow Statements: This is a
control structure that allows the execu tion of a block of statements multiple times until a loop
termination condition is met (for loop and while loop). Loop Control Flow Statements are also called

You might also like