Python - Variables, Data Types, Operations

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

input statement

allows us to get some type of information from our "user" age = input("What is your age?: ")

Statements

an instruction that the python interpreter can execute or run

str

data type that holds a string of characters which can be letters, numbers, punctuation, spaces ect can have single or double quotes

float

decimal numbers

==

equivalent - shows equality has the same value as something else example: 10-2 == 8 a = 5 b = 5 a==b

int

integer which is whole numbers negative and positive

assignment statement

is the variable name along with the value that has been assigned to it. example: today = "Monday"

% Modulus

it returns the remainder in a whole number after dividing the two numbers example: 10%4 This is going to return "2" as there is rem remainder 2 after dividing 10 by 4 15%3 This is going to return "0" as there is no remainder

reassigning a variable

just change the variables value example today = "Monday" today = "Tuesday"

Input

data that has been entered (our code)

multi-line comments

" " " this is a multi-line comment in python" " "

Concatenation

Adding two Strings together using the '+' operator.

object

Basically everything in python is an object, also known as data object or a data value. The basic things that programs are designed to manipulate

Program parts

Input, process, output

expressions

a combo of literals, variables, names, operators, and calls to functions. They need to be evaluated and the result is a value or object

single line comments

begin with a # example: #This is a comment

data type

indicates the type of data that can be stored as a variable value. Three types - Strings, Integers, Floats

!=

not equal to

literal

number or sting that is written directly into a program

value

one of the fundamental things(word or number) that the program manipulates

variables

placeholders that stores information in a program so it can be used later - putting names to values we always use an equal sign to assign a value + 3 things to a variable - name, type, and value example: today = "Monday"

Operators

symbols use to perform mathematical, logical manipulations, or string concatenation * multiply ** exponent / division // truncated division - truncates to the nearest integer % modulus - returns the remainder

output

the results that take place after our program has run, for example, could be a printout on the screen

Operands

the values or variables which the operator has been applied to and is going to be manipulated example: 9 + 2 (9 and 2 are the operands, and + is the operator)

process

when our code is being executed or run


Ensembles d'études connexes

PrepU Chap32: Skin Integrity and Wound Care

View Set

Vocabulary Workshop Level A Unit 14

View Set

Psychology Exam 2 (Chp: 4,6,8,9)

View Set

A&P 106: Chapter 8 - Appendicular Skeleton

View Set

psychology quiz number 4: Prenatal development

View Set

Intermediate Accounting - Chapter 1 Homework

View Set

Chapter 9: Patterns of Inheritance

View Set