際際滷

際際滷Share a Scribd company logo
WELCOME TO SI
SI LEADER: CALEB PEACOCK
WHAT IS SI?
 SI stands for supplemental instruction
 You can think of these as peer led study sessions that help develop
your own study skills and retain concepts learned in class
 I will try my best to answer any questions, or find answers and report
back to you, but will also refer you to the professor as she is much
more experienced
 際際滷shows, quizzes, games, exam review
AVOCADO PRICE CALCULATOR ALGORITHM
Price per pound=$2.50
Individual Weight= 遜 lb
Get number of avocados
Total weight= individual weight * # of avocados
Total Cost=Total Weight / Price Per Pound
LAST WEEK REVIEW
 Python is case sensitive, True or False?
 Which of these is the correct use of the print statement?
A. Print(This is the correct use)
 B. print(This is the correct use)
 C. print(This is the correct use)
 D. print(This is the correct use?
 What is the output of print(24+7)? A.31 B. 24+7 C. No output D. 24+7
 What does n do?
 Can you describe what an algorithm is?
INTRODUCTION TO VARIABLES
 A variable is a named storage location for a computer program.
 You define the variable by giving it a name, and assigning a value to that
variable with an assignment statement, =
 Variables are used to store values that will be referenced later on in your
code.
 There are 12 cans in a pack of coke. Lets create a variable representing
the number of cans. cansPerPack will do. Now, lets set it equal to its
value, 12.
cansPerPack=12
 Pull up your IDEs and type this, followed by print(cansPerPack) . What
was the output?
UPDATING A VARIABLE
 Updating a variable is quite easy, just change the value on the right hand side. The variable
will now store the new value
 cansPerPack=12 12 is the value being stored to the variable cansPerPack.
print(cansPerPack) will yield the output 12.
 cansPerPack=14 14 is now the value being stored for variable cansPerPack.
Print(cansPerPack) will now yield the output 14
 Variables can only store one value at a time, and will change every time you update them.
UPDATING A VARIABLE
TYPES OF DATA
Three main data types are
 Integer
 Float
 String
 Integer is a whole number(no decimal) 5
 Float is any number with a decimal 5.0
 String is a sequence of characters or letters five
 IMPORTANT: The data type is associated with the value(whatever is on the right side)
and not the variable.
numberOfAvocados= 12 This is an Integer or int
pricePerPound= 2.50 This is a float
These data types are universal across many coding languages and not just python, so
they are important. You will use them a lot so dont worry you will be comfortable with
them.
NAMING VARIABLES
 Names have to describe the purpose and should be easily recognizable to the coder and whoever
is reading it. If I read avocadoNumber as a variable, I immediately know what this variable does.
 Names must start with a letter or underscore(_), and be followed up with letters(upper or
lowercase), digits, or underscore
 NO SPACES OR OTHER SYMBOLS
 Two common ways to write your variable name: using a underscore as a space, or using camelCase
 avocado_Number or avocadoNumber It is personal preference just like single or double
quotes for your print statement. Just be consistent
Which of these names are not legal variable names?
avocadoNumber1
X
AvocadoNumber
4avocado
avocado Number
Avocado_Number
CONSTANT VARIABLES
 Constant Variables or Constants are variables whose value should never be changed after its value has been assigned. You do not
have to, but it is best practice to name your constant variables using all caps
 So the difference between a regular variable, and a constant variable, is constant variables do not change their value.
 How do I know when to use a constant variable vs a regular variable?
Think about fixed values, values that should never really change, or at the very least not change often. Like how manyfl oz are in a
can of coke. Its always going to be 12. Something like cans per 12 pack is always going to be 12. How many packs we buy though?
That can change. Maybe I just want 1, maybe theres a sweet deal and I buy 6.
 FL_OZ=12
 CANSPERPACK=12
 packsPurchased=2
The first two are constant variables because their value is fixed, and they are in all caps to signify that. The third is just a regular
variable, because the amount of cans you purchase varies. Since it is a regular variable, you would follow basic naming rules and not
capitalize it.
CONSTANT VARIABLES
It is very good practice to use named constant variables in place of numbers in your calculations
For an example, think back to our avocado example from last session, we said that the total price was total
weight/ price per pound and that the price per pound was 2.50
 totalPrice= totalWeight / 2.50
This totally works, but is bad practice. If we were working on a program together, and you came upon this
line of code I had written, you would be wondering what the 2.50 was or represented. Maybe if the program
you were building was large enough, you might forget what the value represented yourself.
totalPrice=totalWeight / pricePerPound is much better and more descriptive. If we initialized our variables
and their values beforehand, this should yield the same output. I will show you later
 Never change the name of your constant variables.
COMMENTS
 Comments are used to describe what each aspect of your code does. It is mostly for other people
reading your code to easily understand what is going on. Again, useful for collaborative projects.
 The compiler ignores the comments, and use the # symbol beforehand.
 Try it in your compiler,
#This would be ignored
print(but this would not)
output:
____________
MAYBE LOW ON TIME? ARITHMETIC
 Basic Operations
Addition + print(6+7) output=?
Subtraction - print(6-7) output=?
Multiplication * print (6*7) output=?
Division / print(42/7) output=?
 Just like in regular math, PEMDAS applies. Parentheses, exponents, multiplication or division, addition
or subtraction
 print(2+3*5) output=?
print( (2+3) *5 ) output=?
MIXING DATA TYPES
 Remember float and integers? For an example, 7 is an integer and 7.0 would be a float data type.
 print(7 * 7) output=49
 print(7 * 7.0) output=? What do you think the value would be? What happens when you mix different
data types like integer and float?
OTHER MATHEMATICAL OPERATORS THAT ARE HANDY
 Powers, or exponents, are used with double stars **
print(6**2) output=36
 Floor division is when you divide two integers numbers and if there is a remainder, it is discared. In
other words, if you divide 7/3, the output will be 2.333333333333. We divided two integers, and got a
floating number. If you want to discard the remainder(the .33333), use floor division
 Floor division is used by // print(7 // 3) output=2 It rounds to the nearest number.
 If you want the remainder of two dividing numbers, use the % operator(Modulus)
print(7%3) output=1
powerpoint 1-19.pdf
INPUT FUNCTION
 It is very common to prompt a user for input. What are some real world examples you can think of, when you the user, are prompted
for an input to enter in the computer?
 It is also very common to store the value the user inputs into a variable. Think to our avocado example. How are we going to know
how many avocados someone buys? It is not a fixed value, and it depends on the user. It is best to use an input function
 numberofAvocados=input(Enter the number of avocados you wish to purchase:)
Inside the   , you should prompt the user for input, or let them know what they are supposed to be inputting.
 When prompting the user for input, you have to specify what data type you are asking for(str, int, float)
 In our avocado example, we are asking for a number. So it is an integer or float. Would # of avocados be better as a integer data type
or float data type?
 Lets check out our avocado Calculator one more time.
 A lot of your errors in your labs will be using the wrong data types or not converting integers to strings.
Q&A
 Ask me anything about the class, lesson, last week, this week, anything coding. I am experienced in this
class, but still am relatively new just like you! I will do my best to answer and research for you, and if
not, refer you to the professor if I can not answer
 This section is MASSIVE and really important. I just really wanted you all to grasp the variable, and be
comfortable with plugging them into your equations. This is where the class really begins in my
opinion. Make sure to read the whole section and give yourself plenty of time on the labs. Ask
questions or watch videos online(so much content out there) if you get stuck!
 Next week I will do a quick recap of things we might have skipped in this session. An hour is not
enough. Really do go over index, the input statement, and string concatenation. These are all super
important, useful, and input statement is used CONSTANTLY. You will need to be comfortable with it
and switching between data types. A lot of times, you will get errors because your data types do not
match up. Really really study the book and slides. Watch videos.

More Related Content

Similar to powerpoint 1-19.pdf (20)

PDF
Introduction to Python Programming | InsideAIML
VijaySharma802
PDF
The python fundamental introduction part 1
DeoDuaNaoHet
PDF
Free Complete Python - A step towards Data Science
RinaMondal9
PPTX
c++ computer programming language datatypes ,operators,Lecture 03 04
jabirMemon
PPTX
Learning to code with Python! (MVA).pptx
JoshuaJoseph70
PPTX
Learning to code with Python! (Microsoft Virtual Academy).pptx
JoshuaJoseph70
DOCX
Course set three full notes
geekinlibrariansclothing
PPTX
Brixton Library Technology Initiative Week0 Recap
Basil Bibi
PPTX
Basics of Python Programming
ManishJha237
PPTX
Creating Python Variables using Replit software
afsheenfaiq2
PPTX
20BCT23 PYTHON PROGRAMMING.pptx
gokilabrindha
PPTX
Python-Beginer-PartOnePython is one of the top programming languages in the w...
ahmedosman389
PPT
Python001 training course_mumbai
vibrantuser
PPTX
Python Programming for basic beginners.pptx
mohitesoham12
PPTX
Pseudocode intro (for grade 8 students).pptx
nseaton
DOCX
python isn't just a snake
geekinlibrariansclothing
PPTX
03 Variables - Chang.pptx
Dileep804402
PPTX
Application development with Python - Desktop application
Bao Long Nguyen Dang
PPTX
An Introduction To Python - Variables, Math
Blue Elephant Consulting
Introduction to Python Programming | InsideAIML
VijaySharma802
The python fundamental introduction part 1
DeoDuaNaoHet
Free Complete Python - A step towards Data Science
RinaMondal9
c++ computer programming language datatypes ,operators,Lecture 03 04
jabirMemon
Learning to code with Python! (MVA).pptx
JoshuaJoseph70
Learning to code with Python! (Microsoft Virtual Academy).pptx
JoshuaJoseph70
Course set three full notes
geekinlibrariansclothing
Brixton Library Technology Initiative Week0 Recap
Basil Bibi
Basics of Python Programming
ManishJha237
Creating Python Variables using Replit software
afsheenfaiq2
20BCT23 PYTHON PROGRAMMING.pptx
gokilabrindha
Python-Beginer-PartOnePython is one of the top programming languages in the w...
ahmedosman389
Python001 training course_mumbai
vibrantuser
Python Programming for basic beginners.pptx
mohitesoham12
Pseudocode intro (for grade 8 students).pptx
nseaton
python isn't just a snake
geekinlibrariansclothing
03 Variables - Chang.pptx
Dileep804402
Application development with Python - Desktop application
Bao Long Nguyen Dang
An Introduction To Python - Variables, Math
Blue Elephant Consulting

Recently uploaded (20)

PPTX
How to Manage Wins & Losses in Odoo 18 CRM
Celine George
PDF
CAD25 Gbadago and Fafa Presentation Revised-Aston Business School, UK.pdf
Kweku Zurek
PDF
Indian National movement PPT by Simanchala Sarab, Covering The INC(Formation,...
Simanchala Sarab, BABed(ITEP Secondary stage) in History student at GNDU Amritsar
PDF
TechSoup Microsoft Copilot Nonprofit Use Cases and Live Demo - 2025.06.25.pdf
TechSoup
PDF
Gladiolous Cultivation practices by AKL.pdf
kushallamichhame
PPTX
Matatag Curriculum English 8-Week 1 Day 1-5.pptx
KirbieJaneGasta1
PDF
Genomics Proteomics and Vaccines 1st Edition Guido Grandi (Editor)
kboqcyuw976
PPTX
PLANNING A HOSPITAL AND NURSING UNIT.pptx
PRADEEP ABOTHU
PDF
DIGESTION OF CARBOHYDRATES ,PROTEINS AND LIPIDS
raviralanaresh2
PPTX
How to Configure Taxes in Company Currency in Odoo 18 Accounting
Celine George
PDF
Lesson 1 - Nature of Inquiry and Research.pdf
marvinnbustamante1
PDF
TLE 8 QUARTER 1 MODULE WEEK 1 MATATAG CURRICULUM
denniseraya1997
PPTX
Lesson 1 Cell (Structures, Functions, and Theory).pptx
marvinnbustamante1
PPTX
Elo the Hero is an story about a young boy who became hero.
TeacherEmily1
PDF
Learning Styles Inventory for Senior High School Students
Thelma Villaflores
PDF
Rapid Mathematics Assessment Score sheet for all Grade levels
DessaCletSantos
PPTX
Comparing Translational and Rotational Motion.pptx
AngeliqueTolentinoDe
PPTX
How to Configure Refusal of Applicants in Odoo 18 Recruitment
Celine George
PDF
Wikinomics How Mass Collaboration Changes Everything Don Tapscott
wcsqyzf5909
PPTX
SYMPATHOMIMETICS[ADRENERGIC AGONISTS] pptx
saip95568
How to Manage Wins & Losses in Odoo 18 CRM
Celine George
CAD25 Gbadago and Fafa Presentation Revised-Aston Business School, UK.pdf
Kweku Zurek
Indian National movement PPT by Simanchala Sarab, Covering The INC(Formation,...
Simanchala Sarab, BABed(ITEP Secondary stage) in History student at GNDU Amritsar
TechSoup Microsoft Copilot Nonprofit Use Cases and Live Demo - 2025.06.25.pdf
TechSoup
Gladiolous Cultivation practices by AKL.pdf
kushallamichhame
Matatag Curriculum English 8-Week 1 Day 1-5.pptx
KirbieJaneGasta1
Genomics Proteomics and Vaccines 1st Edition Guido Grandi (Editor)
kboqcyuw976
PLANNING A HOSPITAL AND NURSING UNIT.pptx
PRADEEP ABOTHU
DIGESTION OF CARBOHYDRATES ,PROTEINS AND LIPIDS
raviralanaresh2
How to Configure Taxes in Company Currency in Odoo 18 Accounting
Celine George
Lesson 1 - Nature of Inquiry and Research.pdf
marvinnbustamante1
TLE 8 QUARTER 1 MODULE WEEK 1 MATATAG CURRICULUM
denniseraya1997
Lesson 1 Cell (Structures, Functions, and Theory).pptx
marvinnbustamante1
Elo the Hero is an story about a young boy who became hero.
TeacherEmily1
Learning Styles Inventory for Senior High School Students
Thelma Villaflores
Rapid Mathematics Assessment Score sheet for all Grade levels
DessaCletSantos
Comparing Translational and Rotational Motion.pptx
AngeliqueTolentinoDe
How to Configure Refusal of Applicants in Odoo 18 Recruitment
Celine George
Wikinomics How Mass Collaboration Changes Everything Don Tapscott
wcsqyzf5909
SYMPATHOMIMETICS[ADRENERGIC AGONISTS] pptx
saip95568

powerpoint 1-19.pdf

  • 1. WELCOME TO SI SI LEADER: CALEB PEACOCK
  • 2. WHAT IS SI? SI stands for supplemental instruction You can think of these as peer led study sessions that help develop your own study skills and retain concepts learned in class I will try my best to answer any questions, or find answers and report back to you, but will also refer you to the professor as she is much more experienced 際際滷shows, quizzes, games, exam review
  • 3. AVOCADO PRICE CALCULATOR ALGORITHM Price per pound=$2.50 Individual Weight= 遜 lb Get number of avocados Total weight= individual weight * # of avocados Total Cost=Total Weight / Price Per Pound
  • 4. LAST WEEK REVIEW Python is case sensitive, True or False? Which of these is the correct use of the print statement? A. Print(This is the correct use) B. print(This is the correct use) C. print(This is the correct use) D. print(This is the correct use? What is the output of print(24+7)? A.31 B. 24+7 C. No output D. 24+7 What does n do? Can you describe what an algorithm is?
  • 5. INTRODUCTION TO VARIABLES A variable is a named storage location for a computer program. You define the variable by giving it a name, and assigning a value to that variable with an assignment statement, = Variables are used to store values that will be referenced later on in your code. There are 12 cans in a pack of coke. Lets create a variable representing the number of cans. cansPerPack will do. Now, lets set it equal to its value, 12. cansPerPack=12 Pull up your IDEs and type this, followed by print(cansPerPack) . What was the output?
  • 6. UPDATING A VARIABLE Updating a variable is quite easy, just change the value on the right hand side. The variable will now store the new value cansPerPack=12 12 is the value being stored to the variable cansPerPack. print(cansPerPack) will yield the output 12. cansPerPack=14 14 is now the value being stored for variable cansPerPack. Print(cansPerPack) will now yield the output 14 Variables can only store one value at a time, and will change every time you update them.
  • 8. TYPES OF DATA Three main data types are Integer Float String Integer is a whole number(no decimal) 5 Float is any number with a decimal 5.0 String is a sequence of characters or letters five IMPORTANT: The data type is associated with the value(whatever is on the right side) and not the variable. numberOfAvocados= 12 This is an Integer or int pricePerPound= 2.50 This is a float These data types are universal across many coding languages and not just python, so they are important. You will use them a lot so dont worry you will be comfortable with them.
  • 9. NAMING VARIABLES Names have to describe the purpose and should be easily recognizable to the coder and whoever is reading it. If I read avocadoNumber as a variable, I immediately know what this variable does. Names must start with a letter or underscore(_), and be followed up with letters(upper or lowercase), digits, or underscore NO SPACES OR OTHER SYMBOLS Two common ways to write your variable name: using a underscore as a space, or using camelCase avocado_Number or avocadoNumber It is personal preference just like single or double quotes for your print statement. Just be consistent
  • 10. Which of these names are not legal variable names? avocadoNumber1 X AvocadoNumber 4avocado avocado Number Avocado_Number
  • 11. CONSTANT VARIABLES Constant Variables or Constants are variables whose value should never be changed after its value has been assigned. You do not have to, but it is best practice to name your constant variables using all caps So the difference between a regular variable, and a constant variable, is constant variables do not change their value. How do I know when to use a constant variable vs a regular variable? Think about fixed values, values that should never really change, or at the very least not change often. Like how manyfl oz are in a can of coke. Its always going to be 12. Something like cans per 12 pack is always going to be 12. How many packs we buy though? That can change. Maybe I just want 1, maybe theres a sweet deal and I buy 6. FL_OZ=12 CANSPERPACK=12 packsPurchased=2 The first two are constant variables because their value is fixed, and they are in all caps to signify that. The third is just a regular variable, because the amount of cans you purchase varies. Since it is a regular variable, you would follow basic naming rules and not capitalize it.
  • 12. CONSTANT VARIABLES It is very good practice to use named constant variables in place of numbers in your calculations For an example, think back to our avocado example from last session, we said that the total price was total weight/ price per pound and that the price per pound was 2.50 totalPrice= totalWeight / 2.50 This totally works, but is bad practice. If we were working on a program together, and you came upon this line of code I had written, you would be wondering what the 2.50 was or represented. Maybe if the program you were building was large enough, you might forget what the value represented yourself. totalPrice=totalWeight / pricePerPound is much better and more descriptive. If we initialized our variables and their values beforehand, this should yield the same output. I will show you later Never change the name of your constant variables.
  • 13. COMMENTS Comments are used to describe what each aspect of your code does. It is mostly for other people reading your code to easily understand what is going on. Again, useful for collaborative projects. The compiler ignores the comments, and use the # symbol beforehand. Try it in your compiler, #This would be ignored print(but this would not) output: ____________
  • 14. MAYBE LOW ON TIME? ARITHMETIC Basic Operations Addition + print(6+7) output=? Subtraction - print(6-7) output=? Multiplication * print (6*7) output=? Division / print(42/7) output=? Just like in regular math, PEMDAS applies. Parentheses, exponents, multiplication or division, addition or subtraction print(2+3*5) output=? print( (2+3) *5 ) output=?
  • 15. MIXING DATA TYPES Remember float and integers? For an example, 7 is an integer and 7.0 would be a float data type. print(7 * 7) output=49 print(7 * 7.0) output=? What do you think the value would be? What happens when you mix different data types like integer and float?
  • 16. OTHER MATHEMATICAL OPERATORS THAT ARE HANDY Powers, or exponents, are used with double stars ** print(6**2) output=36 Floor division is when you divide two integers numbers and if there is a remainder, it is discared. In other words, if you divide 7/3, the output will be 2.333333333333. We divided two integers, and got a floating number. If you want to discard the remainder(the .33333), use floor division Floor division is used by // print(7 // 3) output=2 It rounds to the nearest number. If you want the remainder of two dividing numbers, use the % operator(Modulus) print(7%3) output=1
  • 18. INPUT FUNCTION It is very common to prompt a user for input. What are some real world examples you can think of, when you the user, are prompted for an input to enter in the computer? It is also very common to store the value the user inputs into a variable. Think to our avocado example. How are we going to know how many avocados someone buys? It is not a fixed value, and it depends on the user. It is best to use an input function numberofAvocados=input(Enter the number of avocados you wish to purchase:) Inside the , you should prompt the user for input, or let them know what they are supposed to be inputting. When prompting the user for input, you have to specify what data type you are asking for(str, int, float) In our avocado example, we are asking for a number. So it is an integer or float. Would # of avocados be better as a integer data type or float data type? Lets check out our avocado Calculator one more time. A lot of your errors in your labs will be using the wrong data types or not converting integers to strings.
  • 19. Q&A Ask me anything about the class, lesson, last week, this week, anything coding. I am experienced in this class, but still am relatively new just like you! I will do my best to answer and research for you, and if not, refer you to the professor if I can not answer This section is MASSIVE and really important. I just really wanted you all to grasp the variable, and be comfortable with plugging them into your equations. This is where the class really begins in my opinion. Make sure to read the whole section and give yourself plenty of time on the labs. Ask questions or watch videos online(so much content out there) if you get stuck! Next week I will do a quick recap of things we might have skipped in this session. An hour is not enough. Really do go over index, the input statement, and string concatenation. These are all super important, useful, and input statement is used CONSTANTLY. You will need to be comfortable with it and switching between data types. A lot of times, you will get errors because your data types do not match up. Really really study the book and slides. Watch videos.