Tuesday, 29 September 2026
Python Coding challenge - Day 1267| What is the output of the following Python Code?
Python Developer September 29, 2026 Python Coding Challenge No comments
Code Explanation:
400 Days Python Coding Challenges with Explanation
Python Coding challenge - Day 1266| What is the output of the following Python Code?
Python Developer September 29, 2026 Python Coding Challenge No comments
Code Explanation:
500 Days Python Coding Challenges with Explanation
Monday, 28 September 2026
✨ Python Turtle The Neon Ferris Wheel
Python Developer September 28, 2026 Python Library No comments
Code:
import turtle
import math
import time
screen = turtle.Screen()
screen.setup(700, 700)
screen.bgcolor("#050510")
t = turtle.Turtle()
t.hideturtle()
t.speed(0)
t.width(3)
colors = [
"#ff2d75", "#ffe600",
"#00e5ff", "#7c4dff",
"#00ff9d", "#ff7b00"
]
# ๐ก Main wheel
t.penup()
t.goto(0, -190)
t.color("#00e5ff")
t.pendown()
t.circle(190)
# Inner wheel
t.penup()
t.goto(0, -160)
t.color("#7c4dff")
t.pendown()
t.circle(160)
# Spokes
for i in range(12):
angle = math.radians(i * 30)
x = 160 * math.cos(angle)
y = 160 * math.sin(angle)
t.penup()
t.goto(0, 0)
t.pendown()
t.goto(x, y)
screen.update()
time.sleep(0.12)
# ๐ Colorful cabins
for i in range(12):
angle = math.radians(i * 30)
x = 190 * math.cos(angle)
y = 190 * math.sin(angle)
t.penup()
t.goto(x, y)
t.dot(28, colors[i % len(colors)])
screen.update()
time.sleep(0.15)
# Center
t.penup()
t.goto(0, -22)
t.dot(44, "#ffe600")
t.goto(0, -10)
t.dot(18, "white")
# ✨ Ground
t.color("#00ff9d")
t.width(5)
t.penup()
t.goto(-260, -195)
t.pendown()
t.goto(260, -195)
# Small lights
for x in range(-240, 241, 40):
t.penup()
t.goto(x, -190)
t.dot(7, "#ffe600")
screen.update()
time.sleep(0.05)
time.sleep(2)
turtle.done()
๐ Python Pattern Challenge — Day 15
Python Developer September 28, 2026 Python Pattern Challenge No comments
๐ Python Pattern Challenge — Day 15
Pattern printing is a simple but powerful way to improve your Python loops, spacing, repetition, and logical thinking. For Day 15, let's create a simple Number 1 Diamond Pattern.
The pattern uses only the number 1, but the number of 1s increases toward the center and then decreases, creating a symmetric diamond.
Today's Challenge
Write a Python program to print:
Best and cleanest code will be rewarded! ๐
Solution 1 — Using Nested for Loops
n = 5 for i in range(1, n + 1): print(" " * (n - i), end="") for j in range(i): print("1", end=" ") print() for i in range(n - 1, 0, -1): print(" " * (n - i), end="") for j in range(i): print("1", end=" ") print()
How it works
The first loop creates the increasing half:
11 1 1 1 1 1 1 1 1 1 1 1 1 1
The second loop creates the decreasing half:
1 1 1 11 1 1 1 1 1
This creates the complete symmetric diamond.
Solution 2 — Using String Multiplication
n = 5 for i in range(1, n + 1): print(" " * (n - i) + "1 " * i) for i in range(n - 1, 0, -1): print(" " * (n - i) + "1 " * i)
How it works
This line:
" " * (n - i)controls the indentation.
And:
"1 " * iprints the required number of 1s.
For example, when i = 3:
1 1 1is generated automatically.
Solution 3 — Using a Single Loop
n = 5 for i in list(range(1, n + 1)) + list(range(n - 1, 0, -1)): print(" " * (n - i) + "1 " * i)
How it works
Instead of using two separate loops, we create one sequence:
[1, 2, 3, 4, 5, 4, 3, 2, 1]Each value determines how many 1s should appear on that row.
This makes the code short and easy to understand.
Solution 4 — Using a Function
def number_one_diamond(n): for i in list(range(1, n + 1)) + list(range(n - 1, 0, -1)): print(" " * (n - i) + "1 " * i) number_one_diamond(5)
Now you can easily change the size:
number_one_diamond(7)and generate a larger pattern.
⚡ Short & Clean Code
for i in [1, 2, 3, 4, 5, 4, 3, 2, 1]: print(" " * (5-i) + "1 " * i)
๐ฅ Just one loop is enough to create the complete pattern.
๐ Challenge Yourself
Can you modify this pattern:
- Take n from the user using input()?
- Replace 1 with *?
- Replace 1 with letters?
- Create the same pattern using a while loop?
- Create a hollow version of the diamond?
- Generate the increasing/decreasing sequence without manually writing it?
Drop your solution below! ๐
15 Days. 15 Patterns. Stronger Python Logic. ๐๐ฅ
Learn • Practice • Grow with CLCODING
Book: Data Structures and Algorithm Design using Python
Popular Posts
-
Are you fascinated by the possibilities of Artificial Intelligence but feel limited by your current coding skills? Do you dream of creatin...
-
Machine Learning Projects is a free practical resource focused on learning machine learning by building projects with Python. Rather than...
-
In a world increasingly shaped by data, the demand for professionals who can make sense of it has never been higher. Businesses, governmen...
-
GitHub is more than just a platform for storing code. It's a place to learn from experienced developers, explore open-source projects,...
-
Are you looking for free resources to learn Python? Amazon is offering over 40 Python books for free, including audiobooks that can be ins...
-
๐ Python Pattern Challenge — Day 16 Pattern printing is a great way to improve your Python loops, conditions, spacing, and logical think...
-
ML Papers Explained is an open GitHub collection created to make important machine learning papers and concepts easier to explore. Instea...
-
Artificial Intelligence is revolutionizing scientific discovery, and one of its most exciting applications is molecular discovery . Tradit...
-
Linear Algebra Done Right by Sheldon Axler is a well-known textbook that presents linear algebra from a more conceptual and proof-orient...
-
Learning with Kernels by Bernhard Schรถlkopf and Alexander J. Smola is a foundational book on kernel methods in machine learning. It expl...
