0% found this document useful (0 votes)
14 views17 pages

Presentation 1

The document is an introduction to backend development using Python, covering its applications, installation, and basic programming concepts. It explains Python's versatility in areas like web development, AI, and automation, and provides examples of simple programs and variable usage. The content is structured to guide beginners through the essentials of Python programming and its application in backend development with Django.
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)
14 views17 pages

Presentation 1

The document is an introduction to backend development using Python, covering its applications, installation, and basic programming concepts. It explains Python's versatility in areas like web development, AI, and automation, and provides examples of simple programs and variable usage. The content is structured to guide beginners through the essentials of Python programming and its application in backend development with Django.
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/ 17

DevUpshot

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

Why Python for Backend Devlopment:


1.Easy to Learn and Use
2.High-Level Language
3.Interpreted Language
4.Object-oriented
5.Career Opportunities and Salary
DevUpshot

Installing and setting up Python IDLE


-For Mac Users:
-For Windows User:
-For Andriod User:
-For Online User:
DevUpshot
3.0 A First Program
A first program Start IDLE and open up a new window (choose New Window under
the File Menu). Type in the following program.
temp= eval(input('Enter a temperature in Celsius: '))
Print('In Fahrenheit, that is', 9/5*temp+32)
Then, under the Run menu, choose Run Module (or press F5). IDLE will ask you to
save the file, and you should do so. Be sure to append '.py' to the filename as
IDLE will not automatically append it. This will tell IDLE to use colors to make
your program easier to read. Once you’ve saved the program, it will run in the
shell window. The program will ask you for a temperature. Type in 20 and press
enter. The program’s output looks something like this:
Enter a temperature in Celsius: 20
In Fahrenheit, that is 68.0
DevUpshot
3.1 A second program

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

Optional arguments There are two optional arguments to the print


function. but they are useful for making your output look nice.
sep Python will insert a space between each of the arguments of the print
function. There is an optional argument called sep, short for separator, that
you can use to change that space to something else. For example, using
sep=':' would separate the arguments by a colon and sep='##' would separate
the arguments by two pound signs.
One particularly useful possibility is to have nothing inside the quotes, as in
sep=' ' This says to put no separation between the arguments. Here is an
example where sep is useful for getting the output to look nice:
print ('The value of 3+4 is', 3+4, '.')
print ('The value of 3+4 is ', 3+4, '.', sep='')
The value of 3+4 is 7 .
The value of 3+4 is 7.
DevUpshot

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

In the example below, we perform a calculation and need to use the


result of the calculation in several places in the program. If we save the
result of the calculation in a variable, then we only need to do the
calculation once. This also helps to make the program more readable.
temp = eval(input('Enter a temperature in Celsius: '))
f_temp = 9/5*temp+32
print('In Fahrenheit, that is', f_temp)
if f_temp > 212:
print('That temperature is above the boiling point.')
if f_temp < 32:
print('That temperature is below the freezing point.')
DevUpshot

A second example Here is another example with variables. Before reading


on, try to figure out what the values of x and y will be after the code is
executed.
x=3
y=4
z=x+y
z=z+1
x=y
y=5
DevUpshot
Variable names There are just a couple of rules to follow when naming
your variables.
• Variable names can contain letters, numbers, and the underscore.
• Variable names cannot contain spaces.
• Variable names cannot start with a number.
• Case matters—for instance, temp and Temp are different

You might also like