Python is programming language that has become popular in last 8 years or so.
The recommendation is to learn C and C++ first for non programmers.
These languages are like learning‘ alphabets of the programming sector.
We assume the reader knows or has basic concepts of programming.
We like to say Hello World .
print(“Hello World. Welcome to Python basics by Tektrain”)
Output
Hello World. Welcome to Python basics by Tektrain
What ever is placed in the quotes , gets printed.
The function print() is a prebuilt by developers of Python.( In C you would be learning how to make basic functions and thus have a clearer understanding.)
comments
Sometimes you need to write notes to remember right? In programming we call these side notes as comments. If you write them in your program you will get errors. The thing is if you don’t you might not recall what line of code was about. No use in writing in your notebook.
We do this in the program by using # (hash symbol) . Remember the telephone dialpad had this symbol.
#to print hello world.
The above line would be ignored. If #symbol was not given , then an error would be given.
Variables
What is a variable in programming?
Variables store information. Say a T shirt.
In programming, say tshirt’ can be thought as a datatype. The variable may be the type of shirt, Ralph Lauren T shirt
In above datatype is tshirt and variable is Ralph Lauren .
Datatypes are building blocks. Think of the real world.
Building
Say construction of a building. The windows and doors are datatypes for example.
Similarly in programming datatypes are building blocks of the program.
Types of Datatypes
- Character
- int
- float. / numerical data type
- double. /same
- string
- boolean/ yes or no, 1,0 values
Data types depends on programming languages. But all languages have some common datatypes.
Think like making a villa vs a building. Some things are common in above and something are not common.
Python Variables
- str / text type
- int, float. / Numeric
- list. / sequence type
Programming Statement end.
Think of programming codes as statement, look back at English grammar rules. Actually programming is grammar rules for programmers.
Look at below sentence.
John goes to school .
Full stop tells end of sentence. Similarly in programming languages to end sentences or statements, semi colon is used in case of
- C
- C++
- Java
In python no need to use semi colon .
Just press enter. This is called line break.
Assignment Operators
How to assign values to variables in programming?
How do we do this in maths?
= operator
say in Algebra
let x=5.
After this statement we know x equals 5. Same concept
In programming
a=6
b=7
c=a+b
In above left side values are stored in variables.
After last line we want to know results
so write
#to get results
print (c) // result is 13
Follow us
https://www.facebook.com/share/14Jsx9P7qRf/?mibextid=wwXIfr
0 Comments:
Post a Comment