DEV Community

Lakshmi Pritha Nadesan
Lakshmi Pritha Nadesan

Posted on

Full stack python developer - day 3

Data type:
Data type identifies the type of data that a variable can store.

1.String(str):
a="hello world"
a='hello world'

2.Number(int):
a=10

3.Float(float):
a=12.2

4.Boolean(bool):
a=True
b=False

Some other data types:

list, set, complex, tuple, range, dict, set, frozenset, bytes,bytearray, memoryview, nonetype.

Reference variable:
To create a variable in python is to assign it a value using assignment operator.

Syntax:
variablename=value

Example:
number=12

Rules to write variablename:

1.Name should be meaningful.
number,word
2.Space is not allowed.
bike_no,bikeNo
3.Number are allowed but not in first place.
age1
4.No special character is allowed except _ and $ symbol.
car_no1

pass:

pass statement is null operation that does nothing when executed.The pass statement is used for future code.

type():

It is a build in function that is used to return the type of data stored in the variables of the program.

return:

The return is keyword is to exit a function and return a value.

Example 1:

num1 = 10
print(num1)
print("Datatype of num1 is",type(num1))

num2 = 26.5
print(num2)
print("Datatype of num2 is",type(num2))

num3 = 2 + 6j
print(num3)
print('Datatype of num3 is',type(num3))

Enter fullscreen mode Exit fullscreen mode

Result:

10
Datatype of num1 is <class 'int'>
26.5
Datatype of num2 is <class 'float'>
(2+6j)
Datatype of num3 is <class 'complex'>
Enter fullscreen mode Exit fullscreen mode

Example 2:

def add(no1, no2):
    print(no1+no2)
    return no1+no2

def subtract(no1,no2):
    print(no1-no2)
    return no1-no2

def multiply(no1,no2):
    print(no1*no2)
    return no1*no2

def divide(no1,no2):
    print(no1/no2)

def modules(no1,no2):
    pass

result1=add(10,12)
result2=subtract(12,8)
result3=multiply(result1,result2)
result4=divide(result3,10)

print(type(subtract(100,50)))
print(type(divide(10,20)))
print(type(modules(10,20)))
Enter fullscreen mode Exit fullscreen mode

Result:

22
4
88
8.8
50
<class 'int'>
0.5
<class 'NoneType'>
<class 'NoneType'>

Enter fullscreen mode Exit fullscreen mode

Image of AssemblyAI

Automatic Speech Recognition with AssemblyAI

Experience near-human accuracy, low-latency performance, and advanced Speech AI capabilities with AssemblyAI's Speech-to-Text API. Sign up today and get $50 in API credit. No credit card required.

Try the API

Top comments (0)

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

👋 Kindness is contagious

Engage with a sea of insights in this enlightening article, highly esteemed within the encouraging DEV Community. Programmers of every skill level are invited to participate and enrich our shared knowledge.

A simple "thank you" can uplift someone's spirits. Express your appreciation in the comments section!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found this useful? A brief thank you to the author can mean a lot.

Okay