0% found this document useful (0 votes)
4 views7 pages

Python Minor

This document outlines a project to visualize the Solar System using Python, specifically utilizing the Turtle and Math modules. It describes the creation of a GUI, the Sun, and the planets, detailing their attributes and movements. The project aims to enhance understanding of the Solar System through interactive visualization, with potential for future educational applications.

Uploaded by

20sourabh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views7 pages

Python Minor

This document outlines a project to visualize the Solar System using Python, specifically utilizing the Turtle and Math modules. It describes the creation of a GUI, the Sun, and the planets, detailing their attributes and movements. The project aims to enhance understanding of the Solar System through interactive visualization, with potential for future educational applications.

Uploaded by

20sourabh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Visualize a Solar System with Python

Introduction:
It would be so fun if we could see how a solar system actually looks in space. Infact,
why not try and make a visual depiction of a Solar System using Python? In this
project, we are going to develop a visual of our Solar System using Python.
What is a Solar System?
Our solar system consists of the Sun and 8 planets including Earth. Following are the
planets in the Solar System in the given order:
1. Mercury
2. Venus
3. Earth
4. Mars
5. Jupiter
6. Saturn
7. Uranus
8. Neptune
In this Python Project, I am going to visualize a Solar System. We will see how the
planets revolve around the sun. Also, we will be using different colours to show
different planets and assign them with speed and paths to make our project look real.
We are going to use the Math Module and Turtle Module to create objects in the solar
system and depict their movement.

Project Prerequisites:
In this project, we will require basic knowledge of python and its concepts. In this
project we will be using two modules:

 Math Module
 Turtle Module
Brief:
import turtle
import math
from math import *
screen = [Link]()#creating the screen
[Link](50)
sun = [Link]()#turtle object for sun
[Link]('circle')#shape of sun
[Link]('yellow')#color of sun
class Planet([Link]):
def __init__(self,name,radius, color):#initialize function
super().__init__(shape='circle')
[Link] = name
[Link] = radius
self.c = color
[Link](self.c)
[Link]()
[Link]()
[Link] = 0
def move(self):
x = [Link]*cos([Link]) # Angle in radians
y = [Link]*sin([Link])
[Link]([Link]()+x,[Link]()+y)
# making plantes
mercury = Planet("Mercury",40, 'grey')
venus = Planet("Venus",80, 'orange')
earth=Planet("Earth",100,'blue')
mars = Planet("Mars",150, 'red')
jupiter=Planet("Jupiter",180, 'brown')
saturn=Planet("Saturn",230, 'pink')
uranus=Planet("Uranus",250, 'light blue')
neptune=Planet("Neptune",280, 'black')
#adding planets to a list
myList = [ mercury, venus,earth, mars,jupiter,saturn,uranus,neptune]
while True:#while statement
[Link]()#updating the screen
for i in myList:
[Link]()#moving the elements of the list
# Increase the angle by 0.0x radians
[Link] += 0.05
[Link] += 0.03
[Link] += 0.01
[Link] += 0.007
[Link] += 0.02
[Link] += 0.018
[Link] += 0.016
[Link] += 0.005

Following are the steps followed :

1. Install the Modules:


We are going to use the Turtle Module and the Math Module in this project. Install
the modules using the following commands:
2. Import the Modules:

 Turtle Module – This provides us the functionality to create the planets and the
sun. We will also make the orbits using the turtle module.
 Math Module – This provides us the functionality to do mathematical
operations. We will do many operations to create our solar system.

3. Create the GUI Screen:

 Screen() – creates a GUI Window.


 Tracer() – This traces the path of the turtle visible.

4. Create the Sun:

 Turtle() – Makes the new turtle object. This object will make the Sun in our
Solar System.
 shape() – Defines what shape our Sun will be.
 color() – Defines the color of our Sun.
5. Next Create the planets:

 init() – The init() method is to initialize the attributes of our planets. We have
defined the name, color, radius, velocity, distance and mass of the planets.
 Turtle() – Creates the turtle object which will help us create and move the
planets around the Sun.
 super() – Creates temporary objects of the planet class.
 color() – Defines the color of the planets.
 shape() – Defines the shape of the planets.
 pd() – Stands for pen down. This moves the turtle object to another position.
 goto() – moves the turtle to an absolute position.
 Using the math module, we do different calculations to find the position of the
planet.
6. Changing angles and adding planets on the screen:
 We make the planets and set them with the attributes. After making the planets
we add them to a list.
 update() – to update the screen
 move() – to move the planets one by one in loop.
 [Link] – we set the angel of the planets.

Output:

Conclusion:
We have successfully visualized the Solar System Project. We have learned how to
use the Turtle Module and Math Module. You can modify the project and add more
planets or even make a new Solar System using the same technique.
Future Scope:
Python’s accessibility and ease of use in this concept can be used in developing
educational tools and outreach programs. Python-based visualizations can be used for
better understanding of the concept and engage students in interactive learning
experiences and promote literacy among a broader audience. In future we can expect
collaborative efforts to further improve solar system visualizations through shared
libraries, framework and resources. This can lead to the creation of comprehensive
and feature-rich tools for visualizing the solar system in python.

References:
 [Link]
 [Link]
 [Link]

You might also like