Skip to content

Instantly share code, notes, and snippets.

View pralabhsaxena05's full-sized avatar

Pralabh Saxena pralabhsaxena05

View GitHub Profile
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))
def square(n):
return n * n
num_list = [1,2,3,4]
result = map(square, num_list)
print('Mapped result is: ', list(result))
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)
result1 = eval('10 + 15')
result2 = eval('3 * 8')
print(result1)
print(result2)
x = ord('a')
y = ord('$')
z = ord(' ') #space character
print(x)
print(y)
print(z)
class Student:
name = "Joy",
age = 16,
rollNo = 25
print(dir(Student))
txt1 = "apple#banana#cherry#orange"
txt2 = "Hello how are you"
result1= txt1.split("#")
result2 = txt2.split(" ")
print(result1)
print(result2)
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)
#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)
name = "John"
age = 18
print(f"Hello World! My name is {name} and my age is {age}")