DEV Community

Punitha
Punitha

Posted on

Data Types

  • Why Programming?
    Programming is the process of writing instructions that tell a computer what to do.

  • What is a Data Types?
    A data type Specific the type of value that a variable can store.

  • What is a Primitive Data Types?
    Primitive data types are the basic built-in data types that store a single value.

  • int -> Integer numbers -> (10, -5)

  • float -> Decimal numbers -> (3.14, 25.5)

  • str -> Text/String -> ("Hello")

  • bool -> Boolean values -> (True, False)

Example:

age = 21         -> integer
price = 99.99    -> float
name = "Python"  -> string
is_pass = True   -> boolean
Enter fullscreen mode Exit fullscreen mode
  • What is a Built-in Function in Python?

A built-in function is a function that is already available in Python.

print()
input()
len()
type()
Enter fullscreen mode Exit fullscreen mode
  • print() -> Display output on the screen
print("Hello World")
Enter fullscreen mode Exit fullscreen mode

Output

Hello World
Enter fullscreen mode Exit fullscreen mode
  • input() -> Takes input form the user
name = input("Enter your name: ")
Enter fullscreen mode Exit fullscreen mode

Output

Enter your name:
Enter fullscreen mode Exit fullscreen mode
  • len() -> Returns the length of a string, list, etc.
name = "Python"
print(len(name))
Enter fullscreen mode Exit fullscreen mode

Output

6
Enter fullscreen mode Exit fullscreen mode
  • type() -> Returns the data type of a variable
x = 10
print(type(x))
Enter fullscreen mode Exit fullscreen mode

Output

<class 'int'>
Enter fullscreen mode Exit fullscreen mode

Top comments (0)