Просмотр содержимого документа
«Python программалоо тили англис тилинде»
Class work
5/1/20
Subject: Introduction to programming language, Python
Plan:
[ Algorithm, Program language, Code. ] H/W
Simple arithmetic operators: +, -, /, *.
Order of operations and parenthesis.
Variables and data types. Data input and output.
Use comments.
Algorithm
An is a list of rules to follow in order to solve a problem.
The term algorithm itself derives from the 9th Century mathematician Musá Al-Khuwarizmi, Latinized 'Algoritmi'
For example:
Imagine that you need to show someone how you brush your teeth so they can learn how to do it themselves.
The instructions would go like this:
1 Open the toothpaste
2 Put a bit of toothpaste on the toothbrush
3 Open your mouth
4 Brush your teeth nicely
5 Rinse your mouth with water
6 Smile
my daily plan, time-table, …
Ways to representing algorithm
- Verbal - explain with words
- Flowchart - Chart or diagram
- Pseudo code - using special symbols
- Program - execute on a compute, need to know the programming language
Examples of Prog. Languages Basic, Fortran, C++, Delphi, Pascal, Python
used for creating
high-level programming language
Web applications
Dynamic Web content
custom plug-ins
…
designed to be easy to read and simple to implement.
Extension of program .py
The print() function prints the given object to the standard output device
print( arguments)
Variables (a, b, …)
String (“text”)
Value (number)
# 1st program
print("Hello 9 grades")
print (55) # output 55
print ( 5+5)
print(a)
program
output
# 1st program
Hello 9 grades
print("Hello 9 grades")
10
print (5+5) # output 10
Good bye
print (“Good bye”, )
Comments in Python
Hash (#) character, single-line comments are created simply by beginning a line
Creating Variables
A variable is created the moment you first assign a value to it.
Variables:
Output:
x=5 – number
5
Y=“John” - String (text)
John
Variable Names
A variable can have a short name (like x and y) or a more descriptive name (age, name, ICT total_volume). Rules for Python variables:
A variable name must start with a letter or the underscore character
A variable name cannot start with a number
A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )
Variable names are case-sensitive (age, Age and AGE are three different variables)
Fill yourself, (testing variables)
Write output
Output
Python input() Function
The input() function allows user input.
Syntax
input(prompt)
Write Python code here