2page Essay

princessamay224
Intro_to_prog1.pptx

Intro to Programming

What is programming?

Programming is a set of instructions to complete a task.

The components of computer programming;

Environment; is the editor where you are going to write the code.

Structure of the code;

Follow the concept of IPO (input-processing-output)

elements of a programming language

3) How to run the program

For the environment; we are going to use www.pythontutor.com or https://py3.codeskulptor.org/

Let us write a simple program that will add two numbers

# inputs

first_number = 5

second_number = 7

#process

sum = first_number + second_number

#output

Print (“Sum =”, sum)

The above code is not useful because the input values are hard coded, before we correct this, let us talk about the elements of any programming language.

Storage or variable; in the above example first_number and second_number are variables. Note that first_number is not the same as First_number. Python is a case sensitive language.

If – then

we can say if (sum > 10):

print(“Too much”)

3) loop

for - in

2

print("Welcome to programming")

# inputs

first_number = float(input("Enter first number "))

second_number = float(input("Enter second number "))

#process

sum = first_number + second_number

#if-then

if (sum > 10):

print("too much")

else:

#output

print ("Sum =", sum)

#loop

for i in range(int(sum)):

print(i)