Download presentation
Presentation is loading. Please wait.
Published bySylvia Adam Modified over 5 years ago
1
IST256 : Applications Programming for Information Systems
Python Data Types
2
Agenda Connection Activity Teaching: Practice Activity Review for Quiz
Types: String, List String formatting Practice Activity Magic 8-Ball
3
Connect Activity Full-Contact Kahoot!:
Let’s prepare for the quiz with a game of Kahoot! 986f-5ba6b0e0baf9
4
Strings are Sequence Types
Python strings are actually sequences of characters. Why is this important? You can index strings and retrieve sub-strings. Name = ‘Fudge’ Name[0] ‘F’ Name[4] ‘e’ Name.find(‘d’) 2
5
Lists are Sequence Types, too
Python lists are variables which hold a collection of values. They are actually sequences of values. Why is this important? You can index lists and retrieve values. Lists can contain values of any type but the convention is they contain values of the same type. Grades = [‘A’,’A’,’C’,’F’] Grades[0] ‘A’ Grades.index(‘C’) 2
6
Check Yourself: 30 Second Challenge
X = “Python” Y = [“Programming”, “Is”, “Fun”] What is: X[3] ? Y[1] ? Y[0][1] ?
7
Watch Me Code Understanding Strings and Lists: Slice Notation
Find() and Index()
8
Python Print Formatting
Code Type Example Output %d Integer print(“%d” % 50) 50 %f Float print(“$%.2f” % 4.5) $4.50 %s String print(“[%s]” % ’mike’) [mike]
9
Watch Me Code Print Formatting
10
Python Packages: Random numbers
Python has an extensive package system allowing us to add new functionality to our programs easily. Python packages contain one or more code files called modules. To use a module we must import it, one time: import random Rnd = random.randint(1,10)
11
Help me Code Tax Calculations!
The country of “Fudgebonia” determines your tax rate from the number of dependents: 0 30% 1 25% 2 18% 3 10% Write a program to prompt for number of dependents (0-3) and annual income. It should then calculate your tax rate and tax bill. Format numbers properly!
12
Now You Code Magic 8 ball! https://en.wikipedia.org/wiki/Magic_8-Ball
Build a Python list of 10 “fortunes” which answer yes/no questions. The user to asks a yes/no question, then return 1 of the 10 fortunes from the list at random. Criteria: Use Jupyter Notebook Work with a partner!
13
Conclusion Activity Use one word to describe class today
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.