A challenge to write and get the o/p in a single line
<pedro3005>we can say that each letter has a number equivalent. a = 1, b = 2, etc. Write a program that takes in a name and outputs the sum of all numbers of the equivalent letters, in one line, not counting the “import” lines
<pedro3005> It must ignore spaces and be case-insensitive
<pedro3005> Mohan_chml, like “pedro” must be 58
Indentation
Whitespace is important in Python. Actually, whitespace at the beginning of the line is important.
This is called indentation. Leading whitespace (spaces and tabs) at the beginning of the logical line is used to determine the indentation level of the logical line, which in turn is used to determine the grouping of statements.
Read the rest of this entry »
Operators and their usage
| Operator | Name | Explanation | Examples |
|---|---|---|---|
| + | Plus | Adds the two objects | 3 + 5 gives 8. ‘a’+’b’ gives ‘ab’. |
| – | Minus | Either gives a negative number or gives the subtraction of one number from the other | -5.2 gives a negative number. 50 – 24 gives 26. |
| * | Multiply | Gives the multiplication of the two numbers or returns the string repeated that many times. | 2 * 3 gives 6. ‘la’ * 3 gives ‘lalala’. |
| ** | Power | Returns x to the power of y | 3 ** 4 gives 81 (i.e. 3 of 3* 3 * 3 * 3) |
| / | Divide | Divide x by y | 4/3 gives 1 (division of integers gives an integer).4.0/3 or 4/3.0 gives 1.3333333333333333 Read the rest of this entry » |
How variable work in Pyton
Now lets enter into the programming.
The first thing that one has to know is how to define variables, so that those variables can be used in the programs in future.
In python, there is no need to declare a variable, Instead we define one whenever needed. python knows what operations suit for the values in that variable.
Lets make it known by writing some examples
Make your python program run like an Application In Linux
Try this:
Type: $ firefox
This code opens up the firefox installed in our machine.
In a similar fashion, you can make your .py program to run like an application.
Traditional Program :D
Ok. Lets start with our traditional program, the Hello world program.
The main purpose of IDLE and python terminal is to dynamically check whether the code we entered is correct or not. Read the rest of this entry »
Install and code Python In your Machine
For Windows users, you can download and install Python from here.
And for Linux Users. Python Is default in Operating Systems like Ubuntu.
Ways to Code Python In linux
There are many ways to code Python in linux. They are
- Using Terminal
First Pen About python
Whoa!!! Here we go.
I mean Lets start (Don’t go away 😛 ).
The stuff I am going to pen in this blog is about Python. To begin with any process, We must look at the History. So My first Post is about the History of Python.