Bessy Beach

Today morning we went to Besent nagar beach. I went along with my friends with a strength of 8 members. We reached at 6am to see the early sunrise, after that we sit together and ahd fun. The journey ended with a Tea and Bonda which is the best finish for this wonderful journey

College Starts

Today the college has started and I am stepping into second year. I felt so sleepy as I watched the match between India and English which is waste of time. The college started the classes with aptitude, which comes under the placement training.

Little Exploration

This day me and my friends went to Max to buy some dresses for the daily use. I am new to Max as my friend suggested. But I really surprised about the collection there. Though the dresses were awesome, the prices were less compared to other shops like Relaince trends.

After finishing the shopping, we were so thirsty as the day was very hot. So we decided to have a ice cream. So we chose Ibaco which is famous for icecream. The was more interactive with more than 10 types of icecream. I chosen Italian delight were the name itself is soo catchy. They placed the scoop in a cone and requested me to select the toppings. It was new to me. I selected choco chip, blueberry and liquid chocolate with almonds. When I tried it, it was awesome that I haven’t tasted a icecream like that. If you want to try something new, especially in the summer I strongly recommend to go for it for tasty icecream.

Trip to Village

It’s been a week since the last blog. Just visited some villages in the interior of Tamil Nadu. Just spent only one day but it feels like a week. The purpose that my family and me visited the village is to worship the Lord Neelavaeni Amman. The temple is located at the corner of the village nedungulam. As there is no place to stay, we decided to stay in the temple itself. I think it is the worst part of the journey. As the time went the mosquito started to intrupt our sweet dreams, and we all suffered from severe lack of sleep. And another major issue is the day which we went is a sunny day. It’s been too hot as we cannot stand even a minute. Anyhow we managed to visit the temple. The people around us were very careful and we felt a secured feeling. Then after worshipping the Lord Venkateswara we moved to the Cuddalore bus stand and returned to our home.

List

a = [ ” Chandru ” , 1 , 456 , ” Python ” ]

List is a collection of the datatypes. The value denote the index 0, such that when we print the value a[0], it will gives the output as Chandru. Similarly when we print a[3], it will give the output as 456.

If we give the negative sign it will access the list in the backwise order.

So that when we print a[-1], it will give the output as “Python”. We can aslo search whether the word is present in the list.

>>> ” Chandru ” in a

True

>>> ” Linux ” in a

False

Program to print Power series

To write a program that prints series of 1+x/1+x**2/2!…+x**n/n.

n = int(input( ” Enter the number ” )

sum = term = n = 1

while n < 100:

term *= x / n

sum += term

n = n+1

if sum < 0:

break

print( ” Sum is = %d ” % sum )

When we execute this, the output will be

Enter the number 0

Sum is = 1

For loop

For loop in Python is not same as in c. It will automatically increment the value which is in the range.

a = [ ” Python ” , ” is ” , ” easy’ ]

for i in a:

print(i)

When we execute this program, first it will print the value ” Python ” which has the index 0 and followed by the next index. Similarly we can fix some range in which the for loop has to be executed.

Program to print Asterisk symbol in tringle manner :-

row = int(input(” Enter the number of rows “))

while row >=0:

print( “*” * row)

row = row – 1

The output of this program will be

Enter the number of rows 5

*****

****

***

**

*

Condition statement

One of the condition statement used in the Python is if-else. If condition checks the set of code and executes only if the condition satisfies. If the condition is not satisfied, else condition is used

Number = int(input ( ” Enter the number ” ))

if number < 100 :

print(” The number is less than 100 “=)

else :

print(” The number is greater then 100″)

Looping statement

Looping statement is used when a set of code has to be repeated. It must have an range for the number of times the loop has to be executed. In Python there are many looping statements like while and for.We look on a example that to print values within the ramge as we the range as input

Range = int(input(” Enter the range “))

n = 1
While n <= Range :

print(n)

n += 1

Thus when we execute the program, the loop starts from 1 and continues to execute this block of code till the range.

Fibonacci series

Fibonacci series is the series of addition of first and second number and producing third number.

a , b = 0, 1

print(a)

while b < 10 :

print(b) # print(b, end=’ ‘ )

a , b = b , a + b

Output

0
1

1

2

3

5

8

Note – When we want to print the above output in a same line, end keyword is used.

0 1 1 2 3 5 8

Operators

Operator are the special symbols which we can use for arithmetic and logical expression. There are many types of operator based on their use like arithmetic operator(+.-./,*), comparative operator and so on.

>>> a=10

>>> b=20

>>> a+b

30 # Thus + is the arithmetic operator

Similarly for comparative operator, there are equal to(==), less than or equal to(<=), greater than or equal to(>=), not equal to (!=), less than (<) and greater than(>) operator.

>>> 1<5

True

>>> 1>5

False

A simple program to calculate the months and days when we give the input as days.

days = int(input(” Enter the number of days “

months = days / 30

remaining_days = days % 30

print(” %d months and %d days ” % (months, remaining_days)

When we give the input as 135, this will show the input as ” 4 months and 15 days “

Expression

>>> a = 5

>>> b = 10

>>> c = 15

>>>x= a + (b*c)

>>> print(x)

155

In the program the expression which is enclosed with the () parentheses will be given first priority and gets executed. And then the value is added to the expression. Similarly for different variable there is different priority in which it is executed.

Type Conversion

>>> a = ” Chandru “

>>> int(a)

274

Thus we want to change the type of variable manually. The second line converts the string value and displays the equivalent value which is converted to the integer type. Similarly we can convert float to string or string to float and any other variable.

Datatypes and Variables

In python there are many keywords which has different attributes. The keyword has special attribute to the python language. Example int is a keyword which is used to declare a variable with integer type. Similarly there are many keywords which we can used in python.

In python, based on the values we are assigning, the datatype of the variable is automatically assigned while in the other programming language we want to declare the datatype for every declaration. If we declared a=1, the compiler will automatically assign the datatype of a as integer. If we assign a=1.5, the compiler will automatically assign the datatype as float.

Reading Values through Keyboard

In python we can read the values from the keyboard in a easy way.

number = int(input(” Enter the number ” )

Thus when we execute the program, it will show “Enter the number” and ask the user to enter the number. To read the values,we want to declare the datatype of the input.

Assigning a Variable

The variable can be assigned in different ways in python. But the assignment is more easy compared to other languages.

a , b = 10, 20 # Thus the compiler will assign the value of a as 10 and the value of the b has 20

So by this way, Swapping of two numbers can be easily done.

a , b = b , a

The value stored in the a will be assigned to b and the value stored in b will assigned to will assigned to a. Thus when we print the value

print( a ) # The Output will be 20

print( b ) # The Output will be 10

Formatting Method

Python has various formatting methods in string. The most common and preferable method is .format method.

name = ” Chandru “

place = ” Chennai “

sentence = ” {0} lives in {1} “.format(name, place)

print( sentence )

When we print the sentence, {0} is replaced by the name and {1} is replaced by the place. The second method is f String.

name = ” Chandru ”

place = ” Chennai “

sentence = f” {name} lives in {place} “

print( sentence )

When we print this, the string which is stored in the variable name will be replaced and similarly for the place.