Part 1 : Python From Scratch
This article explains basic data types and print function. This is good place to start your Python programming journey.
Lets Begin
- Data types -
Python has many data types, below are some most basic data types with examples .
We will learn about more data types/structures as we proceed…
## Data Types
1. int -> eg - 1,3,4,etc.
2. float -> eg - 1.02, 2.4, 4.8, etc
3. str -> eg - "Hello", "Anything", 'Hii', '''Something''' , etc.
4. And more...
print()functionusing
print()function we can show output values on screen.
print(1)
print(2.5)
print("Hello")
print("Hii","Python",15)
print("Bye","C",sep=">",end=' ')
print("Bye")
Output :
1
2.5
Hello
Hii Python 15
Bye>C Bye
As shown above, for printing
intorfloat, we can directly pass it inside print function. But for string we use double quotes -"string", we can also use single quotes -'string'or three single quotes -'''string'''or three double quotes -"""string""".Syntax of print function is :
print(*objects, sep=' ', end='\n')Let’s break down the syntax -
*objectsmeans we give any number of arguments toprintfunction.sep = ' 'as we an give any number of inputs values to the function,separgument separates each values, by default it is set to single space' '.end = '\n'using the end argument we can set end behavior ofprintfunction, by default it is set to'\n', which is a escape sequence called newline character. This forces print function to switch to newline at the end each execution.