Leap Year

Mon 21 July 2025
# created :20250629
https://share.google/camtfs4z8aiYAJNSz
year = 2000
2000 is a leap year
if (year % 400 == 0) and (year % 100 == 0):
    print("{0} is a leap year".format(year))
elif (year % 4 ==0) and (year % 100 != 0):
    print("{0} is a leap year".format(year))
else:
    print("{0} is not …

Category: basics

Read More

Length Of A String

Mon 21 July 2025
# created :20250629
# own code
string = input("Enter a string: ")
count = 0
for char in string:
    count += 1
print("Length of string is:", count)

Score: 0

Category: basics

Read More

Map

Mon 21 July 2025
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 …

Category: basics

Read More

Num

Mon 21 July 2025
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 …

Category: basics

Read More

Numpy

Mon 21 July 2025
# 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 5
np.ones((3, 3))
# Cell 6
np.eye(4)  # Identity matrix
# Cell 7
np.arange(10, 50, 5)
# Cell …

Category: basics

Read More

Palindrome

Mon 21 July 2025
# created :20250629
# own code
text = input("Enter text: ")
if text == text[::-1]:
    print("It is a palindrome")
else:
    print("It is not a palindrome")

Score: 0

Category: basics

Read More

Pandas

Mon 21 July 2025

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)
print(data.head())
data = data[['v1', 'v2 …

Category: basics

Read More

Prime Numbers

Mon 21 July 2025
# created :20250629
https://share.google/camtfs4z8aiYAJNSz
num = 29
flag = False
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")
 else:
        print …

Category: basics

Read More

Quiz

Mon 21 July 2025
# created :20250629
https://openai.com/chatgpt/overview/
import random






if __name__ == "__main__":
    quiz()
Question 1/10


What is 6 + 1?  7


✅ Correct!

Question 2/10


What is 10 + 10?  20


✅ Correct!

Question 3/10


What is 7 + 7?  14


✅ Correct!

Question 4/10


What is 5 + 1?  6


✅ Correct!

Question …

Category: basics

Read More

Rename

Mon 21 July 2025
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)
x = [1, 2, 3 …

Category: basics

Read More
Page 2 of 3

« Prev Next »