Module 1 Types and Expressions

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/33

flashcard set

Earn XP

Description and Tags

Part 1

Last updated 5:34 AM on 6/11/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

34 Terms

1
New cards

Data Types

Refers to the type of data a value representing

2
New cards

Numeric - All Numbers

  • Integers, floating-point numbers, comple numbers

  • Boolean values

3
New cards

Sequences - Ordered Collections

  • lists, tuples, ranges

  • strings (a sequence of characters)

4
New cards

Mappings - Key-Value collections

  • dictionaries

5
New cards

Integeres

Whole numbers of any size

<p>Whole numbers of any size </p><p></p>
6
New cards

Floating-point Numbers (or float)

Any numeric value with decimal point will be read as a float data type

  • precision up to 14 decimals places

<p>Any numeric value with decimal point will be read as a float data type </p><ul><li><p>precision up to 14 decimals places </p></li></ul><p></p>
7
New cards

Float Rounding

Include the value and the number of decimal places you wish to round

<p>Include the value and the number of decimal places you wish to round</p>
8
New cards

Banker’s Rounding or Round Half-to-Even

When you use the function to round to the nearest integer, it will always prefer the closes even integer

9
New cards

Complex

Numbers with a real and an imaginary part

  • “j” as the imaginary unit

<p>Numbers with a real and an imaginary part </p><ul><li><p>“j” as the imaginary unit </p></li></ul><p></p>
10
New cards

Boolean

This data type represents two values: True or False

  • numeric

11
New cards

Strings

Considered a sequence, since a sequence of none, one, or more characters.

  • represented by encolosing the value in single or double quotes.

12
New cards

Functions - len()

Return the number of charater; the length of the string

13
New cards

Function - replace()

Replaces part of the string with another string

14
New cards

Function - lower() & upper()

Changes the string to either allow all lower case or upper case

15
New cards

Function - isnumeric()

Checks if the string is a number

16
New cards

Function - split()

Useful function for splitting a string into separate parts

17
New cards
<p><em>View of All Functions </em></p>

View of All Functions

18
New cards

Type

Type “type“ inside the parentheses to define any value. In return the funciton will give the data type of that value.

<p>Type “type“ inside the parentheses to define any value. In return the funciton will give the data type of that value. </p>
19
New cards

int()

This function converts any value you define in between the parentheses into an integer type.

20
New cards

float()

This function converts any value you define in between the parentheses into a float type.

21
New cards

str()

This function converts any value you define in between the parentheses into a string type.

22
New cards

String Formatting

The process of buildin a larger string value by combining or “glueing” strings and other values.

23
New cards

Concatenation

the operation of “gluing“ string values together

  • “+”

  • if you have a numeric type value it will perform addition

  • cannot perform concatenation with a numeric value

24
New cards

f-string

Allows you to embed variables or expressions directly inside a string

  • add the letter “f'“ as prefix

  • any non string {}

25
New cards

f-string w/ Rounding and Fixing

  • add a colon : after the float value you want to round

  • add a period . followed by the number that will represent the decimal place you want to round

  • add “f” to make it fixed

<ul><li><p>add a colon : after the float value you want to round </p></li><li><p>add a period . followed by the number that will represent the decimal place you want to round </p></li><li><p>add “f” to make it fixed</p></li></ul><p></p>
26
New cards

Escape Sequences

A special type of character that we can use to represent characters or formatting into a string

  • “\”

27
New cards

Formatting Characters - Escape Sequences

\b: - backspace

\t: tab(indentation)

\n: new line

<p>\b: - backspace</p><p>\t: tab(indentation) </p><p>\n: new line </p>
28
New cards

Escape Sequences - Characters

\”: double-quote

\’: single-quote

\\: backslash

<p>\”: double-quote </p><p>\’: single-quote </p><p>\\: backslash </p>
29
New cards

Expressions

A combination of values, variables, and operators that your computer will calculate and evaluate into a value.

30
New cards

Literals

These are the simplest of expressions since they do not need evaluation since they are the values themselves.

31
New cards

Operators

Wheneber you use any sort of operators like mathematical operators, Python must resolve the value before is able to perform any other task.

32
New cards

Function Calls

Some function calls are expressions. Whenever you use a funciton, the computer must evluate the value it returns.

33
New cards

Comparion Operators

  • in

  • not in

  • is

  • is not

<ul><li><p>in </p></li><li><p>not in </p></li><li><p>is </p></li><li><p>is not </p></li></ul><p></p>
34
New cards

Logical Operators

  • not

  • and

  • or

<ul><li><p>not </p></li><li><p>and </p></li><li><p>or </p></li></ul><p></p>