Coding A Christmas Tree with Python in 10 Minutes (A Beginner-Friendly Project)

python
youtube
Coding A Christmas Tree with Python in 10 Minutes (A Beginner-Friendly Project) #Programming #Python #pythonproject Christmas Tree Python Program Project for Beginners! This script prints a simple ASCII Christmas tree made of stars (*) and a trunk made of vertical bars (|). The Code is below: # --------------------------------------------- # Christmas Tree Program in Python # This script prints a simple ASCII Christmas tree # made of stars (*) and a trunk made of vertical bars (|). # --------------------------------------------- # Set the height of the tree (number of star layers) height = 10 # You can change this to make the tree taller or shorter # ----------------------------- # Build the leafy part of the tree # ----------------------------- for i in range(height): # Number of spaces before the stars (centers the tree) spaces = ' ' * (height - i - 1) # Number of stars for this row (odd numbers: 1, 3, 5, ...) stars = '*' * (2 * i + 1) # Print one row of the tree print(spaces + stars) # ----------------------------- # Build the trunk of the tree # ----------------------------- trunk_width = 3 # Width of the trunk (number of | characters) trunk_height = 3 # Height of the trunk (number of rows) # Center the trunk under the tree trunk_spaces = ' ' * (height - trunk_width // 2 - 1) #Produce a string of n spaces where n is (height - trunk_width // 2 - 1). Note '//' is integer division (e.g. 5 // 2 = 2 and not 2.5) for _ in range(trunk_height): print(trunk_spaces + '|' * trunk_width) ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  2025/12/25      youtube

関連するプログラミング動画 [python]

Our Tag

最近投稿されたプログラミング学習動画

BMW Group transforms digital driving experience on AWS | Amazon Web Se

Amazon

BMW Group revolutionizes the automotive ...

  2026/01/28

Building a multi-user productivity app | Code, Commit, Deploy, Repeat

Join Marina and @PeterFriese as they tak...

  2026/01/28

Convert screenshots into code in Android Studio

android
android
Design

You can turn design mocks into working c...

  2026/01/27

Marimo: The .py Notebook That Changes Everything

python

Download your free Python Cheat Sheet he...

  2026/01/27

Relational Database Design – Full Course

Design

Learn relational database design from th...

  2026/01/27

Remember your first hackathon? While it was probably scary, you probab

Remember your first hackathon? While it ...

  2026/01/27

Gemini CLI Tips & Tricks: IDE Integration Magic

Jack shows how Gemini CLI automatically ...

  2026/01/27

Top new year's resolutions for Android developers

android
android

Looking for ways to improve your develop...

  2026/01/26

Why does my AWS Glue test connection fail?

Amazon

For more details on this topic, visit th...

  2026/01/26

Connect to MCP servers in Android Studio

android
android
telework

Android Studio now connects directly to ...

  2026/01/26

Polars vs Pandas: Lazy Execution Changes Everything

pandas
python

Download your free Python Cheat Sheet he...

  2026/01/26

Let's Build Pipeline Parallelism from Scratch – Tutorial

Pipeline parallelism speeds up training ...

  2026/01/26

Advance Excel Full Course 2026 [FREE] | Advance Excel Tutorial | Advan

🔥Data Analyst Masters Program (Discount ...

  2026/01/26

🔥Amazon SQL Interview| Second Highest Salary Hack 2026 #simplilearn #s

sql
Amazon

Ready to crush your Amazon SQL interview...

  2026/01/26

Top 30 Generative AI Interview Questions 2026 | Gen AI Interview Quest

🔥Purdue - Applied Generative AI Speciali...

  2026/01/26