Python Fundamentals Flashcards
Python Features?
Easy to code
High level language
Case sensitive
OOPS
Portable
Interpreted language
Python uses?
AI, Data science, Deep learning, machine learning
IDLE?
Integrated development learning environment
Name some offline code editors
Jupyter, Spyder, Pycharm, VS code
Name some online code editors
Google collab, Github, W3 schools, geek for geeks
IDLE modes?
Interactive mode (Difficult to edit) → python shell
Script mode (Difficult to save) → file
Python character sets?
Set of valid characters a language can recognize
-+)%$awfa etc
Tokens/ Lexical units?
Smallest individual unit in a program
Tokens types?
Keywords, literals, operators, identifiers, punctuators
Keywords?
convey special meaning, reserved for special purpose. Cant be used as variables. There are 33 such keywords
if else elif etc
Identifiers?
Fundamental building blocks of python. User defined.
Identifier rules?
Cant contain special characters except ‘_’
Cant use keyword as identifier
First character must be letter( _ counts)
No space in between
Literals?
Data items having fixed value
Types of literals?
String literals
Numeric literals
Boolean literals
Special case ‘none’
Literal collections
Operators?
Tokens that trigger →computation
when applied to variables.
Operands?
Variables to which computation is applied
Operator Classifications?
→Unary operator (require 1 operand)
→Binary operator (require 2 operand)
Operator types?
→arithmetic(+,-/,*,//,%,**)→comparision(>,<)
→assignment(=, +=)
→logical(and, or, not)
→membership(in,notin)
→identity ( is, is not)
Punctuators?
Symbols used to organize sentences structures and indicate rhythm
@$!<>, ; etc
What are datatypes?
Type of data given to a variable
1)Numerical (int, float, complex)
2)Boolean (True & false)
3)Sequential (strings)
4)Collection(list, tuples)
Dictionaries (dict.)?
a=3
print (type(a))
o/p: class <int></int>
Strings?
Quotation enclosed sequence of characters.
“a’, “xyz”, ‘abc’
How to access character in string?(Indexing)
Indexing:
Hello world
01234 5 678910
str1= “Hello world”
print (str1[10])
o/p → d
Indexing specific characters or skipping?
Hello world
01234 5 678910
str1= ‘Hello world”
[Start→Includes index Stop→ Doesn’t include index
Step→ Skipping characters]
Mutability?
Data types which can change value in a statement Ex: Lists, dictionaries
Immutability?
Data types which cannot change value in a statement Ex: Strings, tuples
what are Lists?
Collection of different types of elements within square brackets. They are mutable
L= [‘1’, ‘2”, (“a”,”b”)]
what are tuples?
Collection of different types of data within curved brackets. They are immutable
Dictionaries?
Collection of key value pair elements within flower brackets They are mutable
Dictionary syntax?
D= {<key1>: <value1>,<key2>:<value2>}
D= {'a':1, 'b':2, 'c':3}
print (D['b']) #2</value2></key2></value1></key1>
What is type casting?
Conversion of types of data either forcefully or automatically
→Implicit (Automatic)
a=2 ,b=3.4, c= a +b
print (type(c)) #float
→Explicit (Forced)
a=2
print (type(a)) #int
a= float(a)
print (a) #2.0