Showing posts with label Python. Show all posts
Showing posts with label Python. Show all posts

Tuesday, 22 September 2026

Hands-on Python Tutorial

 




Hands-on Python Tutorial by Dr. Andrew N. Harrington is a practical learning resource designed to introduce beginners to programming through Python. Harrington is associated with the Computer Science Department at Loyola University Chicago, and the tutorial is listed as one of his research outputs.

Rather than treating programming as a collection of syntax rules, the tutorial takes a hands-on approach. Readers learn Python concepts by working through examples involving variables, strings, functions, dictionaries, loops, files, graphics, and flow control.

Introduction to Python

The tutorial begins with the fundamentals of Python programming and the Python interpreter. Beginners are introduced to the interactive programming environment and gradually learn how Python statements are executed.

Early topics include:

  • Python interpreter and IDLE

  • Variables and assignment

  • Numbers and arithmetic

  • Strings

  • Printing and input

  • Functions

  • Dictionaries

  • Loops and sequences

  • Floating-point numbers

  • Basic program structure

This progression makes the material suitable for learners who are starting programming from the beginning.


Download the PDF for free: http://anh.cs.luc.edu/python/hands-on/3.1/Hands-onPythonTutorial.pdf

Learning Through Practical Examples

One of the main strengths of the tutorial is its emphasis on experimentation. Instead of only explaining what a programming feature means, the material encourages readers to type, execute, and modify Python code.

This approach helps beginners understand an important programming skill: learning by observing what a program actually does.

For example, after learning about variables, a learner can immediately change values and observe how the program behaves. The same approach continues with strings, functions, loops, and other Python features.

Variables, Data Types, and Functions

The tutorial introduces the fundamental building blocks used in almost every Python program.

Readers learn how variables refer to objects, how Python handles different types of data, and how operations can be performed on those objects.

Functions are also introduced as a way of organizing reusable pieces of code. This gives beginners an early understanding of how larger programs can be divided into smaller, manageable components.

Strings and Dictionaries

Strings receive considerable attention throughout the tutorial. Beginners explore string operations and progressively move toward more advanced string-related concepts.

Dictionaries are another important topic. They introduce a powerful way of organizing information through key-value relationships and help prepare learners for more structured Python programming.

Loops and Sequences

The tutorial introduces loops and sequences as essential tools for repetitive tasks.

Learners work with concepts such as:

  • Iteration

  • Sequences

  • Loop-based processing

  • Tuples

  • Repeated operations

  • Controlling program flow

These concepts are particularly important because they allow programs to process collections of information efficiently.

Objects and Methods

The second major section moves beyond basic syntax into Python's object-oriented model.

Readers encounter:

  • Objects

  • Classes

  • Methods

  • String methods

  • Object behavior

This provides an early introduction to one of Python's most important programming concepts: objects combine data and behavior.

Understanding methods also helps learners move from simply writing individual statements toward interacting with Python's built-in objects.

Practical Mini-Projects

The tutorial includes practical examples such as Mad Libs, graphics, and file processing.

These examples are useful because they demonstrate how individual Python concepts can be combined to create something more meaningful.

For beginners, this transition is important. Learning syntax is one thing; understanding how syntax can be combined to solve a problem is another.

Graphics with Python

An interesting part of the tutorial is its introduction to graphics.

Graphics provide a visual way for beginners to understand programming concepts. Instead of seeing only text output, learners can use Python to create visual results.

This can make concepts such as coordinates, repetition, and program control easier to understand.

Working with Files

The tutorial also introduces file processing.

File handling is an essential programming skill because real applications frequently need to read information from or write information to files.

Learning this topic helps beginners move beyond small interactive programs toward programs capable of processing persistent data.

Flow of Control

A later section focuses on flow of control, including conditional statements and different types of loops.

This section helps learners understand how a program decides:

  • Which statements should execute

  • When a block should execute

  • How many times an operation should repeat

  • How different conditions affect program behavior

These concepts form the foundation for almost every useful application.

Dynamic Web Pages

The tutorial also contains an introductory section on dynamic web pages, including web-page basics, composing web pages with Python, and CGI-based dynamic pages.

This gives learners an early look at how programming can interact with web technologies.

Although modern Python web development has evolved significantly, the section is valuable historically and conceptually because it demonstrates how Python can be used beyond standalone scripts.

Learning Structure

The tutorial follows a gradual progression:

Python Basics → Data and Functions → Objects and Methods → Graphics and Files → Flow Control → Web Programming

This structure makes it possible for beginners to build their knowledge step by step instead of being introduced to advanced concepts immediately.

Who Should Read This Tutorial?

Hands-on Python Tutorial is particularly suitable for:

  • Complete programming beginners

  • Students learning Python for the first time

  • Computer science students

  • Learners who prefer practical examples

  • Teachers looking for introductory Python material

  • Programmers who want a structured refresher

It is especially useful for learners who prefer learning by doing rather than reading theory alone.

Strengths

1. Beginner-Friendly Progression

The tutorial starts with basic programming concepts and gradually introduces more sophisticated ideas.

2. Practical Orientation

Examples, exercises, graphics, file handling, and programming tasks make the material more hands-on.

3. Strong Python Fundamentals

The tutorial covers many fundamentals that remain important for Python programmers, including functions, strings, dictionaries, loops, objects, and methods.

4. Broader Programming Perspective

It does not stop at syntax. The material introduces files, graphics, object-oriented concepts, and web programming.

5. Freely Accessible Resource

The tutorial has been distributed online as a learning resource, and the author's Loyola publication record identifies it as a 2015 research output.

Limitations

The tutorial is based on an older Python 3.1-era version, so some examples and development practices should be considered historically dated when compared with modern Python.

For current Python development, learners should supplement it with modern Python documentation and current libraries.

However, the underlying programming concepts remain useful for learning fundamentals.

Download the PDF for free: http://anh.cs.luc.edu/python/hands-on/3.1/Hands-onPythonTutorial.pdf

Final Verdict

Hands-on Python Tutorial is a practical and structured introduction to Python programming. Its biggest strength is its hands-on philosophy: learners are encouraged to interact with Python, experiment with code, and gradually build more complex programs.

The tutorial covers a surprisingly broad range of topics, moving from basic Python syntax to functions, dictionaries, loops, objects, graphics, files, flow control, and introductory web programming.

For someone beginning their Python journey, it can serve as a strong fundamentals-first learning resource, especially when combined with modern Python tools and documentation.

\

๐Ÿ Stanford Code in Place 2026: Learn Python for Free

 




๐Ÿ Stanford Code in Place 2026: Learn Python for Free

Stanford Code in Place 2026 is a popular international programming course from Stanford University. It is based on Stanford's introductory computer science curriculum and is designed to help beginners learn programming using Python.

๐ŸŽ“ What is Code in Place?

Code in Place is a beginner-friendly online learning program where students learn the fundamentals of programming through practical exercises and projects. You don't need previous programming experience to start learning.


Apply Now: https://codeinplace.stanford.edu/apply/cipx/student?

๐Ÿ What Will You Learn?

The course introduces important programming concepts such as control flow, variables, functions, loops, lists, dictionaries, and graphics. These concepts help learners develop programming logic and build a strong foundation in Python.

๐Ÿ’ป Why Learn Python?

Python is one of the most widely used programming languages. After learning the basics, you can explore areas such as Data Science, Artificial Intelligence, Machine Learning, Web Development, Automation, and Software Development.

๐ŸŒŽ Who Can Join?

The course is suitable for beginners, students, aspiring developers, and anyone interested in learning programming. It is especially useful for people who want to start their coding journey with a structured curriculum.

๐Ÿš€ How to Apply?

If applications are open for the relevant 2026 cohort, you can apply through the official Stanford Code in Place application page.

Apply Now: https://codeinplace.stanford.edu/apply/cipx/student?

⭐ Final Thoughts

If you want to start learning Python and programming from the fundamentals, Stanford Code in Place provides a structured way to begin. Learning programming step by step can also prepare you for advanced fields such as AI, ML, and Data Science.

Saturday, 19 September 2026

14 Best GitHub Profiles Every Python, Data Science & AI Developer Should Follow

 


GitHub is more than just a platform for storing code. It's a place to learn from experienced developers, explore open-source projects, and improve your programming skills.

Whether you're learning Python, exploring Data Science, building AI applications, or contributing to open source, following the right GitHub profiles can help you discover valuable resources.

In this blog, let's explore 14 GitHub profiles worth following in 2026.


๐Ÿ Python & Data Science GitHub Profiles

1. Wes McKinney — Creator of pandas

๐Ÿ”— GitHub: https://github.com/wesm

Wes McKinney is the creator of pandas, one of the most widely used Python libraries for data analysis.

Explore his GitHub profile to learn more about his work in data analysis and scientific computing.

Perfect for: Python, Pandas, Data Analysis.


2. Jake VanderPlas — Scientific Python & Data Science

๐Ÿ”— GitHub: https://github.com/jakevdp

Jake VanderPlas is known for his contributions to the scientific Python ecosystem and data science education.

His work covers scientific computing, visualization, and machine learning.

Perfect for: NumPy, Scientific Python, Data Science.


3. Tirthajyoti Sarkar — Machine Learning & Python

๐Ÿ”— GitHub: https://github.com/tirthajyoti

Explore Python projects, machine learning resources, and data science-related repositories.

This profile can be useful for developers looking for practical learning materials.

Perfect for: Machine Learning, Python, Data Science.


4. Andrej Karpathy — AI & Deep Learning

๐Ÿ”— GitHub: https://github.com/karpathy

Andrej Karpathy is known for his work in deep learning and AI education.

His repositories include projects and educational resources that help developers understand modern AI concepts.

Perfect for: Deep Learning, Neural Networks, AI.


5. Manu Joseph — Machine Learning

๐Ÿ”— GitHub: https://github.com/manujosephv

Explore machine learning-related projects, including work associated with PyTorch Tabular.

Perfect for: Machine Learning, PyTorch, Data Science.


๐Ÿค– AI & Machine Learning GitHub Profiles

6. Hugging Face — Open-Source AI

๐Ÿ”— GitHub: https://github.com/huggingface

Hugging Face provides open-source tools and libraries for machine learning, natural language processing, and AI development.

Developers can explore popular projects such as Transformers and other machine learning tools.

Perfect for: NLP, LLMs, Transformers, AI.


7. OpenAI — AI Research & Tools

๐Ÿ”— GitHub: https://github.com/openai

Explore OpenAI's public GitHub repositories, which include open-source projects and developer tools.

Perfect for: AI Development, Machine Learning, Open Source.


8. Microsoft — Cloud, AI & Developer Tools

๐Ÿ”— GitHub: https://github.com/microsoft

Microsoft maintains a wide range of open-source repositories covering AI, cloud computing, developer tools, and programming languages.

Perfect for: AI, Cloud Computing, Software Development.


9. Google — AI & Open Source

๐Ÿ”— GitHub: https://github.com/google

Explore Google's public repositories, covering software development, AI, machine learning, and other open-source projects.

Perfect for: AI, Machine Learning, Open Source.


๐Ÿ’ป Programming & Open Source GitHub Profiles

10. Sindre Sorhus — Open Source Developer

๐Ÿ”— GitHub: https://github.com/sindresorhus

Sindre Sorhus is a prolific open-source developer known for a large collection of JavaScript and Node.js packages.

Perfect for: JavaScript, Node.js, Open Source.


11. freeCodeCamp — Programming Education

๐Ÿ”— GitHub: https://github.com/freeCodeCamp

freeCodeCamp offers free programming education and maintains open-source learning resources.

Developers can explore educational content and contribute to the project.

Perfect for: Programming, Web Development, Beginners.


12. Real Python — Python Learning Resources

๐Ÿ”— GitHub: https://github.com/realpython

Real Python is a popular Python education platform.

Its GitHub profile provides access to public repositories and learning-related resources.

Perfect for: Python, Tutorials, Programming Education.


13. The Algorithms — Algorithms in Multiple Languages

๐Ÿ”— GitHub: https://github.com/TheAlgorithms

The Algorithms organization provides algorithm implementations in multiple programming languages.

It's a useful place to explore algorithms, data structures, and programming concepts.

Perfect for: Data Structures, Algorithms, Problem Solving.


14. Donnemartin — Data Engineering & Python

๐Ÿ”— GitHub: https://github.com/donnemartin

Explore repositories related to Python, software development, and data engineering.

Perfect for: Python, Data Engineering, Software Development.


๐ŸŽฏ Why Should You Follow GitHub Profiles?

Following developers and organizations on GitHub can help you:

✅ Discover real-world coding projects
✅ Learn from open-source contributors
✅ Improve your programming skills
✅ Explore new Python libraries
✅ Understand software development practices
✅ Find resources for AI and Data Science
✅ Contribute to open-source projects

GitHub is one of the best places to learn by exploring real code.


๐Ÿš€ How to Start Learning from GitHub

If you're a beginner, follow these simple steps:

Step 1: Choose a GitHub profile related to your interests.

Step 2: Explore their repositories.

Step 3: Read the README files to understand each project.

Step 4: Run the code on your local machine or in Jupyter Notebook.

Step 5: Try modifying the project and building something of your own.

Step 6: Contribute to open source when you're ready.

Thursday, 17 September 2026

Python Turtle Graphics - RGB & HSV Colors

 



Code:

import turtle import math t = turtle.Turtle() screen = turtle.Screen() screen.bgcolor("black") t.speed(0) t.hideturtle() t.width(2) for i in range(80): y = -240 + i * 6 x1 = 100 * math.sin(i * 0.25) x2 = -x1 t.color("cyan") t.penup() t.goto(x1, y) t.pendown() t.dot(7) t.color("magenta") t.penup() t.goto(x2, y) t.pendown() t.dot(7) t.color("white") t.penup() t.goto(x1, y) t.pendown() t.goto(x2, y) screen.mainloop()


Explanation:

1. Import Libraries
import turtle
import math
turtle → Used to draw graphics and shapes.
math → Provides mathematical functions such as sin().

2. Create Turtle and Screen
t = turtle.Turtle()
Creates a Turtle object named t.
This turtle acts as the drawing pen.
screen = turtle.Screen()
Creates the drawing window.
screen.bgcolor("black")
Sets the background color to black.

3. Configure the Turtle
t.speed(0)
Sets the turtle's drawing speed to maximum.
t.hideturtle()
Hides the turtle arrow/cursor while drawing.
t.width(2)
Sets the pen width to 2 pixels.

4. Create the Wave Using a Loop
for i in range(80):
Runs the loop 80 times.
i takes values from 0 to 79.
Each iteration creates one pair of dots and one connecting line.

5. Calculate the Vertical Position
y = -240 + i * 6
Calculates the y coordinate for each row.
Starting position is -240.
Every iteration moves upward by 6.

For example:

i = 0   → y = -240
i = 1   → y = -234
i = 2   → y = -228
...

This creates 80 horizontal levels.

6. Calculate the First Wave Position
x1 = 100 * math.sin(i * 0.25)
math.sin() generates a smooth wave-like movement.
i * 0.25 controls how quickly the wave changes.
100 controls the horizontal size/amplitude of the wave.

So x1 continuously moves left and right.

7. Create the Opposite Wave
x2 = -x1
Makes x2 the exact opposite of x1.
This creates a mirror effect.

For example:

x1 = 80
x2 = -80

So the two dots appear symmetrically around the center.

๐Ÿ”ต 8. Draw the Cyan Dot
t.color("cyan")
Changes the turtle drawing color to cyan.
t.penup()
Lifts the pen so movement doesn't create a line.
t.goto(x1, y)
Moves the turtle to the calculated (x1, y) position.
t.pendown()
Places the pen down again.
t.dot(7)
Draws a circular dot with size 7.

So this creates the left cyan wave.

๐ŸŸฃ 9. Draw the Magenta Dot
t.color("magenta")
Changes the drawing color to magenta.
t.penup()
Stops drawing while moving.
t.goto(x2, y)
Moves to the mirrored position (x2, y).
t.pendown()
Enables drawing again.
t.dot(7)
Creates the magenta dot.

This creates the right-side mirrored wave.

⚪ 10. Connect Both Dots
t.color("white")
Changes the line color to white.
t.penup()
Prevents a line from being drawn while moving to the first dot.
t.goto(x1, y)
Moves back to the cyan dot's position.
t.pendown()
Starts drawing.
t.goto(x2, y)
Draws a white horizontal line from the cyan dot to the magenta dot.

๐Ÿ” 11. Repeat the Pattern

The loop repeats everything:

for i in range(80):

Each repetition creates:

๐Ÿ”ต────────────๐ŸŸฃ
 ๐Ÿ”ต──────────๐ŸŸฃ
  ๐Ÿ”ต────────๐ŸŸฃ
    ๐Ÿ”ต────๐ŸŸฃ
      ๐Ÿ”ต๐ŸŸฃ

Because sin() changes the x positions, the endpoints form two mirrored waves.

๐Ÿ–ฅ️ 12. Keep the Window Open
screen.mainloop()
Keeps the Turtle window open.
Without this, the window may close immediately after the program finishes.

๐ŸŽฏ Main Concept

The most important line is:

x1 = 100 * math.sin(i * 0.25)

It uses the sine function to create the wave, while:

x2 = -x1

creates its mirror image. The result is a symmetrical neon-style wave pattern made from dots and connecting lines.













Wednesday, 16 September 2026

๐Ÿ Python Turtle Art ๐ŸŒ€ | Coding Meets Creativity!

 



Code :

import turtle import math t = turtle.Turtle() screen = turtle.Screen() screen.bgcolor("black") t.speed(0) t.hideturtle() t.width(2) for i in range(80): y = -240 + i * 6 x1 = 100 * math.sin(i * 0.25) x2 = -x1 t.color("cyan") t.penup() t.goto(x1, y) t.pendown() t.dot(7) t.color("magenta") t.penup() t.goto(x2, y) t.pendown() t.dot(7) t.color("white") t.penup() t.goto(x1, y) t.pendown() t.goto(x2, y) screen.mainloop()













Explanation:


1. Import the Turtle Module
import turtle

This imports Python’s built-in turtle module, which allows us to create graphics, drawings, and patterns using a turtle cursor.

2. Import the Math Module
import math

The math module provides mathematical functions. Here, we use math.sin() to create the wave effect.

3. Create a Turtle Object
t = turtle.Turtle()

This creates a Turtle object named t. The turtle will be responsible for drawing the dots and lines.

4. Create the Drawing Screen
screen = turtle.Screen()

This creates the Turtle graphics window and allows us to control its properties.

5. Set the Background Color
screen.bgcolor("black")

This changes the background of the Turtle window to black, making the colored pattern stand out.

6. Set Turtle Speed
t.speed(0)

speed(0) sets the turtle to its fastest drawing speed.

7. Hide the Turtle Cursor
t.hideturtle()

This hides the turtle icon so that only the artwork is visible.

8. Set the Line Width
t.width(2)

This sets the thickness of the lines drawn by the turtle to 2.

๐Ÿ”„ Creating the Pattern
9. Run the Loop 80 Times
for i in range(80):

The loop runs 80 times, with i taking values from 0 to 79.

Each iteration creates one horizontal level of the pattern.

10. Calculate the Y Coordinate
y = -240 + i * 6

This calculates the vertical position of the current row.

The pattern starts at -240.
Each iteration moves 6 pixels upward.
As i increases, the pattern moves from bottom to top.

11. Calculate the First X Coordinate
x1 = 100 * math.sin(i * 0.25)

This is the main mathematical part of the program.

math.sin() generates a smooth wave-like value.

100

controls the approximate width/amplitude of the wave.

i * 0.25

controls how quickly the wave changes.

Together, they create the left-side movement of the dots.

12. Calculate the Opposite X Coordinate
x2 = -x1

This creates the mirror position of x1.

For example:

x1 = 80
x2 = -80

So the two dots appear symmetrically on opposite sides.

๐Ÿ”ต Drawing the Cyan Dot
13. Set the Color to Cyan
t.color("cyan")

The turtle's drawing color is changed to cyan.

14. Lift the Pen
t.penup()

This prevents the turtle from drawing a line while moving to the next position.

15. Move to the First Position
t.goto(x1, y)

The turtle moves to the calculated (x1, y) coordinate.

16. Put the Pen Down
t.pendown()

The turtle is now ready to draw.

17. Draw the Cyan Dot
t.dot(7)

This creates a cyan dot with a diameter of 7 pixels.

๐ŸŸฃ Drawing the Magenta Dot
18. Change the Color
t.color("magenta")

The turtle's color is changed to magenta.

19. Lift the Pen
t.penup()

The pen is lifted so the turtle can move without drawing an unwanted line.

20. Move to the Second Position
t.goto(x2, y)

The turtle moves to the mirrored (x2, y) coordinate.

21. Put the Pen Down
t.pendown()

The turtle is ready to draw again.

22. Draw the Magenta Dot
t.dot(7)

This creates a magenta dot with a diameter of 7 pixels.

⚪ Connecting the Two Dots
23. Set the Color to White
t.color("white")

The color is changed to white for the connecting line.

24. Lift the Pen
t.penup()

The pen is lifted to avoid drawing an unwanted line while moving back to the first point.

25. Move to the First Point
t.goto(x1, y)

The turtle returns to the first dot's position.

26. Put the Pen Down
t.pendown()

The turtle is now ready to draw the connecting line.

27. Connect the Two Points
t.goto(x2, y)

The turtle draws a white horizontal line from the first point to the second point.

Each row therefore looks approximately like:

๐Ÿ”ต────────────๐ŸŸฃ

Because the x positions change using the sine function, these lines form a beautiful wave-like pattern.

๐Ÿ–ฅ️ Keep the Window Open
28. Start the Main Event Loop
screen.mainloop()

This keeps the Turtle graphics window open and allows it to continue handling events.

Tuesday, 15 September 2026

Python Turtle: Turn Code into Creative Art ๐ŸŽจ


 Code :

import turtle, colorsys, math s = turtle.Screen() s.bgcolor("black") s.setup(700, 700) s.tracer(0) t = turtle.Turtle() t.speed(0) t.hideturtle() t.pensize(1) hue = 0 for i in range(120): t.penup() t.goto(0, 0) t.setheading(i * 3) t.pendown() t.pencolor(colorsys.hsv_to_rgb(hue, 1, 1)) hue += 0.008 for j in range(361): a = math.radians(j) r = 220 + 35 * math.sin(2 * a + i * 0.08) t.goto(r * math.cos(a), r * math.sin(a)) s.update() t.pensize(2) for i in range(120): t.penup() t.goto(0, 0) t.setheading(i * 3) t.pendown() t.pencolor(colorsys.hsv_to_rgb(i / 120, 1, 1)) t.forward(115) s.update() turtle.done()




















Explanation:

1. Import Required Libraries
import turtle, colorsys, math
turtle → Used to create drawings and graphics.
colorsys → Used to generate HSV-based rainbow colors.
math → Used for mathematical functions such as sin(), cos(), and converting angles to radians.

2. Create the Screen
s = turtle.Screen()

Creates the Turtle graphics window and stores it in the variable s.

3. Set Background Color
s.bgcolor("black")

Sets the background of the Turtle window to black.

4. Set Window Size
s.setup(700, 700)

Creates a 700 × 700 pixel Turtle window.

5. Turn Off Automatic Updates
s.tracer(0)

Stops Turtle from refreshing the screen after every drawing command.

This makes the drawing much faster and allows us to control when the screen updates.

๐Ÿข Creating the Turtle

6. Create Turtle Object
t = turtle.Turtle()

Creates a Turtle and stores it in the variable t.

7. Set Turtle Speed
t.speed(0)

Sets the Turtle to its fastest drawing speed.

8. Hide the Turtle
t.hideturtle()

Hides the Turtle cursor so only the artwork is visible.

9. Set Pen Thickness
t.pensize(1)

Sets the drawing line thickness to 1 pixel, creating a fine and detailed pattern.

๐ŸŒˆ Creating the Outer Rainbow Ring

10. Start Hue
hue = 0

Initializes the color value.

hue controls the position in the HSV color spectrum.

11. Create 120 Layers
for i in range(120):

Runs the outer-ring drawing process 120 times.

Each iteration creates another colorful curved layer.

12. Lift the Pen
t.penup()

Lifts the Turtle's pen so it can move without drawing.

13. Move to Center
t.goto(0, 0)

Moves the Turtle to the center of the screen.

14. Rotate the Turtle
t.setheading(i * 3)

Changes the Turtle's direction.

Since i increases each time, the starting direction changes by 3° per layer.

This creates the overlapping circular effect.

15. Put the Pen Down
t.pendown()

Places the pen back down so the Turtle starts drawing.

16. Set Rainbow Color
t.pencolor(colorsys.hsv_to_rgb(hue, 1, 1))

Converts the HSV color value into an RGB color and applies it to the Turtle's pen.

The values:

Hue        → hue
Saturation → 1
Brightness → 1

produce bright, vivid colors. ๐ŸŒˆ

17. Increase the Hue
hue += 0.008

Slightly changes the hue after every layer.

This creates the smooth rainbow color transition.

๐ŸŒ€ Drawing the Wavy Ring

18. Create 360 Points
for j in range(361):

Runs from 0 to 360.

This gives the Turtle enough points to complete a full circular shape.

19. Convert Degrees to Radians
a = math.radians(j)

Converts the angle from degrees into radians because Python's sin() and cos() functions use radians.

20. Calculate the Radius
r = 220 + 35 * math.sin(2 * a + i * 0.08)

This is the main mathematical trick behind the design. ๐ŸŒ€

220 → Base radius of the ring.
35 → Controls how much the ring waves outward and inward.
sin() → Creates the smooth wave.
2 * a → Creates two major waves around the circle.
i * 0.08 → Changes the wave position for every layer.

This produces the beautiful wavy outer ring instead of a simple circle.

21. Calculate X and Y
t.goto(r * math.cos(a), r * math.sin(a))

Calculates the X and Y coordinates of each point on the circular pattern.

The mathematical formulas are:

X = r × cos(angle)
Y = r × sin(angle)

The Turtle moves through these points and creates the curved ring.

22. Update the Screen
s.update()

Refreshes the screen after each layer.

Because tracer(0) was used earlier, the drawing only becomes visible when update() is called.

This creates the live layer-by-layer drawing effect.

๐ŸŒˆ Creating the Center Rainbow Rays

23. Increase Pen Size
t.pensize(2)

Makes the center rays slightly thicker than the outer pattern.

24. Create 120 Rays
for i in range(120):

Runs 120 times to create 120 colorful rays from the center.

25. Lift the Pen
t.penup()

Stops the Turtle from drawing while moving.

26. Return to Center
t.goto(0, 0)

Moves the Turtle back to the center before drawing each ray.

27. Set Ray Direction
t.setheading(i * 3)

Rotates the Turtle by 3° for every iteration.

This spreads the rays around the complete circle.

28. Start Drawing
t.pendown()

Puts the pen down so the ray can be drawn.

29. Give Each Ray a Rainbow Color
t.pencolor(colorsys.hsv_to_rgb(i / 120, 1, 1))

Generates a different HSV color for each ray.

As i changes from 0 to 119, the colors smoothly move through the rainbow spectrum.

30. Draw the Ray
t.forward(115)

Moves the Turtle 115 pixels forward, creating one ray from the center.

✅ Finish the Drawing

31. Final Screen Update
s.update()

Refreshes the screen one final time so the complete artwork is displayed.

32. Keep the Window Open
turtle.done()

Finishes the Turtle program and keeps the graphics window open.
























Popular Posts

Categories

100 Python Programs for Beginner (119) AI (345) Android (25) AngularJS (1) Api (7) Assembly Language (2) aws (31) Azure (12) BI (10) book (1) Books (359) Bootcamp (14) C (78) C# (12) C++ (83) cloud (1) Course (93) Coursera (305) Cybersecurity (36) data (10) Data Analysis (47) Data Analytics (31) data management (16) Data Science (433) Data Strucures (18) Deep Learning (220) Django (16) Downloads (3) edx (21) Engineering (15) Euron (30) Events (9) Excel (24) Finance (13) flask (4) flutter (1) FPL (17) Generative AI (77) Git (13) Google (55) Hadoop (3) HTML Quiz (1) HTML&CSS (48) IBM (43) IoT (3) IS (25) Java (99) Leet Code (4) Machine Learning (404) Meta (24) MICHIGAN (5) microsoft (13) Nvidia (8) Pandas (16) PHP (20) Projects (35) Python (1377) Python Coding Challenge (1247) Python Library (6) Python Mathematics (17) Python Mistakes (51) Python Pattern Challenge (10) Python Quiz (638) Python Tips (112) Questions (3) R (72) React (7) Scripting (3) security (4) Selenium Webdriver (4) Software (21) SQL (55) Udemy (22) UX Research (1) web application (11) Web development (9) web scraping (3)

Followers

Python Coding for Kids ( Free Demo for Everyone)