Presentation 1
Presentation 1
INTRODUCTION TO BACKEND
DEVELOPMENT
Olude Adeola
DevUpshot
CONTENT
1.What is python programming language, what is it used for, and why python
for Backend Devlopment.
2.installing and setting up python IDLE
3.A First program
4.Getting input
5.printing
6.Variables
DevUpshot
1.0 What is python and why learn it
python is a powerful and versatile computer programming language used
to build websites, software, automate tasks, and conduct data
analysis. Its general-purpose nature allows it to be applied to a wide
range of problems, making it an ideal choice for beginners and
experienced developers alike. Python's popularity stems from its ease
of use, simplicity, and flexibility, making it one of the most widely
used programming languages today.
Created by Guido van Rossum in 1991, Python has evolved significantly
over the years, with continuous updates and improvements. Its vast
libraries and frameworks make it an excellent choice for web
development. Django, a high-level framework, enables rapid
development of secure, maintainable, and scalable websites, making
it the perfect choice for our backend development journey. In this
program, we will be focusing on building backend applications using
Python and the Django framework.
DevUpshot
What is python used for:
1.AI and Machine Learning
2.Data Analysis
3.Web Devlopment
4.Automation and scripting
Here is a program that computes the average of two numbers that the
user enters:
num1 = eval(input('Enter the first number: '))
num2 = eval(input('Enter the second number: '))
print('The average of the numbers you entered is', (num1+num2)/2)
For this program we need to get two numbers from the user. There are
ways to do that in one line, but for now we’ll keep things simple. We get
the numbers one at a time and give each number its own name. The only
other thing to note is the parentheses in the average calculation. This is
because of the order of operations. All multiplications and divisions are
performed before any additions and subtractions, so we have to use
parentheses to get Python to do the addition first.
DevUpshot
3.2 Typing Things in
Case Case matters. To Python, print, Print, and PRINT are all different things.
For now, stick with lowercase as most Python statements are in lowercase.
Spaces Spaces matter at the beginning of lines, but not elsewhere. For
example, the code below will not work.
temp = eval(input('Enter a temperature in Celsius: '))
print('In Fahrenheit, that is', 9/5*temp+32)
Python uses indentation of lines for things we’ll learn about soon. On the other
hand, spaces in most other places don’t matter. For instance, the following lines
have the same effect:
print('Hello world!')
print ('Hello world!')
Print('Hello world!')
DevUpshot
4.0 Getting input
The input function is a simple way for your program to get information
from people using your program. Here is an example:
name = input('Enter your name: ')
print('Hello, ', name)
The basic structure is
variable name = input(message to user)
The above works for getting text from the user. To get numbers from the
user to use in calculations, we need to do something extra. Here is an
example:
num = eval(input('Enter a number: '))
print('Your number squared:', num*num)
The eval function converts the text entered by the user into a number.
One nice feature of this is you can enter expressions, like 3*12+5, and
eval will compute them for you.
DevUpshot
5.0 Printing
Here is a simple example:
print('Hi there')
The print function requires parenthesis around its arguments. In the program
above, its
only argument is the string 'Hi there'. Anything inside quotes will (with a few
exceptions) be printed exactly as it appears. In the following, the first
statement will output 3+4, while the second will output 7.
print('3+4')
print(3+4)
To print several things at once, separate them by commas. Python will
automatically insert spaces between them. Next page is an example and the
output it produces.
DevUpshot
Examples.
print('3+4')
print(3+4)
To print several things at once, separate them by commas. Python will
automatically insert spaces between them. Below is an example and the
output it produces.
print('The value of 3+4 is', 3+4)
Print('A', 1, 'XYZ', 2)
The value of 3+4 is 7
A 1 XYZ 2
DevUpshot
5.1 Optional Argument
end The print function will automatically advance to the next line. For
instance, the following will print on two lines:
print('On the first line')
print('On the second line')
On the first line
On the second line
There is an optional argument called end that you can use to keep the
print function from advancing to the next line. Here is an example:
print('On the first line', end='')
print('On the second line')
On the first lineOn the second line
Of course, this could be accomplished better with a single print, but we
will see later that there are interesting uses for the end argument.
DevUpshot
6.0 Varaiable
Looking back at our first program, we see the use of a variable called
temp:
temp = eval(input('Enter a temperature in Celsius: '))
print('In Fahrenheit, that is', 9/5*temp+32)
DevUpshot