Examples · Programming
Code with Qwen3-Coder
The model made for programming. Have it write a log analyser, explain it and find a bug in it, then get your own code reviewed.
Intermediate · 40 min
The model
Qwen3-Coder 30B (qwen3-coder-30b) is the model for programming: it writes, explains and fixes code in Python, Bash, JavaScript, SQL and more, and it can call tools. It is fast: on the school's machines it writes more than 100 tokens a second.
It can be wrong, like every model. Run and test what it writes before you trust it.
1. Write a script, in the chat
Open the chat, choose Qwen3-Coder 30B and ask:
Write a Python script that reads a Linux
/var/log/auth.logfile and prints, for each IP address, how many failed SSH logins it made, from the most to the least. Use only the standard library.
Then, in the same conversation:
- Explain the regular expression, piece by piece.
- Add a
--min Noption that shows only the addresses with at least N failures. - Write two tests with
unittest. - Now do the same with a Bash one-liner (
grep,awk,sort,uniq).
2. Find the bug
Paste this function and ask: "Why does it never find port 22 open? Fix it."
import socket
def open_ports(host, first, last):
found = []
for port in range(first, last):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(0.5)
if s.connect_ex((host, port)) == 0:
found.append(port)
s.close()
return found
print(open_ports("127.0.0.1", 1, 22))
Try to find it yourself first: the answer is at the end of the page.
3. Review your code, from Python
You need your API key, from Your first API call in Python.
import os
import sys
from openai import OpenAI
client = OpenAI(
base_url="https://api.ai.itsincom.org/v1",
api_key=os.environ["API_KEY"],
)
code = open(sys.argv[1]).read()
review = client.chat.completions.create(
model="qwen3-coder-30b",
temperature=0,
messages=[
{"role": "system", "content": "You are a senior developer and a security reviewer. Be concise."},
{"role": "user", "content": "Review this code. List the bugs and the security problems, "
"the most serious first, then show the fixed code.\n\n" + code},
],
)
print(review.choices[0].message.content)
Save it as review.py and run python review.py my_script.py.
4. Exercise
- Ask the same script to Gemma 4 26B and to Qwen3-Coder 30B: which code runs at the first try?
- Review one of your own scripts with the program above. Do you agree with every remark?
- Ask Qwen3-Coder to explain a piece of code you did not write, as if to a first-year student.
Good to know
- Never paste passwords, keys or real customer data into a prompt.
- One request can hold about 32,000 tokens, question and answer together: a few thousand lines of code.
- Every question uses your credits; your Usage page shows what each one cost.
The bug in section 2: range(first, last) stops before last, so range(1, 22) ends at 21 and port 22 is never tried. Use range(first, last + 1).
