Programming 2 Flashcards
get better at python
can you combine strings and numbers in python ?
you cant do it directly unless u add str before the number
eg : (“yoyo” + str(123))
Where should normal arguements be placed ?
Normal arguements should be placed before variable arguements , ALWAYS
What is the special case called where you add another statement apart from “if” and “else” statements
“elif” statements are used , these statements allow us to add more than one condition
Collection
grouping multiple items tgt and storing them in a single name (variable)
List
groups pieces of data tgt in a certain order and assigns the collection a name
Should you add comma at the end of a list/array ?
Yes
Mutable & Immutable values
- mutable = values that can be changed after their created
- immutable = values that cant be changed once created
Iteration
repeats the same procedure multiple times until it ends
- loop is a code that iterates
Module
Python file that contains code, like variable or functions
Python Libraries
- machine learning tasks
* TensorFlow
* pandas - Math stuff
* Numpy
* Scipy
Python Frameworks
used for web development management
- Django
- Flask
Concatenate
combine multiple strings into one string
Slicing
getting part of a string value
string[start:end]
String methods
(making changes/finding strings etc)
newstringname.stringname.methodname()
- the new string name is the new name u give the string
- the stringname is the string that u want to add the function or wtv to
- the “.” is used to tell python that a method/change is coming next
- method name is what u wanna do to the string
- always end with ()
Regular Expression
aka Regex
Allows you to create a description of a pttern that you want to match
6 ways to make a description of patterns you want using regular expressions
- /content\ : enclose in slashes for specific content
- \d : indicates digits that your looking for
- \w : indicates words that your looking for
- . : indicates any character
- : to indicate 1 or more occurences of the preceding pattern
- : indicates zero or more occurences of the preceding pattern*
- ? : indicates zero or one occurences of the preceding pattern
Class
describes the type of attributes and behaviours an object can have
Memory Management
code that decides what kept in memory and whats not
alternatively u can use garbage collection - automated memory management process which clears unnecessary items
Algorithm
set of instructions that are used to describe the exact result
Memory Allocation types
- Static : compile time, before the execution of the program
- Dynamic : runtime happens during executin of the program
Deallocation
disposes of memory when its no longer useful
Manual Memory Management and Automatic Memory Management
- MMM - developers have to write code to allocate and deallocate memory
- AMM - allocating and deallocating of memory is done automatically by the program
Stack, Stack overflow, Call stack
variables created by other functions are stored by stacks, when functions call other functions , it stores memory temporarily by creating new stack record
stacks hv max no of records, record hv a max limit
- Stack : special data type that follows last in first out principle
- Stack overflow : when the data exceeds the max limit of records
- Call stack : order of the functions
Interpreters and Compilers
- Interpreters - translate line by line and execute instructions
- Compilers - take the whole file and turn it into machine code