Skip to content

Instantly share code, notes, and snippets.

View makwanadeepam's full-sized avatar
😄

Deepam Makwana makwanadeepam

😄
View GitHub Profile
# Linear Regression
# Model
from sklearn.linear_model import LinearRegression
reg=LinearRegression()
# Data
X=[[1], [2], [3], [4], [5], [6]]
Y=[2+1,4+1,6+1,8+1,10+1,12+1]
s: set={1,2,3,4,5,55,5}
print(s)
# for loop
for i in s:
print(i)
# add, remove, clear, discard
s.add(33)
print(s)
t: tuple=(1,2,3,4,5,5,5)
# for loop
for i in t:
print(i)
# immutable
# count
print(t.count(5))
l: list=[1,2,3,4,5]
# for loop
for i in l:
print(i)
# append
l.append(55)
print(l)
# Parameter in definition, argument in function call
# No args + No return value
def printHello():
print("Hello")
printHello()
# args + no return value
def printHelloWithName(name):
print("Hello",name)
# print 1 to 10
# using while loop
x=1
while(x<=10):
print(x)
x+=1
# using for loop
for i in range(1,11):
# if elif else
x=15
if(x>18): # Using circular brackets
print("Eligible to vote")
elif(x==18):
print("Just became eligible to vote")
elif x<=5: # Using space
print("You're a child")
else:
# Arithmetic Operators & Assignment Operators
print(
5+3,
5-3,
5*3,
5/3,
5%3,
5**3,
5//3
)
name=input("Enter your name: ")
# input function by default takes string arguments
try:
x=input("Enter number to add with 5: ")
print(x+5)
except:
print("Error")
# What do you think happened?
# Initializing a variable (declaration is done at the time of initialization)
x=5
y="Hello World"
truthValue=True
# variableName = value
# Primitives: bool, int, float, complex, string
booleanVariableTrue=True