Introduction to Programming
Introduction to Programming Course Overview
Course Introduction
Objective: At the end of this lecture, students will understand:
What the course encompasses
Class schedules
Resources for additional help
Importance of learning programming
Course teaching methodology
Executing a simple Python program
Adjusting a pendulum on a grandfather clock
Welcome and Introductions
Teaching Staff:
Prof. Kathryn Kasmarik
Dr. Yangyang Shu
Dr. Ali Ahrari
Wasura Wattearachchi
Reda Ghanem
Maryam Shahsavari
Mohammad Askarin
Other Contacts:
FLTLT Ryan Locke (Casual address with first names encouraged)
Course Timetable
Structure:
Lectures: Two per week focused on programming concepts
Tutorials: One per week aimed at practicing program/algorithm design and testing. Tutorials will form the basis of the exam.
Labs: One per week for coding practice, particularly with Sphero BOLT+ robots. Lab work correlates with Assignments 1 and 2.
Class Expectations
In Lectures:
Students encouraged to ask questions by raising hands
Talking amongst peers discouraged due to room acoustics
In Tutorials:
Discussion is permissible as long as it does not interrupt tutor explanations
In Labs:
Collaboration and conversation encouraged but eating is not allowed inside labs. Kitchen in B13 available for eating needs.
Resources Available
Moodle Platform:
Lecture slides, lab exercises (which are also Assignments 1 and 2), tutorial exercises, and solutions
Course Textbook:
An Introduction to Programming Using Python by Schneider
Supplemental Reading:
Systems Analysis and Design With UML by Dennis, Wixom, and Tegarden
Learning Outcomes
Students will learn:
Solving real-world problems with computers
Designing effective programs
Constructing programs in Python
Documenting code thoroughly
Testing methodologies
Gaining confidence to experiment with programming
Being self-directed in their learning
Following a structured approach to experimentation
Purpose of Learning Programming
The automation in various industries highlights:
The significance of understanding computer systems’ strengths and limitations, particularly in defense
Programming skills enhance employability across diverse job markets, including defense and beyond
Programming teaches:
Structured problem solving
Systematic testing approaches and troubleshooting strategies
Teaching Methodology
Problem-Based Learning:
Content framed around engineering/computer science problems
Labs will utilize the Sphero BOLT+ robot for practical applications
Learning Style:
Top-down approach focusing first on high-level design, followed by detail-oriented implementation
Students have the autonomy to select specific details to explore
Practical applications will contextualize theoretical discussions
Ongoing feedback to cater to student needs and adapt course material
Assessments in the Course
Total of Four Assessments:
Assignment 1: Individual lab work with weekly submissions and feedback
Mid-session Test: Practical testing during lab sessions, including a practice test in Week 5
Assignment 2: Collaborative lab work where students design, build, and test programs; ongoing feedback provided
Final Exam: Mirrors the weekly tutorial structure
Use of ChatGPT in the Course
ChatGPT’s capabilities highlighted:
Effective for generating initial Python code
Caution against substituting personal learning with generated code
Recommendations for Use:
Leverage ChatGPT for specific inquiries (e.g., syntax questions)
Consult professors or tutors for understanding issues
Policy on Original Work:
Submissions of entire codes generated by ChatGPT are prohibited to ensure authentic learning and assessment.
Example Case Study: Adjusting a Grandfather Clock
Problem Identification:
The clock runs too slowly as it inaccurately measures seconds.
Steps to Develop a Solution:
Understand the problem in layman’s terms.
Draft a rough solution on paper.
Implement the solution in Python.
Test the implemented solution.
Key Learning Outcome:
This cycle from problem identification to testing is vital for course success.
Pendulum Mechanics Overview
Force Dynamics:
A pendulum bob experiences a restoring force due to gravity (-mg sin(θ)). The torque affecting the pendulum can be expressed as:
Where:
$ au$ = torque
$L$ = length of the pendulum string
$m$ = mass of the bob
$g$ = acceleration due to gravity
Equation of Motion:
Newton's second law gives:
For small angles (less than 15°), the approximation is:
Resulting in:
Form of Simple Harmonic Motion:
Determines the angular frequency as:
Calculated using:
Developing a Rough Solution for the Pendulum
Measurement Steps:
Measure the current length of the pendulum and verify it is excessive.
Calculation for the required length for a 1-second tick:
Rearrange period formula to solve for $L$ when $T = 1.0$ and $g = 9.8$:
Adjust the physical length of the pendulum accordingly.
UML Class Design in Programming
Unified Modeling Language (UML):
A notation system for designing and illustrating code structures prior to coding.
Example of UML Structure:
SimplePendulum:Attributes:
_length_GRAVITY
Methods:
__init__(length, gravity)calculate_period()→ floatcalculate_length(desired_period)→ float
Key Learning Outcome: Understanding UML aids in organizing thoughts before coding.
Programming Implementation
Execution of Python Code:
Implementing the designed solution into Python effectively.
Assessing the Solution
Importance of Documentation and Comments:
Note on solutions generated by ChatGPT might lack thorough documentation.
Emphasis on adherence to Python naming conventions and variable significance.
Testing and Debugging:
An introduction to concepts will be provided in Week 2, focusing on validating the solution such as adjustments needed on a grandfather clock.
Recap of Today’s Lecture
Topics Covered:
Introduction to running a basic Python program
Overview of the software lifecycle
Recap of Chapter 1 and preview of Chapters 2 and 4 topics:
Variables, data types (int, float, string)
Assignment syntax and formatted strings
Mathematical operators and built-in methods $ ext{math.sqrt}$, print
Internal documentation through commenting, user-defined methods, and classes.
Summary of the Lecture
Key Takeaways:
Understanding the course context, expectations, resources, importance of programming, and foundational concepts such as demonstrating code in Python and the practical applications of theoretical knowledge in the context of programming.