Technical Documentation Page - Build a Technical Documentation Page

ERROR: it tells me to…

  1. Each .main-section should have an id that matches the text of its first child, having any spaces in the child’s text replaced with underscores (_ ) for the id’s.

  2. Each .nav-link should have an href attribute that links to its corresponding .main-section (e.g. If you click on a .nav-link element that contains the text “Hello world”, the page navigates to a section element with that id).

My code so far

<!DOCTYPE html>
    <title>Python Programming</title>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="styles.css">
      <main id="main-doc">
        <section class="main-section" id="Object_Oriented_Programming_in_Python"><header>Object-Oriented Programming in Python</header>
        <p>Python is an object-oriented programming (OOP) language, which means it supports the creation of classes and objects. OOP is a programming paradigm that uses objects (instances of classes) to model and represent real-world entities and their interactions. Python's implementation of OOP is both powerful and easy to use.</p>
        <p>In Python, a class is a blueprint for creating objects. It defines the attributes (data) and methods (functions) that objects of the class will have. To create an object from a class, you instantiate it using the class name followed by parentheses.</p>
        <p>Python supports inheritance, which allows you to create new classes that are based on existing classes. This promotes code reuse and allows you to model complex relationships between objects. Subclasses inherit attributes and methods from their parent classes.</p>
        <li>Python provides mechanisms for encapsulation, which is the practice of hiding the internal details of an object and exposing a public interface. By using private and protected attributes and methods, you can control access to the inner workings of a class, promoting data integrity and security.</li>
        <li>Polymorphism is another key OOP concept in Python. It allows objects of different classes to be treated as objects of a common base class. This facilitates flexibility and extensibility in your code.</li>
        <code>class Dog:
    def __init__(self, name): = name

    def bark(self):
        return f"{} says woof!"

my_dog = Dog("Buddy")
        <section class="main-section" id="Working_with_Files_in_Python">
  <header>Working with Files in Python</header>
        <p>Working with files is a common task in programming, and Python provides a straightforward and flexible way to read from and write to files. You can work with text files, binary files, and even CSV or JSON files.</p>
        <p>To work with files in Python, you typically open them using the open() function, specifying the file's name and mode (read, write, append, etc.). It's important to close files explicitly using the close() method to release system resources.</p>
        <p>You can read the contents of a file in various ways, including reading the entire file at once, line by line, or character by character. The read(), readline(), and readlines() methods are commonly used for reading.</p>
        <li>To write data to a file, you open it in write mode ("w") or append mode ("a") and use the write() method to add content.</li>
        <li>Python can also work with binary files, such as images or executable files. When working with binary files, you should use binary mode ("rb" for reading, "wb" for writing).</li>
    file = open("example.txt", "r")  # Open for reading
    content =
    # Process the file content
        <section class="main-section" id="List_Comprehensions">
  <header>List Comprehensions</header>
        <p>List comprehensions are a concise and elegant way to create lists in Python. They allow you to create a new list by applying an expression to each item in an existing iterable (such as a list, tuple, or range) and optionally filtering the items based on a condition.</p>
        <p>List comprehensions are not only efficient but also make your code more readable.</p>
        <p>List comprehensions are used in a variety of scenarios, such as creating new lists, filtering data, and performing calculations on iterables. </p>
        <li> They are particularly useful when you want to apply a simple operation to every element in a sequence and collect the results in a new list</li>
        <li>They can improve code performance because they are optimized by Python.They promote a functional programming style, making your code more Pythonic</li>
        <code>numbers = [1, -2, 3, -4, 5]
squares = [x**2 for x in numbers if x > 0]</code>
        <section class="main-section" id="Python_Libraries_for_Data_Science">
  <header>Python Libraries for Data Science</header>
        <p>Python has gained immense popularity in the field of data science and machine learning, thanks in large part to its rich ecosystem of libraries and tools. Some of the most important libraries for data science in Python include NumPy, pandas, and matplotlib.</p>
        <p>NumPy, short for "Numerical Python," is a fundamental library for scientific computing in Python. It provides support for arrays and matrices, along with a collection of mathematical functions to operate on them efficiently.</p>
        <p>pandas is a powerful library for data manipulation and analysis. It offers data structures like DataFrame and Series, which are ideal for handling structured data. With pandas, you can perform tasks such as data cleaning, transformation, aggregation, and visualization.</p>
        <li>matplotlib is a versatile library for creating static, animated, and interactive plots and charts in Python. It provides a wide range of plotting functions and customization options, making it a valuable tool for data visualization.</li>
        <li>NumPy is the foundation for many other data science libraries in Python.</li>
        <code>import pandas as pd

# Read data from a CSV file
data = pd.read_csv('sales_data.csv')

# Calculate total sales
total_sales = data['Revenue'].sum()

# Create a bar chart of sales by product category
        <section class="main-section" id="Exception_Handling_in_Python">
  <header>Exception Handling in Python</header>
        <p>Exception handling is a crucial aspect of Python programming that allows you to gracefully manage errors and unexpected situations in your code. Exceptions are events that disrupt the normal flow of a program, and Python provides mechanisms to catch, handle, and raise exceptions.</p>
        <p>The try and except blocks are used to handle exceptions in Python. Code within the try block is executed, and if an exception occurs, control is transferred to the except block where you can handle the exception.</p>
        <p>The finally block is used to specify code that should always be executed, whether an exception is raised or not. This is useful for tasks like closing files or releasing resources.</p>
        <li>You can also raise exceptions using the raise statement. This is useful when you want to indicate that an error condition has occurred.</li>
        <li>Exception handling is essential for writing robust and error-tolerant code in Python. It allows your program to handle errors gracefully without crashing</li>
    result = 10 / 0  # This will raise a ZeroDivisionError
except ZeroDivisionError:
    print("Division by zero is not allowed.")</code>
        <nav id="navbar">
            <a href="#Object-Oriented_Programming_in_Python" class="nav-link">Object-Oriented Programming in Python</a>
            <a href="#Working_with_Files_in_Python" class="nav-link">Working with Files in Python</a>
            <a href="#List_Comprehensions" class="nav-link">List Comprehensions</a>
            <a href="#Python_Libraries_for_Data_Science" class="nav-link">Python Libraries for Data Science</a>
            <a href="#Exception_Handling_in_Python" class="nav-link">Exception Handling in Python</a>

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36 Edg/117.0.2045.41

Challenge: Technical Documentation Page - Build a Technical Documentation Page

Link to the challenge:

Hi! Could you maybe post the code in codepen so we can see the html? What you posted is, I assume, the text that appears on the page?

1 Like

I’m sorry, this is my html code. what should i do

Your code wasn’t displaying correctly, as it needs to be enclosed within two sets of triple backticks. I’ve edited your post to add the missing backticks.

The only issue causing your code to fail those tests is:

<section class="main-section" id="Object_Oriented_Programming_in_Python">
            <header>Object-Oriented Programming in Python</header>

You’ve mistakenly replaced a hyphen with an underscore.

1 Like

Hey! Thanks for pointing out! I changed the code and passed one test.
Still it shows one error stating “Each .main-section should have an id that matches the text of its first child, having any spaces in the child’s text replaced with underscores (_ ) for the id’s”

I don’t know what mistake I have made.

Can you show me what change(s) you made to the two lines of code which I showed you please?
(You should have made one change to your id attribute).

1 Like

I pinpointed the mistake. The issue that’s been baffling around is that I placed a hypen(-) between Object and Oriented in header which is not mentioned in my id attridute. I now removed the hypen.

My previous code:

Object-Oriented Programming in Python

My altered correct code:

Object Oriented Programming in Python

Yes, that was the issue. However, ‘Object-orientated programming’ would usually have a hyphen, so you could keep the hyphen in. You would just have to put the hyphen in the id attribute too, instead of an underscore. The only character which is not permitted in an id attribute is a space.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.