0% found this document useful (0 votes)
8 views4 pages

computer term-2 7

The document provides an overview of variables and data types in Python, including integers, floating-point numbers, strings, and booleans. It also explains basic mathematical operations, algorithm design, loops, functions, and event handling in programming. Key concepts such as sequencing, selection, iteration, and the role of event handlers are discussed to illustrate their importance in coding.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views4 pages

computer term-2 7

The document provides an overview of variables and data types in Python, including integers, floating-point numbers, strings, and booleans. It also explains basic mathematical operations, algorithm design, loops, functions, and event handling in programming. Key concepts such as sequencing, selection, iteration, and the role of event handlers are discussed to illustrate their importance in coding.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

To use variables in programming, we need to create the variables and assign them a reference in

computer memory.

A variable that is not initialized ever has an undefined value. Such a variable cannot be used until it is
assigned with a certain value.

Datatype VariableName = Value;

Below are some basic data types available in Python:

1. Integer

2. Floating-Point Number

3. String

4. Boolean

Integer

Integer is a data type used to define integer variables. Integers can be of any length.

Floating-Point Number

A floating-point number in Python is used to define decimal numbers and is. accurate up to 15 decimals
places.

String

A string in Python is a sequence of Unicode characters

Boolean

Boolean data in Python is used to define Boolean variables. Boolean variables can hold only two values
in it, either "true" or "false".

Addition

Addition operation is used to perform mathematical addition of two variables. In programming, we refer
to "+" as a symbol of addition.

Multiplication

Multiplication operation is used to perform the mathematical multiplication of two variables. In


programming, we refer to "*" as a symbol of multiplication.

Division
Division operation is used to perform the mathematical division of two variables. In programming, we
refer to "/" as a symbol of division.

Modulus

Modulus operation is used to perform the mathematical remainder of two variables. In programming,
we refer to "%" as a symbol of modulus.

Subtraction

Subtraction operation is used to perform mathematical subtraction6 of two variables. In programming,


we refer to "-" as a symbol of subtraction.

Sequencing

An algorithm is a detailed step-by-step process that needs to be followed in

order to complete a task or to solve a problem.

There are three basic building blocks that can be used when designing algorithms:

●Sequencing

●Selection

●Iteration

Step 1: Start

Step 2: READ num1, num2

Step 3: temp num1

Step 4: num1 = num2

Step 5: num2 = temp

Step 6: PRINT num1, num2

Step 7: Stop

: What is a Bug?

A bug is a terminology used to describe any unexpected problem in your program.

What would be the steps to draw a rectangle of length 5 cm and height 3 cm on your screen?
First, draw a line 5 cm in length

Then turn the cursor right by 90 degrees

Then draw a second line 3 cm in length

Then turn right by 90 degrees

Then draw a third line 5 cm in length

Then turn right by 90 degrees

Then draw a fourth line 3 cm in length

: While Loop

The While Loop can execute a set of commands till the condition is true.

: For Loop

For Loop is needed for iterating over a sequence.

Nested Loops

Any loop in program may contain another loop inside it.

Selection refers to the situation in which the algorithm needs to make a choice between two or more
alternatives

Iteration refers to the process of doing the same task over and repeatedly, until a certain task is
complete, or a certain condition is met.

A function is a block of code made up of a set of steps that results in a single specific action.

Few of the advantages of using functions are:

Increases readability makes code organized and easy to understand.

Reduces code length: redundant code is removed and replaced by functions.

Reusability: Code reusability increases.

: the variables accepted by a function to perform the set of tasks defined in its body are called function
parameters.

the usefulness of using a function in a program comes to the forefront, when an operation performed
inside a function. gives back a value, which can be used later in the program to generate meaningful
results.
What is an event?

An event is something that happens

: Some common examples of event include:

1. Clicking on the button of a web page

2. A web browser fully loading a web page

3. Key press inside a desktop. application

What are Event Handlers?

An event handler is a piece of code associated with an event in the code. An event handler gets
executed, when that event occurs.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy