Podcast
Questions and Answers
Python is a high-level, ______, interactive and object-oriented scripting language.
Python is a high-level, ______, interactive and object-oriented scripting language.
interpreted
The standard, most popular Python development environment is called ______, which is an acronym for Integrated Development Environment.
The standard, most popular Python development environment is called ______, which is an acronym for Integrated Development Environment.
IDLE
To exit from Python's interactive mode, you can type quit()
, exit()
, or press ______ + D.
To exit from Python's interactive mode, you can type quit()
, exit()
, or press ______ + D.
Ctrl
[Blank] are special symbols representing computations, applied on operands, and categorized as Arithmetic, Relational, Logical and Assignment.
[Blank] are special symbols representing computations, applied on operands, and categorized as Arithmetic, Relational, Logical and Assignment.
Name the operator: //
in python is used for ______.
Name the operator: //
in python is used for ______.
The ______ operator in Python, denoted by ==
, checks for equality between two values.
The ______ operator in Python, denoted by ==
, checks for equality between two values.
In Python, the logical operator that returns True
only if both operands are True
is ______.
In Python, the logical operator that returns True
only if both operands are True
is ______.
[Blank] are names given to entities like classes, functions, and variables to differentiate them.
[Blank] are names given to entities like classes, functions, and variables to differentiate them.
In Python, text that does not affect the output of the code is called a ______.
In Python, text that does not affect the output of the code is called a ______.
[Blank] statements in Python allow you to control the flow of your program based on certain conditions.
[Blank] statements in Python allow you to control the flow of your program based on certain conditions.
Flashcards
What is a program?
What is a program?
A collection of instructions that perform a task when executed by a computer, written in a programming language.
What is Python?
What is Python?
A high-level, interpreted, interactive, object-oriented scripting language known for readability.
IDLE
IDLE
An Integrated Development Environment which allows one to edit, run, browse and debug Python programs.
print() Function
print() Function
Signup and view all the flashcards
Python Operators
Python Operators
Signup and view all the flashcards
Comparison Operators
Comparison Operators
Signup and view all the flashcards
Logical Operators
Logical Operators
Signup and view all the flashcards
Identifiers
Identifiers
Signup and view all the flashcards
Python Comments
Python Comments
Signup and view all the flashcards
input() Function
input() Function
Signup and view all the flashcards
Study Notes
What is a Program?
- A computer program comprises instructions to perform a specific task when executed by a computer
- Computer programs get written in a programming language
What is Python?
- Python is a high-level, interpreted, interactive, object-oriented scripting language
- Python is designed for high readability
- Python is used in web applications, software development, data science, and machine learning (ML)
- Guido van Rossum created Python
- Python was released in 1991
Features of Python
- Python is open source
- Python is beginner-friendly
- Python is an interpreted language
- Python is interactive
- Python is portable
- Python is object-oriented
What Python Can Do
- When Python is installed, an IDE called IDLE also gets installed
- IDLE (GUI integrated) facilitates running Python
- IDLE is the standard, popular Python development environment
- IDLE is an acronym for Integrated Development Environment
- IDLE enables editing, running, browsing, and debugging Python Programs using one interface
- The Python shell can be used in interactive mode and script mode
- Interactive mode allows interaction with the OS
- Script mode lets users create and edit Python source files
Downloading and Installing Python for Windows
- The Windows Python interpreter is available for free download
- The website is
https://www.python.org/downloads/
- After downloading the installer, run it
- After installation, Python 3.7 can be found in the start menu
Starting Python
- On Windows, open the Start menu, select All Programs, Python 3.7, and then IDLE (Python 3.7 32 bit)
- A window with the
>>>
prompt indicates the interactive shell - Python statements get executed one by one in this window
- This is preferable when you want to see the output of each line of code
Print Function
- Functions print a specified message to the screen or standard output device
- The message is a string or any other object (converted to a string before printing)
- To print "Hello World" use:
>>>print("Hello World!")
- You can print multiple objects:
>>>print("Hello,", "How Are You?")
Try it Yourself
- Practice by finding the average of three marks using
(75+85+65)/3
- Find the area of a circle with radius 5 using
22/7 * 5 * 5
- Combine strings "RAVI" and "Kant" using the
+
operator - Multiply the string "###" by 3
Exiting Python
- To exit, use these commands:
quit()
,exit()
, orCtrl+D
Writing Python Programs
- Write instructions into the file editor to create an entire Python program
- The file editor, accessible via File -> New File in IDLE, offers features for coding
Python Operators
- Operators are symbols for computations applied to operands (values or variables)
- Operators have different behaviors based on the data type
- Applying operators to operands forms an expression
- Operators are categorized as Arithmetic, Relational, Logical, or Assignment
- Values and variables used with an operator are called operands
Arithmetic Operators
- Perform mathematical operations like addition, subtraction, multiplication, etc.
- Addition:
+
- Subtraction:
-
- Multiplication:
*
- Division:
/
- Integer Division:
//
- Remainder:
%
- Raised to power:
**
Comparison Operators
- Comparison operators compare two values/variables and return True or False (boolean result)
>
Greater Than,<
Less Than,==
Equal To,!=
Not Equal to ,>=
Greater than or Equal to,<=
Less than or equal to
Logical Operators
- Combine and manipulate Boolean values (True or False)
and
: Returns True if both operands are Trueor
: Returns True if at least one operand is Truenot
: Returns the opposite of the operand's Boolean value
Variables and Data Types
- Identifiers name entities like classes, functions, and variables, differentiating them
Datatypes
- Every value in Python has a datatype
- Everything is an object; data types are classes, and variables are instances of these classes
Python Comments
- Comments are text that doesn't affect code output; they explain the program
Single-Line Comments
- Single line comments in Python start with
#
(hash sign)
Multi-Line Comments
- Multi-line comments use triple single quotes (
'''
) at the beginning and end
Input Function
- Displays a string message to prompt user input
- Program flow pauses until the user enters input and presses return
Difference Between == and = Operators
==
is a relational operator that checks if the values on both sides are equal=
is an assignment operator that assigns the value on the right to the variable on the left
Conditional Statements / Control Statements
- Control the program flow based on conditions, executing different code blocks depending on whether a condition evaluates to True or False
- Flow control directs a program's path based on conditions; the outcome is True or False
If Statement
- The simplest decision-making statement
- If a condition is true, a statement or code block gets executed
If...Else Statements
- Executes code based on whether the condition is true (if block) or false (else block)
- Else statements consist of the keyword
else
, a colon, and an indented block of code
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Related Documents
Description
Learn about Python, a high-level, interpreted, object-oriented language created by Guido van Rossum and released in 1991. Python is open source, beginner-friendly, and used in web applications, software development, data science, and machine learning.