Lecture 4: More Variables Operators and Operands Code Execution ..., Schemes and Mind Maps of Web Programming and Technologies

Some more Python operators: Exponentiation. Integer division. Modulus (remainder). Integer division does division and evaluates to the integer quotient ...

Typology: Schemes and Mind Maps

2022/2023

Uploaded on 02/28/2023

dewan
dewan 🇺🇸

4.6

(17)

253 documents

1 / 108

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CSCI 141
Lecture 4:!
More Variables!
Operators and Operands!
Code Execution: Statements and Expressions!
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f
pf60
pf61
pf62
pf63
pf64

Partial preview of the text

Download Lecture 4: More Variables Operators and Operands Code Execution ... and more Schemes and Mind Maps Web Programming and Technologies in PDF only on Docsity!

CSCI 141

Lecture 4:

More Variables

Operators and Operands

Code Execution: Statements and Expressions

Announcements

One small syllabus change:

  1. Previously: drop up to 9 missed poll questions. Now: poll questions are batched by day; drop up to 3 days of missed polls.

Announcements

QOTD

What does the following code print? print ( int (3.91))

Which of the following programs does not print the same thing as the others? a = 14 b = 3 print (a, b) a = 3 b = 14 print ( 14 , 3 ) a = 14 b = a print (a, b) a = 3 b = 14 print ( 14 , a)

A: B:

C: D:

QOTD

Which of the following programs does not print the same thing as the others? a = 14 b = 3 print (a, b) a = 3 b = 14 print ( 14 , 3 ) a = 14 b = a print (a, b) a = 3 b = 14 print ( 14 , a)

A: B:

C: D:

QOTD

Which of the following programs does not print the same thing as the others? a = 14 b = 3 print (a, b) a = 3 b = 14 print ( 14 , 3 ) a = 14 b = a print (a, b) a = 3 b = 14 print ( 14 , a)

A: B:

C: D:

QOTD

Goals

  • Understand how to use variables in assignment statements and elsewhere in place of values
  • Know the rules for naming variables, and the conventions for deciding on good variable names
  • Know how to use the^ sep, and^ end^ keyword arguments with the^ print function.
  • Know the definition and usage of operators and operands
    • Know how to use the following operators: =, +, -, *, **, /, //, %
  • Understand the distinction between a statement and an expression.
  • Understand function calls as expressions that evaluate to their return values.
  • Assigning a value is not stating an equality, like in math: it’s storing a value. A variable’s value can be updated (overwritten) by a new value using the assignment operator. Last time: How to read an assignment statement my_age = 31 my_age = 32 “my_age equals 32” “my_age becomes 32” “my_age gets 32” “the variable my_age takes on the value 32”
  • Assigning a value is not stating an equality, like in math: it’s storing a value. A variable’s value can be updated (overwritten) by a new value using the assignment operator. Last time: How to read an assignment statement my_age = 31 my_age = 32 “my_age equals 32” “my_age becomes 32” “my_age gets 32” “the variable my_age takes on the value 32”
  • Assigning a value is not stating an equality, like in math: it’s storing a value. A variable’s value can be updated (overwritten) by a new value using the assignment operator. Last time: How to read an assignment statement my_age = 31 my_age = 32 “my_age equals 32” “my_age becomes 32” “my_age gets 32” “the variable my_age takes on the value 32”
  • Assigning a value is not stating an equality, like in math: it’s storing a value. A variable’s value can be updated (overwritten) by a new value using the assignment operator. Last time: How to read an assignment statement my_age = 31 my_age = 32 “my_age equals 32” “my_age becomes 32” “my_age gets 32” “the variable my_age takes on the value 32”

Variable Names

Variable Names

How do you use variables?

  1. Decide what value you want to store in the variable 2. Decide on a sensible name
  2. In your program, use the assignment operator to store that value in the variable