You are on page 1of 6

EXP NO :1

TITLE: Introduction to variable & data


NAME:KHUSHI KUMAWAT
ROLL NO:136
DATE:15/01/2024
Experiments No 1
AIM:
Write Introduction Variable & Data .
CODE:
roll="Roll no : 136"
print(roll)
name="Name : Khushi Kumawat"
print(name)
clg="Collgee Name: Thadomal Shahni Enginerring Clg"
print(clg)
print("Branch: SE/IT")
print("DOB: 12/08/2004")
print("Address: bhadar nagar, m2, rooom no 7,malad(west)")
#this is comment
#if part
"""hii
how are you?
this is multilin string"""
if 5>2:
print("5 is greater than 2")
print("done!")
#variable
x=3
y="me"
print(x)
print(type(x))
print(y)
print(type(y))
x="new value"
print(x)
print(type(x))
#casting
x=int(3)
print(x)
#case sensistive
a=1
A="khushi"
print(a)
print(A)
#legal variable can have (A-z)(1-9) and _
roll_no="Roll no : 136"
print(roll_no)
_name_="Name : Khushi Kumawat"
print(_name_)
_clg_name_="Collgee Name: Thadomal Shahni Enginerring Clg"
print(_clg_name_)
#unpacking
fruits=["mango","apple","banana"]
EXP NO :1
TITLE: Introduction to variable & data
NAME:KHUSHI KUMAWAT
ROLL NO:136
DATE:15/01/2024
x,y,z=fruits
print("array: ",x,y,z)
#gobal variable
def fun1():
global x
x="hello"
fun1()
print(x)

#Built-in Data Types

#int
x=5
print(type(x))
#string
x = "hello"
print(type(x))
#float
x = 5.5
print(type(x))
#list
x = ["apple", "strawberry", "cherry"]
print(x)
print(type(x))
#tuple
x = ("apple", "banana", "strawberry")
print(x)
print(type(x))
#range
x = range(6)
print(x)
print(type(x))

#list and array


x = frozenset({"apple", "banana", "cherry"})
print(x)
print(type(x))

#bool
x = True
print(x)
print(type(x))
#bits

x = b"Hello"
print(x)
print(type(x))
#bytearray
EXP NO :1
TITLE: Introduction to variable & data
NAME:KHUSHI KUMAWAT
ROLL NO:136
DATE:15/01/2024
x = bytearray(5)
print(x)
print(type(x))
#memoryview
x = memoryview(bytes(5))
print(x)
print(type(x))
#nonetype
x = None
print(x)
print(type(x))

#specific data type

#string
x = str("Hello Khushi")
print(x)
print(type(x))

#int
x = int(20)
print(x)
print(type(x))

#float
x = float(20.5)
print(x)
print(type(x))

#complex
x = complex(1j)
print(x)
print(type(x))

#list
x = list(("apple", "strawberry", "cherry"))
print(x)
print(type(x))

#tuple
x = tuple(("apple", "banana", "strawberry"))
print(x)
print(type(x))

#range
x = range(10)
print(x)
EXP NO :1
TITLE: Introduction to variable & data
NAME:KHUSHI KUMAWAT
ROLL NO:136
DATE:15/01/2024
print(type(x))

#dict
x = dict(name="ANSH", age=45)
print(x)
print(type(x))

#Convert from one type to another:


x = 10 # int
y = 20.8 # float
z = 1j # complex
print(x)
print(y)
print(z)
print(type(x))
print(type(y))
print(type(z))
#convert from int to float :
a = float(x)
#convert from float to int:
b = int(y)
#convert from int to complex:
c = complex(x)
print(a)
print(b)
print(c)
print(type(a))
print(type(b))
#convert from int to float:
print(type(c))

#random() function
import random
print(random.randrange(1, 40))

OUTPUT:
y
Roll no : 136
Name : Khushi Kumawat
Collgee Name: Thadomal Shahni Enginerring Clg
Branch: SE/IT
DOB: 12/08/2004
Address: bhadar nagar, m2, rooom no 7,malad(west)
5 is greater than 2
done!
3
<class 'int'>
me
EXP NO :1
TITLE: Introduction to variable & data
NAME:KHUSHI KUMAWAT
ROLL NO:136
DATE:15/01/2024
<class 'str'>
new value
<class 'str'>
3
1
khushi
Roll no : 136
Name : Khushi Kumawat
Collgee Name: Thadomal Shahni Enginerring Clg
array: mango apple banana
hello
<class 'int'>
<class 'str'>
<class 'float'>
['apple', 'strawberry', 'cherry']
<class 'list'>
('apple', 'banana', 'strawberry')
<class 'tuple'>
range(0, 6)
<class 'range'>
frozenset({'banana', 'cherry', 'apple'})
<class 'frozenset'>
True
<class 'bool'>
b'Hello'
<class 'bytes'>
bytearray(b'\x00\x00\x00\x00\x00')
<class 'bytearray'>
<memory at 0x0000011BDDE9FC40>
<class 'memoryview'>
None
<class 'NoneType'>
Hello Khushi
<class 'str'>
20
<class 'int'>
20.5
<class 'float'>
1j
<class 'complex'>
['apple', 'strawberry', 'cherry']
<class 'list'>
('apple', 'banana', 'strawberry')
<class 'tuple'>
range(0, 10)
<class 'range'>
{'name': 'ANSH', 'age': 45}
<class 'dict'>
EXP NO :1
TITLE: Introduction to variable & data
NAME:KHUSHI KUMAWAT
ROLL NO:136
DATE:15/01/2024
10
20.8
1j
<class 'int'>
<class 'float'>
<class 'complex'>
10.0
20
(10+0j)
<class 'float'>
<class 'int'>
<class 'complex'>
26

You might also like