Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

UNIT-6 Fundamentals of Programming

Notes
„ Note that the area of a circle in the above example in Figure 6.5 is
incorrectly calculated as “area=PI*radius*2”. The correct formula for
the area of a circle is “area=PI*radius**2”. However, the interpreter
did not generate any error and simply displayed the incorrect output.
This is a logic error: even though the program does not have any
syntax error, it does not produce the intended correct output.
„ The * symbol serves as a multiplication operator in Python. Table 6.1
of this chapter has a list of operators in Python and examples of how
they are used.

Activity 6.3
1. What is the difference between Python’s interactive interpreter and text editor?
2. Use the print() function to display your full name on the screen using the text
editor.

6.3. Variables and Data Types

6.3.1 Variables

Variables are computer memory locations. They are the means to store data in
computer memory. A variable is used every time user data or intermediary data is
needed to be kept.

In Python, a variable is created along with its value. Values are assigned to variables
using the assignment (=) operator, which has two operands. The operand to the left
of the operator is always a variable while the operand to the right of the operator
is either a literal value or any other type of expression. The following example
demonstrates how a variable named “x” is created with the value 5 in the interactive
interpreter.

139 INFORMATION TECHNOLOGY GRADE 11 ~ STUDENT TEXTBOOK

You might also like