
LESSON 3: PREDEFINED FUNCTIONS, BOOLEAN & SELECTION STATEMENTS
Presentation
•
Computers
•
7th Grade
•
Hard
Esperanza Sabangan
Used 12+ times
FREE Resource
29 Slides • 21 Questions
1
PYTHON PROGRAMMING: HANDS-ON ACTIVITY 5 & 6
LESSON 3: Predefined Functions, Boolean Expressions and Selection Statements
2
3
4
Poll
Which among these things you did do after you get vaccinated?
5
6
There are TWO rules that must hold in playing the game.
“What’s the logic behind?” is a VISUAL BRAIN TEASER LOGICAL PUZZLE GAME. The game will enhance your critical thinking ability.
ALL OF YOU will be the participants and must answer by analyzing the pictures or illustrations to be shown.
You will be given a duration of 45 seconds to answer.
Let's Get it on Pythons!
7
Open Ended
What’s the logic behind?
Your task is to move just one matchstick to fix the equation. This math question seems simple, however, how quickly can you find all 3 solutions?
8
POSSIBLE ANSWERS
1. 5 + 4 = 9
2. 8 - 4 = 4
3. 0 + 4 = 4
9
Open Ended
What’s the logic behind?
Mike, Andrew, Kevin and Rory are playing tug of war. Mike and Andrew pulled Kevin and Rory easily. After that, both Mike and Kevin together managed to pull Rory and Andrew hardly. Then, both Mike and Rory played against Andrew and Kevin but neither of them won the game.
Thus, can you compare them according to their strength?
10
ANSWER: Mike>Andrew>Kevin>Rory
11
Open Ended
What’s the logic behind?
Replace the question mark with a number respecting the equations below. Find the pattern.
12
ANSWER
If we think that each number on the left is the power of 4.
41=4
42=16
43=64
44= 256
13
Open Ended
What’s the logic behind?
Two people played chess 5 times.
Both of them won the same number of games and there was not a single draw. How could this happen?
14
ANSWER
It is only possible if they play with other people.
15
Open Ended
What’s the logic behind?
Please use all the numbers and equation marks only once and do the correct equation.
16
ANSWER
4+5=32
17
Open Ended
What’s the logic behind?
In order to transfer all the balls from the 1st tube to the 3rd tube by keeping them in their original order, how many moves should be done and what are those movements?
(P.S: Name the balls like 1-2-3, and name the tubes I-II-III)
18
ANSWERS
OPTION 1:
Do these moves in these orders:
Transfer the 3rd ball from 1st tube to 2nd tube
Transfer the 2nd ball from 1st tube to to 2nd tube
Transfer the 1st ball from 1st tube to 3rd tube
OPTION 2:
Transfer the 2nd ball from 2nd tube to to 3rd tube
Transfer the 3rd ball from 2nd tube to to 3rd tube
19
Open Ended
What’s the logic behind?
If the dice will be moved until the pointed arrow's end, which number will be on the top?
20
ANSWERS
As a tip, The sum up of the numbers of two reciprocal squares on dice is always 7.
So, the answer is 3.
21
Open Ended
What’s the logic behind?
When you fold this figure and get a cube, what will be the colors of reciprocal squares?
22
ANSWERS
Reciprocal squares will be: Yellow-Red / Blue-Purple / Green-Pink
23
24
Open Ended
How will apply your programming skills in Python's arithmetic operations in daily real life situations?
25
Open Ended
How do you create and assign values to variables?
26
Let's go deeper Pythons! LESSON 4: PREDEFINED FUNCTIONS
27
LEARNING OBJECTIVES
Content:
✓ Explain the purpose of a predefined function
✓ Explain the functions: abs(), pow(), int() round(), random
✓ Explain the math library functions: floor() and ceil()
✓ Explain the use of the import statement
✓ Explain the purpose of a function argument
Process:
✓ Write code that uses predefined functions
28
Let's go deeper Pythons!
Python Activity 5: Predefined Functions Learning Objectives Contents
29
Open Ended
Easy Level Based on your hands-on 3.3 experience and in your own words, how will you define predefined functions in python?
30
A function is a piece of code in a program. The function performs a specific task. The advantages of using functions are:
Reducing duplication of code
Decomposing complex problems into simpler pieces
Improving clarity of the code
Reuse of code
Information hiding
Functions in Python are first-class citizens. It means that functions have equal status with other objects in Python. Functions can be assigned to variables, stored in collections or passed as arguments. This brings additional flexibility to the language.
31
“Modularizing your Code”
32
Python Activity 7: Functions Program Structure
33
Open Ended
Average Level Enter and execute the Python program.
print(abs(-4.67))
print(pow(5,3))
print(pow(49,.5))
print(int(34.8))
print(round(6.9))
import random
print(random.randint(1,100))
a. What is the output for each statement?
b. What is the difference between the round() function and the int() function?
34
35
Open Ended
Difficult Level Enter and execute the Python program.
import math
x = 4.7
y = 5.3
z = -4.8
a = -3.2
print(math.ceil(x)) print(math.ceil(y)) print(math.ceil(z)) print(math.ceil(a)) print(math.floor(x)) print(math.floor(y)) print(math.floor(z)) print(math.floor(a))
a. What is the output for each statement?
b. What is the difference between the ceil() function and the floor() function?
36
37
Open Ended
Easy Level Why and how do we use import statement in python?
38
Identify the function definition, function header and the function call in given program.
39
SAMPLE FUNCTIONS IN MATH MODULE
40
Open Ended
Easy Level What is an argument?
If a function contains more than one argument, do you think the order of the arguments makes a difference? Explain your answer.
41
Let's get it on Pythons!
Python Activity 5: Predefined Functions Learning Objectives Process
42
Open Ended
Easy Level Write a line of code that prints the integer portion of the number 21.45.
43
Open Ended
Easy Level Write code that prompts the user for a floating-point number and prints the smallest integer that is larger than the number the user entered.
44
Open Ended
Easy Level Write a line of code that prints a random number between one and 6.
45
Open Ended
Difficult Level Assume that a user enters any number and that the number is stored in the variable userNumber. Write a line of code that converts the input to a float. Then write a line of code that prints the positive value of the user’s input.
46
Open Ended
Average Level Write a line of code that calculates the square root of 900 and stores the result in the variable answer.
47
48
49
50
Attendance Monitoring & Class Record Python Program
Attendance Monitoring, Class Record and Task Management Program
PYTHON PROGRAMMING: HANDS-ON ACTIVITY 5 & 6
LESSON 3: Predefined Functions, Boolean Expressions and Selection Statements
Show answer
Auto Play
Slide 1 / 50
SLIDE
Similar Resources on Wayground
45 questions
Danger! This Mission to Mars Could Bore You to Death!
Presentation
•
7th Grade
43 questions
The Cell System
Presentation
•
7th Grade
47 questions
Probability Lesson 1
Presentation
•
7th Grade
47 questions
The Rise of Democracy
Presentation
•
6th - 7th Grade
49 questions
Mobile App vs. Mobile Website
Presentation
•
8th Grade
47 questions
Genetic Mutations
Presentation
•
7th Grade
45 questions
Gregor Mendel
Presentation
•
7th Grade
45 questions
MS Word Basics
Presentation
•
7th Grade
Popular Resources on Wayground
24 questions
PBIS-HGMS Day 10
Quiz
•
6th - 8th Grade
10 questions
HCS SCI 03 Summer School Review 3
Quiz
•
3rd Grade
11 questions
Home Scope
Quiz
•
7th - 8th Grade
15 questions
HCS SCI 05 Summer School Assessment 3 Review
Quiz
•
5th Grade
35 questions
Lufkin Road Middle School Student Handbook & Policies Assessment
Quiz
•
7th Grade
18 questions
Geo 11.3 Area of Circles and Sectors
Quiz
•
9th - 11th Grade