IBM SkillsBuild & SkillUp Online Presents
Programme in
Artificial
Intelligence
Agenda
1. Introduction
2. Colab Notebook Setup
3. Lists, Tuples, and Dictionaries
4. Writing Basic Python Scripts
5. Program Flow and Control Structures
6. Handling Errors
7. Functions
8. Learning Kata
9. Q&A and Closing
Introduction
Hands on
Session for
Beginners
Welcome and session Importance of Python Overview of topics to
agenda in AI/ML applications be covered
Step-by-Step Guide to Creating a Google Colab
Account
Create a Google Account (if you don't already have one):
https://support.google.com/accounts/answer/27441?hl=en
Access Google Colab
https://colab.research.google.com/
If you are not already signed in to your Google account, click "Sign in" in the upper right corner and log in
with your Google account credentials.
Save a copy of Session1 Notebook
https://colab.research.google.com/drive/10ZTbzzrTTrYpzu4xFcN88gV_Rai4Y-
Rj?usp=sharing
File > Save a copy in Drive
Open Your Session1 Notebook
Open Your Session1 Notebook
Colab notebook setup
Making the Most of your Colab Subscription - Colab
(google.com)
https://www.youtube.com/watch?v=qN4WSbpW8-w
Lists, Tuples, and Dictionaries
Activity: Create
a list of student • Lists: Ordered, mutable collections
names, a tuple
of grades, and a Example: my_list = [1, 2, 3]
dictionary with
student names • Tuples: Ordered, immutable collections
as keys and
grades as values.
Example: my_tuple = (1, 2, 3)
• Dictionaries: Key-value pairs, mutable
Example: my_dict = {'key': 'value'}
Writing Basic Python Scripts
Activity: Write a • Arithmetic operations: +, -, *, /
script to perform
arithmetic Example: result = 5 + 3
operations and
print the results. • String manipulation: Concatenation, slicing
Manipulate strings
and assign the Example: greeting = "Hello, " + "world!"
outputs to
variables
• Variable assignments: Assigning values to variables
Example: x = 10
Program Flow Control Structures
Activity: • for loop: Iterating over a sequence
Implement loops Example: for i in range(5): print(i)
to iterate through
a list of numbers
and conditional • while loop: Repeats as long as a condition is true
statements to Example: while x < 5: x += 1
check for
specific • Conditional Statements: if, elif, else
conditions
Example:
if x > 5: print("x is greater than 5")
Handling Errors
Activity: Write a • try-except blocks: Catching and handling exceptions
script to divide 2 Example:
numbers and
handle potential
errors using try- try:
except blocks result = 10 / 0
print(result)
except ZeroDivisionError:
print("Cannot divide by zero")
Functions
Activity: Define • Defining functions: Using def keyword
a function to Example:
calculate the def greet(name):
square of a
number and call return "Hello, " + name
it with different
arguments. • Calling functions: Executing defined functions
Example:
greet("Alice")
Essential for good coding practices like Separation of
Concerns (SOC) and Single Responsibility Principle (SRP)
Learning Kata
Activity: Problem Statement: Create a program that takes a
Implement the list of student names and grades, calculates the
kata in a average grade, and prints the result. Handle any errors
Colab that occur during input.
notebook Tasks:
1. Create a dictionary of students and grades.
2. Write a function to calculate the average grade.
3. Implement error handling for invalid inputs.
4. Call the main program
Q&A and Closing
Python Coding Resources
IBM SkillsBuild [Python for
Programmers](https://skills.yourlearning.ibm.com/activity/URL-806B8D9B07FD)
Code with Mosh [Complete Python Mastery ](https://codewithmosh.com/p/python-
programming-course-beginners)
Udemy or Coursera Python courses
Practice Katas, for example, [Code Wars](https://www.codewars.com/)
Thank you!
For further queries, email us at
[email protected]