Posts

Showing posts with the label 001-Python

Playing with Numbers and Variables in Python

Image
We will try to learn how to do declare number types (integer, floating points) arithmetic expressions in python. Lets start: First we will try doing simple arithmetic expressions on numbers : For Addition, use '+' For Subtraction, use '-' For Multiplication, use '*' For Floating point division, use '/' For Integer division, use '//' For a raise to b, use a ** b. Lets demonstrate : if you want to find the speed of a train, the formula is : speed = distance / time Instead of repeatedly using values, you can use variables, lets try it out : And yes, you can use '#' to write comments whatever you write after '#' will not be processed!!! :)

First Python Program!

Image
Lets start with writing the program, all the beginners write : Oh.. Isn't it like really great! Your first python program. In IDLE!!! So how does this work??? Just type anything you want to, in single quotes (' ') and all that will be printed. No what if you want to print 'Hey isn't this a wonderful day?' OOPS... Syntax Error. Reason?? Python finds for the next '. So it thinks that the string is 'Hey isn' and since it is not able to decode what the next part of the string ie. t this a wonderful day?' is., so it throws the ERROR. (Observe the color of the content written inside print() ) How to fix it?? Many ways. Lets look at some : The use of double quotes (" ") and escape character ( \ in this case) did the trick! :)

Starting with Python!

Image
Hi... Download Python Go to this site. download the python version 3 or above . Just run the installable. Don't worry about the security. Just run it. Follow the steps for installation. They are really simple. Use "IDLE" to run python programs!