Distinguishing absolute and relative paths through a small terminal exercise.
Screenshot of a sample terminal session prepared for this article.
When working in a terminal, we first need to know our current directory. The pwd command shows it. The ls command lists directory contents, while cd changes the working directory.
An absolute path starts at the root directory. /home/melih/projects describes a complete location. A relative path depends on the current directory. cd .. moves up one level. This example only navigates directories and does not delete files.
Example
$ pwd
/home/melih
$ mkdir -p projects/demo
$ cd projects/demo
$ pwd
/home/melih/projects/demo
$ cd ..
First steps with conditions in Python
Using if, elif and else in a discriminant exercise.
Screenshot of the Python example prepared and run for this article.
An if statement runs a block when its condition is true. elif checks another possibility; else runs when none of the earlier conditions hold. Indentation defines code blocks in Python.
For a quadratic equation, the discriminant is b² − 4ac. A positive value indicates two distinct real roots; zero indicates one repeated real root. A negative value means there are no real roots. In this example a is nonzero; if a were zero, the equation would not be quadratic.
Example
a, b, c = 1, 5, 4
d = b ** 2 - 4 * a * c
if d > 0:
print("Two distinct real roots")
elif d == 0:
print("One repeated real root")
else:
print("No real roots")
Structure and appearance on a web page
Exploring the roles of HTML and CSS with a small card example.
Browser screenshot of the HTML/CSS exercise prepared for this article.
HTML defines a page’s semantic structure. Headings, paragraphs, links and images are parts of that structure. CSS controls appearance, including colour, spacing, font size and layout.
This example uses a heading and paragraph inside an article element. A max-width and padding keep the card readable on smaller screens. The screenshot shows an example made for this article, not a client project.
Example
<article class="sample-card">
<h2>Learning together</h2>
<p>A small HTML and CSS exercise.</p>
</article>