Search Header Logo
LESSON 3: PREDEFINED FUNCTIONS, BOOLEAN & SELECTION STATEMENTS

LESSON 3: PREDEFINED FUNCTIONS, BOOLEAN & SELECTION STATEMENTS

Assessment

Presentation

Computers

7th Grade

Hard

Created by

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

media

2

media

3

media

4

Poll

Which among these things you did do after you get vaccinated?

5

media

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

Question image

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


media

9

Open Ended

Question image

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

media

11

Open Ended

Question image

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 

media

13

Open Ended

Question image

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.


media

15

Open Ended

Question image

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

media

17

Open Ended

Question image

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

media

19

Open Ended

Question image

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.

media

21

Open Ended

Question image

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

media

23

media

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

media

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

media

28

Let's go deeper Pythons!

Python Activity 5: Predefined Functions Learning Objectives Contents

media

29

Open Ended

Question image

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”

media

32

Python Activity 7: Functions Program Structure

media

33

Open Ended

Question image

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

Question image

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

Question image

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.

media

39

SAMPLE FUNCTIONS IN MATH MODULE

media

40

Open Ended

Question image

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

media

42

Open Ended

Question image

Easy Level Write a line of code that prints the integer portion of the number 21.45.

43

Open Ended

Question image

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

Question image

Easy Level Write a line of code that prints a random number between one and 6.

45

Open Ended

Question image

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

Question image

Average Level Write a line of code that calculates the square root of 900 and stores the result in the variable answer.

47

48

media

49

media

50

Attendance Monitoring & Class Record Python Program

media

​Attendance Monitoring, Class Record and Task Management Program

PYTHON PROGRAMMING: HANDS-ON ACTIVITY 5 & 6

LESSON 3: Predefined Functions, Boolean Expressions and Selection Statements

media

Show answer

Auto Play

Slide 1 / 50

SLIDE