Skip to main content

Command Palette

Search for a command to run...

Part 1 : Python From Scratch

Updated
2 min read

This article explains basic data types and print function. This is good place to start your Python programming journey.

Lets Begin

  1. 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...
  1. print() function

    using 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 int or float , 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 -

    • *objects means we give any number of arguments to print function.

    • sep = ' ' as we an give any number of inputs values to the function, sep argument separates each values, by default it is set to single space ' '.

    • end = '\n' using the end argument we can set end behavior of print function, 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.

Python

Part 1 of 1