0% found this document useful (0 votes)
3 views16 pages

Python 2

Chapter 2 introduces basic programming concepts using Python, starting with simple programs and arithmetic operations. It covers variable assignments, types, and the importance of comments in code, as well as user input for dynamic calculations. The chapter emphasizes the dynamic typing nature of Python and provides examples for clarity.

Uploaded by

natashasarkar18
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views16 pages

Python 2

Chapter 2 introduces basic programming concepts using Python, starting with simple programs and arithmetic operations. It covers variable assignments, types, and the importance of comments in code, as well as user input for dynamic calculations. The chapter emphasizes the dynamic typing nature of Python and provides examples for clarity.

Uploaded by

natashasarkar18
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Chapter 2

Simple Programs

Does a child learns grammar before speaking?

I am beginning this book with a question. I am sure you will agree that a child
learns to speak first and then learn the grammar. So following this natural way
of learning I will introduce you to programs first and then explain what it is all
about.

2.1 My first program

Once you open the Python Interpreter you should see something like this: t To begin programming,
open a terminal by pressing
ap@ap:~\$ python3 crt + alt + t this will open
Python 3.6.9 (default, Apr 18 2020, 01:56:04) the terminal in Ubuntu
[GCC 8.4.0] on Linux
Type "help", "copyright", "credits" or "license" for more t Next type python3 and
information. press enter to open Python
>>> Interpreter

The Python prompt (>>>) is the place where you will type you commands for the
time being.
>>>print("Hello world") t Go ahead and try it. You
can print almost anything
Hello world
by putting them within the
inverted commas.

This is a simple command that will print the matter within the inverted commas.
You must be careful so that there is no spaces between the >>>and your command.
If you want to print Hello and world on two different lines then you can simply
insert \n between the two words. t \n stands for new line

9
Draft copy of PYTHON: for physics students ©Akhileshwar Prasad [Link]@[Link] Chapter 2 Simple Programs

>>>print(" Hello \n World")


Hello
World

2.2 Arithmetic

Let us try to perform some simple mathematical operations. Say we have two
numbers and we want to add, subtract, divide and multiply them. Well it cannot
get any simpler:
t You can use Python as a >>>2+5
simple calculator.
7
>>>2-5
t If you already know C or -3
C++ then don’t worry 2/5 >>>2/5
will be 0.4. Python takes
0.4
care of it.
>>>2*5
10

t Modulus: a%b finds the


remainder after division of Table 2.1 Python Arithmetic Operators
a by b
Operator Name Example
+ Addition x+y
t Floor division: Floor divi- - Subtraction x-y
sion returns the quotient
* Multiplication x*y
in which the digits after the
decimal point are removed. / Division x/y
What happens if one of the % Modulus x%y
numbers is negative? ** Exponentiation x ** y
// Floor division x // y

2.3 Variables and assignments

Till now we have dealt with numbers directly as we did in junior classes but you
certainly grew up and learnt algebra. Similar to algebra, we can assign a name to
the quantity of interest. Let us go back to the example in section 2.2
t Note that there is no output >>>a=2
for the assignment a=2, b=5
>>>b=5
and c=a+b. You can use
print statement to see the >>>a+b
output. ex. print(c) 7
>>>c= a+b

Draft copy of PYTHON: for physics students ©Akhileshwar Prasad [Link]@[Link]


2.3 Variables and assignments Draft copy of PYTHON: for physics students ©Akhileshwar Prasad [Link]@[Link]

>>>

a=2 is an assignment statement. It tells the computer to store the number 2 in a


memory location called “a”. Similarly, it stores the vale 5 in a memory location
called b. Since the assignment is from right to left, it then adds the values stored
at location “a” and “b” and stores the value to memory location “c”. The right
hand side of the expression is assigned to the variable on the left hand side.
>>>a=2
>>>b=5
>>>c = a+b # valid
>>>a+b = c # invalid

ADD SWAPPING WITH EXAMPLE


In Python the variable names can be as long as you like. However, a few rules
apply.
t Can a variable name start
• A variable name can only start with a letter or the underscore character _. with a number?

• A variable name can only contain alpha-numeric characters and under-


scores. ( A-Z, a-z, 0-9 and _ )

• Variable names are case sensitive. (Area, area, areA, ArEa are all different
variables)

Apart from these three rules there is one more restriction. There are 33 names
that cannot be used as variables and theses are known as keywords. To get the list
simply use the command help ("keywords").
>>>help ("keywords") t While it may be good to re-
member the keywords don’t
worry if you cannot. Note
Here is a list of the Python keywords. Enter any keyword to that there are no numbers
get more help. in the keywords. so if you
doubt whether area is a key-
False def if raise word or not just use area1
None del import return or area2.
True elif in try
and else is while
as except lambda with
assert finally nonlocal yield
break for not
class from or
continue global pass

>>>

Draft copy of PYTHON: for physics students ©Akhileshwar Prasad [Link]@[Link]


Draft copy of PYTHON: for physics students ©Akhileshwar Prasad [Link]@[Link] Chapter 2 Simple Programs

t Still not sure whether veloc- You can use any variable name that you want but life will be easier if you variable
ity is a key word? well use
names clearly indicate what they represent. So aaa may be a valid variable name
velocity1.
but velocity is a better variable name to represent velocity.

2.4 Variable Types

L After getting a basic famil- There are many types of variables but as a physics students we are mainly in-
iarity with programming it trusted in three (integer, float and complex).
is strongly recommended
to read the section on data
type. Integer

t There is a built-in function As the name indicates, integer variables can take only integer values. Both positive
called type() which tells us and negative values are allowed. In Python 3, there is effectively no limit to how
the type of variable we are long an integer value can be. It is only constrained by the amount of memory the
dealing with. ex. type(2) computer has.
gives us <class ’int’>. (don’t
worry about the term class >>>a=3
in <class ’int’>. >>>type(a)
<class 'int'>
>>>a = 123456789012345678901234567890
>>>type(a)
<class 'int'>
>>>print(a*a)
15241578753238836750495351562536198787501905199875019052100
>>>

[Link] add binary elsewhere

Float
t People have died because
someone failed to under- After reading the chapter data type in section Computer architecture and organi-
stand Float sation you will fully appreciate float. Hoverer, in a layman’s terms we can say a
float or a floating-point number,it is a number that has a decimal place. Floats are
used when we need a decimal number. Float may be written in scientific notation
using ’e’ or ’E’.
>>>b=3.4
>>>type(b)
<class 'float'>
>>>type(1.2e-14)
<class 'float'>
>>>

Draft copy of PYTHON: for physics students ©Akhileshwar Prasad [Link]@[Link]


2.4 Variable Types Draft copy of PYTHON: for physics students ©Akhileshwar Prasad [Link]@[Link]

A little more detail: According to the IEEE 754 standard, almost all platforms t Don’t worry if you don’t un-
derstand in first go. Come
represent Python float values as 64-bit “double-precision” values. In that case, the
back to it later.
maximum value a floating-point number can have is approximately 1.8 × 10308 .
Python will indicate a number greater than that by the string inf: The magnitude
of the smallest non-zero number is approximately 5.0 × 10−324 . Anything smaller
than that is effectively zero: Floats are represented internally as fractions in binary
system. Hence, with finite number of digits, most of the decimal fractions cannot
be represented exactly as a binary fraction. The difference between the two is very
small for normal cases but special care needs to be taken for scientific computing.
I once again strongly recommend to get a proper understanding of floating point
representation before starting serious programming.

Complex
p
Python has an unbuilt complex data type. The number −1 which is written as
i in mathematics is represented as j in Python. Thus, 3+4j is a complex number
where 3 is the real part and 4 is the imaginary part.
>>>a=2+3j
>>>b=3+4j
>>>a+b
(5+7j)
>>>type(a)
<class 'complex'>
>>>

String

A sequence of characters is a string. In Python anything enclosed between the t Did I say three types of
variables?
single quote or double quote is a string. characters enclosed by three single or
double quote is also a string. ex """as123""" or ”’as123”’ are strings.
>>>a="abcd" t what will be the output of
the following:
>>>type(a)
<class 'str'> >>>a=’1234’
>>>b='abcd' >>>type(a)
>>>type(b)
<class 'str'>

Python has a very rich features to handle string and a separate discussion on
strings have been included in appendix.

Draft copy of PYTHON: for physics students ©Akhileshwar Prasad [Link]@[Link]


Draft copy of PYTHON: for physics students ©Akhileshwar Prasad [Link]@[Link] Chapter 2 Simple Programs

Why do we need various types of variables?

Cannot we make life simpler by using only one type of variable? After all float and
integer seems to be a sub set of complex. We can, but it would take double the
memory space and computation speed will be almost half as compared to real. We
will come across cases where an integer say 1 is represented as 0.9999999999999.
This can lead to problems. So it is always advisable to keep an eye on the variable
type.
However the good news is that Python is dynamically typed. That means Python
doesn’t know about the type of the variable until the code is run. At while running
it assigns the proper type of variable. This is different from say C where you have
to declare the type of the variable before using it.
It may seem to make life easy as Python will take care but this feature drastically
reduces the computation speed. Also, if proper care is not taken you may end up
getting unexpected results.
If needed we can convert a variable from one type to another.
>>>a="2.3" #note the quotes makes "2.3" a string
>>>type(a)
<class 'str'>
>>>b = float(a) #we are converting string float
>>>type(b)
<class 'float'>
>>>c=int(a)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: invalid literal for int() with base 10: '2.3'

As you can see the attempt to convert string to int failed. If the string was not a
valid float within quotes say ‘2.3a’ then the float('2.3a') will also fail.
...... #continuing from previous code
>>>c=int(b)
>>>type(c)
<class 'int'>
>>>c
2
>>>

If you convert float to int the decimal part will be dropped. NOTE: it will not be
rounded. the decimal part simply vanishes.

Note

Draft copy of PYTHON: for physics students ©Akhileshwar Prasad [Link]@[Link]


2.5 My second program Draft copy of PYTHON: for physics students ©Akhileshwar Prasad [Link]@[Link]

As you can see after some lines of code I have written some comments
in plain English starting with an #. The # symbol is used to add comment.
These comments are ignored by Python while running. However, it is very
important that you develop the habit of writing comments to explain your
codes so that you will save time later when you are trying to edit or reuse
the code.

2.5 My second program

Our first program in section 2.1 only printed some string on the screen. Now let
us solve some simple physics problems.
Say we want to calculate the area of a rectangle. We know area = length × breadth.
Read the following program line by line and with what we have discussed till now
you should be able to understand it fully.
>>>length=10 # assign the value 10 to variable length t Note the space in line one
and two. The only place
>>>breadth = 22.5 # assign the value 22.5 to variable breadth
where space matters is
>>>area = length*breadth # multiply length, breadth and assign immediately after >>>.
the value to a variable area
>>>print(area) #print the value of area on screen
225.0

That was nice. However,what is the use of the program if we have change it every t If you could not under-
stand the above code then
time the size of your rectangle changes? We need some command to get input
I strongly recommend that
from the user. The command is input. To underspent it lets use it first. you go back to Chapter ??
>>>length = input("please enter the length ") and read carefully.
please enter the length

If you type the first line and press enter key you will see the second line and
Python will wait till you enter something.
please enter the length 20
>>>type(length)
<class 'str'>

As you can see I have entered 20 and pressed the enter key. Everything was OK
but the type of length is string. In Python everything that you enter is stored as
string. If you need an integer or float then you can easily convert as discussed
earlier.
>>>length = float(input("please enter the length ")) #
converting the entered value to

Draft copy of PYTHON: for physics students ©Akhileshwar Prasad [Link]@[Link]


Draft copy of PYTHON: for physics students ©Akhileshwar Prasad [Link]@[Link] Chapter 2 Simple Programs

float
please enter the length 12
>>>type(length)
<class 'float'>

Now let us rewrite our program to calculate area.


t Note how we have used the >>>length = float(input("please enter the length "))
print in a new way.
please enter the length 12
>>>breadth = float(input("please enter the breadth "))
please enter the breadth 10.5
>>>area = length*breadth
>>>print("Area of a rectangle with length ",length," and
breadth ",breadth,"is",area)
Area of a rectangle with length 12.0 and breadth 10.5 is
126.0
>>>

In this example we used print command in a new way. Till now we had been
using print as print("string") or print(number) but in this case note how
multiple strings and numbers separated by commas have been printed using a
single print command. print("string1", number1, number2, "string2")

2.6 Grow up

Now that you have successfully written and executed your first functional pro-
grams we need to discuss a few things. We have been working at the Python
prompt in the terminal. This is a convenient way for very small tasks but no one
uses it anything more than a few lines. We have a few alternatives. The simplest
one is to write the codes in a text files and then execute them from the command
prompt.
t in Ubuntu press con-
trol+alternate+t key to- There are other options of using one of the various Integrated Development
gether. This will open the Environments (IDE) like spyder, pycharm or jupyter notebook. These have been
terminal. Now you can use covered in the Appendix. However, no matter what IDE you use Python will be
gedit (which is a text editor) the same. So for the time being you can learn the hard way and use text editor
by simply using the com- to type your programs and run them from the terminal. Once you have gained
mand ‘gedit &’ to type your sufficient fluency you can switch to an IDE.
program and save it with .py
extension.

Draft copy of PYTHON: for physics students ©Akhileshwar Prasad [Link]@[Link]


2.7 Some more programs Draft copy of PYTHON: for physics students ©Akhileshwar Prasad [Link]@[Link]

2.7 Some more programs

Now that we have learnt how to get an input from the user and perform basic
calculations we can begin to write some simple codes to solve problems. We will
learn about new commands and features by working examples.

2.7.1 Program to calculate the acceleration

We know from Newton’s Second Law of Motion f or ce = mass × accel er at i on.


We want to write a program which will calculate the acceleration produced if the
force and mass is given.
Algorithm:
f or ce
1. accel er at i on = mass

2. Ask for force.

3. Ask for mass.

4. calculate acceleration.

5. print the result.

File name: [Link]


force = float(input("Please enter the force "))
mass = float(input("Please enter the mass "))
accleration = force/mass
print("Given \n\tforce = %f\n\tmass = %f\n"%(force, mass))
print("the accleration is %f"%accleration)

output:
ap@ap:~/home/codes$ python3 [Link]
Please enter the force 12.4
Please enter the mass 24.7
Given
force = 12.400000
mass = 24.700000

the acceleration is 0.502024


ap@ap:~/home/codes$

After reading the code properly you should have noticed a few new things in
the print statement. Apart from the new line \n escape sequence a new escape
sequence \t and %f formatting statement have been used.

Draft copy of PYTHON: for physics students ©Akhileshwar Prasad [Link]@[Link]


Draft copy of PYTHON: for physics students ©Akhileshwar Prasad [Link]@[Link] Chapter 2 Simple Programs

Escape Sequence

A number of escape sequence have been given in the table below.


t You may not understand
the use of all the escape Table 2.2 List of Escape Sequence
sequences at present but
don’t worry. Try them out in No. Escape Sequence Meaning
a print statement. 1 \newline Ignored
2 \\ Backslash (\)
3 \’ Single quote (’)
4 \" Double quote (")
5 \a ASCII Bell (BEL)
6 \b ASCII Backspace (BS)
7 \f ASCII Formfeed (FF)
8 \n ASCII Linefeed (LF)
9 \r ASCII Carriage Return (CR)
10 \t ASCII Horizontal Tab (TAB)
11 \v ASCII Vertical Tab (VT)
12 \ooo ASCII character with octal value ooo
13 \xhh... ASCII character with hex value hh...

So from the table we can see \t inserts a tab.

String formatting

Another new thing introduced in this program is the formatting statement


t C style formatting has some %f. In Python there are a number of ways in which you can format a string.
problems but will be suffi-
The simplest is the C-style string formatting by using % operator.
cient for our needs, the other
method is using .format() The "%" operator is used together with a format string, which contains
normal text and together we get the "argument specifiers", like the "%f" we
used in out code.

Table 2.3 Commonly used argument specifiers

%s String
%d Integers
%f Floating point numbers
%.<number of digits>f Floating point numbers with a fixed amount
of digits to the right of the dot.
%x/%X Integers in hex representation (lowercase/up-
percase)

We shall learn more about formatting as we proceed.

Draft copy of PYTHON: for physics students ©Akhileshwar Prasad [Link]@[Link]


2.7 Some more programs Draft copy of PYTHON: for physics students ©Akhileshwar Prasad [Link]@[Link]

Going back to our program in on acceleration ?? did you find any error?
What if we entered the value of mass as negative? In scientific programs you write
for yourself it is expected you will not make such mistakes but let us see how we
can avoid these if we want.
File name: [Link]
force = float(input("Please enter the force "))
mass = float(input("Please enter the mass "))
while mass<0:
mass = float(input("Please enter the positive mass "))
accleration = force/mass
print("Given \n\tforce = %f\n\tmass = %f\n"%(force, mass))
print("the accleration is %f"%accleration)

output:
ap@ap:~/home/codes$ python3 [Link]
Please enter the force 12
Please enter the mass -3
Please enter the positive mass 34
Given
force = 12.000000
mass = 34.000000

the acceleration is 0.352941

ap@ap:~/home/codes$

Here we see a new command while. Due to which the program will keep asking
for the mass till a positive value is entered. Did you notice the indention, that is a
blank space before mass in line 4. In Python this indention has a very important
meaning.

while loop

while provides us a loop with a logical decision making. As long as the


condition is satisfied the statements inside the loop will be executed. It’s
syntax is as following:
t Note the colon : and the
while condition: space before statement
statemen1 (inside the loop)
stetement2 (inside the loop) B If you put yourself in a in-
.......... (inside the loop) finite loop press crt + C to
statement (outside the loop) terminate the program.

Draft copy of PYTHON: for physics students ©Akhileshwar Prasad [Link]@[Link]


Draft copy of PYTHON: for physics students ©Akhileshwar Prasad [Link]@[Link] Chapter 2 Simple Programs

If you compare this with our program you see our condition was mass <
0, which is a comparison. All the statement that are to be inside the loop
must be indented equally (normally 4 whitespace is included before the
statement)
L Apart from comparison
more can be done in condi-
tion. Have patience....

Indenting Code

Instructions or commands written in the program for execution are called


statements. Thus there are seven statements in our program accelera-
[Link]. A group of such statements form a block. A block of code is
defined with help of indentation. If you see the program [Link]
then apart from line 4 all other lines start from the margin. Only line 4 has
a whitespace before it. Thus there are 2 blocks in this program. All lines
except line 4 is one block and line 4 is another block.
All the statements that are lined up vertically belong to the same block. A
block can be put inside another block by just increasing the indentation. In
the pseudo code below we can identify the three blocks by looking at the
whitespace before them.
t If you notice carefully you
will find the line before a statement 1 # block 1
new block ends with a colon: statement 2 # block 1
see line 3 [Link] statement 3 # block 1
statement 4 # block 2
B In Python indention is com- statement 5 # block 2
pulsory not a choice as in C
statement 6 # block 3
or C++
statement 7 # block 3
statement 8 # block 2
....# block 2
....# block 2
statement n # block 1
....... # block 1

In program [Link], instead of asking for the mass till a positive value
was entered we could simply check if the value is negative and informs the user
about the same. Let us take a look at the following program.
File name:[Link]
force = float(input("Please enter the force "))
mass = float(input("Please enter the mass "))
if mass>0:

Draft copy of PYTHON: for physics students ©Akhileshwar Prasad [Link]@[Link]


2.7 Some more programs Draft copy of PYTHON: for physics students ©Akhileshwar Prasad [Link]@[Link]

accleration = force/mass
print("Given \n\tforce = %f\n\tmass = %f\n"%(force, mass))
print("the accleration is %f"%accleration)

else:
print("Mass cannot be negative ")

output:
ap@ap:~/home/codes$ python3 [Link]
Please enter the force 12
Please enter the mass -4
Mass cannot be negative
ap@ap:~/home/codes$

In this program we come across two new commands if and else.

if .... else .....

How often do we hear these words in our day to day life. If you do this I will
do that else .... Well, in python its no different. Let us see the syntax
if condition:
statemen1 (executed if condition is true)
stetement2 (executed if condition is true)
.......... (executed if condition is true)
else:
statement3 (executed if condition false true)
statement4 (executed if condition false true)
........ (executed if condition false true)
statement (executed irrespective of the if else condition)
The if statement checks if the condition is true. If true it executes all the
statement that are indented. The else statement is optional and if needed
we can use only if. The else cannot be used alone. If the if statement is
followed by else statement then the indented statements after else are
executed only if the condition is false.

Going back to our program [Link]. What will you do if you have to
ensure that both force and mass is positive. Y you may use two if statements but
there are better ways. Study the code below.
File name: [Link]
force = float(input("Please enter the force "))

Draft copy of PYTHON: for physics students ©Akhileshwar Prasad [Link]@[Link]


Draft copy of PYTHON: for physics students ©Akhileshwar Prasad [Link]@[Link] Chapter 2 Simple Programs

mass = float(input("Please enter the mass "))


if mass>0 and force >0:
accleration = force/mass
print("Given \n\tforce = %f\n\tmass = %f\n"%(force, mass))
print("the accleration is %f"%accleration)

else:
print("Mass or force cannot be negative ")

Did you notice the condition in line 3. We have used a logical operator and to club
together two conditions. Multiple comparison can be clubbed together using
logical operators. The other logical operators are given in the table 2.4

Table 2.4 Logical Operators

No. Operator Description Example


1 and Returns True if both statements x < 5 and x < 10
are true
2 or Returns True if one of the state- x < 5 or x < 4
ments is true
3 not Reverse the result, returns False not(x < 5 and x < 10)
if the result is true

Till now in all our programs we have used only “greater than” conditions. Other
comparison operators are given below in the table 2.5.
B Note: For comparing if
equal we are using == Table 2.5 Comparison Operators
which is different from =
which is for assignment. No. Operator Name Example
if x==5: compares if x is 1 == Equal x == y
equal to 5. if x=5: assigns 2 != Not equal x != y
the value 5 to x and will
3 > Greater than x>y
always be true.
4 < Less than x<y
5 >= Greater than or equal to x <= y
6 <= Less than or equal to x >= y

2.7.2 Program to check if a given year was a leap year:

In Gregorian calendar, every fourth year has an additional day to keep it in syn-
chronized with the solar year.
To test a leap year we can use the algorithm below.
Algorithm:

Draft copy of PYTHON: for physics students ©Akhileshwar Prasad [Link]@[Link]


2.7 Some more programs Draft copy of PYTHON: for physics students ©Akhileshwar Prasad [Link]@[Link]

1. Ask for a year.

2. If (year is not divisible by 4) then (it is a common year)

3. else if (year is not divisible by 100) then (it is a leap year)

4. else if (year is not divisible by 400) then (it is a common year)

5. else (it is a leap year) .

t Do not try to memorise the


File name: leap_year.py
programs. Go through them
year = int(input("Please enter the year to be checked:")) line by line. Try to under-
if year % 4 !=0: stand them. Run them on
print("The year %d is not a leap year"%year) your pc or mobile. Then
elif year % 100 !=0: write a similar program
print("The year %d is a leap year"%year) on your own or from the
exercise.
elif year % 400 !=0:
print("The year %d is not a leap year"%year)
else:
print("The year %d is a leap year"%year)

output:
ap@ap:~/home/codes$ python3 leap_year.py
Please enter the year to be checked:1800
The year 1800 is not a leap year
ap@ap:~/home/codes$

One new thing that you should have noticed is how we are using if with else.
we are not writing else if we are writing elif.

elif

elif is a short for else if. In program leap_year.py if the condition (year
% 4 != 0 ) in line 2 is satisfied only line 4 will be executed. If however the t By using elif we can speed
up our code by skipping
condition in line 2 it is not satisfied then goes to the elif on line 4. If this
some condition checking
conation is also not satisfied then the next elif is [Link] all conditions but use it with care as un-
fails then the else block (if present) is executed. planned use may lead to cer-
tain conditions never being
tested. ADD AN EXERCISE
Does the code in leap_year.py look complicated. we can condense the code and TO SHOW THIS
write the same program as follows
File name: leap_year2.py

Draft copy of PYTHON: for physics students ©Akhileshwar Prasad [Link]@[Link]


Draft copy of PYTHON: for physics students ©Akhileshwar Prasad [Link]@[Link] Chapter 2 Simple Programs

year = int(input("Enter year to be checked:"))


if(year % 4 == 0 and year % 100 !=0 or year % 400 == 0):
print("%d is a leap year"%year)
else:
print(year,"is not a leap year")

If you have made it till here then you certainly are hungry for more. Hoverer, have
patience. Solve the exercises below on your own and run them on any device you
have. It dosen’t matter even it is a smart phone. Once completed we meet in the
next chapter.

2.8 Things to remember

2.9 Exercises

a number of exercises

Draft copy of PYTHON: for physics students ©Akhileshwar Prasad [Link]@[Link]

You might also like