0% found this document useful (0 votes)
8 views11 pages

1-Chapter 5 Advanced Programming

Chapter 5 of the Computer Science Workbook focuses on advanced programming concepts, including objective-type questions about programming languages, operators, and loops. It also covers descriptive questions on programming languages, their features, and applications, as well as practical Python coding exercises. The chapter concludes with short answer questions highlighting key programming concepts and data types.

Uploaded by

raiha.kashif002
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views11 pages

1-Chapter 5 Advanced Programming

Chapter 5 of the Computer Science Workbook focuses on advanced programming concepts, including objective-type questions about programming languages, operators, and loops. It also covers descriptive questions on programming languages, their features, and applications, as well as practical Python coding exercises. The chapter concludes with short answer questions highlighting key programming concepts and data types.

Uploaded by

raiha.kashif002
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Chapter # 5 (Advance Programming)

Day: Classwork / Homework Date: _

Objective Type Questions


Q No 1: Choose the correct option. (Tick all that apply.)
a. A person that writes codes in different programming languages is known as
.
i. A programmer iii. A Writer
ii. A Technician iv. A polyglot
b. Which one of the following is not a programming language?
i. C++ iii. Python
ii. JavaScript iv. B++
c. Which version of Python did you learn in this chapter?
i. Python1 iii. Python3
ii. Python2 iv. Python4
d. Which of the following is an assignment operator? i.
+ iii. %
ii. - iv. =
e. Which of the following is a loop in Python3?
i. While Loop iii. None of the above
ii. For Loop iv. All of the above.

Q No 2: Choose the correct answer: (Additional)

1. Which language is best suited to code low-level embedded systems?

a. Assembly language c. HTML

b. C++ d. Java

2. Drag and drop block is an example of:

a. Assembly language c. C language

b. Visual programming language d. None of them

3. Which of the following was the first computer language?

a. C c. Visual basic

b. Java d. None of them

Computer Science Workbook 8 (4th Edition)


Chapter # 5 (Advance Programming)
Day: Classwork / Homework Date: _

4. The language best suited for GUIs and web-based gaming is?

a. Java c. Assembly languages

b. C d. None of them

5. Which symbol is used to join a string and a number?

a. + c. *

b. – d. All of them

6. Which of the following is a command in Python to declare a variable?

a. DECLARE c. STORE

b. ASSIGN d. None of them

7. Which data type in Python will hold a collection of characters or letters?

a. int c. string

b. float d. char

8. %= is an example of:

a. Comparison operator c. Arithmetic operator

b. Assignment operator d. None of them

Q No 3: Fill in the blanks:


1. Assembly language helps in contacting the hardware directly as it is based on
computer architecture.

2. Block-based programming is an example of visual programming language


.
3. Every programming language has
syntax, semantics, and pragmatics.

4. The code of Python is executed line by line; hence it is called interpreted language .

5. The command used to display output in C++ is called cout _.

Computer Science Workbook 8 (4th Edition)


Chapter # 5 (Advance Programming)
Day: Classwork / Homework Date: _

Descriptive Type Questions


Q No 4: Answer the following.
a. Define programming language. What are the most commonly used
programming languages?
A programming language is the computer language used by programmers and developers
to write and develop different programs and software. The most commonly used
programming languages are:

• C++
• JavaScript
• Python
• Java
• C

b. Differentiate between the types of programming languages.


Languages Features Applications
It is a low-level programming Used for:
language Coding device drivers
It allows complex jobs to run in a Low level embedded systems
Assembly
simple way Reverse engineering
Language
It is based on computer architecture,
hence provides help in contacting the
hardware

Mid-level programming language Used in:


Has lots of built-in functions Programming OS Games
C++ It helps to structure and break the Banking applications

Computer Science Workbook 8 (4th Edition)


Chapter # 5 (Advance Programming)

Capable of handling runtime errors Used in:


Has strong memory management GUI
JAVA system Web based gaming
More secure than other languages Cloud based application

Computer Science Workbook 8 (4th Edition)


Chapter # 5 (Advance Programming)
Day: Classwork / Homework Date: _

c. How do you use blocks to create a script in Scratch?


Following are the steps to create and run the program in SCRATCH

1. Create a new project

2. Rename the project

3. Click create

4. Erase everything in main.py and start coding

5. To run the code, right click and select Run main or press ctrl+shift+F10

d. Can you give some examples of different types of blocks that are available in
Scratch?

1. Motion blocks: they help the sprite to move in different directions.

2. Looks block: allows to change the color, size and costume of the sprite.

3. Sound block: allows to add sounds to your program. You can add sound from

the default sound library or upload from your computer.

4. Events: tell scratch when to start the program by specifying a triggering

Movement such as clicking the green flag.

5. Control block: provides options such as wait, use loops or conditional Statement

6. Sensing: they are used to detect things such as position of mouse pointer on the
screen.

7. Operators: allows to perform calculations on both numbers and text also known
as strings.

8. Variables: allow to save the variables that are used in the program.

9. My blocks: allow to create your own blocks for a sprite. You can name this block
and define what the new block does using other scratch blocks.

Computer Science Workbook 8 (4th Edition)


Chapter # 5 (Advance Programming)
Day: Classwork / Homework Date: _

Lab Activity
Q No 5: Answer the following.

1. Write the script in Python to enter the marks of English, Mathematics, and
Science. Find the total and the percentage.

The code is given below:

Print (“Enter Marks Obtained in English Mathematics, Science: “)

English = int(input())

Mathematics = int(input())

Science = int(input())

sum = English+Mathematics+Science

perc = (sum/300)*100 print (end=” Sum”)


print (sum) print(end=”Percentage Mark = “)

print(perc)

2. Write the script in Python to create a variable and assign a value to it. Then
add 255 using the assignment operator.

my_variable = 100
my_variable += 255
print("The new value of the variable is:", my_variable)

Computer Science Workbook 8 (4th Edition)


Chapter # 5 (Advance Programming)
Day: Classwork / Homework Date: _

3. Write the script in Python to print the table of TWO using the assignment
operator.

number = 2
for i in range(1, 11):
result = number
result *= i
print(f"{number} x {i} = {result}")

Extra Question Answers


Q No 6: Short questions and answers.

1. Complete the table below:


Language Features Applications
Low-level programming Boot codes
language Reverse engineering
Assembly Language

Capable of handling Used in mobile application

Java runtime errors Web based gaming

Cloud based applications


Strong memory
management

Used in banking
It is high level programming
language. applications
C++ It is portable language Data structures
It is rich in library Software engineering
It locate errors and rectifiy Web browser games

Computer Science Workbook 8 (4th Edition)


Chapter # 5 (Advance Programming)
Day: Classwork / Homework Date: _

2. What do you understand by cross-platform language? Justify your response


with an example.

A cross-platform language allows applications to run on multiple operating systems with


Minimal changes to the code.
This is achieved by abstracting OS-specific details, often through the use of virtual machines or
Interpreters.

3. Why is python preferred over other languages? Highlight its features.

Python is preferred for its simplicity, versatility, and ease of use. Key features include:

1. Simple Syntax: Easy to learn and write.


2. Cross-Platform: Runs on multiple OS.
3. Large Standard Library: Reduces need for third-party tools.
4. Interpreted Language: Easier debugging.
5. Dynamically Typed: Flexible and concise code.
6. Supports Multiple Paradigms: Object-oriented and functional.

4. How would you differentiate between programming language and computer


program?

A programming language is a tool used to write instructions for a computer (e.g.,


Python, Java).
A computer program is the actual application or software that performs tasks, created
using a programming language (e.g., Google Chrome, Microsoft Word).

Computer Science Workbook 8 (4th Edition)


Chapter # 5 (Advance Programming)
Day: Classwork / Homework Date: _

5. Name the most commonly used datatypes in Python.

 int: Integer values (e.g., 5, -3)


 float: Floating-point numbers (e.g., 3.14, -0.001)
 str: Strings (e.g., "Hello", 'Python')
 list: Ordered, mutable collection of items (e.g., [1, 2, 3])

6. Name the given operators.

S. No. Operator Arithmetic / Name


Comparison
Arithmetic Addition
1 +
Arithmetic Subtraction
2 -
Comparison Equal
3 ==
Arithmetic Multiplication
4 *
Comparison Not equal
5 !=
Arithmetic exponentiation
6 **
Comparison Greater than
7 >
Comparison Less than equal to
8 <=
Arithmetic Floor division
9 //
10 Comparison Greater than equal to
>=
Comparison Less than
11 <
Arithmetic Division
12 /
Arithmetic modulus
13 %

Computer Science Workbook 8 (4th Edition)


Chapter # 5 (Advance Programming)
Day: Classwork / Homework Date: _

Q No 7: What will be the output of the following codes.

S. No. Code Output


a=1
b=2
1 c=a+b 3
print ( c )

a = 10
b=2
2 c=a–b 8
print ( c )

a=5
b=3
3 c=a*b 15
print ( c )

a = 10
b=2
4 c=a/b 5
print ( c )

a = 10
a += 5
5 print ( a ) 15

a=9
a -= 5
6 print ( a ) 4

b=5
b *= 2 10
7 print ( b )

a = 10
a /= 5 2
8 print ( a )

c = 11
c %= 2 1
9 print ( c )

Computer Science Workbook 8 (4th Edition)


Chapter # 6 (Advance C Language)

Computer Science Workbook 8 (4th Edition)

You might also like