demo IT Report
demo IT Report
demo IT Report
&
Python Programming
A
Industrial/Field Project Report
submitted
in partial fulfilment
for the award of the degree of
Bachelor of Technology
in department of Computer Science
with specialization in Computer Science
Submitted To : Submitted By :
Dr. Pratap Singh Patwal, ANKIT YADAV
HOD, CSE Roll no:21ELDCS060
LIET-Alwar
We would like to first of all express our thanks to Dr. Rajesh Bhardwaj , Group Director of
LIET , for providing us such a great infrastructure and environment for our overall
development.
We express sincere thanks to Principal Dr. Manvijay Singh and Dr. Dwarka Prasad, the Vice
Principal of LIET, for his kind cooperation and extensible support toward the completion of
our seminar .
Words are inadequate in offering our thanks to Dr. Pratap Singh Patwal , HOD of CSE
Department , for consistent encouragement and support for shaping our seminar in the
presentable form. Also, for his support in providing technical requirement and fulfilling our
various other requirement for making our seminar success.
We would like to thanks our project co-ordinator Mr. Nitin Gandhi (Web Development) and
Mr. Deepak Yadav (Python Programming) , Asst. Prof. CSE Department for there support
and guiding us to make seminar successful. Without there support and measurement we
would not able to accomplished our goal.
We also like to express our thanks to all supporting CSE faculty members who have been a
constant source of encouragement for successful competition of the project.
Also our warm thanks to Laxmi Devi Institute Of Engineering And Technology , who provide
us this opportunity to carry out this prestigious seminar and enhance our learning in various
technical fields.
Ankit Yadav
(21ELDCS060)
1
Candidate’s Declaration
I hereby declare that the Industrial/Field Project, which is being intern in the field, entitled
“Web development & Python Programming” in partial fulfilment for the award of Degree
of “Bachelor of Technology” in Department of Computer Science & Engineering with
Specialization in Computer Science Engineering , and submitted to the Department of
Computer Science & Engineering, Laxmi Devi Institute of Engineering & Technology, Alwar,
Bikaner Technical University is a record of my own Learning and internship carried under the
Guidance of Dr. Pratap Singh Patwal , HOD(CSE) : Laxmi Devi institute of Engineering &
Technology, Alwar.
I have not submitted the matter presented in this field work report anywhere for the award
of any other Degree.
Counter Signed by
Guide Name: DR. Pratap Singh Patwal
Designation: HOD
Department: Computer Science & Engineering Department
Laxmi Devi Institute of Engineering & Technology, Alwar
2
INDEX
Python Programming
Introduction
1.1 Python…………………………………………………………………………………………………….………….…6
1.2 Scripting Language……………………………………………………………………………………….…….6-7
1.3 Object Oriented Programming………………………………………………………………………….7-11
1.4 History of Python……………………………………………………………………………………………11-12
3.5 Dictionary……………………………………………………………………………………………………………20
3.6 Boolean………………………………………………………………………………………….……………………20
3.7 Sets……………………………………………………………………………………………………………………..20
3.8 Iteration………………………………………………………………………………………………………………20
3.9 Conditional Statements………………………………………………………………………….………20-23
3.10 Function…………………………………………………………………………………………………………24-25
3
Uses & Scope Of Python
6.1 What we can do with python ?..............................................................................26
6.2 Who uses Python today?..................................................................................26-27
6.3 Why Do people use Python?.................................................................................27
Web Development
HTML
1.1 What is HTML? ………………………………………………………………………………….………………29
1.2 Features of HTML Editor……………………………………………………………..……….………………29
1.3 HTML Skeleton…………………………………………………………………………….……..….………30-31
1.4 HTML Comments………………………………………………………………………….….…………………31
1.5 HTML Elements …………………………………………………………………………….…………..……31-32
1.5.1 Block level………………………………………………………………………………………………………….31-32
1.5.2 Inline Level………………………………………………………………………………………………………………32
1.6 Basic Tags……………………………………………………………………………………………………….33-37
1.6.1 Empty Tags…………………………………………………………………………………………………………33-36
1.6.2 Attributes……………………………………………………………………………………………………………….37
4
2.3 Position Properties……………………………………………………………………………..…………….………41-43
2.3.1 Static…………………………………………………………………………………………………….………………….….…….41
2.3.1 Relative……………………………………………………………………………………………………………………..….41-42
2.3.3 Absolute…………………………………………………………………………………………..………………………………..42
2.3.4 Fixed……………………………………………………………………………………………………..……………………………42
2.3.5 Sticky …………………………………………………………………………………………………….…………………………..42
2.4 Flexbox……………………………………………………………………………………………………….…………….43-45
2.4.1 Why Flexbox ? …………………………………………………………………………………………………………………..43
2.4.1 The Flex Model……………………………………………………………………………………………………………43-44
2.4.3 Direction…………………………………………………………………………………………………………….………….....44
2.4.4 Wrapping……………………………………………………………………………………………………………….………….44
2.4.5 Flex-Flow shorthand …………………………………………………………………………………………..……………..45
2.4.6 Ordering flex items…………………………………………………………………………………………………………….45
2.5 Grid Layout……………………………………………………………………………………………………………….46-47
2.5.1 What Is Grid Layout? …………………………………………………………………………………………………………46
2.5.2 Defining A Grid…………………………………………………………………………………………………………………..46
2.5.3 Gaps Between tracks………………………………………………………………………………………………………….46
2.5.4 Repeating Track Listings…………………………………………………………………………………………….….46-47
2.5.5 Line Base Placement…………………………………………………………………………………………………………..47
5
Introduction
1.1 Python
Python is a high-level, general-purpose and a very popular programming language.
Python programming language (latest Python 3) is being used in web development,
Machine Learning applications, along with all cutting-edge technology in Software
Industry. Python Programming Language is very well suited for Beginners, also for
experienced programmers with other programming languages like C++ and Java.
This specially designed Python tutorial will help you learn Python Programming
Language in most efficient way, with the topics from basics to advanced (like Web-
scraping, Django, Deep-Learning, etc.) with examples.
Machine Learning
GUI Applications (like Kivy, Tkinter, PyQt etc. )
Web frameworks like Django (used by YouTube, Instagram, Dropbox)
Image processing (like OpenCV, Pillow)
Web scraping (like Scrapy, BeautifulSoup, Selenium)
Test frameworks
Multimedia
Scientific computing
Text processing and many more..
6
Easy entry: Python has a very simple and enjoyable syntax which makes it
relatively easy to learn compared to most other languages. Also there are vast free
resources to learn Python anytime anywhere.
Rich libraries: Rich libraries means higher specialization and maturity for a
programming language. With so many great libraries you can focus on getting the
tasks done and not have to build everything from scratch. For instance, if you want
to create a GUI you don’t have to write a GUI library first, there are already great
options (tkinter, pysimplegui, pyqt, kivy etc.), if you want to work with images you
don’t have to write the whole thing from scratch there is already PIL, if you are
working on a mathematical model you don’t have to build the whole math
equations from ground up, you can use numpy and scipy etc. There is a library for
pretty much every significant field as of today.
Community support: If you struggle or hit a bottleneck, there will be almost instant
free support thanks to the millions of coders and contributors in the Python
programming community.
Language interoperability: Python can conveniently interact with other
programming languages, operating systems and existing software. This makes it
highly convenient for scripting.
7
Class
A class is a collection of objects. A class contains the blueprints or the prototype from
which the objects are being created. It is a logical entity that contains some attributes and
methods.
To understand the need for creating a class let’s consider an example, let’s say you
wanted to track the number of dogs that may have different attributes like breed, age. If a
list is used, the first element could be the dog’s breed while the second element could
represent its age. Let’s suppose there are 100 different dogs, then how would you know
which element is supposed to be which? What if you wanted to add other properties to
these dogs? This lacks organization and it is the exact need for classes.
Example 1: Creating a class and object with class and instance attributes
8
Output
Objects
The object is an entity that has a state and behaviour associated with it. It may be any
real-world object like a mouse, keyboard, chair, table, pen, etc. Integers, strings, floating-
point numbers, even arrays, and dictionaries, are all objects. More specifically, any single
integer or any single string is an object. The number 12 is an object, the string “Hello,
world” is an object, a list is an object that can hold other objects, and so on. You’ve been
using objects all along and may not even realize it.
An object consists of :
Inheritance
Inheritance is the capability of one class to derive or inherit the properties from another
class. The class that derives properties is called the derived class or child class and the
class from which the properties are being derived is called the base class or parent class.
The benefits of inheritance are:
9
Types of Inheritance –
Single Inheritance:
Single-level inheritance enables a derived class to inherit characteristics from a
single-parent class.
Multilevel Inheritance:
Multi-level inheritance enables a derived class to inherit properties from an
immediate parent class which in turn inherits properties from his parent class.
Hierarchical Inheritance:
Hierarchical level inheritance enables more than one derived class to inherit
properties from a parent class.
Multiple Inheritance:
Multiple level inheritance enables one derived class to inherit properties from
more than one base class.
Polymorphism
Polymorphism simply means having many forms. For example, we need to determine if
the given species of birds fly or not, using polymorphism we can do this using a single
function.
Encapsulation
Encapsulation is one of the fundamental concepts in object-oriented programming (OOP).
It describes the idea of wrapping data and the methods that work on data within one unit.
This puts restrictions on accessing variables and methods directly and can prevent the
accidental modification of data. To prevent accidental change, an object’s variable can
only be changed by an object’s method. Those types of variables are known as private
variables.
10
Data Abstraction
It hides the unnecessary code details from the user. Also, when we do not want to give
out sensitive parts of our code implementation and this is where data abstraction came.
In the late 1980s, history was about to be written. It was that time when working
on Python started. Soon after that, Guido Van Rossum began doing its application-
based work in December of 1989 at Centrum Wiskunde & Informatica (CWI) which
is situated in the Netherlands. It was started firstly as a hobby project because he
was looking for an interesting project to keep him occupied during Christmas. The
programming language in which Python is said to have succeeded is ABC
Programming Language, which had interfacing with the Amoeba Operating System
and had the feature of exception handling. He had already helped to create ABC
earlier in his career and he had seen some issues with ABC but liked most of the
features. After that what he did was very clever. He had taken the syntax of ABC,
and some of its good features. It came with a lot of complaints too, so he fixed
those issues completely and had created a good scripting language that had
removed all the flaws. The inspiration for the name came from BBC’s TV Show –
‘Monty Python’s Flying Circus’, as he was a big fan of the TV show and also he
wanted a short, unique and slightly mysterious name for his invention and hence
he named it Python! He was the “Benevolent dictator for life” (BDFL) until he
stepped down from the position as the leader on 12th July 2018. For quite some
11
time he used to work for Google, but currently, he is working at Dropbox.
The language was finally released in 1991. When it was released, it used a lot fewer codes
to express the concepts, when we compare it with Java, C++ & C. Its design philosophy
was quite good too. Its main objective is to provide code readability and advanced
developer productivity. When it was released it had more than enough capability to
provide classes with inheritance, several core data type exception handling and functions.
Following are the illustrations of different versions of Python along with the timeline.
12
Downloading & Installing Python
In this Python tutorial on Installation and Setup, you’ll see how to install Python on
Windows, macOS, Linux, iOS, and Android.
Since windows don’t come with Python preinstalled, it needs to be installed explicitly.
Here we will define step by step tutorial on How to install Python on Windows. Follow the
steps below :
Step 2: Underneath the Python Releases for Windows find the Latest Python 3 Release –
Python 3.10.5 (the latest stable release as of now is Python 3.10.5).
13
Step 3: On this page move to Files and click on Windows x86-64 executable installer for 64-bit or
Windows x86 executable installer for 32-bit.
Run the Python Installer for how to install python on windows downloads folder
Make sure to mark Add Python 3.10 to PATH otherwise you will have to do it explicitly. It
will start installing python on windows.
After installation is complete click on Close. Bingo..!! Python is installed. Now go to windows and
type IDLE.
14
This is Python Interpreter also called Python Shell. I printed Hello geeks, python is
working smoothly.
The three greater than >>> sign is called Python command prompt, where we write
our program and with a single enter key, it will give result so instantly.
15
characters properly, your editor must recognize that the file is UTF-8, and it must use a
font that supports all the characters in the file.
To declare an encoding other than the default one, a special comment line should be
added as the first line of the file. The syntax is as follows:
For example, to declare that Windows-1252 encoding is to be used, the first line of your
source code file should be:
One exception to the first line rule is when the source code starts with a UNIX “shebang”
line. In this case, the encoding declaration should be added as the second line of the file.
For example:
#!/usr/bin/env python3
# -*- coding: cp1252 -*-
This article aims at providing a detailed insight into the execution of the Python program. Let’s
consider the below example.
Output:
16
Suppose the above python program is saved as first.py. Here first is the name and .py is the
extension. The execution of the Python program involves 2 Steps:
Compilation
Interpreter
Compilation
The program is converted into byte code. Byte code is a fixed set of instructions that
represent arithmetic, comparison, memory operations, etc. It can run on any operating
system and hardware. The byte code instructions are created in the .pyc file. The .pyc file
is not explicitly created as Python handles it internally but it can be viewed with the
following command:
-m and py_compile represent module and module name respectively. This module is
responsible to generate .pyc file. The compiler creates a directory named __pycache__
where it stores the first.cpython-38.pyc file.
Interpreter
The next step involves converting the byte code (.pyc file) into machine code. This step is
necessary as the computer can understand only machine code (binary code). Python
Virtual Machine (PVM) first understands the operating system and processor in the
computer and then converts it into machine code. Further, these machine code
instructions are executed by processor and the results are displayed.
However, the interpreter inside the PVM translates the program line by line thereby
consuming a lot of time. To overcome this, a compiler known as Just In Time (JIT) is added
17
to PVM. JIT compiler improves the execution speed of the Python program. This compiler
is not used in all Python environments like CPython which is standard Python software.
To view the byte code of the file – first.py we can type the following command as :
The dis command is known as “disassembler” that displays the byte code in an
understandable format. The code represents 5 columns:
1. Line Number
2. offset position of byte code
3. name of byte code instruction
4. instruction’s argument
5. constants or names (in brackets)
18
Data Types Of Python
3.1 Variables In Python
In many programming languages, variables are statically typed. That means a variable
is initially declared to have a specific data type, and any value assigned to it during its
lifetime must always have that type.
Variables in Python are not subject to this restriction. In Python, a variable may be
assigned a value of one type and then later re-assigned a value of a different type:
19
3.5 Dictionary in Python
In python, the dictionary is similar to hash or maps in other languages. It consists of
key-value pairs. The value can be accessed by a unique key in the dictionary. (Before
python 3.7 dictionary used to be unordered meant key-value pairs are not stored in
the order they are inputted into the dictionary but from python 3.7 they are stored in
order like the first element will be stored in the first position and the last at the last
position.)
if statement :
if condition:
# Statements to execute if
# condition is true
20
Here, the condition after evaluation will be either true or false. if the statement
accepts boolean values – if the value is true then it will execute the block of
statements below it otherwise not. We can use condition with bracket ‘(‘ ‘)’ also.
if-else :
The if statement alone tells us that if a condition is true it will execute a block of
statements and if the condition is false it won’t. But what if we want to do something
else if the condition is false. Here comes the else statement. We can use the else
statement with if statement to execute a block of code when the condition is false.
Syntax:
if (condition):
# Executes this block if
# condition is true
else:
# Executes this block if
# condition is false
21
nested-if :
Syntax:
if (condition1):
# Executes when condition1 is true
if (condition2):
# Executes when condition2 is true
# if Block is end here
# if Block is end here
22
if-elif-else ladder :
Here, a user can decide among multiple options. The if statements are executed from
the top down. As soon as one of the conditions controlling the if is true, the statement
associated with that if is executed, and the rest of the ladder is bypassed. If none of
the conditions is true, then the final else statement will be executed.
Syntax:
if (condition):
statement
elif (condition):
statement
.
.
else:
statement
23
3.10 Function:
Python Functions is a block of statements that return the specific task.
The idea is to put some commonly or repeatedly done tasks together and make a function
so that instead of writing the same code again and again for different inputs, we can do
the function calls to reuse code contained in it over and over again.
After creating a function we can call it by using the name of the function followed by
parenthesis containing parameters of that particular function.
24
Defining and calling a function with parameters :
If you have experience in C/C++ or Java then you must be thinking about the return type
of the function and data type of arguments. That is possible in Python as well (specifically
for Python 3.5 and above).
Arguments are the values passed inside the parenthesis of the function. A function can
have any number of arguments separated by a comma.
In this example, we will create a simple function to check whether the number passed as
an argument to the function is even or odd.
25
Uses & Scope Of Python
“Writing programs is a very creative and rewarding activity,” says University of Michigan
and Coursera instructor Charles R Severance in his book Python for Everybody. “You can
write programs for many reasons, ranging from making your living to solving a difficult
data analysis problem to having fun to helping someone else solve a problem.”
Data Scientists use Python for computing large amounts of data and drawing from large
databases and libraries. It’s particularly useful for those who specialize in machine
learning as Python is able to access machine learning frameworks for those working with
AI.
Where Developers and Data Scientists go, however, Python will follow – and startups hire
a lot of both. Tech startups are drawn to how scalable the language is. Fintech startups
and traditional financial institutions alike rely on Python as part of their tech stack as well.
Python is used by Intel, IBM, NASA, Pixar, Netflix, Facebook, JP Morgan Chase, Spotify,
and a number of other massive companies. It’s one of the four main languages at Google,
26
while Google’s YouTube is largely written in Python. Same with Reddit, Pinterest, and
Instagram. The original BitTorrent client was also written in Python. And it is used as a
scripting language to control Maya, the industry standard 3D modeling and animation
tool.
It’s versatile. Python can be used for many different tasks, from web development
to machine learning.
It’s open source, which means it’s free to use and distribute, even for commercial
purposes.
Python has a large and active community that contributes to Python’s pool of
modules and libraries, and acts as a helpful resource for other programmers. The
vast support community means that if coders run into a stumbling block, finding a
solution is relatively easy; somebody is bound to have encountered the same
problem before.
27
Web
Development
28
HTML
29
1.3 HTML Skeleton
1. <!DOCTYPE html>
Instruction to the browser about the HTML version.
2. <html>
Root element which acts as a container to hold all the code Browser should know that this a
HTML document Permitted content: One head tag followed by one body tag.
30
3. <head>
Everything written here will never be displayed in the browser It contains general information
about the document Title, definitions of css and script sheets Metadata(information about the
document).
4. <body>
● Everything written here will be displayed in the browser
● Contains text, images, links which can be achieved through tags.
● Examples:
○ <p> This is our first paragraph. </p>
○ <ahref="http://www.google.com">GoTo Google</a>
○ <img src="photo.jpg">
31
○ End tag: </p> // optional
○ Content: This is our first Paragraph
○ Takes up full block or width and adds structure in the web page
○ Always starts from new line ○ Always end before the new line
○ Example :
■ <p >
■ <div>
■ <h1>
...
<h6>
■ <ol>
■ <ul>
○ Example :
■ <span>
■ <strong>
■ <em>
■ <img>
■ <a>
● <br> tag
○ Stands for break line
○ Moving to next line
● <img> tag
○ To add images in the web page
● <strong> tag
33
○ Defines the text to be bold
○ Replaced <b>tag //HTML5
● <em> tag
○ Defines the text to be bold
○ Replaced <i>tag //HTML5
● <ol> tag
○ Stands for ordered list
○ To define series of events that take place in some order
○ Example making a tea (like a flow chart)
○ <ol>.........</ol>
● <ul> tag
○ Stands for unordered list
○ To define series of events that take place where order is not important.
○ Example your hobbies
○ <ul>.........</ul>
● <li> tag
○ Defines the list item
○ Used inside the ‘ol’ and ‘ul’ tag to define the events
○ <li>……….</li>
● <img> tag
○ Used to add images in a web page
○ Syntax: <img src=”url”> ○ Self closing tag.
34
○ Both of these are used to group different tags ○ Acts like a container.
○ Effective while styling.
○ <div>.........</div>
○ <span>....</span>
○ Difference <div> is block level and <span> is inline level.
● <a> tags
○ Used to add links in a web page
○ <a href=”url”> Name of the link </a>
● <table> tag
○ Used to create a table on a web page
○ Need other tags for completing the creation of a table
■ <tr> : for marking the table row
■ <th> : for table header
■ <td> : for table column data
○ Everything is always enclosed within <tr>
■ <thead> : to keep all header data
■ <tbody> : to keep all body data
● <form> tag
○ <input>: used to accept data from the user ○ Some types of inputs are:
● Text:
35
used to store text data. Syntax: type="text"
● Password:
used to enter a secure password. Syntax: type="password"
● Placeholder:
temporary text in input fields. It is generally accompanied by "text" and "password" attributes.
Syntax: placeholder="insert- text-here"
● Button:
used to include buttons in the form. Syntax: type="button" value="insert-text-here"
● Submit button:
For creating a submit button. All the data will get submitted when it is clicked. Syntax:
type="submit"
● Checkbox:
to provide the ability to check multiple options. Syntax: type="checkbox". To check options by
default, set it with the checked attribute.
● Radio Button:
allows one to choose a single option. Syntax: type="radio". Keep the name attribute of all the
options the same.
● <select>:
For every possible option to select, use an <option> tag<option>
● Text Areas:
multi-line plain-text editing control. Syntax: <textarea>. You can specify how large the text area is
by using the "rows" and "cols" attributes
● Labels:
add captions for individual items in a form. Syntax: <label>. A label can be used by placing the
control element inside the <label> element, or by using the "for" and "id" attributes.
● Validations ensure that users fill out forms in the correct format
e.g.:
a. required: The Boolean attribute which makes a field mandatory:
b. email: the browser will ensure that the field contains
36
1.6.2 Attributes
Style sheets were added to address this: Specify style to use rather than
browser default Not have to code styling on every element…………………….
37
DRY principle: Don't Repeat Yourself
a:link, a:visited
-Apply rule when link has been visited or not visited (link)
a:visited { a:link {
colour: blue; colour: green;
} }
39
Every box is composed of four parts (or areas), defined by their respective edges: the
content edge, padding edge, border edge, and margin edge.
The content area, bounded by the content edge, contains the "real" content of the
element, such as text, an image, or a video player. Its dimensions are the content
width (or content-box width) and the content height (or content-box height). It often
has a background colour or background image.
If the box-sizing property is set to content-box (default) and if the element is a block
element, the content area's size can be explicitly defined with the width, min-width,
max-width, height, min-height, and max-height properties.
The padding area, bounded by the padding edge, extends the content area to
include the element's padding. Its dimensions are the padding-box width and the
padding-box height.
The border area, bounded by the border edge, extends the padding area to include
the element's borders. Its dimensions are the border-box width and the border-box
height.
The thickness of the borders are determined by the border-width and shorthand border
properties. If the box-sizing property is set to border-box, the border area's size can be
explicitly defined with the width, min-width, max-width, height, min-height, and max-height
properties. When there is a background (background-colour or background-image) set on a
box, it extends to the outer edge of the border (i.e. extends underneath the border
in z-ordering). This default behavior can be altered with the background-clip CSS
property.
The margin area, bounded by the margin edge, extends the border area to include
an empty area used to separate the element from its neighbors. Its dimensions are
the margin-box width and the margin-box height.
40
The size of the margin area is determined by the margin-top, margin-right, margin-bottom,
margin-left, and shorthand margin properties. When margin collapsing occurs, the
margin area is not clearly defined since margins are shared between boxes.
Finally, note that for non-replaced inline elements, the amount of space taken up
(the contribution to the height of the line) is determined by the line-height property,
even though the borders and padding are still displayed around the content.
Syntax:
position: static;
position: relative;
position: absolute;
position: fixed;
position: sticky;
/* Global values */
position: inherit;
position: initial;
position: revert;
position: revert-layer;
position: unset;
Values:
2.3.1 Static
The element is positioned according to the normal flow of the document. The top,
right, bottom, left, and z-index properties have no effect. This is the default value.
2.3.2 Relative
The element is positioned according to the normal flow of the document, and then
offset relative to itself based on the values of top, right, bottom, and left. The offset
does not affect the position of any other elements; thus, the space given for the
element in the page layout is the same as if position were static.
This value creates a new stacking context when the value of z-index is not auto. Its
effect on table-*-group, table-row, table-column, table-cell, and table-caption elements is
undefined.
41
2.3.3 Absolute
The element is removed from the normal document flow, and no space is created for
the element in the page layout. It is positioned relative to its closest positioned
ancestor, if any; otherwise, it is placed relative to the initial containing block. Its final
position is determined by the values of top, right, bottom, and left.
This value creates a new stacking context when the value of z-index is not auto. The
margins of absolutely positioned boxes do not collapse with other margins.
2.3.4 Fixed
The element is removed from the normal document flow, and no space is created for
the element in the page layout. It is positioned relative to the initial containing block
established by the viewport, except when one of its ancestors has a transform,
perspective, or filter property set to something other than none (see the CSS Transforms
Spec), or the will-change property is set to transform, in which case that ancestor
behaves as the containing block. (Note that there are browser inconsistencies with
perspective and filter contributing to containing block formation.) Its final position is
determined by the values of top, right, bottom, and left.
This value always creates a new stacking context. In printed documents, the element
is placed in the same position on every page.
2.3.5 Sticky
The element is positioned according to the normal flow of the document, and then
offset relative to its nearest scrolling ancestor and containing block (nearest block-
level ancestor), including table-related elements, based on the values of top, right,
bottom, and left. The offset does not affect the position of any other elements.
This value always creates a new stacking context. Note that a sticky element "sticks"
to its nearest ancestor that has a "scrolling mechanism" (created when overflow is
hidden, scroll, auto, or overlay), even if that ancestor isn't the nearest actually scrolling
ancestor.
Description
Types of positioning
42
element's containing block. (The containing block is the ancestor relative to which the
element is positioned.) If the element has margins, they are added to the offset. The
element establishes a new block formatting context (BFC) for its contents.
A stickily positioned element is an element whose computed position value is sticky. It's
treated as relatively positioned until its containing block crosses a specified threshold (such
as setting top to value other than auto) within its flow root (or the container it scrolls within),
at which point it is treated as "stuck" until meeting the opposite edge of its containing block.
Most of the time, absolutely positioned elements that have height and width set to auto
are sized so as to fit their contents. However, non-replaced, absolutely positioned
elements can be made to fill the available vertical space by specifying both top and
bottom and leaving height unspecified (that is, auto). They can likewise be made to fill the
available horizontal space by specifying both left and right and leaving width as auto.
2.3 Flexbox
Flexbox is a one-dimensional layout method for arranging items in rows or columns. Items flex
(expand) to fill additional space or shrink to fit into smaller spaces. This article explains all the
fundamentals.
For a long time, the only reliable cross-browser compatible tools available for
creating CSS layouts were features like floats and positioning. These work, but in
some ways they're also limiting and frustrating.
The following simple layout designs are either difficult or impossible to achieve with
such tools in any kind of convenient, flexible way:
As you'll see in subsequent sections, flexbox makes a lot of layout tasks much easier.
Let's dig in!
When elements are laid out as flex items, they are laid out along two axes:
43
The main axis is the axis running in the direction the flex items are laid out in (for
example, as rows across the page, or columns down the page.) The start and end of
this axis are called the main start and main end.
The cross axis is the axis running perpendicular to the direction the flex items are laid
out in. The start and end of this axis are called the cross start and cross end.
The parent element that has display: flex set on it (the <section> in our example) is
called the flex container.
The items laid out as flexible boxes inside the flex container are called flex items (the
<article> elements in our example).
2.4.3 Direction
Flexbox provides a property called flex-direction that specifies which direction the
main axis runs (which direction the flexbox children are laid out in). By default this is
set to row, which causes them to be laid out in a row in the direction your browser's
default language works in (left to right, in the case of an English browser).
flex-direction: column;
2.4.4 Wrapping
One issue that arises when you have a fixed width or height in your layout is that
eventually your flexbox children will overflow their container, breaking the layout.
flex-wrap: wrap;
44
2.4.5 flex-flow shorthand
At this point it's worth noting that a shorthand exists for flex-direction and flex-wrap:
flex-flow. So, for example, you can replace
flex-direction: row;
flex-wrap: wrap;
with
Flexbox also has a feature for changing the layout order of flex items without
affecting the source order. This is another thing that is impossible to do with
traditional layout methods.
The code for this is simple. Try adding the following CSS to your button bar example
code:
button:first-child {
order: 1;
}
Refresh and you'll see that the "Smile" button has moved to the end of the main axis.
Let's talk about how this works in a bit more detail:
You can set negative order values to make items appear earlier than items whose
value is 0. For example, you could make the "Blush" button appear at the start of the
main axis using the following rule:
button:last-child {
order: -1;
}
2.5 Grid
45
CSS Grid Layout is a two-dimensional layout system for the web. It lets you lay content out in
rows and columns. It has many features that make building complex layouts straightforward.
This article will explain all you need to know to get started with page layout.
A grid is a collection of horizontal and vertical lines creating a pattern against which
we can line up our design elements. They help us to create layouts in which our
elements won't jump around or change width as we move from page to page,
providing greater consistency on our websites.
A grid will typically have columns, rows, and then gaps between each row and
column. The gaps are commonly referred to as gutters.
As a starting point, download and open the starting point file in your text editor and
browser (you can also see it live here). You will see an example with a container,
which has some child items. These display in normal flow by default, so the boxes
display one below the other. We'll be working with this file for the first part of this
lesson, making changes to see how its grid behaves.
To define a grid we use the grid value of the display property. As with Flexbox, this
enables Grid Layout; all of the direct children of the container become grid items.
Add this to the CSS inside your file:
.container {
display: grid;
}
To create gaps between tracks we use the properties column-gap for gaps between
columns, row-gap for gaps between rows, and gap as a shorthand for both.
.container {
display: grid;
grid-template-columns: 2fr 1fr 1fr;
gap: 20px;
}
You can repeat all or merely a section of your track listing using the CSS repeat()
function. Change your track listing to the following:
.container {
display: grid;
46
grid-template-columns: repeat(3, 1fr);
gap: 20px;
}
We now move on from creating a grid to placing things on the grid. Our grid always
has lines — these are numbered beginning with 1 and relate to the writing mode of
the document. For example, column line 1 in English (written left-to-right) would be
on the left-hand side of the grid and row line 1 at the top, while in Arabic (written
right-to-left), column line 1 would be on the right-hand side.
We can arrange things in accordance with these lines by specifying the start and end
line. We do this using the following properties:
grid-column-start
grid-column-end
grid-row-start
grid-row-end
These properties can all have a line number as their value. You can also use the
shorthand properties:
grid-column
grid-row
These let you specify the start and end lines at once, separated by a forward slash /.
47
CONCLUSION
Web Development :
In today's Web development, a good page design is essential. A bad design will lead to the
loss of visitors and that can lead to a loss of business. In general, a good page layout has to
satisfy the basic elements of a good page design. This includes colour contrast, text
organization, font selection, style of a page, page size, graphics used, and consistency. In
order to create a well-designed page for a specific audience. The developer needs to
organized and analyse the users' statistics and the background of the users. Although it
can be hard to come up with a design that is well suited to all of the users, there will be a
design that is appropriate for most of the audience. The better the page design, the more
hits a page will get. That implies an increase in accessibility and a possible increase in
business.
Python Programming :
Understanding the syntax of Python is great and all, and Python by itself is indeed a great
language, but the fundamentals of Python aren't why Python is a successful language.
There are plenty of fun-to-write languages that are just like Python, such as Ruby, Julia,
even R. What makes Python the victor is the community and 3rd-party packages. While
we can do a lot with just an installation of Python and the standard library, we can do
infinitely more with all of the 3rd party libraries out here.
48