Programming L4: Algorithms, Programming Paradigms, IDEs, Debugging

Verified

Added on  2024/05/21

|36
|3793
|212
Report
AI Summary
This report provides a comprehensive overview of fundamental programming concepts within the context of L4 programming. It begins by exploring algorithms, offering step-by-step solutions to various problems, and delves into different programming paradigms, including procedural, object-oriented, and event-driven programming, highlighting their characteristics and how Python fits into each. The report further examines Integrated Development Environments (IDEs), detailing their features such as code editors, auto-completion, syntax checks, and debuggers, while also discussing the pros and cons of using an IDE. Practical examples and figures are included to illustrate the concepts, alongside a demonstration of using IDLE for debugging, showcasing its various functionalities and menus. The document concludes by emphasizing the importance of debugging techniques in software development.
Document Page
Programming (L4)
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
Contents
INTRODUCTION.................................................................................................................................3
Lo1........................................................................................................................................................4
P1......................................................................................................................................................4
M1.....................................................................................................................................................4
D1......................................................................................................................................................4
LO2.......................................................................................................................................................6
P2......................................................................................................................................................6
M2.....................................................................................................................................................7
D2......................................................................................................................................................8
LO3.......................................................................................................................................................9
P3......................................................................................................................................................9
M3...................................................................................................................................................21
D3....................................................................................................................................................25
LO4.....................................................................................................................................................27
P4.....................................................................................................................................................27
P5.....................................................................................................................................................31
M4...................................................................................................................................................32
D4....................................................................................................................................................32
CONCLUSION...................................................................................................................................34
REFERENCES....................................................................................................................................35
1
Document Page
List of Figures
Figure 1 Problem 1.1.............................................................................................................................9
Figure 2Problem 1.2............................................................................................................................10
Figure 3Problem 1.3............................................................................................................................10
Figure 4Problem 1.4............................................................................................................................11
Figure 5 Problem 1.5...........................................................................................................................11
Figure 6 Problem 1.6...........................................................................................................................12
Figure 7Problem 1.7............................................................................................................................13
Figure 8 Problem 1.8...........................................................................................................................13
Figure 9 Problem 1.9...........................................................................................................................14
Figure 10Solution 1.1..........................................................................................................................14
Figure 11Solution 1.2..........................................................................................................................15
Figure 12Solution 1.3..........................................................................................................................15
Figure 13Solution 1.4..........................................................................................................................16
Figure 14Solution 1.5..........................................................................................................................17
Figure 15Solution 1.6..........................................................................................................................17
Figure 16Solution 1.7..........................................................................................................................18
Figure 17Solution 1.8..........................................................................................................................19
Figure 18Solution 1.9..........................................................................................................................20
Figure 19MENU..................................................................................................................................20
Figure 20IDLE....................................................................................................................................22
Figure 21IDLE....................................................................................................................................23
Figure 22About IDLE..........................................................................................................................24
Figure 23Debug IDLE.........................................................................................................................25
Figure 24Program file to debug...........................................................................................................28
Figure 25Program file to debug...........................................................................................................28
Figure 26Setting Breakpoints..............................................................................................................30
Figure 27After breakpoint, the line turns yellow.................................................................................30
Figure 28 Control window of debugging.............................................................................................31
2
Document Page
INTRODUCTION
This report presents the small problems conclude in a menu type which helps to execute all functions
easily in a one go through by selecting an optionfrom the menu to run which problem. Top achieve
passing grades, defining all the topics along description helps to understand easily to anyone. The
main objective of this report is to prepare a program which givesa basic understanding of knowledge
using a programming language and following programming paradigms fulfilling the requirements of
the program. In this, applying some modules which enable the operations performed on identifiers and
run the functions to execute code. This file representing modules done by programming language and
their procedures which help identify the code easily.
3
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
Lo1
Algorithm provides a step wise step detailed solution to solve a problem. Algorithm helps in data
processing, instruct how to make calculations and also used in other mathematical calculation.
P1
a) ALGORITHM 1.7
1) Start the python idle
2) Define functions for calculating and defining the elements
3) First, make defsumofarrayelements() function with an argument to define values
4) The express sum of an array element using for loop in the result variable
5) Return result which adds all the elements and produces output
6) Again make another function which defines array elements defarr()
7) Pass the values to an array
8) Last print the sum of the array by calling the function
9) Exit
M1
Steps were taken to execute code from writing 1.8
1) First, start the idle to open a new file for writing source code
2) Then make the function to run the program, which is very helpful to execute the code
3) Define start height by taking input from the user and also set minimum height limit to 0.5
as given
4) Set howmanyboumce to 0 which will be increment later by checking the condition
5) Now make a condition which checksstartheight to minimum height limit if it is less than
start height then increment howmanybounce by 1
6) Calculate start height by multiply 0.70 to start height
7) Last print the howmanybounces which give the bounces time
8) Exit
D1
Algorithm 1.9 a)
1) Start the program in python language
2) Import math library for mathematical calculation and define a function to execute this
program defmathsquiz()
4
Document Page
3) Take input for no of question from a user in integer and set out from program to False
4) Also, set playnoques and scoregame to 0 which will increment later in this code
5) Define operator array using +, -, *, / for check the solution to user solution
6) Make a while condition which runs until out of program is equal to false
7) Now generate operation through randomly from operation array
8) Check if the condition for playnoques is less than number of question or playnoques
should be greater or equal to 0
9) Then generate questions number 1 and 2 from random range 1 to 10
10) Print the generate number 1, operation, and generate number 2 and take input for user
solution from the userto verify the solution and increment playnoques to 1
11) Now check for all operations performed using if else conditional loop, if the solution will
match with user solution then print correct answer else print incorrect answer and the
correct answer is this.
12) After checking all condition come out of the program and set to true and return
completed your game and your final score is which is calculated
13) Exit
b)
The relation between code algorithm and code variant is just of the language difference. In the
algorithm, we write the code functionality and how it’ll work in the coding language in the normal
description like a paraphrase of source code and code is just a programming language in which we are
performing or executing the problem by compiling and executing the values by standard functions or
libraries of programming language.
5
Document Page
LO2
P2
Procedural programming language
The first programming paradigm that is likely to learn is procedural or imperative programming
which consists of module and data that operates on data information. In this programming,Procedures
are like mini-programs that can be called from anywhere else in the overall program.
Procedure programming computer programs is a programming paradigms in light of methodology
brings in which explanations are organized in subroutines or capacities which are regular systems, this
is procedural paradigm programming.
Object-orientedprogramming language
In Object-oriented paradigm, program or source is built on objects and an object is an instance of the
class. Object-oriented programming consists of data encapsulation, data hiding, abstraction and
inheritance which help in the program to execute and hide some data part from the viewer which is
not needed to see but work normally in the program. The best thing about object-oriented programs is
that we people are extremely used to considering objects. The use of the object model to show causes
considerably to create complex projects and object orientation diminishes the dangers of
programming software development.
Event Drivenprogramming language
In Event-driven programming paradigm, programs are executed in response to events like click,
keyboard key press or any device attaching which works for the event. The fundamental thought in
event-driven programming is that the program which is intended to respond to functions or code.
Hypothetically, all programming languages support the function driven style of programming,
although some language highlights, for example, terminations, make it less demanding to actualize.
Characteristics of procedural
It concentrates mainly on functions, but not on data.
Problem is isolated into sub-problems i.e. program is separated into a few littler projects
called functions.
In this, functions dstrbute global data information which is used in programs to use variables
No security to information moves straightforwardly among the capacities.
6
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
Function changes information from one type to another.
It is based on top-downmethodology.
Characteristics of object-oriented
Encapsulation: It means you can combine data and code which manipulates into a single unit
which is commonly referred as encapsulated data.
Polymorphism: It means which have many forms such as poly means “many” allowsthe
object processed with different data types or classes.
Inheritance: It means reusability of existing classes such as a parent is used to child class and
its objects which perform some functions.
Abstraction: It is a concept which extracts the important information from an object by
eliminating unnecessary information.
Characteristics of Event-driven paradigm
Service-oriented means provides services which are available on a network so the code has
not to be rewritten again and again
Time-driven means relies on time i.e., work until timer off such as traffic light.
Event handlers mean code that relates to event form like a mouse click, a key press on the
keyboard.
Trigger functions decide what causes the event to take place or not.
Some other is simplicity, flexibility, ease of development, etc.
Python fits in all paradigms such as event-driven by clicking events, object-oriented by using classes
which helps to make more than 2 functions in a single class and procedural also by using small
modules in a single unit.
M2
An integrated development environment (IDE) is a product suite that combines the fundamental
devices developers need to compose and test programming. Normally, an IDE contains a code
rewriter, a compiler or translator and a debugger that the designer gets to through a solitary graphical
UI (GUI). An IDE might be an independent application, or it might be incorporated as a component of
at least one existing and good applications.
Some features are as follows:
7
Document Page
1) Code editorial manager: the surrounding where the user can compose code is known as the shell.
The code rewriter is content alter region that enables developer to compose, alter and spare a record of
code.
2) Auto-completion (or code fulfilment): This is intended to spare time while composing code.
3) Bracket coordinating: This is utilized for dialects that utilization sets of sections to stamp out
squares of code.
4) Syntax checks: This perceives the off-base utilization of linguistic structure and features any
blunders.
5) Translator: This gathers or translates the code.
6) Libraries: These give capacities that are excluded in the centre piece of the programming dialect.
7) Debugger: This is a program inside the IDE that is utilized to identify mistakes.
8) Runtimemistakes: They are blunders which will make the program or PC crash regardless of
whether there gives off an impression of being nothing amiss with the program code.
9) Syntaxblunders: They are mistakes in how the code is composed. Interpreters can just execute a
program on the off chance that it is grammatically right. Basic sentence structure blunders incorporate
spelling mistake, wrong utilization of accentuation and the utilization of capital letters.
D2
On evaluating the program code of an application software which applies the all programming
paradigms in term of source code format or characteristics by applying class and its objects used from
object-oriented programming paradigm and some of by clicking events of an application are
considered in event-driven paradigm in code structure and lastly some code part is written in modules
using functions and encapsulated with a single class which also referred as a part of programming
paradigm implementation which matches the characteristics of programming paradigms.
8
Document Page
LO3
P3
Programs
Figure 1 Problem 1.1
9
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
Figure 2Problem 1.2
Figure 3Problem 1.3
10
Document Page
Figure 4Problem 1.4
Figure 5 Problem 1.5
11
chevron_up_icon
1 out of 36
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]