Python Tutorials

You might also like

You are on page 1of 6

PYTHON TUTORIALS

Requirement
Install Python
Choose the best IDE

Hello World
print ("Hello Philippines")

Variables
Age = 24
Name = "Jerome Macarilao"

print(Age)
CreditCard = 99999
print(CreditCard)
print(Name)
print("My name is " + Name)

Turtle Graphics
import turtle

yee_turtle = turtle.Turtle()
yee_turtle.forward(1000)

import turtle

yee_turtle = turtle.Turtle()
yee_turtle.forward(100)
yee_turtle.right(90)
yee_turtle.forward(100)

import turtle

yee_turtle = turtle.Turtle()
yee_turtle.forward(100)
yee_turtle.right(90)
yee_turtle.forward(100)
yee_turtle.right(90)
yee_turtle.forward(100)
yee_turtle.right(90)
yee_turtle.forward(100)

Functions

OR
import turtle

yee_turtle = turtle.Turtle()

def square ():

yee_turtle.forward(100)
yee_turtle.right(90)
yee_turtle.forward(100)
yee_turtle.right(90)
yee_turtle.forward(100)
yee_turtle.right(90)
yee_turtle.forward(100)

square()
yee_turtle.forward(150)
square()

Calendar
The Week Header
import calendar

print(calendar.weekheader(2))
print(calendar.weekheader(10))

Note that the values inside the braces like 2 and 10 are lengths
of the names of the days, just like 2 will display the first 2
letters of the day and 10 displays the complete name of the day,
we will have this result
OUTPUT
How to Display a Month Calendar
import calendar

print(calendar.weekheader(2))
print(calendar.weekheader(10))
print()
print(calendar.firstweekday()) # this will display 0 as the start of the day
print(calendar.month(2021, 3)) # this will display the calendar for March 2021

OUTPUT:

Display the Entire Year Calendar


print(calendar.calendar(2021))

OUTPUT

Days of the Month in 3 Dimensional Array


import calendar

print(calendar.monthcalendar(2021, 3))
OUTOUT

Display the Integer Value of the Date


Date_today = calendar.weekday(2021, 3, 24)
print(Date_today)

This syntax will display the date today in integer value, saying
that 0 is Monday

Is Leap
“isleap” function determines a year if it’s leap year or not. The
result will display a Boolean value:

Leap Days
This function displays how many leap days in a certain number of
years. Let say we will look on how many lead days are there from
the years 2021 to 2030:
34:40
https://www.youtube.com/watch?v=4F2m91eKmts

You might also like