Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

0x00. Pascal's Triangle 🔺

Welcome to the Pascal's Triangle project for the ALX Interview Preparation. In this project, you will implement an algorithm in Python to generate Pascal's Triangle up to a given number of rows.

📝 Learning Objectives

By completing this project, you will:

  • 🔢 Understand Pascal's Triangle: Learn how to generate Pascal’s Triangle, a triangular array where each number is the sum of the two directly above it.
  • 🗂️ Python Lists and List Comprehensions: Revise how to create, access, modify, and iterate over lists. Use list comprehensions for concise and readable code.
  • 🧠 Functions and Recursion: Understand how to define and call functions, pass parameters, and return values. Optional: use recursion for generating rows of the triangle.
  • 🔄 Loops and Conditional Statements: Implement logic using loops and conditionals to handle edge cases, such as the first and last elements in each row.
  • Arithmetic Operations: Perform addition, the essential operation for generating the elements of Pascal's Triangle.
  • 🔢 Indexing and Slicing: Master accessing list elements and slices, crucial for summing up values to generate new rows.

📂 Project Structure

This project includes the following:

  1. 🛠️ Pascal's Triangle Function

    • File: 0-pascal_triangle.py
    • Description: Implements the pascal_triangle(n) function that returns a list of lists of integers representing Pascal's Triangle of size n. It returns an empty list if n <= 0.
  2. 🧪 Main File for Testing

    • File: 0-main.py
    • Description: Contains a test case that calls the pascal_triangle() function with n = 5 and prints the triangle.

📚 Resources

Read or Watch:

Additional Resources

📜 License

This project is licensed under the terms of the MIT License.


© 2024 ALX. All rights reserved.