Unit 3 - Advance Python
Unit 3 - Advance Python
• Easy language: Python is an easy language. It is easy to read, write, learn and
understand.
• Interpreted language: Python is an interpreted language, which means that the
programs are passed straight to an interpreter that executes them directly.
• Open source: Python is an open-source programming language.
• Free of cost: Python is tree to download and use.
• Cross-platform: Python is compatible with various operating system, like Mac,
Windows, Linux, Unix, etc.
5 Applications of Python:
• Web development: Python helps the user in writing server-side code, which helps in
managing databases, write backend programming logic, mapping URLs etc.
• Game development: Python is suitable for building tools for game designers that
simplify tasks, such as "level designing" or "dialogue tree creation: etc.
• Machine learning: Python has all the qualities that a machine learning application
requires. Hence it has become one of the most favored languages of Data Science
professionals.
• Scripting: Scripting is writing small programs to automate simple tasks, like sending
automated response emails. Such type of applications can also be written in Python
programming language.
• Data analysis: Python has a unique attribute and is easy-to-use when it comes to
quantitative and analytical computing. Its massive libraries are used for data
manipulation and very easy to learn even for a beginner data analyst
Question 2: Explain variable with syntax and example and mention the rules for
naming variable in Python.
Answer: Variables in Python can be thought of as containers for storing data values.
The value of the data stored in variables, i.e.,the value of variables, can change
depending upon the program. The variables are created when the values are assigned
to them.
The syntax for assigning a variable to the variable is: variable name = variable value.
When writing a variable name that has more than 1 word, make sure that an underscore
C) is put between the gaps of words. Text can also be assigned to the variable by
enclosing them in double C, ', ", or single quotes. Rules for naming a variable:
Example: hello, n e I I o, he110123, B 2 2 etc. are accepted. dut variable names like
AG#E, qwerty@ etc. are nof accepted.
Rule 3: The variable names are case sensitive.
Example: The variable name age ditters from the variable name AGE.
Rule 4: You can't use a reserved keyword for naming a variable.
Answer:
Arithmetic Operators: Arithmetic operators are used in Python for performing
mathematical operations on variables and values. Python has 7 arithmetic operators.
The following table shows the 7 operators
Conditional Operators: Comparison operators are used to compare values. It returns
either True or False according to the condition. Python has 6 conditional operators. The
following table shows the 6 operators with example:
Logical Operators: Logical operators are the and, or, and not operators. The following
table shows the 3 operators with example:
And operator: Logical and operator returns True if both the operands are True else it
returns False.
a = 5 is a simple assignment operator that assigns the value 5 on the right to the variable
a on the left.
Answer: The input() is an inbuilt function for getting user's response. The syntax for
input() function is:
input(prompt)
The default data type for the input provided by the user is the string data type.
Example,
Answer: if statement: The body of the it statement is executed only it the corresponding
condition evaluates to true. The piece of code inside the it statement is skipped it the
condition evaluates to false.
Syntax:
if condition:
body
else:
body