UNIT I - Introduction To Python
UNIT I - Introduction To Python
Introduction to Python
Why Programming?
The computer understands 1s and 0s only. To communicate a real-life problem
to the computer, you need to create a speci c type of text, called a source code
or a human readable code, that software can read and then process to the
computer in 1s and 0s
Terms De nition
A sequence of instructions that designate(select) how
Program
to execute a computation(calculation)
Taking a task and writing it down in a programming
Programming language that the computer can understand and
execute
fi
About Python….
Monty python’s flying circus- British Comedy Movie
Why Python?
Python is an open-source, general-purpose and high-level programming language.
- Subtraction * Multiplication
Performs power
/ Division **
calculation
Python Fundamentals: Basic Python Syntax
The Double Equality Sign Reassign Values
Dynamic typing
fl
Python Fundamentals: String indexing
Continuation
Assign a String
Python Fundamentals: String Indexing Elements
Python Fundamentals: String Indexing Elements
Python Fundamentals: String Slicing
Python Fundamentals: String Slicing
Python Fundamentals: String Slicing
Python Fundamentals: String Properties
Python Fundamentals: String Properties
Python Fundamentals: Basic built-in string methods
Writing to the screen
❖ open() returns a le object, and is most commonly used with two arguments:
open( lename, mode).
❖ Example: >>> f = open('work le', ‘w’)
❖ The rst argument is a string containing the lename.
❖ The second argument is another string containing a few characters
describing the way in which the le will be used.
fi
fi
fi
fi
fi
There are three ways of writing values
❖ Expression statements:
❖ Expression statements are used (mostly interactively) to compute and write a value, or
(usually) to call a procedure.
❖ Print() function:
❖ The print function in Python is a function that outputs to your console window
whatever you say you want to print out
❖ Write() method:
❖ he method write() writes a string ‘str’ to the le. There is no return value. Due to
buffering, the string may not actually show up in the le until the ush() or close()
method is called.