Python.science
7.3K subscribers
1 photo
21 files
12 links
Download Telegram
Python notes ☝️☝️
17👍4
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.linear_model import LogisticRegression

# Sample training data (manually added)
texts = [
"NASA finds water on Mars",
"Apple launches new iPhone with AI",
"Aliens have landed in Delhi",
"Government bans all smartphones",
"COVID-19 vaccine approved worldwide",
"World ends tomorrow",
"Elon Musk buys the Moon",
"UN announces global peace treaty",
]
labels = ["REAL", "REAL", "FAKE", "FAKE", "REAL", "FAKE", "FAKE", "REAL"]

# Step 1: Preprocess
vectorizer = TfidfVectorizer()
X = vectorizer.fit_transform(texts)

# Step 2: Train model
model = LogisticRegression()
model.fit(X, labels)

# Step 3: Take input and predict
headline = input("📰 Enter a news headline: ")
headline_vec = vectorizer.transform([headline])
prediction = model.predict(headline_vec)

print(" This news is:", "FAKE " if prediction[0] == "FAKE" else "REAL ")
10🔥6👍2
Fake News Detector ☝️
👍71
from instabot import Bot

bot = Bot()

#Login
bot.login(username="your_username", password="your_password")
#Don't use your main account because it might get affected!
#Create a demo account for test purpose!

#Follow a user
bot.follow("elonmusk")

#comment
bot.comment("coding","Great content!")

#send DM to someone
bot.send_message("Hey! Big fan",["python.science","only_programming"])
7🔥3
Instagram Bot
from openai import OpenAI

client = OpenAI(api_key="YOUR_API_KEY")

messages = [
{"role": "system", "content": "You are an intelligent assistant."}
]

while True:
message = input("User : ")
if message:
messages.append({"role": "user", "content": message})

chat = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=messages
)

reply = chat.choices[0].message.content
print(f"ChatGPT: {reply}")

messages.append({"role": "assistant", "content": reply})
7😱4
Chatbot using python
# YT Complete Playlist Download
from pytube import Playlist

p = Playlist("https://www.youtube.com/playlist?list=PLxgZQoSe9cg00xClkch7Gr")

for video in p.videos:
video.streams.first().download()
4😢4
I really wish my seniors told me about these websites before my final year 👇

1/ NotebookLM:
Upload your study notes or articles and instantly turn them into podcasts.
https://notebooklm.google/

2/ Writefull:
Specially trained on journals to improve your academic writing and works seamlessly with Overleaf & Word.
https://www.writefull.com/

3/ Undetectable AI:
Upload your study notes and get text that sounds natural and authentic.
https://undetectable.ai/?dv=ca&peoc=true

4/ PDF Drive:
Access all the books and articles you need for school or college in one place.
https://pdfdrive.com.co/

5/ Writefull:
Specially trained on journals to improve your academic writing - and works seamlessly with Overleaf & Word.
https://mapify.so/
5