Professional Documents
Culture Documents
Logical Operators
There are three logical operators in Python - and, or and not. They are used to
combine two or more conditional statements.
Membership Operators
Membership operators in and not in are used to find whether a value is present
in a particular Python object or not.
Identity Operators
Identity operators is and is not are used to check whether the memory
locations of two variables/objects are the same or not. Also, we can use these
operators to find if a variable/object belongs to a particular type or not.
CONDITIONAL STATEMENT
If Statement
This is the simplest decision-making statement in Python. It is used to decide if
a particular block of code needs to be executed or not. Whenever the given
condition is True, then the block of code inside it gets executed, else it does
not.
If else Statement
The statements written within the else block get executed whenever the if
condition is False. You can imagine the flow of execution this way,
Elif Statement
The keyword elif is a combination of else and if. This statement works similar to
'else if' statements in the C and other languages. The statements in elif block
get executed when the previous if condition is False.
Nested If statement
One if statement inside another if statement is called Nested if statement. The
structure and flow of execution can be assumed as shown below.
While loop
The while loop checks the condition first, and if it returns true, the code within
it runs. The loop continues until the condition provided returns false, then
stops.
For loop
for loops are used when you have a block of code which you want to repeat a
fixed number of times. The for-loop is always used in combination with an
iterable object, like a list or a range. The Python for statement iterates over the
members of a sequence in order, executing the block each time.
Nested Loop
Nested for loops places one for loop inside another for loop. The inner loop is
repeated for each iteration of the outer loop.
13-July-2023
1.Perform Control Statement in Python.
2.Write a program in sum of n numbers.
17-July-2023
1. Write a Python program to create a tuple.
2. Write a Python program to create a tuple with
different data types.
24-July-2023
1.write a program to find out what version of
python you are using.
2.write a program to find out the current date
and time.
25-July-2023
1. Write a python program that print a
calendar of a given month and year.
26-July-2023
1.Write a python program to handle a zero
Division error exception when dividing a
number by zero.
2.Write a python program that prompts the
user to input an integer and raises a value
error exception if the input is not a valid
integer.
02-Agust-2023
CURD OPERATION
After CRUD Operation we need to install some software and
driver like Python, MySQL Workbench and a connector driver
(pip).
Step 1: - Go to the search bar and type Python.exe You will
see a Python exe file. place to open file
Step 2: - Double Click on Scripts folder.
Step 3: - click on address bar and type CMD
Output: -
If you want to see whether these databases are in mysql or
not, then open mysql and you can see.
Output: -
Output: -
Update data
Output: -
Delete data
Output: -
Now you will see in the mysql table your data is deleted.
03-Agust-2023
Python_Flask
Flask is an API of Python that allows us to build up web-
applications. It was developed by Armin Ronacher. Flask's
framework is more explicit than Django's framework and is
also easier to learn because it has less base code to
implement a simple web-Application.
INSTALLATION OF VIRTUAL ENVIRONMENT
Step 1: -Open VS code Editor and Create a new python_flask
folder in any location.
Step 2: -Open Terminal on Vs code and run the command
for installed virtual environment and hit enter.
Command: - pip install virtualenv
Step 9: - After run the code you will see the URL you
can Ctrl+click on the Link.
Now you can see the result on the web browser.
Step 3: - Run the file with flask and click on URL link
(127.0.0.1:5000).
Then Click on submit button and you will see your data is
submitted.
Step 6: - Open mysql workbench and run the select * from
tableName command and then you will see your data is
inserted in the table successfully.