Презентация Basic programming онлайн
На нашем сайте вы можете скачать и просмотреть онлайн доклад-презентацию на тему Basic programming абсолютно бесплатно. Урок-презентация на эту тему содержит всего 74 слайда. Все материалы созданы в программе PowerPoint и имеют формат ppt или же pptx. Материалы и темы для презентаций взяты из открытых источников и загружены их авторами, за качество и достоверность информации в них администрация сайта не отвечает, все права принадлежат их создателям. Если вы нашли то, что искали, отблагодарите авторов - поделитесь ссылкой в социальных сетях, а наш сайт добавьте в закладки.
Презентации » Устройства и комплектующие » Basic programming
Оцените!
Оцените презентацию от 1 до 5 баллов!
- Тип файла:ppt / pptx (powerpoint)
- Всего слайдов:74 слайда
- Для класса:1,2,3,4,5,6,7,8,9,10,11
- Размер файла:170.62 kB
- Просмотров:58
- Скачиваний:0
- Автор:неизвестен
Слайды и текст к этой презентации:
№5 слайд
![Variables - Motivation Two](/documents_6/da85ec2d7809bd58b79afcfdb1ea2a35/img4.jpg)
Содержание слайда: Variables - Motivation
Two problems :
The expression 1.5*1.5 –3.14*(1.5/2 )**2
is really difficult to understand :
When you get back to it after one week
When debugging
When the side of the square changes. Should you have an expression per side-length?
Side=1.5 : 1.5*1.5 – 3.14*(1.5/2 )**2
Side=3.7 : 3.7*3.7 – 3.14*(3.7/2 )**2
Side=9 : 9*9 – 3.14*(9/2) )**2
№9 слайд
![Variables Naming conventions](/documents_6/da85ec2d7809bd58b79afcfdb1ea2a35/img8.jpg)
Содержание слайда: Variables – Naming conventions
Use lower case letter
number,apples
Separate multiple words with underscore
word_and_more_words
Use meaningful names for names (don’t be shy to open a dictionary)
z = x/y ???
words_per_page = words_in_book/number_of_pages
Use capitals for constants (variables which do not change their value after first initialization)
PI = 3.14, ERROR_MESSAGE = ‘You had an error’
№11 слайд
![Types int Integer represent](/documents_6/da85ec2d7809bd58b79afcfdb1ea2a35/img10.jpg)
Содержание слайда: Types
int (Integer) : represent an Integer number (מספר שלם).
E.g. 1024, 13, 92,0
float : represent a fractional number.
E.g. : 0.0, 15.62545, 3.14
str (String) : represent text, a list of characters. Defined between a couple of apostrophe or quotes (equivalent).
E.g. ‘hello’, “hello”, ‘13’
№22 слайд
![But what if we do want to mix](/documents_6/da85ec2d7809bd58b79afcfdb1ea2a35/img21.jpg)
Содержание слайда: But what if we do want to mix types?
my_apples = 3
print('I have ' + my_apples + ' apples')
TypeError: Can't convert 'int' object to str implicitly
The error message tells us we have tried to convert an int to a str but we cannot do this implicitly.
So let’s do it explicitly.
№24 слайд
![Converting types int ,float](/documents_6/da85ec2d7809bd58b79afcfdb1ea2a35/img23.jpg)
Содержание слайда: Converting types – int(),float()
Converts string representing numbers to the represented numbers
int('5')5
Cannot convert strings not representing an int :
int('5.5'), int('Hello')
Converts float to int by rounding the number down.
int(5.9)5
Converts string representing numbers to the represented numbers
float('5.5')5.5
Cannot convert strings not representing a float:
float('Hello')
Converts int to float by treating it as a round number.
float(5)5.0
№25 слайд
![User input To make a program](/documents_6/da85ec2d7809bd58b79afcfdb1ea2a35/img24.jpg)
Содержание слайда: User input
To make a program interactive we can ask the user for some inputs and act upon them.
The function input(s) :
Prints to the screen s
Halts the program execution and waits for the user to insert some input and press enter
Return a string representing the user’s input
№39 слайд
![Functions parameters default](/documents_6/da85ec2d7809bd58b79afcfdb1ea2a35/img38.jpg)
Содержание слайда: Functions’ parameters default value
Sometimes ….
A function has an obvious use case that will be utilized most of the time
You have prepared a good option for the user but don’t want to force her to use it
In such cases, you can define a default value to the function’s parameters. A value that will be used if no other value is specified.
№40 слайд
![Functions parameters default](/documents_6/da85ec2d7809bd58b79afcfdb1ea2a35/img39.jpg)
Содержание слайда: Functions’ parameters default value
def shoresh(number, root=2):
print(number ** (1/root))
The first parameter, number, has no default value. Hence every call to the function must indicate its value.
The second parameter, root, has a default value. Hence if we don’t indicate its value it will get the default declared value, 2.
№41 слайд
![Functions parameters default](/documents_6/da85ec2d7809bd58b79afcfdb1ea2a35/img40.jpg)
Содержание слайда: Functions’ parameters default value
def shoresh(number, root=2):
print(number ** (1/root))
shoresh(64) # Here we didn’t indicate the second variable, hence the default value was used
>> 8
shoresh(64, 3) # Here we indicated the second variable, hence its value was used and not the default
>> 4
№45 слайд
![Function calling a function](/documents_6/da85ec2d7809bd58b79afcfdb1ea2a35/img44.jpg)
Содержание слайда: Function calling a function
We can use the return value of one function as another function’s input.
def per_week(per_day=1):
return per_day * 7
def per_year(how_many_per_week):
return how_many_per_week * 52
print('Apples per year : ' + str(per_year(per_week())))
What happens here?
№46 слайд
![Function calling a function](/documents_6/da85ec2d7809bd58b79afcfdb1ea2a35/img45.jpg)
Содержание слайда: Function calling a function
def per_week(per_day=1):
return per_day * 7 # return 7
def per_year(how_many_per_week):
return how_many_per_week * 52
print('Apples per year : ' + str(per_year(per_week())))
per_week()is called with no value and so gets the default value, 1, hence its return value is 7.
№47 слайд
![Function calling a function](/documents_6/da85ec2d7809bd58b79afcfdb1ea2a35/img46.jpg)
Содержание слайда: Function calling a function
def per_week(per_day=1):
return per_day * 7 # return 7
def per_year(how_many_per_week):
return how_many_per_week * 52 # return 364
print('Apples per year : ' + str(per_year(7)))
per_year()is called with the value 7 and so returns the value 364
№48 слайд
![Function calling a function](/documents_6/da85ec2d7809bd58b79afcfdb1ea2a35/img47.jpg)
Содержание слайда: Function calling a function
We can use the return value of one function as another function’s input.
def per_week(per_day =1):
return per_day * 7 # return 7
def per_year(how_many_per_week):
return how_many_per_week * 52 # return 364
print('Apples per year : ' + str(per_year(7)))
>>> Apples per year : 364
№53 слайд
![Boolean expressions Boolean](/documents_6/da85ec2d7809bd58b79afcfdb1ea2a35/img52.jpg)
Содержание слайда: Boolean expressions
Boolean expressions are expressions which use Boolean operators to evaluate a value of True or False.
For example > is a Boolean operator. Its Boolean evaluation is “Is the object on the right larger than the object on the left?”
5 > 7 is a Boolean expression because it uses a Boolean operator. Its value is False.
№57 слайд
![Complex Boolean operators](/documents_6/da85ec2d7809bd58b79afcfdb1ea2a35/img56.jpg)
Содержание слайда: Complex Boolean operators
Take few Boolean operators and evaluate a new Boolean value from them.
and and or evaluate 2 Boolean expressions
not evaluates 1 Boolean expression
The return value of complex Boolean operators could be represented in a Truth table – a table that lists al the combination of truth value of input variables and their evaluated output
№59 слайд
![Conditional operation We do](/documents_6/da85ec2d7809bd58b79afcfdb1ea2a35/img58.jpg)
Содержание слайда: Conditional operation
We do not always want to execute all the lines in our code. Sometimes we want to execute some lines only if a certain condition is maintained.
For example : Divide 9 by user’s input.
We get the number from the user.
Only if the number is different than 0, we can divide 9 by it.
№62 слайд
![Conditional operation - if](/documents_6/da85ec2d7809bd58b79afcfdb1ea2a35/img61.jpg)
Содержание слайда: Conditional operation - if
num = float(input('Insert a number'))
if num != 0 :
print(9/num)
if num == 0 :
print('Cannot divide by 0')
This is not a natural way to present our intention. What we would usually say is : if the number is different than 0 divide, else print some message to the user.
Python lets us use such structure using the else keyword.
№65 слайд
![Conditional operation - elif](/documents_6/da85ec2d7809bd58b79afcfdb1ea2a35/img64.jpg)
Содержание слайда: Conditional operation - elif
if now == 'Morning':
print('Good morning!')
elif now == 'Noon':
print('Good noon')
else:
print('It must be evening')
The first elif should appear directly under an if block with the same indention.
As many elif’s as you wish can follow.
elif can be terminated by a single else, or not at all.
№70 слайд
![Example Calculate the](/documents_6/da85ec2d7809bd58b79afcfdb1ea2a35/img69.jpg)
Содержание слайда: Example
Calculate the circumference (היקף) of a circle or square according to user request.
Let’s break the problem into parts :
1. Get user input
2. Validate if is it either a circle or a rectangle
If it is not print an error message and do not continue
3(a). If it is a circle
Ask for the radius, calculate circumference
3 (b). If it is a square
Ask for the side’s length, calculate circumference
4. Report to user the calculated result
№71 слайд
![Example break it up into](/documents_6/da85ec2d7809bd58b79afcfdb1ea2a35/img70.jpg)
Содержание слайда: Example – break it up into functions
calculate_circle_ circumference()
calculate_rectangle_ circumference()
is_valid_shape_choice(choice)
get_user_input()
calculater_user_choice_circumference()
error_safe_circumference()
Then call the function to run the program:
error_safe_circumference()
Скачать все slide презентации Basic programming одним архивом:
Похожие презентации
-
Machine-Level Programming I: Basics
-
High and low level programming languages. Basics of programming languages
-
Алгоритмическая структура ветвление на языке Visual Basic
-
Логические переменные в Visual Basic
-
Программирование. Оператор Mod в Visual Basic
-
Строковые функции в Visual Basic
-
Языки программирования QBasic и Turbo Pascal 7. 0
-
Графические возможности языка Visual Basic
-
Язык программирования Qbasic
-
Решение задач. Basic