P1-4096
Sat 18 April 2026
my_int = 25
my_float = 7.5
my_string = "Hello"
my_bool = False
print("Integer:", my_int)
print("Float:", my_float)
print("String:", my_string)
print("Boolean:", my_bool)
Integer: 25
Float: 7.5
String: Hello
Boolean: False
features=["age","version","income"]
age=[12]
version=[3.11]
income=[200000]
print("Features:",features)
print("Age:",age)
print("Version:",version)
print("Income:",income)
Features: ['age', 'version', 'income']
Age: [12]
Version: [3.11]
Income: [200000]
from fastapi import FastAPI
from pydantic import BaseModel
app = FastAPI()
# Sample in-memory "database"
items = [
{"id": 1, "name": "Laptop", "price": 800},
{"id": 2, "name": "Phone", "price": 500}
]
# -----------------------
# GET endpoint
# -----------------------
@app.get("/items")
def get_items():
return {"items": items}
# -----------------------
# POST endpoint
# -----------------------
class Item(BaseModel):
name: str
price: float
@app.post("/items")
def create_item(item: Item):
new_item = {
"id": len(items) + 1,
"name": item.name,
"price": item.price
}
items.append(new_item)
return {
"message": "Item created",
"item": new_item
}
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
Cell In[5], line 1
----> 1 from fastapi import FastAPI
2 from pydantic import BaseModel
3
4 app = FastAPI()
ModuleNotFoundError: No module named 'fastapi'
Score: 5
Category: narmatha