COMPUTER SCEINCE
What is python?-chapter 7
-Python is a high-level programming language which is open source
and object oriented. Object-oriented programming is based on the
concept of objects.
-Python was developed by Guido Van Rossum in 1991.
Python can be used to:
. Creates web based applications
. Handles large amounts of data
. Performs complex calculations
. Connects to database, read and modify files.
Writing and executing program in Python
-Python has 2 programs, Command line window or Python IDLE
(Integrated Development Learning Environment). It allows you to edit,
run, browse and debug a Python program from the interface.
- You can directly type the command in the IDLE, or you can use print()
function.
Variables in Python
. Can consist of alphabets, digits and underscore only.
. Can start with an alphabet or underscore but not with a digit/number.
. Cannot have space in it.
. Keywords in Python cannot be used as variable name, ex: print, and,
not,etc.
. Python is a case sensitive
Declaring variables
To declare variable in Python we can just write, a=3 It will
automatically assign the value of 3 in variable a.( Unlike JavaScript you
don’t have to give var and no semicolon symbol needed)
You can assign multiple values to multiple variables using a single
Python statement. Example: You want to assign 3 variables lets say x,
y and z.
Using input function
Similar like JavaScript and other programming language, variable in Python
can be stored either declared within the program or can be accepted from
the user.
-Use input() as example to accept value from the user.
a=input(“Enter your name “)
print(a)
Using input() Function Python will converts any user input into string. To treat
the users input as a numeric value we need to convert it either using int or
float. Example: b=int(input(“Enter your age”)
c=b+1
Arithmetic operators
These operators used as basic operator to perform common arithmetic
calculations:
Assignment operators
Conditional structures
A program usually follow flow of control, which means the statements written
first are executed first in the sequence. We can change how the flow of
control based with conditional statements. In order words, using if.
There are three types of conditional statements in Python:
• if statement • if-else • if-elif else
- If statement must end with a colon (:) symbol
- A true condition of statement needs to be indented.
- You can give the condition inside () (brackets) but this is not mandatory
-. No limit of number of statement can appear under an if.
If statement: This statement checks if the condition given after is true, then
the statements following the if condition will be executed. If the condition is
false then next statement will be executed.
Ex: : Create a program where the user have to insert their age. If the age
above or equal to 18 then they are allowed to join the driving test.
age=int(print(“Enter your age”))
if age>=18:
print(“You are allowed”)
if-else statement: The condition before only executed true condition. To give
false or other condition beside true then we can use else statement.
Ex:Create a program where the user have to insert their age. If the age
above or equal to 18 then they are allowed to join the driving test below than
that they are not allowed.
age=int(print(“Enter your age”))
if age>=18: print(“You are allowed”)
else:
print(“You are not allowed”)
More about python-chapter 8
Loops in python
-Sometimes there is a need to repeat a set of statements more than once
based on a certain condition. This process is called loop or iteration in
programming.
For loop-For loop structure is used when you want to perform a loop in a
specific number of times. For loop using counter variable which is
incremented or decremented with each repetition of the loop
-use colon symbol (:) after for statement and the statement below for must
be indented.
-Range(start,stop,step)
A for loop can have an optional else block as well. The else part is executed
when the loop is finished
While loop-while loop executes a block of code repeatedly as long as the
test/control condition of the loop is true. It is ideally suited when the number
of iterations are not known prior to the execution of the loop.
• while is a reserved/keyword
• It will check for true/false. The statements will executed only if the
condition is true.
Ex: name=input(“Enter your name:”)
while name==“”:
print(“You did not enter your name”)
name=input(“Enter your name:”)
-While statement on the second line asks the user to enter their name. If the
condition remains true, third and fourth line will always be executed
-With the else statement we can run a block of code once when the condition
no longer is true
name=input(“Enter your name:”)
while name==“”:
print(“You did not enter your name”)
name=input(“Enter your name:”)
else: print(“Hello”,name)
Jump statements in python
Python offers two jump statements to be used within loops to jump out of
loop iterations.
Using break-The break statement enables a program to skip over a part of
the code. This statement terminates the current loop and resumes execution
at the statement immediately after the body of the loop.
Ex;
Using continue-With the continue statement we can stop the current iteration
of the loop, and continue with the next
Ex:
Write a program where the user enters a number. If the number matches the
number, acknowledge the user and stop the program. If the number does not
match, keep asking for the next number
Virus and anti virus-chapter 10
Information Technology has changed our society to a great deal. There are
group of software developers that support its growth by contributing in
positive ways. They develop tools and applications to help us work better. On
the other hand, there are group of software developers that contribute in a
destructive way by causing damage to the IT industry. They design and
spread destructive programs.
Computer virus
computer virus is a destructive software program. All computer viruses are
man-made.
Malware(malicious software)
-A computer virus is considered as malware; therefore, there really is no
difference. The term 'malware' is used as a way describe any malicious
software.
-Some viruses remain active even when you shut down the computer while
the others become active only when the infected program or application is
[Link] a malware is active, it loads onto the computer’s memory
and is saved there and replicate itself
What a computer virus/malware can do
• Some malwares are programmed specifically to damage the data on your
computer.
• Some make your computer behave erratically.
• Corrupt programs.
• Delete files.
• Or crash your computer system.
Why is it called a computer virus?
The metaphor of the "computer virus" was adopted because of the similarity
in form, function and consequence with biological viruses that attack the
human system.
• A biological virus destroys the cells of the body, likewise a computer virus
is a program that is secretly put onto a computer in order to destroy the
information within.
• Like biological virus, it can copy itself and infect other programs.
• Similar to biological virus, you do not realize the presence of it until your
computer has already been affected.
What a computer virus/malware cannot do
• Computer virus cannot infect write-protected discs (CD-ROMs) or infect
written documents.
• Virus do not infect compressed files, unless the file was infected prior to
compression.
• No virus can do direct physical damage to computer hardware.
• In addition, Macintosh virus do not infect Windows and vice versa.
Windows executables cannot run on a Mac and Mac executables cannot run
on Windows.
How does malware spread?
.free software
.suspicious popup ads
.spam email attachments
.p2p sharing files
.malicious websites
Symptoms of a computer virus
You can detect the presence of a virus in your computer. The following are
some of the primary indicators that a computer may be infected.
. Slower than usual.
.Stops responding, or locks up frequently.
. Crashes and restarts every few minutes.
.Apps on computer do not work correctly.
. Disks or drives are inaccessible.
. Unusual error messages
.Unrecognize extension on file name
.New icon appear that you did not place
.Strange sounds or music play unexpectedly
. Programs disappears from computer without your intervention
Types of computer viruses
Boot sector virus
Boot sector is the area of the computer that is accessed when the computer
starts. A boot sector virus infects this part. Boot sector virus is an old type of
virus where it requires storage media that is used to start up the computer.
Ex: Polyboot and Brain.
Program virus
This types of malware infects files that contain executable codes
like .exe, .com, .dll, etc. Some of these type of virus are memory resident.
The only way to disinfect this type of virus is to delete the file and prepare
backup before infected. It means that the virus will stay in memory and
continue to infect other programs. Ex:Jerusalem and Cascade.
Macro computer virus
Macro is a set of commands written by the user to be executed later.
Example, In Word, you can automate frequently used tasks by creating and
running macros. This type of virus infects the macro files and whenever any
macro is execute they show their effect by altering the macro code.
Examples: [Link] and Melissa.
Multipartile virus
This kind of computer virus is a hybrid type. Which means this computer
virus infects both boot sector (used to start the OS) and program files. It is
difficult to repair, because if you are able to clean 1 area and not the others,
the virus will simply spread and infect the other sectors. Examples: One_Half
and Emperor.
Polymorphic virus
This kind of virus is written in such a way that they change their code
whenever they pass to another machine. Polymorphic virus infects the
computer with encrypted copies of it. Thus, making it difficult for anti-virus to
scan and locate. Example: StormWorm.
Worms
Worms are destructive software programs designed to spread through
computer networks. Computer worms able to execute independently and
spread on its own through network connections. Examples: ILOVEYOU and
Stuxnet.
Trojan horse
Trojan horse does not reproduce by infecting other files, nor selfreplicating
like worms. It disguises as useful software, but actually contain malicious
code, where when triggered causes loss or even theft of data. Example: Zeus
or ZBot..
Logic bombs
A logic bomb is a destructive program which lies inactive until a specific
piece of program logic is activated. Its objective is to destroy data on the
computer once certain conditions have been met. Example: [Link]
Spyware
It is a software that secretly gathers information about a person or an
organization without their knowledge. It passes on this information to
advertisers or third parties. Spyware commonly spread through suspicious
pop up windows. Example: Keyloggers
Protection Against Computer Viruses
Using an Anti-virus Software
Anti-virus software is used to prevent, detect and remove destructive
programs.
Does antivirus 100% protect you from malware?
The more number of viruses are known to the anti-virus database, the easier
it becomes to detect them on your system.
Using an Anti-virus Software
Regular scan with anti-virus provide early detection if your computer has
been infected.
[Link] your anti-virus program installed in your computer. Initiate virus scan
by clicking on the scan options.
2. If your system has been infected, usually you will be asked to repair,
delete or quarantine the infected file.
Other ways to help to protect your computer
. Use original software
. Do not open attachment from unknown sender
.Using password protection
. Download from reputed source
. Be careful when sharing storage media with friends, ex: flash drive
. Scan with and update your anti-virus frequently
.Do not turn off your firewall, especially when browsing the internet.
Trouble shooting-chapter 11
Troubleshooting is the identification of trouble in a system caused by a failure of
some kind
Any problem within computer is initially described as symptoms of
malfunction. You can say that troubleshooting is a process of identifying a
computer problem so that it can be fixed.
Importance of computer maintenance
.It will increase the speed and the life of your computer
.It prevents errors
. It secures your data and information from any unwanted damages.
.It saves your precious time
Areas to troubleshoot
Hardware
These are the physical part of a computer and not frequently changed or
updated. Some parts are built-in, which mean they cannot be seen without
you open your computer. Some basic problems you can get are:
[Link] failure in the computer
[Link] problem like keyboard, mouse, etc not recognized
Software
These could be any program files or any applications. This is also the most
common area in troubleshooting. Mostly because of unexplained crashes or
strange messages. Some basic problems you can get are:
[Link] to install programs properly.
[Link] does not load when you trying to open.
[Link] when you try to open specific software.
Operating system
This could be the most frustrating problem a computer user can experienced.
Most because the OS are either crash or unable to boot up Basic problems
you can get are:
.OS restart without warning
.OS stops responding
.OS do not boot properly.
OS starts in a safe mode
Booting
This is what happened when you switch on a computer.
[Link] is switched on
[Link] conducts POST
[Link] checks drives for system disk
[Link] loads MBR
5. MBR program loads OS files
Beeping sound
Computer when turn on will go to POST (Power On Self Test) which will alert
user if something goes wrong. the computer will start generating a beep
code telling the user the source of the problem. The beep code can be
different in every manufacturer’s computer
STEPS OF TROUBLE SHOOTING
Step 1. Find out the Problem
This is the step to gather all information needed for the problem. The
information regarding how frequently the problem occurs, does it require
your attention and which part of the computer is getting affected. Hardware
or software.
Step 2. Categorize your problem
Once you have figured out whether the problem is related to the hardware or
the software.
Hardware problems
❑ Check power supply (for PC)
❑ Check devices connected to it.
❑ Refers back to beeping sound, check and clean your memory.
Software problems
❑ Check the OS files (any missing files or somehow quarantined by antivirus)
❑ Check missing drivers (drivers are software used to control devices such
as, keyboard, mouse,etc.
Step 3. Check the Service Manual
The service manual contain instructions for troubleshooting and service
information. Most computer and peripheral made today has a set of service
documentation in the form of books, CD and websites.
Step 4. Back to Its Original State
When you troubleshoot, make one change at a time in the problem sector. If
the change does not solve the problem then restore it back to the original
state. You must not make any alterations at a time as this may lead to more
complications.
Step 5. Call the Expert
If you feel that you not able to solve the problem of your computer, then it is
advisable to seek a technician. This to ensure you do not end up creating
more complications rather than solving the problem.
Common problems and troubleshooting
Computer is frozen/locks up
When you are trying to work with your computer and suddenly it
stop working and you cannot make any changing. You could open
Task Manager and ‘kill’ the specific apps/programs.
1. Press Ctrl + Alt + Del (at the same time)
2. Choose Start Task Manager
3. It will display Task manager, go to process list.
4. Select any program and right click with your mouse > End
Task.
The mouse and the keyboard does not work
First, check the cable connection if you use wired mouse or keyboard. Reboot
helps. If by rebooting does not help, check your device manager.
1. Click on the Start button
2. Select Control Panel
3. Click on Device Manager
4. Try to plug/unplug to see if your mouse/keyboard has been detected by
computer (if not then there is possibility of malfunction with the
keyboard/mouse).
5. If unrecognize device shows up, you need to install appropriate driver.
The sound isn't working
Solution 1: Check the volume level. Click the audio button in the top-right or
bottomright corner of the screen to make sure the sound is turned on and
that the volume is up. Solution 2: Check the audio player controls. Many
audio and video players will have their own separate audio controls. Make
sure the sound is turned on and that the volume is turned up in the player.
Solution 3: Check the cables. Make sure external speakers are plugged in,
turned on, and connected to the correct audio port or a USB port. If your
computer has colorcoded ports, the audio output port will usually be green.
Solution 4: Connect headphones to the computer to find out if you can hear
sound through the headphones.
Defragmentation
Defragmentation, also known as defragging or defrag, is the process of
rearranging the data on a storage medium, such as a hard disk drive (HDD),
for efficient storage and access.
Why is defragmentation needed?
Defragmentation can solve and mitigate problems, such as slow speeds,
freeze-ups and extended boot times of a computer.
How does fragmentation occur?
• If an excessively large file, such as a media or movie file, cannot fit into the
empty spaces on a hard drive, fragmentation will occur.
• If an existing file is updated, but the space it occupies doesn't have room
for any new changes, then it will cause fragmentation.
• The file system -- the part of the operating system (OS) that controls how
files are stored -- may break the files into smaller chunks when trying to save
them quickly
How to perform defragmentation
• Go to the search bar on the Start menu and type defrag.
• On the Defragment and Optimize Drives option, select the drive that needs
to be defragmented and click on Optimize.