Search Header Logo
Python1

Python1

Assessment

Presentation

Computers

6th Grade

Practice Problem

Medium

Created by

Enes Nas

Used 8+ times

FREE Resource

33 Slides • 10 Questions

1

PYTHON

2

Why Learn Python?

Learning Python is super fun and opens up a world of possibilities! It's easy to pick up, so you can start making your own games or cool projects right away. Plus, with so many people using Python for things like apps and robots, knowing it can help you stand out later on. It's a great way to get creative and solve problems while having a blast!

3

Softwware

Visit python.org and download the latest version.

4

Basic Data Types

  • Strings (str): Text, e.g., "Hello"

  • Integers (int): Whole numbers, e.g., 5

  • Floats (float): Decimal numbers, e.g., 3.14

  • Booleans (bool): True or False, e.g., is_student = True

5

Variables and Data Types

media

6

Basic Operators

  • Arithmetic: +, -, *, / (e.g., 2 + 3)

  • Comparison: ==, !=, >, < (e.g., age > 18)

7

Comments

Use # to add notes or explanations in code:

media

8

Input and Output

Print statements for output

Input for user interaction

media
media

9

Simple Exercise:

Create a small program that asks for their name and age, then prints a greeting:

media

10

Write with me

result = 5 + 3
print(result)

11

Exercise:

Calculate the area of a rectangle:
Length: 5
Width: 3

12

Exercise:

Calculate the area of a rectangle:
Length: 5
Width: 3

13

Exercise:

Calculate the Average of Three Numbers:
num1 = 10
num2 = 15
num3 = 20

14

Multiple Choice

What is Python?

1

A type of snake

2

A video game

3

A programming language

4

A website

15

Multiple Choice

What does the print() function do?

1

It prints documents.

2

It displays text on the screen.

3

It creates a new variable.

4

It calculates numbers.

16

Multiple Choice

Which of the following is a valid variable name?

1

1st_variable

2

my-variable

3

myVariable

4

my variable

17

Multiple Choice

What symbol is used for comments in Python?

1
//
2

/*

3
#comment
4
#

18

Multiple Choice

If length = 5 and width = 3, what is length * width?

1
12
2
20
3
15
4
8

19

For loop

You can use the range() function to generate a sequence of numbers. For example:
for i in range(5): # This will iterate from 0 to 4

print(i)

A for loop can be used to iterate over a list of values.
fruits = ["apple", "banana", "cherry"]

for fruit in fruits:

print(fruit)

20

Create a Mad lib game

media

Mad Lib game that asks for a verb and a noun, then outputs the sentence "The [noun] likes to [verb]"


Example output:

21

If condition

The if condition in Python is used to make decisions in a program. It allows the program to perform certain actions only if a specified condition is true. If the condition is false, the program can either do nothing or take an alternative action.

media

Write a Python program that asks the user for the temperature in degrees Celsius. Based on the temperature, the program should print different messages.

22

Multiple Choice

What data type is the result of the expression 3.14 + 1

1
string
2
boolean
3
integer
4
float

23

Multiple Choice

What does the len() function do in Python?

1

returns the number of items in an object.

2

sorts the items in an object.

3

calculates the sum of numbers in a list.

4

converts an object to a string.

24

Multiple Choice

What will be the output of the following code?
x = "Python" print(x[0])

1
P
2
Pytho
3
Python
4
y

25

Multiple Choice

What is a valid Python list?

1

[1, 2, 3, 4]

2

(1, 2, 3, 4)

3

{1, 2, 3, 4}

4

1, 2, 3, 4

26

Multiple Choice

Which of the following is a correct use of a Python for loop?

1

for x 0 to 5:

2

for x in range[5]:

3

for x = 0 to 5:

4

for x in range(5):

27

If-Elif COndition

Create a Python program where the computer asks the user to guess a secret number.

Instructions:

  1. Set a secret number (e.g., secret_number = 7).

  2. Ask the user to enter a guess: "Guess the secret number between 1 and 10: "

  3. Convert the user's guess to an integer.

  4. Use if conditions to check:

    • If the guess is equal to the secret number, print: "Congratulations! You guessed it right!"

    • If the guess is less than the secret number, print: "Too low! Try again."

    • If the guess is greater than the secret number, print: "Too high! Try again."

28

Practice

  • We learned lists before,
    students = ["John", "Sarah", "Alex", "Emily"]

  • Use a for loop to go through each item in the list (for i in list)

for student in students:
print(student)

  • use if, elif, and else to check conditions for each item in the list.

for student in students:

if student == "John":

print("John is present!")

elif student == "Sarah":

print("Sarah is here!")

else:

print(f"{student} is here!") #indicates an f-string

29

Practice 2

Basic list methods: .append(), .remove(), and .sort()

1.
The .append() Method:

Adds an item to the end of the list.
students = ["John", "Sarah", "Alex"]

students.append("Emily")

print(students) # Output: ['John', 'Sarah', 'Alex', 'Emily']

2.
The .remove() Method:

Removes the first occurrence of an item from the list.
students = ["John", "Sarah", "Alex"]

students.remove("Sarah")

print(students) # Output: ['John', 'Alex']


3. The .sort() Method:

Sorts the items in a list in alphabetical or numerical order.

students = ["John", "Sarah", "Alex"]

students.sort()

print(students) # Output: ['Alex', 'John', 'Sarah']

30

Task

Write a code that:

  1. Adds "Berlin" to the list of cities.

  2. Removes "London" from the list.

  3. Sorts the list alphabetically.

Cities:
Paris
London
Tokyo

31

Assignment

Create a list of 5 students. Use a for loop to check each student and print:

  • "Welcome John!" if the student is "John". (Use ==)

  • "Hello" for every other student.

32

Assignment - 2

Create a list of scores. Use an if-elif-else statement to print:

  • "Score is below average" if the score is less than 50.

  • "Good score" if the score is 50 or greater but less than 80.

  • "Excellent score" if the score is 80 or higher.

33

Number Comparison Game

Objective:
Write a Python program that asks the user to enter three numbers. The program should compare the numbers and print which one is the largest, or if there is a tie between any of them.

Requirements:

  1. Prompt the user to enter three numbers.

  2. Use if, elif, and else statements to compare the numbers.

  3. Print which number is the largest.

  4. If two or more numbers are equal, print a message indicating that there is a tie.

media
media

34

Print Numbers 1 to 10

Write a Python program that prints the numbers from 1 to 10.

Hint: Use a for loop.

35

Even or odd

Write a program that asks the user for a number and checks if it’s even or odd. The program should then print "Even" or "Odd".
Hint: Use the modulus operator (%).

36

Simple calculator

Create a program that asks the user for two numbers and then asks the user what kind of operation they want to perform: addition, subtraction, multiplication, or division. The program should then perform the operation and display the result.

Hint: Use if statements to check the operation and perform the corresponding arithmetic.

37

SUm of numbers

Write a program that takes a list of numbers and calculates the sum. The program should display the result.

Example input: [1, 2, 3, 4, 5]
Hint: Use sum() to calculate the sum.

38

FIND maximum number

Write a Python program that takes a list of numbers and finds the largest number in the list.

Example input: [12, 43, 54, 29]

Hint: Use the max() function.

39

Count vowels

Write a program that asks the user for a string and then counts how many vowels (a, e, i, o, u) are in that string.

Hint: Use a loop and if statements to check for vowels.

40

Fibonacci sequence

Write a Python program that generates the first n numbers in the Fibonacci sequence. Ask the user for the value of n.

Example input: 5

Hint: Use a for loop and the formula: next_number = previous + current.

41

palindrome checker

Write a program that asks the user to input a word and checks if the word is a palindrome (the word is the same backward and forward).

Example input: "racecar"

Hint: Reverse the string and compare it to the original string.

42

Temperature Converter

Create a Python program that converts temperatures from Celsius to Fahrenheit. The program should prompt the user for a temperature in Celsius and then output the temperature in Fahrenheit.

Formula: Fahrenheit = (Celsius * 9/5) + 32

43

prime number checker

Write a program that asks the user for a number and checks if the number is prime. A prime number is a number that is greater than 1 and has no divisors other than 1 and itself.

Hint: Use a for loop to check divisibility from 2 up to the square root of the number.

PYTHON

Show answer

Auto Play

Slide 1 / 43

SLIDE