[PDF] [PDF] COMPSCI 101 Learning Outcomes Installing Python 3

use variables to store values see the link to python where you will be able to download Assign a value to a variable location using (the assignment



Previous PDF Next PDF





[PDF] Python Variable Types - Tutorialspoint

Assigning Values to Variables Python variables do not need explicit declaration to reserve memory space The declaration happens automatically when you assign a value to a variable The equal sign = is used to assign values to variables



[PDF] 1 The Assignment Statement and Types - Cornell CS

equals what is on the right In Python, “=“ prescribes an action, “evaluate the expression on the right and assign its value to the variable named on the left ”



[PDF] Introduction to Python

Python variables do not need explicit declaration to reserve memory space The declaration happens automatically when you assign a value to a variable Multiple 



[PDF] Variables and Data types

Python allows you to assign a single value to several variables simultaneously For example: Here, an integer object is created with the value 1, and all three variables are assigned to the same memory location You can also assign multiple objects to multiple variables



[PDF] 12 STRUCTURE OF A PYTHON PROGRAM - GGPS Chas

Any value is an expression ➢ Statements: Anything that does something is a statement Any assignment to a variable or function call is a statement Any value  



[PDF] 1 Python as a calculator 2 Python types

3 Variables A variable in Python is a name of some value 3 1 Variable assignment Form of an assignment statement: variable = expression How it's executed



[PDF] 4:24 Lecture - Control Flow Python - Squarespace

24 avr 2020 · Name your variable and add a = to assign your variable a value • To Use a while loops function the exact same way in Python as how we



[PDF] Chapter 1: Scalar Variables and Data Types

assigning a value to it 4 Scalar variables Python has two types of scalar values: numbers and strings Both types ca be assigned to a scalar variable >>> 4+5



[PDF] CS303E: Elements of Computers and Programming Assignment

7 déc 2020 · A variable in Python actually holds a pointer to a class object, rather than the object itself CS303E Slideset 2: 3 Simple Python Types in Python



[PDF] COMPSCI 101 Learning Outcomes Installing Python 3

use variables to store values see the link to python where you will be able to download Assign a value to a variable location using (the assignment

[PDF] assigning values to variables in r

[PDF] assigning values to variables in shell script

[PDF] assigning values to variables in spss

[PDF] assignment on mean

[PDF] assignment on measures of central tendency pdf

[PDF] assignment statement in c

[PDF] assistance freebox crystal

[PDF] assistance freebox delta

[PDF] assistance freebox revolution

[PDF] assistive technology keyboard

[PDF] association francophone

[PDF] association hemochromatose paris ile de france

[PDF] association mathusalem paris ile de france

[PDF] association paris ile de france d'attelage

[PDF] assr scholarship canada

COMPSCI 101

Principles of Programming

Lecture 2 - Variables, program execution,

calculations, print()Learning Outcomes

COMPSCI 101 - S1, 2020

Installing Python 3

https://www.cs.auckland.ac.nz/courses/compsci101s1c/resources/A Program is a Sequence of Instructions

COMPSCI 101 - S1, 2020

The Python Interpreter

COMPSCI 101 - S1, 2020

INTERPRETER

IDLE - The program editor used in

COMPSCI 101

COMPSCI 101 - S1, 2020

Programs are Deterministic

COMPSCI 101 - S1, 2020

Storing Information - Variables

COMPSCI 101 - S1, 2020

Variable Names

COMPSCI 101 - S1, 2020

x age age_of_child box1 box_2 _age age_3 age of child age-child 1st 2_box

Variable Naming Conventions

COMPSCI 101 - S1, 2020

name age course user_input age_allowed age_of_child circle_area

Variable Names Should Not Be Key Words

COMPSCI 101 - S1, 2020

and elif import raise as else in return assert except is try break finally lambda while class for nonlocal with continue from not yield def global or del if pass

Style Guide

COMPSCI 101 - S1, 2020

What Kind of Information Can Our

Programs Store?

COMPSCI 101 - S1, 2020

202
0 -32 1.0 -3.405 0.0

3.3333333

Note that the precision

of floating point numbers is limited.

Assigning to a Variable

COMPSCI 101 - S1, 2020

result1 =54 my_age= 21 bank_balance= 2019

The left hand side of the assignment operator is

always a variable.

Doing Calculations

COMPSCI 101 - S1, 2020

result1 = 54 +4 result2 = 15 /5 bank_balance = 2019 *2 solution = 4 ** 3

Expressions

COMPSCI 101 - S1, 2020

result1 = 54 + 4 / 5 result2 = 15 / 5 bank_balance = 2019 * 3 / 100 age = 1 + 2 + 1 + 1 result3 = 7

Expressions

COMPSCI 101 - S1, 2020

result1 = 54 + 4 / 5 result2 = result1/ 10 bank_balance = 2019 * 3 / result2 age = 5 age = age+ 4 age = age * 3

Printing to Standard Output

print(45.67) print(100000) print(44)

COMPSCI 101 - S1, 2020

principal = 100 years = 15 print(43) print(principal) print(2 * years + 1) 43
100
31

Printing a Blank Line

COMPSCI 101 - S1, 2020

principal = 100 years = 15 print(43) print() print(principal) print() print() print(2 * years + 1) 43
100
31

An Example Python Program

COMPSCI 101 - S1, 2020

M = P(1 + i/100)

n principal = 100 years = 15 rate = 10 final_amount = 100

417.7248169415656

Strings - Another Python Built-in Type

COMPSCI 101 - S1, 2020

principal = 100 years = 15 rate = 10 final_amount = principal * (1 + rate /100) ** years print("Initial amount") print(principal) print("Final amount") print(final_amount)

Initial amount

100

Final amount

417.7248169415656

Printing more than one value on a

single line

COMPSCI 101 - S1, 2020

principal = 100 years = 15 rate = 10 final_amount = principal * (1 + rate /100) ** years print("Initial amount", principal) print("Final amount", final_amount)Initial amount 100

Final amount 417.7248169415656

1 Hello World

The final results are: 56 and 44

Printing more than one value on a

single line

COMPSCI 101 - S1, 2020

principal = 100 years = 15 rate = 10 final_amount = principal * (1 + rate / 100) ** years print("Initial amount $", principal, sep = "") print("Final amount $", final_amount, sep = "")

Initial amount $100

Final amount $417.7248169415656

1*Hello*World

The final results are:56and44

Exercise

COMPSCI 101 - S1, 2020

amount_to_convert = 500 nz_to_aus_rate = 0.95 nz_dollars = amount_to_convert

NZ $500 = AUS $475.0

AUS $500 = NZ $526.3157894736842

Summary

COMPSCI 101 - S1, 2020

Examples of Python features

used in this lecture principal = 100 years = 15 rate = 10 final_amount = principal * (1 + rate / 100) ** years years = 15 rate = 0.01 print("Final amount $", final_amount)print()print("Final amount $", final_amount, sep = "")

COMPSCI 101 - S1, 2020

quotesdbs_dbs9.pdfusesText_15