Python Projects & Free Books
40.2K subscribers
620 photos
94 files
283 links
Python Interview Projects & Free Courses

Admin: @Coderfun
Download Telegram
Python Projects
👍2🔥1
🔰 For Loop In Python
🔥3
- Location of Mobile Number Code -

import phonenumbers
from phonenumbers import timezone
from phonenumbers import geocoder
from phonenumbers import carrier

number = input("Enter the phone number with country code : ")

# Parsing String to the Phone number
phoneNumber = phonenumbers.parse(number)

# printing the timezone using the timezone module
timeZone = timezone.time_zones_for_number(phoneNumber)
print("timezone : "+str(timeZone))

# printing the geolocation of the given number using the geocoder module
geolocation = geocoder.description_for_number(phoneNumber,"en")
print("location : "+geolocation)

# printing the service provider name using the carrier module
service = carrier.name_for_number(phoneNumber,"en")
print("service provider : "+service)
🔥2
Convert any long article or PDF into a test in a couple of seconds!

Mini-service: we take the text of the article (or extract it from PDF), send it to GPT and receive a set of test questions with answer options and a key.

First, we load the text of the material:
# article_text — this is where we put the text of the article
with open("article.txt", "r", encoding="utf-8") as f:
    article_text = f.read()

# for PDF, you can extract the text in advance with any library (PyPDF2, pdfplumber, etc.)


Next, we ask GPT to generate a test:
prompt = (
    "You are an exam methodologist."
    "Based on this text, create 15 test questions."
    "Each question is in the format:\n"
    "1) Question text\n"
    "A. Option 1\n"
    "B. Option 2\n"
    "C. Option 3\n"
    "D. Option 4\n"
    "Correct answer: <letter>."
    "Do not add explanations and comments, only questions, options, and correct answers."
)
response = client.chat.completions.create(
    model="gpt-4o",
    messages=[
        {"role": "system", "content": prompt},
        {"role": "user", "content": article_text}
    ])
print(response.choices[0].message.content.strip())


Suitable for online courses, educational centers, and corporate training — you immediately get a ready-made bank of tests from any article.
👍1