Python

Python

1. Learn from Python Docs

                        1.1 What is Python?
                        1.2. Using the Python Interpreter
                        1.3. An Informal Introduction to Python
                        1.4. More Control Flow Tools
                        1.5. Data Structures
                        1.6. Modules
                        1.7. Input and Output
                        1.8. Errors and Exceptions
                        1.9. Classes
                        1.10. Brief Tour of the Standard Library
                        1.11. Brief Tour of the Standard Library — Part II
                        1.12. Virtual Environments and Packages
                        1.13. What Now?
                        1.14. Interactive Input Editing and History Substitution
                        1.15. Floating Point Arithmetic: Issues and Limitations
                        1.16. Interactive Mode



#simple program to calculate age
_______________________________________

print('Answer the quesion to know how long you have lived in this life..')
name= input('NAME:')
print('What is your age?', (name), '?')
age= int(input('age:'))  # int means integer
days= age*365
minutes = age*525948
seconds = age*31556926

print(name, 'has been alive for', days, 'days',minutes,'minutes',seconds,'seconds')
print('Thank you for using this age calculator program')
_____________________________________________________________________


#Program to Draw Square

_________________________________________________________________
from turtle import *

forward(200)
left(90)
forward(200)
left(90)
forward(200)
left(90)
forward(200)

bye()
________________________________________________________________
________________________________________________________________

#Program To Draw Polygon
_________________________________________________________________
from turtle import *

# Draw a hexagon
forward(150) 
left(60)
forward(150) 
left(60)
forward(150) 
left(60)
forward(150) 
left(60)
forward(150) 
left(60)
forward(150) 

bye()
____________________________________________________________________

# Make a diameter 200 semicircle, curving down
___________________________________________________________________
from turtle import *

forward(200)

# Make a diameter 200 semicircle, curving down
for i in range(100):
    forward(3.416)
    right(1.8)

forward(200)

bye()
__________________________________________________________________

A red, 10-point star

If you run the code, it draws a red, 10-point star, drawing the whole star once and then retracing the whole star a second time.

_____________________________________________
from turtle import*
color('red')

for i in range(20):
forward(200)
left(108)

bye()
____________________________________________

Comments