1. Chapter # 5
Advance Programming
Teacher: Ahmad Zarif Contact # 0343-924-9404
Fazaia Inter College & School KOHAT
2. Points for Copy Work
Friday, April 5, 2024 Teacher : Ahmad Zarif Contact # 0343-924-9404 2
3. Friday, April 5, 2024 Teacher : Ahmad Zarif Contact # 0343-924-9404 3
Date H/W Chapter # MCQS Date H/W Chapter #
Descriptive
Types Question Date H/W Chapter #
Application
based Questions
4. Friday, April 5, 2024 Teacher : Ahmad Zarif Contact # 0343-924-9404 4
Date H/W Chapter # SLO MCQS Date H/W Chapter # Lab Questions Date H/W Chapter # Group Project
5. Agenda
1) MCQS
2) Descriptive Type Question’s
3) Application Based Question
4) Lab Based Question
5) Group Questions
6) SLO Based MCQ’s
7) SLO Based Question’s
Friday, April 5, 2024 Teacher : Ahmad Zarif Contact # 0343-924-9404 5
6. Choose the Correct Option.
a. A person that writes codes in different programming languages is known as ________?
b. Which one of the following is not programming language?
c. Which version of python did you learn in this chapter?
d. Which of the following is an assignment operator?
e. Which of the following is a loop in Python3?
Friday, April 5, 2024 Teacher : Ahmad Zarif Contact # 0343-924-9404 6
i. A Programmer ii. A Technician iii. A Writer iv. A Polygot
i. C++ ii. Java Script iii. Python iv. B++
i. Python1 ii. Python2 iii. Python3 iv. Python4
i. + ii. - iii. % iv. =
i. For Loop ii. While Loop iii. None of These iv. All of these
7. Descriptive Type Question
a. Define programming language. What are the most commonly used programming languages?
Answer: A programming language is the computer language or it is set of instructions, used by
programmer and developers to write and develop different programs and software, a programming
languages uses words form the English language, every programming language has its syntax, rules and
structure, Common example of programming languages are:
C Language: C languages is considered as the base for other programming languages, that is why
it is known as mother language.
C++ Language: C++ is an object-oriented programming language which gives a clear structure to
programs.
Java: Java is a high level, robust, object-oriented and secure programming language.
Python: Python is a high-level, interpreted, interactive and object-oriented scripting language.
Python is designed to be highly readable.
Friday, April 5, 2024 Teacher : Ahmad Zarif Contact # 0343-924-9404 7
8. b. Differentiate between the types of programming languages.
1) Assembly Language:
Define: Assembly language program is consisting of mnemonics that is translated into machine
code. A program that is used for this conversion is known as assembler.
Features:
1) It is a low-level programming language.
2) It allows programmers to use human readable code.
3) It allows complex jobs to run in a simpler way.
4) It helps in contacting the hardware directly.
Application:
It is used for coding device drivers, real time system, low level embedded systems, boot codes etc.
Friday, April 5, 2024 Teacher : Ahmad Zarif Contact # 0343-924-9404 8
Descriptive Type Question
9. b. Differentiate between the types of programming languages.
2) C++
Define: C++ is an object-oriented programming language which gives a clear structure to
programs.
Features:
1) It is a mid level programming language.
2) It provides a structure approach of breaking a problem into separate part.
3) It is a portable language which means that it can be used on any platform.
4) It has a rich library and has a lot of built in functions.
Application:
It is used in operating system, web browsers, games, banking applications, software engineering, data
structure
Friday, April 5, 2024 Teacher : Ahmad Zarif Contact # 0343-924-9404 9
Descriptive Type Question
10. b. Differentiate between the types of programming languages.
3) Java
Define: Java is a general-purpose, class-based, object-oriented programming language
Features:
1) It is considered as one of the easiest programming languages.
2) It is a portable languages which means that it can be used on any platform.
3) It is more secure than other programming languages.
4) It is capable of handling run time errors.
Application:
It is used in mobile applications, desktop graphics, user interface (GUI), web based gaming and cloud based
application.
Friday, April 5, 2024 Teacher : Ahmad Zarif Contact # 0343-924-9404 10
Descriptive Type Question
11. c. How do you install python on your computer?
There are following steps for install python:
1) Go to google.com and search “Python download”
2) Click on the link.
3) Select your platform and click “Download Python 3.10.5”.
4) Choose the download location and wait for the file to download.
5) Click the downloaded file.
6) Select “Add python 3.10 to Path”.
7) Then click “Install Now”.
8) Wait for the installation to finish and then click “Close”.
Friday, April 5, 2024 Teacher : Ahmad Zarif Contact # 0343-924-9404 11
Descriptive Type Question
12. d. How do you create and run a python program?
There are following steps are included:
1) To start coding , create a new project.
2) Rename the project.
3) Click Create.
4) Erase everything in “main.py”.
5) start coding.
6) To run the code ,right click and select “Run main” or you can press Ctrl+Shift+F10.
7) To run python code, you must first download and install python.
8) Go to Google.com and search “Python download”.
Friday, April 5, 2024
Teacher : Ahmad Zarif Contact # 0343-924-9404 12
Descriptive Type Question
13. e. How do you use blocks to create a script in Scratch?
To use this block, just follow the following steps:
1. Click on the “My Blocks” button.
2. Click on “Make a Block”.
3. To add a number or text to your customized block,
4. Click on the first option of the three available options present at the extreme left.
5. To add a Boolean value to your customized block,
6. Click on the second option of the three available options present in the middle
To add a label to your customized block,
7. Click on the third option of the three available options present at the extreme right. after creating
the block and giving it a name, click on “OK” to move forward.
8. Once you click on “OK”, the new block will appear in the block palette
Friday, April 5, 2024
Teacher : Ahmad Zarif Contact # 0343-924-9404 13
Descriptive Type Question
14. f. Can you give some examples of different types of blocks that are available in Scratch?
In Scratch we use following types of blocks,
1) Motion Block: Motion block is a type of block in the block palette. This type of block is used to c
control the sprite's movement.
2) Looks Block: The script blocks under the looks category control the visual appearance of your sprite.
these functions allow you to change your sprite's costume.
3) Control Block: The function of the control blocks is to control the movement of the sprite under
certain conditions.
4) Events Block: Events blocks are blocks of code that are triggered by events. An event is something
that happens in the program, such as a sprite being clicked on or a key being pressed.
5) Sensing Block: Sensing blocks are used to identify and measure how objects within a project
are interacting with each other or to detect certain keyboard and mouse
movement.
Friday, April 5, 2024
Teacher : Ahmad Zarif Contact # 0343-924-9404 14
Descriptive Type Question
15. 1. Write the script in python to enter the marks of English, mathematics, and science and find the
total and the percentage.
Friday, April 5, 2024
Teacher : Ahmad Zarif Contact # 0343-924-9404 15
Application Based Question
English = 40
Mathematics = 55
Science = 53
total= English+Mathematics+Science
percentage = (total/300)*100
print(total)
print(percentage)
16. 2. What are some common techniques for designing and implementing game mechanics in Scratch?
Here are some common techniques and tips for designing and implementing game mechanics in Scratch:
a) Character Movement:
• Use the "Move" blocks to control the movement of characters or objects in your game.
• Utilize arrow keys or other input controls to move characters smoothly.
b) Collision Detection:
• Use "If on edge, bounce" and "touching [sprite]" blocks to detect collisions between sprites.
c) Level Design:
• Design and build levels with different layouts and challenges.
• Implement win conditions to advance to the next level.
d) Testing and Iteration
• Playtest your game frequently to identify and fix issues with game mechanics.
Friday, April 5, 2024
Teacher : Ahmad Zarif Contact # 0343-924-9404 16
Application Based Question
17. 3. How do you use variables, conditions and loops to create more complex and interactive games in
scratch?
We use variable, conditions and loops to create more complex and interactive games in scratch by
following ways:
Add a variable in Scratch
Click on Variables in the Code tab, then click on Make a Variable. Type in the name of your
variable. You can choose whether you would like your variable to be available to all sprites, or to
only this sprite.
Add a Condition in Scratch
Drag and drop an "if" block From the "Control" category in the Scratch blocks palette, you can
find the "if" block. Drag this block to your project's scripting area.
Add a loops in Scratch
Drag a "Forever" block from the "Control" category in the blocks palette.Place the blocks you
want to repeat indefinitely inside the "Forever" block.
Friday, April 5, 2024
Teacher : Ahmad Zarif Contact # 0343-924-9404 17
Application Based Question
18. 1. Create a variable and assign a value to it. Then add 500 using the assignment operator.
# Create a variable and assign a value to it
my_variable = 100
# Use the assignment operator to add 500 to the variable
my_variable += 500
# Print the updated value of the variable
print(my_variable)
Friday, April 5, 2024
Teacher : Ahmad Zarif Contact # 0343-924-9404 18
Lab Based Question
19. 2. Print the table of two using the assignment operators.
Friday, April 5, 2024
Teacher : Ahmad Zarif Contact # 0343-924-9404 19
Lab Based Question
# Multiplication table (from 1 to 10) in Python
num = 2
# Iterate 10 times from i = 1 to 10
for i in range(1, 11):
print(num, ‘x’ , i , ‘=‘ , num * i)
20. 3. Enter the marks of three students , and find out who scored the highest using the
comparison
operator.
Ahmad =40;
Ali =34;
Haleem =43;
if Ahmad > Ali and Ahmad > Haleem:
largest = Ahmad;
elif Ali > Ahmad and Ali > Haleem:
largest = Ali;
else:
largest = Haleem;
print(largest)
Friday, April 5, 2024
Teacher : Ahmad Zarif Contact # 0343-924-9404 20
Lab Based Question
21. Code a simple calculator, take two numbers as user inputs. Give user conversion options
to perform different mathematical operations on these numbers and print the out put.
21
Group Project
n1 = float(input("Enter the first number"))
n2 = float(input("Enter the second number"))
op = input("What's the programming language you want to learn? ")
match op:
case "+":
r = n1 + n2;
print(r)
case "-":
r1 = n1 - n2;
print(r1)
case "*":
r2 = n1 * n2;
print(r2)
case "/":
r3 = n1 / n2;
print(r3)
case _:
print("You Enter invalid operator")
22. SLO MCQ’s
1. Drag and drop blocks is related to ________?
2. b. Text based programming languages in which programmers____________?
3. ______________ is example of a visual program.
4. ______________ is example of a textual program.
5. ____________ helps in contacting the hardware directly.
Friday, April 5, 2024 Teacher : Ahmad Zarif Contact # 0343-924-9404 22
i. A Programmer ii. Visual based iii. Textual iv. A Polygot
i. Drag ii. Drop iii. Write Code iv. B++
i. Python1 ii. Python2 iii. Scratch iv. Textual
i. C ii. C++ iii. Python iv. All of these
i. C++ ii. Python iii. Assembly iv. All of these
23. SLO MCQ’s
6. ________________ was the first programming language?
7. b. A programming language uses words from the _______ language?
8. Python 2 and Python 3 both the versions are ____________ from each other.
9. Python is an ___________ language.
10. Python is developed by_____________.
Friday, April 5, 2024 Teacher : Ahmad Zarif Contact # 0343-924-9404 23
i. C++ ii. A iii. FORTRAN iv. B Language
i. High ii. English iii. Urdu iv. None
i. Same ii. Different iii. Simple iv. Hard
i. Compiler ii. Hard iii. Python iv. Interpreter
i. Guido ii. Alex iii. Tonny iv. All of these
24. SLO MCQ’s
11. ____________ operator is used to join a string and number?
12. Python does not have a command for declaring ___________.
13. “int” just assign a ___________ value.
14. “Float” just assign a____________value.
15. _____________ is simply a collection of characters or letters.
Friday, April 5, 2024 Teacher : Ahmad Zarif Contact # 0343-924-9404 24
i. ++ ii. + iii. “+” iv. “++”
i. Text ii. Constant iii. Variable iv. None
i. Float ii. Numeric iii. Text iv. Binary
i. Text ii. Address iii. String iv. All of these
i. Float ii. Numeric iii. Text iv. Binary
16. When the comparison statement is correct the output will be _________
i. ++ ii. + iii. True iv. False
25. 1) Differentiate between visual and textual programming.
Visual-based programming languages are ones that allow you to manipulate visual elements — e.g. drag and drop
blocks — to make a program, as opposed to text-based programming languages, which have you write lines and lines of
code to make a program.
2) Define Computer Program.
Computer Program is a sequence of instructions written in a proper language through which the computer can
understand and solve the problem given to it. It is the method by which the whole computing process is directed and
controlled.
3) What is programming language?
A programming language is a set of instructions written by a programmer to deliver instructions to the computer to
perform and accomplish a task.
4) Describe python.
Python is a popular programming language. It was created by Guido van Rossum, and released in 1991.
It is used for:
• web development (server-side),
• software development,
• mathematics,
• system scripting.
Friday, April 5, 2024
Teacher : Ahmad Zarif Contact # 0343-924-9404 25
SLO Based Questions
26. 5) Write down the features of python.
6) Write the step for writing your python program.
Friday, April 5, 2024
Teacher : Ahmad Zarif Contact # 0343-924-9404 26
SLO Based Questions
27. 5) Write the step for writing your python program.
Friday, April 5, 2024
Teacher : Ahmad Zarif Contact # 0343-924-9404 27
SLO Based Questions
28. 6) Write the Algorithm to in which its IDE take two inputs and convert into integer and run the loop 10 time.
Friday, April 5, 2024
Teacher : Ahmad Zarif Contact # 0343-924-9404 28
SLO Based Questions
29. 7) Write the Flowchart to in which its IDE take two inputs and convert into integer and run the loop 10 time.
Friday, April 5, 2024
Teacher : Ahmad Zarif Contact # 0343-924-9404 29
SLO Based Questions
30. 8) Write the Python Code in which its IDE take two inputs and convert into integer and run the loop 10 time.
Friday, April 5, 2024
Teacher : Ahmad Zarif Contact # 0343-924-9404 30
SLO Based Questions
31. 9) Briefly describe python syntax.
Friday, April 5, 2024
Teacher : Ahmad Zarif Contact # 0343-924-9404 31
SLO Based Questions
32. 10) Write about datatypes mostly use in Python.
Friday, April 5, 2024
Teacher : Ahmad Zarif Contact # 0343-924-9404 32
SLO Based Questions
33. 11) Explain different types of operator.
a) Arithmetic Operator:
Friday, April 5, 2024
Teacher : Ahmad Zarif Contact # 0343-924-9404 33
SLO Based Questions
34. 11) Explain different types of operator.
a) Assignment Operator
Friday, April 5, 2024
Teacher : Ahmad Zarif Contact # 0343-924-9404 34
SLO Based Questions
35. 11) Explain different types of operator.
a) Comparison Operator
Friday, April 5, 2024
Teacher : Ahmad Zarif Contact # 0343-924-9404 35
SLO Based Questions
36. 12) Write the Python Code for All Arithmetic Operators.
Friday, April 5, 2024
Teacher : Ahmad Zarif Contact # 0343-924-9404 36
SLO Based Questions
37. 13) Write the Python Code for Assignment Operator.
Friday, April 5, 2024
Teacher : Ahmad Zarif Contact # 0343-924-9404 37
SLO Based Questions
38. 13) Write the Python Code for Compression Operator.
Friday, April 5, 2024
Teacher : Ahmad Zarif Contact # 0343-924-9404 38
SLO Based Questions
39. 14) Write down the steps for Scratch new project.
a) Add your sprite
b) Add a backdrop
15) Write down the step for wizard movement.
a) If/then movement
b) Loop it
c) Two directions
Friday, April 5, 2024
Teacher : Ahmad Zarif Contact # 0343-924-9404 39
SLO Based Questions
40. 16) Write down the program in scratch for the fire ball. Book page:104
Friday, April 5, 2024
Teacher : Ahmad Zarif Contact # 0343-924-9404 40
SLO Based Questions
41. 17) Write down the step for create variable for player health.
18) Write down the program for player health.
Friday, April 5, 2024
Teacher : Ahmad Zarif Contact # 0343-924-9404 41
SLO Based Questions
42. 19) Write down the program for Enemy health.
Friday, April 5, 2024
Teacher : Ahmad Zarif Contact # 0343-924-9404 42
SLO Based Questions