This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
str1 = "Hello World" | |
a = 12.5 | |
tup = ('a', 'b', 'c') | |
print('hash value for a string: ', hash(str1)) | |
print('hash value for a decimal: ', hash(a)) | |
print('hash value for a tuple: ', hash(tup)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def square(n): | |
return n * n | |
num_list = [1,2,3,4] | |
result = map(square, num_list) | |
print('Mapped result is: ', list(result)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
numbers = [1, 2, 3] | |
letters = ['One', 'Two', 'Three'] | |
result = zip(numbers, letters) | |
# converting values to print as set | |
result = set(result) | |
print('The zipped result is: ', result) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
result1 = eval('10 + 15') | |
result2 = eval('3 * 8') | |
print(result1) | |
print(result2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x = ord('a') | |
y = ord('$') | |
z = ord(' ') #space character | |
print(x) | |
print(y) | |
print(z) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Student: | |
name = "Joy", | |
age = 16, | |
rollNo = 25 | |
print(dir(Student)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
txt1 = "apple#banana#cherry#orange" | |
txt2 = "Hello how are you" | |
result1= txt1.split("#") | |
result2 = txt2.split(" ") | |
print(result1) | |
print(result2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tqdm.notebook import trange, tqdm | |
from time import sleep | |
for i in tqdm(range(4), desc = "outer loop"): | |
for j in tqdm(range(10), desc = "inner loop"): | |
sleep(0.25) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#List containing even numbers | |
even_List = [num for num in range(10) if num%2 == 0] | |
#Square of given numbers | |
square_List = [num*num for num in range(10)] | |
print("Even numbers are: ", even_List) | |
print("Squared numbers are: ", square_List) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name = "John" | |
age = 18 | |
print(f"Hello World! My name is {name} and my age is {age}") |
OlderNewer