Input comments
Дипломдар мен сертификаттарды алып үлгеріңіз!
1 слайд
1 слайд
2 слайд
3.4 INPUT.
COMMENTS
2 слайд
3.4 INPUT. COMMENTS
3 слайд
You will:
•
apply input commands to enter data;
•
solve mathematical problems.
3 слайд
You will: • apply input commands to enter data; • solve mathematical problems.
4 слайд
Terminology
•
object - нысан - объект
•
nevertheless - соған қарамастан - тем не менее
•
container - контейнер - контейнер
•
to confuse - шатастыру - запутывать
•
relevant - орынды - c оответствующий
•
bucket - шелек - ведро
•
to refer - жүгіну – обращаться
•
whole numbers - бүтін сандар - целые числа
•
several - бірнеше - несколько
•
fractional numbers - бөлшек сандар - дробные числа
•
to remain - қалу - оставаться
•
editorial - редакциялық - редакционный
4 слайд
Terminology • object - нысан - объект • nevertheless - соған қарамастан - тем не менее • container - контейнер - контейнер • to confuse - шатастыру - запутывать • relevant - орынды - c оответствующий • bucket - шелек - ведро • to refer - жүгіну – обращаться • whole numbers - бүтін сандар - целые числа • several - бірнеше - несколько • fractional numbers - бөлшек сандар - дробные числа • to remain - қалу - оставаться • editorial - редакциялық - редакционный
5 слайд
5 слайд
6 слайд
Input data
•
A computer program (software) consists of three parts:
Input, Process and Output.
•
Input (data entry) is the process of entering data.
•
In Python, this process is performed through the
command
“ Input ()”.
x = input (‘Enter the data’) #gets data as string (text)
•
The variable x is by default a text value.
a = int (input (‘Enter the data’) #gets data as int
(number)
•
To enter integers, add int () for integers and float () for
fractional numbers.
6 слайд
Input data • A computer program (software) consists of three parts: Input, Process and Output. • Input (data entry) is the process of entering data. • In Python, this process is performed through the command “ Input ()”. x = input (‘Enter the data’) #gets data as string (text) • The variable x is by default a text value. a = int (input (‘Enter the data’) #gets data as int (number) • To enter integers, add int () for integers and float () for fractional numbers.
7 слайд
Comments
•
Sometimes programmers leave notes in different areas.
code for explanation or warning.
•
Such notes are called comments and do not are
perceived by the compiler. There are two ways to enter
comments.
1. To add comments, the character “#” and after it is the
text itself. The compiler will ignore everything what is
written after the “#” on this line. Example:
•
Code: #This is a comment, it begins with a ‘#’ sing
#and the computer will ignore it
•
print (“This is not a comment, the computer will ”)
•
print (“run this and print it.”)
•
Output: This is not a comment, this and print it.
7 слайд
Comments • Sometimes programmers leave notes in different areas. code for explanation or warning. • Such notes are called comments and do not are perceived by the compiler. There are two ways to enter comments. 1. To add comments, the character “#” and after it is the text itself. The compiler will ignore everything what is written after the “#” on this line. Example: • Code: #This is a comment, it begins with a ‘#’ sing #and the computer will ignore it • print (“This is not a comment, the computer will ”) • print (“run this and print it.”) • Output: This is not a comment, this and print it.
8 слайд
Comments
2. To comment on a piece of text three single
apostrophes (‘‘ ‘) are used at the beginning and in
end of text.
Code: '''
print(“We are in a comment”)
print (“We are still in a comment”)
'''
print(“We are out of the comment”)
Output: We are out of the comment
8 слайд
Comments 2. To comment on a piece of text three single apostrophes (‘‘ ‘) are used at the beginning and in end of text. Code: ''' print(“We are in a comment”) print (“We are still in a comment”) ''' print(“We are out of the comment”) Output: We are out of the comment
9 слайд
How to solve problems
Apples
You have N apples in a basket. And K students want to
divide
these apples equally. You cannot divide an apple into
several
parts. So it remains in the basket.
1. Calculate how many apples each student will have.
2. Calculate how many apples will remain in the basket.
Input data:
You will have two inputs. First input is number of students
(K).
Second input is number of apples (N).
Output data:
You will have two outputs. The fi rst output is number of
apples given to each student.
The second is number of apples that remain in the basket
9 слайд
How to solve problems Apples You have N apples in a basket. And K students want to divide these apples equally. You cannot divide an apple into several parts. So it remains in the basket. 1. Calculate how many apples each student will have. 2. Calculate how many apples will remain in the basket. Input data: You will have two inputs. First input is number of students (K). Second input is number of apples (N). Output data: You will have two outputs. The fi rst output is number of apples given to each student. The second is number of apples that remain in the basket
10 слайд
Sample tests:
10 слайд
Sample tests:
11 слайд
EDITORIAL
Now let us talk about how to solve problems. Read the
problem carefully. Pay attention on what you should find.
In this problem we must find number of apples given to each
student and number of apples that remain in basket:
To find number of apples given to each student we just
divide N
by K.
answer1 = n / k
To find number of apples that remain in the basket we use
modulus sign (%) to calculate remainder of division of N by
K
answer2 =n % k
Entire code will look like this:
k,
n = map(int,input().split())
print ( n / k , ” “ , n % k )
11 слайд
EDITORIAL Now let us talk about how to solve problems. Read the problem carefully. Pay attention on what you should find. In this problem we must find number of apples given to each student and number of apples that remain in basket: To find number of apples given to each student we just divide N by K. answer1 = n / k To find number of apples that remain in the basket we use modulus sign (%) to calculate remainder of division of N by K answer2 =n % k Entire code will look like this: k, n = map(int,input().split()) print ( n / k , ” “ , n % k )
12 слайд
I liked the lesson
I didn’t like the lesson
The lesson was …
interesting
useful boring
12 слайд
I liked the lesson I didn’t like the lesson The lesson was … interesting useful boring