0% found this document useful (0 votes)
6 views

03_ProgrammingExperiment

it

Uploaded by

hosoointernet1
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)
6 views

03_ProgrammingExperiment

it

Uploaded by

hosoointernet1
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
You are on page 1/ 20

Course Code Course Name Credits

V.ITD215 Programming Experiments 2

Programming Experiments
With Python And Pygame
1
Course schedule
Week Class Title Goal of the class or Tasks
1
1 Introduction to Pygame and Its • Understand what Pygame is and its role in graphical programming.
Capabilities • Learn how to install and set up the Pygame library in Python.
• Run and analyze a simple Pygame program to create a blank window.

2 2 Chapter 1 - Create a Custom • Review Python basics


Calculator • Printing
• Comments
Review Python basics • Variables
• Operators
3 Chapter 1 - Create a Custom • Lab1: Create a Custom Calculator
Calculator • Create a program to calculate your target time for completing a full
Lab 1: Custom Calculators marathon
3 4 Chapter 3 - Quiz Games and If • Review Python basics
Statements • Basic Comparisons
• Indentation
Review Python basics • Using And/Or
• Boolean Variables
• Else and Else If
• Text Comparisons
5 Chapter 3 - Quiz Games and If • Lab 3: Create a Quiz
Statements • Refer to a Sample Quiz and create your own Quiz
• Use if, elif, else
Lab 3: Create a Quiz 2
Course schedule
Week Class Title Goal of the class or Tasks
4 6 Chapter 4 - Guessing Games with • Review Python basics
Random Numbers and Loops • For Loop
• while Loops
Review Python basics • Random Numbers
7 Chapter 4 - Guessing Games with • Lab 4: Create a Game
Random Numbers and Loops • Refer to a Sample game and create your own game.
• Use loop, if
Lab 4: Camel Game
5 8 Chapter 5: Introduction to • Learn basic graphics
Graphics • How the computer handles x, y coordinates.
• How to specify colors.
• How to open a blank window for drawing.
• How to draw lines, rectangles, ellipses, and arcs.
9 Chapter 5: Introduction to • Lab5: Create a Picture
Graphics • You must use multiple colors.
• You must use multiple types of graphic functions (circles, rectangles, lines, etc.)
Lab 5: Create a Picture • You must use a while or for loop to create a repeating pattern.

3
Course schedule
Week Class Title Goal of the class or Tasks
6 10 Chapter 8: Introduction to • Learn to animate objects by making a rectangle bounce around the screen.
Animation • File: bouncing_rectangle.py.
• Use lists to manage and animate multiple objects, like simulating snowfall.
• File: animating_snow.py.
• Exercise: Modify the code to change the rectangle's speed, color, or behavior.
• Exercise: Modify the code to change the appearance or behavior of the snowflakes.
11 Chapter 8: Introduction to • Lab 8: Animation
Animation • Create a program with Animate image.

Lab 8: Animation
7 12 Chapter 11: Bitmapped Graphics • Learn how to use bitmapped graphics (images) to your games.
and Sound • Learn how to add sound to make games more engaging
• File: bitmapped_graphics.py
13 Chapter 11: Bitmapped Graphics • Lab11
and Sound • Create a program with graphics and sound.

Lab11: Create a program with


graphics and sound.
8 14,15 Lab: Designing Your Own • Use the knowledge from previous classes to create your own animation or simple
Animation/Game game.
• Work independently or in small groups to bring your ideas to life.
Presentations and Showcase • Present your completed animation or game to the class.

4
Online Couse, Documentations

• Online Course: Program Arcade Games With Python And Pygame


Home:
http://programarcadegames.com/index.php
Video:
https://youtube.com/playlist?list=PL1D91F4E6E79E73E1&si=MvHx9PHppoIKR5Gj
Python Tutorial site
https://www.w3schools.com/python/default.asp
Pygame Documentation
https://www.pygame.org/docs/
Color Picker
https://www.webfx.com/web-design/color-picker/

https://htmlcolorcodes.com/color-picker/
5
Sample answer program for Lab1

• Exercise2: class2_SampleProgram_exe2.py
• Lab1: calculator_lab1_SampleProgram.py
• Lab1-2: calculator_lab1-2_SampleProgram.py

print(f"Your estimated goal time is {hours} hours and {minutes} minutes.")

print("Your estimated goal time is", hours, "hours and", minutes, "minutes.")
What is an f-string in Python?
In Python, f-strings (f"”) are a way to format and insert variables directly into a string, making it easier
to print meaningful messages.
It allows us to insert variables directly inside the string.
• {hours} and {minutes} inside the string
• {hours} is replaced by the value stored in the hours variable.
• {minutes} is replaced by the value stored in the minutes variable.
6
Week 2, Class 4:
Chapter 3: Quiz Games and If Statements
Goals/Tasks:
1. Review Python basics
• Basic Comparisons
• Indentation
• Using And/Or
• Boolean Variables
• If, Else If and Else
2. Exercise3: write a code using if, elif, else
3. Homework: Review today's class content 7
Chapter 3: If Statements

• Online Course:
http://programarcadegames.com/index.php?chapter=conditional_statements&lang=en#
section_3
1. Understand the Basics of Conditional Logic
○ Basic Comparisons
○ Indentation
○ Using And/Or
○ Boolean Variables
○ Else and Else If
○ Text Comparisons
2. Exercise3: write a code using if, elif, else
3. Homework Quiz:
http://programarcadegames.com/quiz/quiz.php?file=if_statements&lang=en
8
Exercise 3-1:
filename: exe3-1_SampleProgram_tbf.py
Task: This sample program is something wrong.
Run the sample program and input 40. It’s expected to print out "Өө, та зам дээр өндөг
хуурч болно!". But it doesn't. Please modify the script and fix the issue.
Once fix the issue, save the program to exe3-1_<Your name>.py
Upload the file to the Teams Folder.

# sample program : exe3-1_SampleProgram_tbf.py Before uploading your program, please


run it and confirm it works.
# This program is not perfect. Please improve the code
temperature = int(input("What is the temperature in Celsius? "))
if temperature > 25:
print("Гадаа халуун байна")
elif temperature > 35:
print("Өө, та зам дээр өндөг хуурч болно!")
elif temperature < 10:
print("Гадаа хүйтэн байна")
else:
print("Гадаа сайхан байна")
print("Done") 9
Exercise 3-1:
filename: exe3-1_SampleProgram_tbf.py
Hint:

What is the temperature in


Celsius?
It’s 40

Гадаа халуун байна

You should say,


“Өө, та зам дээр өндөг хуурч
болно!"

10
Exercise 3-2:
filename: exe3-2_SampleProgram_tbf.py
Task: This sample program is not perfect.
The sample program asks for the user's name and checks if it matches ”Mariko". However, it is
case-sensitive, meaning ”mariko" or ”MARIKO" will not work.
Modify the sample program so that it recognizes the name ”Mariko" regardless of how the user
types it (e.g., ”Mariko", ”mariko", ”MARIKO", ”mariKO").
Save the program to exe3-2_<Your name>.py
Upload the file to the Teams Folder.

Before uploading your program, please


# Sample File exe3-2_SampleProgram_tbf.py run it and confirm it works.
# This program is not perfect. Please improve the code

userName = input("What is your name? ")


if userName == ”Mariko":
print("You have a NICE name!!")
else:
print("Your name is OK.")
11
Exercise 3-2:
filename: exe3-2_SampleProgram_tbf.py
Hint:
What is your name?
Mariko

You have a NICE name!!

What is your name?


mariko

Your name is OK

12
Attendance Check 4
Please submit the following form at the end of the class.
This is today's attendance check.

https://forms.gle/XdcGSiW5KeyUWtsk6

13
Week 3, Class 5:
Lab3: Create a Quiz
Goals/Tasks:
1. Lab3: Create a Quiz
• Create your own quiz program

14
Lab 3:

Task: Write a Python program to calculate the bus fare based on the age.

Instructions:
1. Ask the user to input their age. Make sure to handle the input as a
number.
2. Use an if-elif-else structure to determine the bus fare based on the age
entered.
3. Print the appropriate bus fare or a message indicating the fare is free for
passengers under 6.

4. Save the file to class5_lab3_<Your name>.py


• Upload the file to the Teams Files.
https://mustedumn.sharepoint.com/:f:/r/sites/I101/Shared%20Documents/General?csf=
1&web=1&e=l750AH
15
Lab 3:

Task: Write a Python program to calculate the bus fare based on the age.

• Input:
How old are you? (ex 15)

• Calculate:
Adult (19 and older): The fare is 500 ₮.
Student (ages 13–18): The fare is 300 ₮.
Child (ages 6–12): The fare is 250 ₮.
Under 6: The fare is free.

• Output:
Your bus fare is 300 ₮
16
Lab 3:

Hint:
How old are you?
15

Your bus fare is 300 ₮

How old are you?


20

Your bus fare is 500 ₮

How old are you?


5

Your bus fare is Free

17
(Option) Lab 3-2:

Task: Refer to the Sample Quiz and create your own Quiz.
http://programarcadegames.com/index.php?chapter=lab_create_a_quiz&lang=en
1. Create a quiz program with five or more questions.
• A number as the answer (e.g., "What is 1 + 1?").
• A text answer (e.g., "What is Harry Potter's last name?").
• A multiple-choice selection (e.g., "Which option is correct? A, B, or C?").
2. Requirements:
• Input : For text answers, make sure your program accepts variations. For example,
A and a is OK.
• Feedback: Let the user know if their answer is correct or incorrect.
• Score Tracking: Keep track of how many questions the user gets right.
• Final Score: At the end, calculate and display the user's percentage score.
3. Save your program as class5_lab3-2_<your name>.py
• Upload the file to the Teams Files.
https://mustedumn.sharepoint.com/:f:/r/sites/I101/Shared%20Documents/General?csf=1&web=
1&e=l750AH 18
(Option) Lab 3-2:

Task: Refer to the Sample Quiz and create your own Quiz.
http://programarcadegames.com/index.php?chapter=lab_create_a_quiz&lang=en
Sample.

Quiz time!
How many books are there in the Harry Potter series? 7
Correct!

What is 3*(2-1)? 3
Correct!

What is 3*2-1? 5
Correct!

Congratulations, you got 4 answers right. Your score is 40%!

19
Attendance Check 5
Please submit the following form at the end of the class.
This is today's attendance check.

https://forms.gle/JA73gowjYm4Wn7hP8

20

You might also like