Что такое findslide.org?

FindSlide.org - это сайт презентаций, докладов, шаблонов в формате PowerPoint.


Для правообладателей

Обратная связь

Email: Нажмите что бы посмотреть 

Яндекс.Метрика

Презентация на тему Simple data manipulation

Compute the arithmetic expressionTask : Python can be used to calculate the arithmetic expression. For example, the position of an object falling from sky currently at velocity 5 m/s after 0.6 seconds. The distance can be
Simple data manipulation Compute the arithmetic expressionTask : Python can be used to calculate the Naming data variables Naming data variablesRules for variable names:The name must begin with a letterThe Naming data variables Adding commentsWhatever instructions we give to the computer, it would be more Printing formatIn the previous slide the output was shown on the screen Printing formatv0 = 5   # initial velocityg = 9.81 Aside :  How to save your work, and continue from a Printing format (cont’d.)Here is a list of some import print format specifications: Type conversiontype(object) can return the type of an object. The data type
Слайды презентации

Слайд 2 Compute the arithmetic expression
Task : Python can be

Compute the arithmetic expressionTask : Python can be used to calculate

used to calculate the arithmetic expression. For example, the

position of an object falling from sky currently at velocity 5 m/s after 0.6 seconds. The distance can be calculated from the equation, y(t) = v0t-0.5gt2.
It can be computed directly in Python:
Step 1: type 0.5*0.6 - 0.5*9.81*0.6**2
Step 2: hit enter and then, the answer will be displayed below
In Python, the four standard arithmetic operator are written as +, -, * and /. The exponentiation employs a double asterisk notation, e.g. 0.62 = 0.6**2.





Слайд 3 Naming data variables

Naming data variables

Слайд 4 Naming data variables
Rules for variable names:
The name must

Naming data variablesRules for variable names:The name must begin with a

begin with a letter
The name can contain only letters,

numbers, and the underscore character. No punctuation marks, spaces, or other special characters are allowed in the name.
The name cannot be a keyword in Python, e.g. if, for, print, float, while.
Names in Python are case sensitive.






Слайд 5 Naming data variables

Naming data variables

Слайд 6 Adding comments
Whatever instructions we give to the computer,

Adding commentsWhatever instructions we give to the computer, it would be

it would be more informative to provide some comments

in a natural human language to explain the idea behind the statements. This helps the programmer to recall the details of the code later in time, or other programmers to understand her work. Comments start with # character, and everything after this character on a line is ignored when the program is run.


# Program for computing the height of a ball in vertical motion
v0 = 5 # initial velocity
g = 9.81 # acceleration of gravity
t = 6 # time

y = v0*t - 0.5*g*t**2 # vertical position

print y


Слайд 7 Printing format
In the previous slide the output was

Printing formatIn the previous slide the output was shown on the

shown on the screen with a command print y.

Instead of just printing the numerical values, suppose we now want to write a more informative text, typically some thing like
At t=0.6 s, the height of the ball is 1.23 m.
It can be produced by the statement:
print "At t=%g s, the height of the ball is %.2f m." % (t,y)
The print statement will print everything enclosed in quotes. % in quotes indicates the place to insert the values. g is the format in decimal or scientific notation and .2f format stands for 2 decimal floating-point number.

Слайд 8 Printing format
v0 = 5 # initial

Printing formatv0 = 5  # initial velocityg = 9.81 #

velocity
g = 9.81 # acceleration of gravity
t =

6 # time

y = v0*t - 0.5*g*t**2 # vertical position

print "At t=%g s, the height of the ball is %.2f m." % (t,y)

Слайд 9 Aside : How to save your work, and

Aside : How to save your work, and continue from a

continue from a different window
Step 1: From the Python

Shell window, click file > New Window
Step 2: Making your code in the new window created
Step 3: From the new window, click file > save as > choose save as type (*py)
Step 4: From the new window, click run > Run Module or press to run the program
Step 5: Output will be displayed in the main Python Shell window


Слайд 10 Printing format (cont’d.)
Here is a list of some

Printing format (cont’d.)Here is a list of some import print format specifications:

import print format specifications:


  • Имя файла: simple-data-manipulation.pptx
  • Количество просмотров: 110
  • Количество скачиваний: 0
Следующая - Брежнев