Class Notes
Class Notes
This is to certify that the work incorporated in this diploma entitled, “Quiz
Compition”, diploma of COMMUNICATION AND COMPUTER
NETWORKING, embodies original work carried-out by the student. We, further
certify that this work has not been submitted to any other University or Institution
in part or full for the award of any degree or diploma. material(s) obtained from
other source(s) and used in this work has/have been duly acknowledged in the
Report. Image(s), illustration(s), figure(s), table(s) etc., used in the report from
other source(s), have also been duly cited and acknowledged.
(Signature of H.O.D)
Name with date
Acknowledgement
I would like to express my sincere gratitude to all these individuals for mentoring
and supporting me in completing this project quiz compition. My project
supervisor Er.Manoj kumar , for providing me with invaluable insights and
direction.
Our esteemed principal Er.Y.k.Goel for fostering an environment of learning and
creativity within our school.
To my parents, their constant encouragement, patience, and understanding have
been the pillars of my success.
I am grateful to my friends who contributed ideas and perspectives that enriched
the project.
Thank you everyone for shaping this project and enhancing my learning
experience.
CONTENT
1. Introduction
2. Why to use python
3. Features of python
4. Control structures in python
5. Comments
6. Variables
7. Keywords
8. Data type
9. Loops
10. Coding in python
11. Output
INTRODUCTION
Python is a widely used general-purpose, high level programming language. It was
initially designed by Guido van Rossum in 1991 and developed by Python
Software Foundation. It was mainly developed for emphasis on code readability,
and its syntax allows programmers to express concepts in fewer lines of code.
Python is a programming language that lets you work quickly and integrate
systems more efficiently.
Why to use Python:
The following are the primary factors to use python in day-to-day life:
1. Python is object-oriented
Structure supports such concepts as polymorphism, operation overloading and
multiple inheritance.
2. Indentation
Indentation is one of the greatest feature in python.
3. It’s free (open source)
Downloading python and installing python is free and easy
4. It’s Powerful
Dynamic typing
Built-in types and tools
Library utilities
Third party utilities (e.g. Numeric, NumPy, sciPy)
Automatic memory management
5. It’s Portable
Python runs virtually every major platform used today
As long as you have a compaitable python interpreter installed, python
programs will run in exactly the same manner, irrespective of platform.
6. It’s easy to use and learn
No intermediate compile
Python Programs are compiled automatically to an intermediate form
called byte code, which the interpreter then reads.
This gives python the development speed of an interpreter without the
performance loss inherent in purely interpreted languages.
Structure and syntax are pretty intuitive and easy to grasp.
7. Interpreted Language
Python is processed at runtime by python Interpreter
8. Interactive Programming Language
Users can interact with the python interpreter directly for writing the programs
9. Straight forward syntax
The formation of python syntax is simple and straight forward which also makes it
popular.
Features of Python
1.Simplicity and Readability Python's syntax is designed to be clean, concise, and
easy to read, making it an accessible language for beginners and experienced
developers alike.
2.Cross-Platform Compatibility Python can run on multiple operating systems,
including Windows, macOS, and Linux, allowing for cross-platform development
and deployment.
3.Extensive Libraries and Frameworks Python has a vast and growing ecosystem
of libraries and frameworks that provide pre-built functionality for a wide range of
tasks, from web development to scientific computing.
4.Dynamic Typing Python is a dynamically typed language, which means that
variables can hold values of different data types without the need for explicit
declarations.
Control Structures in Python
Python provides a range of control structures that allow you to control the flow of
execution in your programs. These include conditional statements (if-elif-else),
loops (for and while), and more advanced constructs like list comprehensions and
generator expressions.
1.If-Elif-Else
The if-elif-else statements allow you to make decisions based on one or more
conditions, and execute different blocks of code accordingly.
2.Loops
Loops, such as for and while loops, allow you to repeatedly execute a block of
code until a certain condition is met, making them useful for iterating over
collections of data or performing repetitive tasks.
3. List Comprehensions
List comprehensions provide a concise and efficient way to create lists by applying
a transformation or filter to each element of an iterable, such as a list or a range.
COMMENTS
Comments are important parts of code they help you and others understand what
your code is doing. It’s extremely helpful when you start writing functions and
need help understanding the connections in your code. To write a comment in
python you use the # symbol at the beginning of the line. In python the line will
turn green and you’ll be able to type anything you want after.
If you want more than one line of code commented out you can use “”” ….
“”” three quotation marks at the start and end to have a set of lines commented
fully out.
>>> # This would be a comment line if you were coding right now
Variables
Variables are placeholders of information in the memory. It’s used in sort of the
same way as in algebra
>>> A = 12
>>> 10 + A = 22
>>> Height = 20
To use the variable you can substitute it into any of the calculations from
earlier.
>>> 12 + height = 32
When creating variables it’s good practice to name the variable so it reflects the
purpose of the variable. Programmers also tend to use camel case or underscores
to denote different words so a variable called grosspay would look
like gross_pay or grossPay .:
Variables can hold a lot more than just numbers. In programming variables can
hold a multitude of information including (strings, numbers, data frames,
Booleans, floats, lists)
# Create a variable and display it
First_name = “James”
last_name = “Smith”
Print(first_Name, last_Name)
KEYWORDS
Keywords are predefined, reserved words used in Python programming that have
special meanings to the compiler.
Here is a list of the Python keywords. Enter any keyword to get more help.
as elif in try
1. Integers (int): These are whole numbers, such as -5, 0, 42, etc.
4. Booleans (bool): Booleans represent truth values, either True or False, and
are often used in conditional statements and logical operations.
5. Lists (list): Lists are ordered collections of items, which can be of any data
type. They are mutable, meaning their elements can be changed after creation,
and are enclosed in square brackets, like [1, 2, 3] or ['a', 'b', 'c'].
6. Tuples (tuple): Tuples are similar to lists but are immutable, meaning their
elements cannot be changed after creation. They are enclosed in parentheses,
like (1, 2, 3) or ('a', 'b', 'c').
While loop:-
For loop:-
For loops are used for sequential traversal. For example: traversing
a list or string or array etc. In Python, there is “for in” loop which is similar to for
each loop in other languages.
CODING IN PYTHON