D
ATA TYPE
x = 5
y = 10
print(x + y)
print(x)
global x
x = "Global variable"
myfunc()
print("After running fun " , x)
a = (green, *yellow, red) = fruits
print(type(a)," = ", a)
x = 35e3
y = 12E4
z = -87.7e1 5j
print(i)
print("Complex num1 = ", com1)
print(a[1])
print(x)
print("free" in txt)
print("expensive" not in txt)
if "Best" not in txt:
print("No, 'Best' is NOT present.")
print(b[2:5])
print(isinstance(x, int))
print("b is greater than a")
else:
print("b is not greater than a")
y = 0
print(bool(x))
ATA TYPE
x = 5
y = 10
print(x + y)
15
x = "normal variable"print(x)
normal variable
def myfunc():global x
x = "Global variable"
myfunc()
print("After running fun " , x)
After running fun Global variable
fruits = ("apple", "banana", "cherry", "strawberry", "raspberry")a = (green, *yellow, red) = fruits
print(type(a)," = ", a)
<class 'tuple'> = ('apple', 'banana', 'cherry', 'strawberry', 'raspberry')
print(type(green)," = ", green)
<class 'str'> = apple
print(type(yellow)," = ", yellow)
<class 'list'> = ['banana', 'cherry', 'strawberry']
print(type(red)," = ", red)
<class 'str'> = raspberry
print(type(fruits)," = ", fruits)
<class 'tuple'> = ('apple', 'banana', 'cherry', 'strawberry', 'raspberry')
i = 7982749187912*41647812648761x = 35e3
y = 12E4
z = -87.7e1 5j
print(i)
332464042600207994442977032
print(type(x),x)
<class 'float'> 35000.0
print(type(y),y)
<class 'float'> 35000.0
print(type(z),z)
<class 'float'> -8.77e+101
com = complex(5j + 4)
print(com.real)
4.0
print(com.imag)
5.0
print(com)
(4+5j)
print(type(com))
<class 'complex'>
com1 = 25 / 5j
com2 = 50j - (-1j)print("Complex num1 = ", com1)
Complex num1 = -5j
print("Complex num2*com1 = ", com2*com1)
Complex num2*com1 = (255+0j)
x = str("s1")
y = str(2)
z = str(3.0)
print(x)
s1
print(y)
2
print(z)
3.0
a = "Hello, World!"print(a[1])
e
for x in "banana":print(x)
b
a
n
a
n
a
txt = "The best things in life are free!"a
n
a
n
a
print("free" in txt)
True
txt = "The best things in life are free!"print("expensive" not in txt)
True
txt = "The best things in life are free!"if "Best" not in txt:
print("No, 'Best' is NOT present.")
No, 'Best' is NOT present.
b = "Hello, World!"print(b[2:5])
llo
print(b[2:])
llo, World!
print(b[:5])
Hello
print(b[-5:-2])
orl
x = 200print(isinstance(x, int))
True
print(10 > 9)
True
print(10 == 9)
False
print(10 < 9)
False
if 200 > 22:print("b is greater than a")
else:
print("b is not greater than a")
b is greater than a
print(bool("Hello"))
True
print(bool(15))
True
x = ""y = 0
print(bool(x))
False
print(bool(y))
False
print(bool(()))
False
print(bool([]))
False
print(bool({}))
False
Comments
Post a Comment