Beruflich Dokumente
Kultur Dokumente
A Course Report
(Course Report for the partial fulfillment in awarding the degree of B.Tech in Computer
Submitted by
SAURAB RAWAT
Submitted to:
August 2019
TABLE OF CONTENTS
This compact modularity has made it particularly popular as a means of adding programmable interfaces
to existing applications. Van Rossum's vision of a small core language with a large standard library and
easily extensible interpreter stemmed from his frustrations with ABC, which espoused the opposite
approach.
ACKNOWLEDGEMENT
I like to express my deep sense of gratitude to my Mentor Dr. Sandesh Tripathi , coordinator of
Department of Computer Science & Engineering, Birla Institute of Applied Sciences, Bhimtal,
Uttarakhand for his guidance, keen interest, constant encouragement and helpful criticism.
His advices were invaluable even when the going got tough during the course of the study embodied in
this project.
My deepest gratitude also goes for our respected Director Sir Dr. B.S. Bisht and
Co-Ordinator of the Department, Dr. Sandesh Tripathi for his valuable advice,
I would like to thank all faculties and staff-members of the Department of Computer
Science & Engineering, BIAS for their help and suggestions for betterment of the project.
I would also like to acknowledge the Dept. of CSE for providing Support, Enthusiasm
and other such lab facilities and the University of Dehradun , for providing infrastructure
development fund.
I would like to thank my friends and colleagues for critically reading the manuscript and
The Language core philosophy is summarized in the document, The Zen of Python (PEP 20) which
includes aphorisms such as....
The software development companies prefer Python language because of its versatile features and fewer
programming codes. Nearly 14% of the programmers use it on the operating systems like UNIX, Linux,
Windows and Mac OS. The programmers of big companies use Python as it has created a mark for itself
in the software development with characteristic features like-Interactive, Interpreted, Modular, Dynamic,
Portable, High level, Extensible in C++ & C.
1. Extensive library support: It provides large standard libraries that include the areas like string
operations, Internet, web service tools, operating system interfaces and protocols.
2. Integration Feature: Python integrates the Enterprise Application Integration that makes it easy to
develop Web services by invoking COM or COBRA components. It has powerful control capabilities as
it calls directly through C, C++ or Java via Python.
3. Improved Programmer’s Productivity: The language has extensive support libraries and clean
object-oriented designs that increase two to tenfold of programmer’s productivity while using the
languages like Java, VB, Perl, C, C++ and C#.
4. Productivity: With its strong process integration features, unit testing framework and enhanced
control capabilities contribute towards the increased speed for most applications and productivity of
applications.
BASIC DATA TYPES IN PYTHON
An introduction to the basic concepts of Python. Learn how to use Python interactively and through a
script. Create your first variables and acquaint yourself with Python's basic data types.
DATA TYPES
Data Type Data types determine whether an object can do something, or whether it just would not make
sense. Other programming languages often determine whether an operation makes sense for an object by
making sure the object can never be stored somewhere where the operation will be performed on the
object (this type system is called static typing). Python does not do that. Instead it stores the type of an
object with the object, and checks when the operation is performed whether that operation makes sense
for that object (this is called dynamic typing). Python has many native data types. Here are the important
ones:
2. Numbers can be integers (1 and 2), floats (1.1 and 1.2), fractions (1/2 and 2/3), or even complex
numbers.
VARIABLES:
Example
x = 5
y = "John"
print(x)
print(y)
A variable can have a short name (like x and y) or a more descriptive name (age, carname, total_volume). Rules for
Python variables:
• String literals may be delimited using either single or double quotes. All the characters between the
opening delimiter and matching closing delimiter are part of the string:
To create a string, put the sequence of characters inside either single quotes, double quotes, or triple quotes and
then assign it to a variable. You can look into how variables work in Python in the Python variables tutorial.
For example, you can assign a character ‘a’ to a variable single_quote_character. Note that the string is a single
character and it is “enclosed” by single quotes.
Next, suppose you need to create a string that contains a tab character in it. Some text editors may allow you to
insert a tab character directly into your code. But many programmers consider that poor practice, for several
reasons:
• The computer can distinguish between a tab character and a sequence of space characters, but you can’t. To
a human reading the code, tab and space characters are visually indistinguishable.
• Some text editors are configured to automatically eliminate tab characters by expanding them to the
appropriate number of spaces.
• Some Python REPL environments will not insert tabs into code.
In Python (and almost all other common computer languages), a tab character can be specified by the escape
sequence \t:
PYTHON
>>> print('foo\tbar')
foo bar
The escape sequence \t causes the t character to lose its usual meaning, that of a literal t. Instead, the combination is
interpreted as a tab character.
Built-In Functions:-
The Python interpreter supports many functions that are built-in: sixty-eight, as of Python 3.6. You will cover many
of these in the following discussions, as they come up in context.
For now, a brief overview follows, just to give a feel for what is available. See the Python documentation on built-
in functions for more detail. Many of the following descriptions refer to topics and concepts that will be discussed
in future tutorials.
Math
Function Description
Type Conversion
Function Description
List is an ordered sequence of items. It is one of the most used datatype in Python and is very flexible. All the items
in a list do not need to be of the same type.
Declaring a list is pretty straight forward. Items separated by commas are enclosed within brackets [ ].
We can use the slicing operator [ ] to extract an item or a range of items from a list. Index starts form 0 in Python.
a = [5,10,15,20,25,30,35,40]
# a[2] = 15
1. >>> a = [1,2,3]
2. >>> a[2]=4
3. >>> a
4. [1, 2, 4]
Python Tuple
Tuple is an ordered sequence of items same as list.The only difference is that tuples are immutable. Tuples once
created cannot be modified.
Tuples are used to write-protect data and are usually faster than list as it cannot change dynamically.
We can use the slicing operator [] to extract items but we cannot change its value.
Python Dictionary
It is generally used when we have a huge amount of data. Dictionaries are optimized for retrieving data. We must
know the key to retrieve the value.
In Python, dictionaries are defined within braces {} with each item being a pair in the form key:value. Key and
value can be of any type.
1. >>> d = {1:'value','key':2}
2. >>> type(d)
3. <class 'dict'>
1. >>> float(5)
2. 5.0
* Conversion from float to int will truncate the value (make it closer to zero).
1. >>> int(10.6)
2. 10
3. >>> int(-10.6)
4. -10
1. >>> float('2.5')
2. 2.5
3. >>> str(25)
4. '25'
5. >>> int('1p')
6. Traceback (most recent call last):
7. File "<string>", line 301, in runcode
8. File "<interactive input>", line 1, in <module>
9. ValueError: invalid literal for int() with base 10: '1p'
1. >>> set([1,2,3])
2. {1, 2, 3}
3. >>> tuple({5,6,7})
4. (5, 6, 7)
5. >>> list('hello')
6. ['h', 'e', 'l', 'l', 'o']
1. >>> dict([[1,2],[3,4]])
2. {1: 2, 3: 4}
3. >>> dict([(3,26),(4,44)])
4. {3: 26, 4: 44}
Booleans, True or False in Python
Boolean values are the two constant objects False and True.
They are used to represent truth values (other values can also be considered false or true).
In numeric contexts (for example, when used as the argument to an arithmetic operator), they behave like the
integers 0 and 1, respectively.
The built-in function bool() can be used to cast any value to a Boolean, if the value can be interpreted as a truth
value They are written as False and True, respectively.
Boolean Strings
A string in Python can be tested for truth value.
Let’s make an example, by first create a new variable and give it a value.
To see what the return value (True or False) will be, simply print it out.
Frozen Sets Frozen sets are immutable objects that only support methods and operators that produce a result
without affecting the frozen set or sets to which they are applied.
I/P
normal_set = set(["a", "b","c"])
normal_set.add("d")
print("Normal Set")
print(normal_set)
frozen_set = frozenset(["e", "f", "g"])
print("Frozen Set")
print(frozen_set)
O/P
Normal Set
set(['a', 'c', 'b', 'd'])
Frozen Set
frozenset(['e', 'g', 'f'])
2. union(s) Method: Returns a union of two set.Using the ‘|’ operator between 2 sets is the same as writing
set1.union(set2)
3. intersect(s) Method: Returns an intersection of two sets. The ‘&’ operator comes can also be used in this case.
victims = people.intersection(vampires)
Python Statement and Indentation
Instructions that a Python interpreter can execute are called statements. For example, a = 1 is an assignment
statement. if statement, for statement, while statement etc. are other kinds of statements.
Python Indentation
Most of the programming languages like C, C++, Java use braces { } to define a block of code. Python uses
indentation.
A code block (body of a function, loop etc.) starts with indentation and ends with the first unindented line. The
amount of indentation is up to you, but it must be consistent throughout that block.
Generally four whitespaces are used for indentation and is preferred over tabs. Here is an example.
1. for i in range(1,11):
2. print(i)
3. if i == 5:
4. Break
The enforcement of indentation in Python makes the code look neat and clean. This results into Python programs
that look similar and consistent.
Indentation can be ignored in line continuation. But it's a good idea to always indent. It makes the code more
readable. For example:
1. if True:
2. print('Hello')
3. a = 5
and
1. if True: print('Hello'); a = 5
both are valid and do the same thing. But the former style is clearer.
Python Comments
Comments are very important while writing a program. It describes what's going on inside a program so that a
person looking at the source code does not have a hard time figuring it out. You might forget the key details of the
program you just wrote in a month's time. So taking time to explain these concepts in form of comments is always
fruitful.
It extends up to the newline character. Comments are for programmers for better understanding of a program.
Python Interpreter ignores comment.
1. #This is a comment
2. #print out Hello
3. print('Hello')
CONCLUSION
The course was Python 3 for Begginers. The video lectures of the course contained a native approach to the
topics they covered. They explained the theoretical portion of the course using living/daily examples
whereas the portion related to programming concepts was covered using Pycharm or Jupyter notebook
itself and hence showing the procedural way of writing and executing the code snippet.
The course covers all the concept of Python, from beginner to intermediate level. The concept regarding
the algorithms, list, searching, sorting, array vs lists was very precisely covered.
As we kept on moving the course becomes slightly difficult and confusing because of the introduction to
complex analysis and asymptotic notation using data structure.
The course was introduced for the basis of programming concepts in Python Language. The course
contains videos lectures of python in which almost all of the key concept of Basic Python Programming is
explained.
The instructor has put all his efforts to make himself clear. The topics covered by him are “About Python”.
It’s advantages, variables, python list, bytes, tuple, sequential datatype, code introspection etc.
After coding the programs with static memory allocation we move onto the concept of dynamic memory
allocation using linked list. The concept of linked list is a little confusing to understand. And then we
finally move on to the concept of data file handling which gives you a basic approach to statements in
python. The course was covered with a highly appreciable approach.
REFRENCES
➢ https://www.w3schools.com
➢ https://github.com/karan/Projects
➢ https://wiki.python.org/moin/CodingProjectIdeas
➢ https://en.wikipedia.org
➢ https://www.tutorialspoint.com
➢ https://www.google.com