Map
nums_1 = list(range(1))
squared_1 = list(map(lambda x: x ** 2, nums_1))
print("Cell 1 - map")
print("Input:", nums_1)
print("Squared:", squared_1)
nums_1 = list(range(2))
squared_1 = list(map(lambda x: x ** 2, nums_1))
print("Cell 1 - map")
print("Input:", nums_1)
print("Squared:", squared_1)
nums_1 = list(range(3))
squared_1 = list …
Read More
Num
a = 1
b = 1 * 2
print(f'Result: {a + b}')
a = 2
b = 2 * 2
print(f'Result: {a + b}')
a = 3
b = 3 * 2
print(f'Result: {a + b}')
a = 4
b = 4 * 2
print(f'Result: {a + b}')
a = 5
b = 5 * 2
print(f'Result: {a + b …
Read More
Numpy
# Cell 1
import numpy as np
# Cell 2
a = np.array([1, 2, 3])
# Cell 3
b = np.array([[1, 2], [3, 4]])
# Cell 4
np.zeros((2, 3))
# Cell 6
np.eye(4) # Identity matrix
# Cell 7
np.arange(10, 50, 5)
Read More
Pandas
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.naive_bayes import MultinomialNB
import streamlit as st
data = pd.read_csv('C:/Users/HP/Desktop/OIB-SIP/emailspam/dataset-mail/spam.csv', encoding='latin-1')
print("Original Shape:", data.shape)
Read More
Prime Numbers
https://share.google/camtfs4z8aiYAJNSz
if num == 0 or num == 1:
print(num, "is not a prime number")
elif num > 1:
for i in range(2, num):
if (num % i) == 0:
flag = True
brea
if flag:
print(num, "is not a prime number")
Read More
Rename
x = [1, 2, 3]
y = ['a', 'b', 'c']
z = zip(x, y)
print(list(z))
x = lambda a, b, c : a + b + c
print(x(1, 2, 3))
nums = [1, 2, 3, 4, 5, 6]
result = list(filter(lambda x: x % 2 == 0, nums))
print(result)
Read More