Logic And Critical Thinking

Logic And Critical Thinking

Share

በቅርቡ

08/05/2021

>>> 2*3
6
>>> 2/3
0.6666666666666666
>>> 2**3
8
>>> 2%3
2
>>> 3%2
1
>>>
In the above case, the Python interpreter is used to execute the commands. This
is referred to as a script mode. This mode works with small codes. Though
simple commands can be executed on the command line, the complex programs
can be written in a file. A file can be created as follows:
Step 1. Go to FILE NEW
Step 2. Save the file as calc.py
Step 3. Write the following code in the file
print(2+3)
print(2*3)
print(2**3)
print(2/3)
print(2%3)
print(3/2)

08/05/2021

PYTHON OBJECTS
After reading this chapter, the reader will be able to
• Understand the meaning and importance of variables, operators, keywords, and objects
• Use numbers and fractions in a program
• Appreciate the importance of strings
• Understand slicing and indexing in strings
• Use of lists and tuples
• Understand the importance of tuples
INTRODUCTION
To be able to write a program in Python the programmer can use Anaconda, the
installation of which was described in the previous chapter—or you can use
IDLE, which can be downloaded from the reference given at the end of the
Chapter 1. IDLE has an editor specially designed for writing a Python program.
As stated earlier Python is an interpreted language, so one need not to compile
every piece of code. The programmer can just write the command and see the
output at the command prompt. For example, when writing 2+3 on the command
line we get
>>2+3
5
As a matter of fact you can add, subtract, multiply, divide and perform
exponentiation in the command line. Multiplication can be done using the *
operator, the division can be performed using the / operator, the exponentiation
can be done using the ** operator and the modulo can be found using the %
operator. The modulo operator finds the remained if the first number is greater
than the other, otherwise it returns the first number as the output. The results of
the operations have been demonstrated as follows:

Want your establishment to be the top-listed Arts & Entertainment in Addis Ababa?
Click here to claim your Sponsored Listing.

Telephone

Website

Address


Addis Ababa

Opening Hours

Monday 09:00 - 17:00
Tuesday 09:00 - 17:00