Python The Complete Course For Beginners by TELCOMA
Python The Complete Course For Beginners by TELCOMA
TELCOMA
Copyright © TELCOMA. All Rights Reserved
Introduction
Entity Function
Entity Function
Entity Function
Entity Function
•Font Face
•Indentation Width
OptionMENU (Highlighting)
•It Has……
•Custom Highlighting
•Highlighting Theme
•It Has…
•Key set
•It Has…..
•Start up preferences
•It Has…..
•Call tips
•Code context
•Format Paragraph
•Parenmatch
•Rstripextension
IDLE SHELL (Window Menu)
Entity Function
Entity Function
IDLE Display a help file for IDLE detailing the menu options, basic
Help editing and navigation, and other tips.
1 Arithmetic Operators
3 Assignment Operators
4 Logical Operators
5 Bitwise Operators
6 Membership Operators
7 Identity Operators
Arithmetic Operators
Operator Description
% Modulus Divides left hand operand by right hand operand and returns
remainder
Operator Description
> left operand is greater than the value of right operand, then
condition becomes true.
< left operand is less than the value of right operand, then
condition becomes true
Operator Description
Operator Description
not Used to reverse the logical state of its Not (a and b) is false
operand.
Bitwise Operators
Operator Description
Operator Description
Operator Description
Type Examples
int 10,100,-786
float -21.9,-90,15.24
complex 3+4j,3e+26j
Number Type Conversion
Type Function
Function Description
round(x) x rounded
Function Description
Constants Description
Backslash Description
notation
Operator Description
not in Returns true if a character does not exist in the given string
String Formatting Operator
Format conversion
symbol
%c character
%o octal integer
%x hexadecimal integer
%e exponential notation
1. capitalize ()
2. center(width, fillchar)
encode(encoding='UTF-8',errors='strict')
decode(encoding='UTF-8',errors='strict')
Ref:
https://docs.python.org/3/library/codecs.html#standard-encodings
Built In String Method
5. String endswith ()
6.String find
7. isalnum()
8. isalpha()
9. isdigit()
10. islower()
11. isspace()
12.istitle()
13. join(seq).
14. len(string)
15.lstrip()
16. maketrans()
17. max(str)
18. min(str)
22. swapcase()
23. zfill()
List
Length
Concatenation
Repetition
Membership
Iteration
Indexing ,slice & Matrixes
1 .Cmp(list1,list2)
2. len(list)
3.max(list)
4. min(list)
5. list(seq)
1. list.append(obj)
• The method append() appends a
passed obj into the existing list
2. list.count(obj)
3. list.extend(seq)
4. list.index(obj)
5. list.insert(index, obj)
•The method insert() inserts
object obj into list at offset index
6. list.pop(obj=list[-1])
7. list.remove(obj)
8. list.reverse()
9. list.sort([func])
Function
Length
Concatenation
Repetition
Membership
iteration
Indexing, Slicing and
Matrixes
● Because tuples are sequences,
indexing and slicing work the same
way for tuples as they do for strings
Built-in Tuple Function
1. cmp(tuple1, tuple2)
2. len(tuple)
3. max(tuple)
4. min(tuple)
5.tuple(seq)
2. len(dict)
3. str(dict)
4. type(variable)
a) raw_____ input Function
The raw_input([prompt]) function reads
one line from standard input and
returns it as a string.
b) input Function
The input([prompt]) function is equivalent
to raw_input, except that it assumes the
input is a valid Python expression and
returns the evaluated result to you.
Opening and closing Files
Name Parameter
file_name Argument is a string value that contains the name of the file that you want to access
access_mode The access_mode determines the mode in which the file has to be opened, i.e., read, write,
append, etc
buffering If the buffering value is set to 0, no buffering takes place. If the buffering value is 1, line
buffering is performed while accessing a file
Open Function
•Here is a list of the different modes of opening a file
Modes Description Modes Description
r Opens a file for reading only wb Opens a file for writing only in
binary format
rb Opens a file for reading only in w+ Opens a file for both writing and
binary format reading
r+ Opens a file for both reading wb+ Opens a file for both writing and
and writing reading in binary format
rb+ Opens a file for both reading a Opens a file for appending.
and writing in binary format
w Opens a file for writing only ab Opens a file for appending in binary
format
Attribute Description
•Syntax: fileObject.close()
Reading and Writing Files
a) Write() Method
Syntax: fileObject.write(string)
Writing Files
b) read() Method
Syntax:fileObject.read([count])
Reading and Writing Files
b) read() Method
Syntax:fileObject.read([count])
● The seek(offset[,from]) method
changes the current file position.
● The seek(offset[, from]) method
changes the current file position
● Syntax:
os.rename(current_file_name,
new_file_name)
Deleting Files
● Syntax:
os.remove(file_name)
Directories in Python
getcwd() :
Syntax :
•os.getcwd()
Create a dict.
mkdir() :
•The mkdir() method of the os module to
create directories in the current directory.
Syntax :
•os.mkdir("newdir")
Remove a dict.
rmdir() :
Syntax :
•os.rmdir('dirname')
Date & Time
0 0 4-digit year
4-digit year 2008
2008
leap-seconds)
6 Day of Week 0 to 6 (0 is Monday)
6 Day of 0 to 6 (0 is Monday)
7 Day of year 1 to 366 (Julian day)
Week
8 Daylight -1, 0, 1, -1 means library
7 Day of savings
1 to 366determines
(JulianDSTday)
year
0 tm_year 2008
● Tuple is equivalent
to struct_time structure. This
1 tm_mon 1 to 12
attributes ….. 3 tm_hour 0 to 23
4 tm_min 0 to 59
6 tm_wday 0 to 6 (0 is Monday)
1. calendar.isleap(year)
2. calendar.leapdays(y1,y2)
3. calendar.month(year,month)
num = 3
num > 0 is the test expression.
if num > 0:
The body of if is executed only if this
evaluates to True. print(num, "is a positive number")
If num is equal to -5, the test expression is # Try these two variations as well.
false and body of else is executed and
body of if is skipped. # num = -5
# num = 0
If num is equal to 0, the test expression is
true and body of if is executed if num >= 0:
print("Positive or Zero")
and body of else is skipped.
else:
print("Negative number")
If test expression:
If..elif..else Syntax Body of if
Elif test expression:
Body of elif
•The elif is short for else if. It allows us to else :
Body of else
check for multiple expressions.
elif num == 0:
print("Zero")
else:
print("Negative number")
Nested if statements
Step 1:
Step 2: