0% found this document useful (0 votes)
16 views19 pages

Udacity - AI - Week2

Uploaded by

Victoria Olagoke
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views19 pages

Udacity - AI - Week2

Uploaded by

Victoria Olagoke
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 19

AI Programming

with Python
Amir Parizi
Session 2

24 – June - 2022

RESTRICTED. CONFIDENTIAL. DO NOT SHARE


Weekly Schedule

- Submit your first projects on time and stay on track.


- Attend your weekly Connect Session because attendance is mandatory.
- Follow your weekly schedule and make the necessary progress in your classroom.

RESTRICTED. CONFIDENTIAL. DO NOT SHARE


Data Types and Operators

RESTRICTED. CONFIDENTIAL. DO NOT SHARE


Data Types and Operators

● Arithmetic Operators

● Variables

RESTRICTED. CONFIDENTIAL. DO NOT SHARE


Data Types and Operators

 Int - for integer values


 Float - for decimal or floating point values
 Booleans - Binary True or False values
 String – for text values
 Print

 Indexing

 Length

● Type Function

RESTRICTED. CONFIDENTIAL. DO NOT SHARE


Data Types and Operators

 Function - Functions use parentheses, and accept one or more arguments.


 Method - Methods are functions that are called using dot notation

 Format() - Documentation
 Split() - Documentation

RESTRICTED. CONFIDENTIAL. DO NOT SHARE


Data Types and Operators

● Debugging the code


o Understand common error messages you might receive and what to do about
them.

o Search for your error message, using the Web community.

o Use print statements.

● Common error messages


○ "ZeroDivisionError: division by zero.

○ "SyntaxError: unexpected EOF while parsing”

○ "TypeError: len() takes exactly one argument (0 given)"

RESTRICTED. CONFIDENTIAL. DO NOT SHARE


Data Types and Operators

Summary

• Function & Method


• Documentation
• Debugging

RESTRICTED. CONFIDENTIAL. DO NOT SHARE


LET'S DO SOME CODING!
GOOGLE COLAB NOTEBOOK

RESTRICTED. CONFIDENTIAL. DO NOT SHARE


Data Structure

RESTRICTED. CONFIDENTIAL. DO NOT SHARE


Data Structure

● Lists
- A list is one of the most common and basic data structures in Python.
- Lists can contain any mix and match of the data types you have seen so far

● Indexing
○ Start with [0]

○ Backward indexing [-1]

● Slice and Dice [ start: end ] , [:end], [start:]


● Search in the list

RESTRICTED. CONFIDENTIAL. DO NOT SHARE


Data Structure

● Mutability : refers to whether or not we can change an object once it has been created. If an
object can be changed, it is called mutable. However, if an object cannot be changed after it has been
created, then the object is considered immutable.

○ String Vs List

● Order : is about whether the position of an element in the object can be used to access the
element. Both strings and lists are ordered. We can use the order to access parts of a list and string.

● List Functions
○ Len()
○ Max()
○ Min()
○ Sorted()
○ Join()
○ Append()

RESTRICTED. CONFIDENTIAL. DO NOT SHARE


Data Structure

● Tuples :
○ It's a data type for immutable ordered sequences of elements. They are often used to store related pieces of
information.

○ Tuples are similar to lists in that they store an ordered collection of objects which can be accessed by their indices.
Unlike lists, however, tuples are immutable - you can't add and remove items from tuples, or sort them in place.

■ Add

■ Pop

● Sets:
○ A set is a data type for mutable unordered collections of unique elements. One application of a set is to quickly
remove duplicates from a list.

RESTRICTED. CONFIDENTIAL. DO NOT SHARE


Data Structure

● Dictionaries
○ A dictionary is a mutable data type that stores mappings of unique keys to values.

○ Dictionaries are mutable, but their keys need to be any immutable type, like strings, integers, or tuples. It's not even
necessary for every key in a dictionary to have the same type

○ s

○ S

○ s

○ You can have anything in your values such as list:

RESTRICTED. CONFIDENTIAL. DO NOT SHARE


Data Structure

● Compound Data Structure


○ We can include containers in other containers to create compound data structures. For example, this dictionary
maps keys to values that are also dictionaries!

RESTRICTED. CONFIDENTIAL. DO NOT SHARE


Data Structure

Summary

RESTRICTED. CONFIDENTIAL. DO NOT SHARE


LET'S DO SOME CODING!
GOOGLE COLAB NOTEBOOK

RESTRICTED. CONFIDENTIAL. DO NOT SHARE


What to do for the next week?

● Control Flow
● Functions
● Let’s take a look at the project!

RESTRICTED. CONFIDENTIAL. DO NOT SHARE


Thank you!
Any Question?

RESTRICTED. CONFIDENTIAL. DO NOT SHARE

You might also like