Python Session Overview
Sakshi Agrawal
immediate joiner | Backend Developer | Java |Spring Boot|Microservices|Hibernate|Jenkins|Bitbuket|Kubernetes|kafka|Putty|Cassandra|Software Engineer
Hello to all my Reader
As you see my daily updates regarding my new work as a?Python faculty in CCCGadarwara?[Christ Church Convent Gadarwara]?. Below I am sharing the day Two detail and workshop complete update. Please have a glance on it Hope you all might be benefited through it.
Day 2 [2/May/2022]
In this session we discuss Programming in python through (Interactive Mode) , Variables and Data types in python.
Python has two basics programming modes- Script Mode and Interactive Mode.
Working with Interactive Mode-
Interactive Mode is a command line shell which gives immediate result for each command. In Interactive mode, we type one command at a time. Python executes the given command and gives the output.
Follow these steps to start Python and work in Interactive Mode:
Step1: Click on Start button.
Step2: Scroll down the list of programs and click on Python 3.8 folder.
step3: Click on IDLE (Python 3.8 64-bits)
The main IDLE window appears. IDLE stands for Integrated Development and Learning Environment. It is a code editor which helps you to write and execute Python programs in the editor itself.
Components of Python window
There are two components of python IDLE window:
Type the commands at the prompt and you will immediately get the results. Simply, type 3 + 3 and press the Enter key. The result 6 appears on the screen. Try more values and see what happens.
Working in Script Mode-
The interactive Mode does not save the commands entered by the user in the form of a program. The Script Mode saves the commands entered by the user in the form of a program. To understand the working of Script Mode, we have divided the process into four parts. Let us discuss these.
Creating a new file
follow these steps to create a new file:
step1: Open the python IDLE window.
step2: Click on the file menu. A drop-down menu appears.
step3: Click on the new File option . A new editor window with blank file ill appear on the screen.
-----------------------------------//----------------------------------
Write a program -Type the program code in python window.
Saving Python Program
step1:- Click file menu.
step2:- Click on the save option. The Save as dialog box appears.
step3:- Select the desired location to save the file.
step4:- Enter the name of the file in the File name box.
step5:- Click on Save button. The file will be saved by the given name at the selected location.
领英推荐
Running Python Program
follow steps-
Step1:- Click on Run in the Menu bar.
Step2:- Click on Run Module option.
The program will execute and the output will be shown in the Shell window.
---------------------------------//-------------------------------
VARIABLES IN PYTHON- Variables are memory reference points where we store values which can be accessed or charged later. The names given to the variables are known as identifiers. In Python, we do not need to specify the type of variable because Python is a dynamically typed language and it identifiers the variable type automatically. Let's understand this with help of the given examples.
Declaring and Initializing a Variable
In Python, variables are declared and initialized at the same time in the following way:
You must follow the given rules while creating and naming the variables:
---------------------------------//---------------------------------------
Data Types -
A data type specifies the type of value a variable can contain. for example, a person's name must be stored as a string value whereas the person's age must be stored as a integer. Data types in python are-
Int : Positive or negative whole numbers(without any fractions). Example a = 3
float: Any real number in which a fraction is denoted by a decimal symbol. Example a = 3.5
string: A string value is a collection of one or more characters put is single or double quotes. Example a = "hello"
-------------------------------------//----------------------------------
COMMENTS IN PYTHON
Comments in Python can be used to explain parts of the code. It can also be used to hide the code as well. Comments enable us to understand the way a program works. In python, any statement starting with # symbol is known as a comment. Python does not execute comments. Comments are not a part of the program, but they do enhance the interactivity of the program and make it readable. Python supports two types of comments: Single line comment and Multiline comment.
Single Line Comment - In case, a user wants to specify a single line comment, then comment must start with the symbol # .
In the above program, to hide more than one line we are using #, its is easy for one or two lines of statements but what about more or that to a single statement with multiple lines, for this we have one more comment-
Multiple-line Comment:- Python does not have a syntax for multiline comments. To add a multiple line comment, you could insert a # for each line otherwise the text written inside a triple quotes (''' or """) is also considered as comment. You can use the triple quotes to write multiline comment
OR
Thanks for Reading!
Published by: Sakshi Agrawal
Date:5/7/2022