Python Session Overview

Python Session Overview

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]

No alt text provided for this image

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:

  • Menu Bar: The Menu Bar of python IDLE window is similar to the menu bar of the other programs. It has various menus such as File, Shell, Debug, Options, Window and help.
  • Prompt: You will see a blinking cursor after the symbol(>>>)in the window. This is known as the prompt. The Prompt allows the user to enter commands directly into Python and get an output instantly by pressing the Enter key.

No alt text provided for this image

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.

No alt text provided for this image

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.

No alt text provided for this image

-----------------------------------//----------------------------------

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.

No alt text provided for this image

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.

No alt text provided for this image

---------------------------------//-------------------------------

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.

No alt text provided for this image

Declaring and Initializing a Variable

In Python, variables are declared and initialized at the same time in the following way:

No alt text provided for this image
No alt text provided for this image
No alt text provided for this image

You must follow the given rules while creating and naming the variables:

  • A variable name must start with a letter or underscore character.
  • A variable name cannot start with a number.
  • A variable name can only contain alphanumeric characters( all the letters of the alphabet and numbers) and underscores(_).
  • variable names are case-sensitive.
  • variable names cannot contain any special character or symbol.

---------------------------------//---------------------------------------

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 # .

No alt text provided for this image
No alt text provided for this image

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

No alt text provided for this image
OR
No alt text provided for this image


Thanks for Reading!

Published by: Sakshi Agrawal

Date:5/7/2022

要查看或添加评论,请登录

Sakshi Agrawal的更多文章

  • SpringBoot Annotation

    SpringBoot Annotation

    Hello, to my all readers, Hope you all are enjoying your daily learning. Among my daily updates, Today I have come up…

  • Inner V/s Sub Classes In Java

    Inner V/s Sub Classes In Java

    Hello, to my all readers, Hope you all are enjoying your daily learning. Among my daily updates, Today I have come up…

  • What’s the variance amid an Abstract Class and Interface in Java?

    What’s the variance amid an Abstract Class and Interface in Java?

    Greetings to all my esteemed readers! I trust that each of you is enjoying a delightful reading experience. Please find…

  • Bitbucket

    Bitbucket

    Hello to my all Readers!..

  • Microservices

    Microservices

    Hello to my all Readers!..

  • My New Journey

    My New Journey

    Hello to my all Readers, Hope you are enjoying your reading. It's being quit long time I haven't shared the thoughts…

    2 条评论
  • Programs on operators

    Programs on operators

    Hello to all my Reader As you see my daily updates regarding my new work as a Python faculty in CCCGadarwara [Christ…

  • Python Session Overview

    Python Session Overview

    Hello to all my Reader As you see my daily updates regarding my new work as a Python faculty in CCCGadarwara [Christ…

  • Python Session Overview

    Python Session Overview

    Hello to all my Reader As you see my daily updates regarding my new work as a Python faculty in CCCGadarwara [Christ…

  • Package in Java

    Package in Java

    Hello to my all Readers!..

社区洞察

其他会员也浏览了