Showing posts with label Tutorials. Show all posts
Showing posts with label Tutorials. Show all posts

Index Tutorial Questions

Basic of Python | Tutorial

What is Python ?

We know that any program or application which is run in computer or mobile phone must be created by any programming language like C,C++,JAVA,Visual Basic,C# etc.As the time changes the programming language also change or we can say that enhance with respect to rich libraries, more functionalities, more features, more simple to write code etc. Now these days one of the most popular language having such all features available in it is called python.
 
Python is a general purpose , encrypted, high level and open source language. It is one of the simple programming language used to write codes for computer program. It is a general purpose , high level , interpreted language. It is created by Guido Van Rossum in 1989 with the thinking that everyone can easy to write and understand. In python for writing code indentation is used in the place of cursory braces. It is very powerful language . We can develop any application by using python in very less time. 

Python is used to develop desktop application, web based application, mobile application, System Software, Game development, server side programs, Computer Graphics etc.This language is also used in Space science, Data Science,Artificial Intelligence. It is basically a object oriented based language. So we can say that it is object oriented programming language. It is also interpreted language.It means there is no need to compile to convert it into computer readable program. But in the other programming language we need to convert source code into object code for make a computer readable program. It can be run in any computer so it is platform independent language.It is modular based language, so that we can use their code in another programs. It can easily run on Windows , Linux, MAC operating system etc.

Features of Python ?

  1. SIMPLE :It is very simple language. It can easily read and write. For programming in python their is no need to know about any programming knowledge or experience.
  2. INTERPRETED LANGUAGE :In other language like C, C++, JAVA etc need to compile before running or executing. Python can not be compiled. Python code are interpreted line by line at run time. That's why it is known as interpreted language. This language become slow compare to other language.
  3. PLATFORM INDEPENDENT : It can easily run on Windows, Linux, MAC operating system. Python code written in any operating system can run on another operating system. That's why it is known as platform independent.
  4. EXTENSIBLE LANGUAGE :It means if we want to add any program code of different language such as C,C++,JAVA etc than python will allow to do.
  5. LARGE AND POWERFUL LIBRARY :Large and powerful library are available in python. Modules and packages are available in python for rapid development. For different task such as GUI, Web Development, Database Connection separate modules are available so no need to write code for different task.


How to install Python

After downloading python we need to install python in your system. For installing python follow following steps.

Step- 1:

We can install python in windows in many ways by downloading web-based installer or executable installer or embedded zip files.Click on above link to download different installer according to the requirement.

Step- 2:

Download python for 64-bit windows.

Step- 3:

Run python installation wizard

Step- 4:

This screen will allow to choose the features that you want to use and goto next.

Step- 5:

This screen allow to choose some advance options and customize path or installation location. Now go for installation.

Step- 6:

Now this screen show the progress of installation.

Step- 7:

After completing installation. Now we check whether python is properly installed in our system or not. Now open command prompt and write python --version or python -V and press enter. If the output show the version that means python is installed successfully.

Best Pythom IDE for Python Development

We know python is very efficient to develop application in many domains such as Data Science or Website Development or Artificial Intelligence & Machine Learning or any other domain.For efficiently,repidly and effictively work on python we require IDE. IDE is Integrated Development Enviorment,It helps to automate the tasks and enhance the productivity and efficiency of the developer. Some of the best IDE for python development are list below.
  1. PyCharm
  2. PyDev
  3. Spyder
  4. Thonny
  5. Wing
  6. AtomIDE

Data Type in Python

In any programming language such as C, C++, JAVA etc we use so many type of data such as Integer, Character, Decimal,Boolean etc.For storing such a data a specified data type are used such as for integer data integer data type is used, decimal data decimal data type is used,for boolean data boolean data type is used. Same way following data type are used in python i.e integer, float, complex numbers, String, List, Tuple, Dictionary, set etc.

Data Type in python are classified into following:

  • Numeric
    1. Integer
    2. Float
    3. Complex Number
    4. Boolean
  • Sequence Type
    1. List
    2. Tuple
    3. String
    4. Range
  • Set
  • Dictionary


Numeric Data Type

There are three distinct numeric types such as integers, floating point numbers, and complex numbers.The introduction of these numeric types are same as give in another language like C or C++ or JAVA etc. Let we know how these numeric data type are used in python practically.
print(3)  #return 3
print(3.435) #return 3.435
print(-5) #return -5
print(2+5) #return 7
print(2+5.2) #return 7.2
print(4%2) #return 0

#define variables
first_num=2
second_num=3
print(first_num*second_num) #return 6
print(str(first_num*second_num) + " is multiply of 2 and 3") #convert number into string

Output:
3
3.435
-5
7
7.2
0
6
6 is multiply of 2 and 3

Using Integer Data Type
data_numeric=4
print((data_numeric))
Output:

4


Using Float Data Type
data_numeric=4.5
print((data_numeric))
Output:

4.5


Using Complex Data Type
data_numeric=5+6j
print((data_numeric))
Output:

(5+6j)


Using Boolean Data Type. Return (true/false)
a=5
b=6
print(a<b)
print(a>b)
Output:

True
False


OR     Return (1/0)    
a=5
b=6
print(int(a<b))
print(int(a>b))
Output:

1
0


How to convert int into float or float into int ?
int_numeric=5
float_numeric=6.5
print(int(float_numeric))
print(float(int_numeric))
Output:

6
5.0


How to convert any number into complex number ? 
int_numeric_r=5
int_numeric_i=6
print(complex(int_numeric_r,int_numeric_i))

Output:

(5+6j)


Sequence Data Type

In python sequence data type are used to store multiple values in container in organized manner just like arrays in C. In Python there are following type of sequence data type such as string,List,Tuples,set. Let we discuss how to use these data type in python.

Using List Data Type
um_list=[2,3,5,6,10]
print(num_list)
print(type(num_list))
Output:

[2, 3, 5, 6, 10]
<class 'list'>

Using Tuple Data Type
data_tuple=(12,20,10,5,8,7)
print(data_tuple)
print(type(data_tuple))
Output:

(12, 20, 10, 5, 8, 7)
<class 'tuple'>

Using String Data Type

#For next line use \n
print("Name is shailu \nAge is 40")

name="shailu" # variable name
print(name.upper()) # return SHAILU
print(name.upper().isupper()) # return True
print(len(name)) # return length of string 6
print(name[0]) # return first character of string i.e s
print(name.index("a")) # return index of a i.e 2
print(name.replace("shailu","chailu")) # replace shailu to chailu
Output:
Name is shailu
Age is 40
SHAILU
True
6
s
2
chailu
Using Range Data Type
print(range(2,10))
print(list(range(2,10)))

Output:
range(2, 10)
[2, 3, 4, 5, 6, 7, 8, 9]

If we want to print the Even number using range data type so we use 3 parameter in range such as:

print(range(2,10,2))
print(list(range(2,10,2)))
Output:
range(2, 10, 2)
[2, 4, 6, 8]


Set Data Type

data_set={12,20,10,5,8,7}
print(data_set)
print(type(data_set))
Output:

{5, 7, 8, 10, 12, 20}
<class 'set'>


Dictionary Data Type

dictionary text
dist={'1':'C-language','2':'ADA','3':'C++','4':'Python'}
print(dist)
# comment: get index or keys
print(dist.keys())
# comment: fetch values
print(dist.values())
# comment: fetch value by index or key
print(dist['2'])
# comment: get value by index or key
print(dist.get('3'))
Output:

{'1': 'C-language', '2': 'ADA', '3': 'C++', '4': 'Python'}
dist_keys(['1', '2', '3', '4'])
dist_values(['C-language', 'ADA', 'C++', 'Python'])
ADA
C++


Variables in Python


We know variable is just like a container where we put values.It is same as we use in C or C++ language. Let we know in python how we declare , define and intialize variables with the help of examples:
We will start with very basic example
let we take two variable and ADD them such as

a=2
b=3
print(a+b)

Output

5

HTML | Tutorial

How to create Simple HTML Page For Beginners

Hell friends,It is very easy to design HTML page.HTML is Hyper Text Markup Language.It is very helpful for beginners. I will demostrate how we start designing simple HTML Page. There are so many HTML editor are available for designing HTML pages. No matter which editor is used. The most common editor is Notepad , Notepad++ , Sublimetext.Let we start with HTML code.

CSS | Tutorial

CSS BASIC

CSS:

h1 {font-family: Georgia, sans-serif;}
p {font-family: Tahoma, serif;}


CSS: For Body Tag

body {margin: 20px;}


CSS: For Combine Elements

h1, h2, h3, h4, h5, h6 {
color: #009900;
font-family: Georgia, sans-serif;
}


CSS: FOR Comments

/* This is a comment */


CSS: FOR Create Class

.container{
width: 80%;
margin: auto;
padding: 20px;
border: 1px solid #666;
background: #ffffff;
}

HTML: FOR Call CSS Class

<div class="container">
  Dot is used to create a css class
</div>


CSS: FOR Create ID

#container{
width: 80%;
margin: auto;
padding: 20px;
border: 1px solid #666;
background: #ffffff;
}

HTML: FOR Call CSS ID

<div ID="container">
  Hash is used to create a css ID
</div>


CSS SELECTORS

There are many different types of CSS selector that allow you to target rules to specific elements in an HTML document. CSS selectors are case sensitive, so they must match element names and attribute values exactly.

Universal Selector

Applies to all elements in the document
   *{ } , Targets all elements on the page

Type Selector

Matches element names
   h1, h2, h3 { } , Targets the <h1>, <h2> and <h3> elements

Class Selector

Matches an element whose class attribute has a value that matches the one specified after the period (or full stop) symbol
  .mark { } Targets any element whose class attribute has a value of mark.
   p.mark { } Targets only <p> elements whose class attribute has a value of mark.

ID Selector

Matches an element whose id attribute has a value that matches the one specified after the pound or hash symbol.
  #remark { }Targets the element whose id attribute has a value of remark.

Child Selector

Matches an element that is a direct child of another
  li > a { } , Targets any <a> elements that are children of an <li> element (but not other <a> elements in the page)

Descendant Selector

Matches an element that is a descendent of another specified element (not just a direct child of that element)
  p a { } , Targets any <a> elements that sit inside a <p> element, even if there are other elements nested between them.

Adjacent Sibling Selector

Matches an element that is the next sibling of another.
  h1+p { } , Targets the first <p> element after any <h1> element (but not other <p> elements)

General Sibling Selector

Matches an element that is a sibling of another, although it does not have to be the directly preceding element.
  h1~p { } , If you had two <p> elements that are siblings of an <h1> element, this rule would apply to both


MIN-WIDTH AND MAX-WIDTH , MIN-HEIGHT AND MAX-HEIGHT

By using max-width and min-width , size of website can be easily adjust according to browser width size.

CSS:

td.text {
  min-width: 400px;
  max-width: 600px;
  margin:0px;
  padding:2px;
  text-align:right; }

Call in HTML Code:

<td class="text">Call text css in td of table to manage text in td according to screen size.</ td>


By using max-height and min-height, size of website can be easily adjust according to browser height.

CSS:

p {
  min-height: 50px;
  max-height: 50px; }

Call in HTML Code:

<p>Call this css implicitly when using p tag and adjust their height.</ p>


INHERITANCE

If you specify the font-family or color properties on the <body> element, they will apply to most child elements. This is because the value of the font-family property is inherited by child elements.

CSS:


  body {
  font-family: Arial, Verdana, sans-serif;
  color: #552211;
  padding: 12px;}
  .page {
  border: 1px solid #552211;
  background-color: #dfdede;
  padding: inherit;}

Call in HTML Code:


  <div class="page">
  <h1>MCA</h1>
  <p>Master of Application.</p>
  <p>MCA students are developers.</p>
  </div>


CSS FOR FOREGROUND COLOR

The color property allows you to specify the color of text inside an element.

CSS:


  /* color name */
  h1 {color: Blue;}
  /* hex code */
  h2 {color: #CF3F80;}
  /* rgb value */
  p {color: rgb(150,120,60);}


CSS FOR BACKGROUND COLOR

CSS treats each HTML element as if it appears in a box, and the background-color property sets the color of the background for that box.

CSS:


  body {
  background-color: rgb(200,200,200);}
  h1 {background-color: DarkCyan;}
  h2 {background-color: #ee3e80;}
  p {background-color: white;}


CSS FOR OPACITY

CSS3 introduces the opacity property which allows you to specify the opacity of an element and any of its child elements. The value is a number between 0.0 and 1.0 (so a value of 0.5 is 50% opacity and 0.15 is 15% opacity).

CSS:


  p.OPY1 {
  background-color: rgb(0,0,0);
  opacity: 0.5;}
  p.OPY2 {
  background-color: rgb(0,0,0);
  background-color: rgba(0,0,0,0.5);}


CSS FOR MARGIN

CSS: BASIC FORMAT

There are Three choices of values for the margin property.
⇒length
⇒percentage
⇒auto

margin-top: length percentage or auto;
margin-left: length percentage or auto;
margin-right: length percentage or auto;
margin-bottom: length percentage or auto;

We can write margin for 4 side in single line

margin: top right bottom left;
margin: 10px 10px 10px 10px;

We can sets the margin on all sides

margin: 10px; → All 4 side have margin 10px

You can set the margin property to negative values.If you do not declare the margin value of an element, the margin is 0.

margin: -10px;

Example:
body{
margin: 10px;
background: #fcfcfc;
font-size: large;
text-align: right;
font-family: Georgia, sans-serif;
}


CSS FOR PADDING

Padding is the Space between the border of an HTML element and the content within it. It is just like Margin but there is no "auto" value, and negative values cannot be declared for padding.

CSS: BASIC FORMAT

There are Two choices of values for the Padding property.
⇒length
⇒percentage

padding-top: length percentage;
padding-left: length percentage;
padding-right: length percentage;
padding-bottom: length percentage;

We can write Padding for 4 side in single line

margin: top right bottom left;
margin: 10px 10px 10px 10px;

We can sets the Padding on all sides

padding: 10px; → All 4 side have padding 10px

Example:
#container{
width: 80%;
border: 2px solid #896;
background: #fcfcfc;
margin: auto;
padding: 20px;
}


CSS FOR TEXT PROPERTIES

Text is important part of website so we must manage text using css. Text contain following properties:



∗ Color
∗ Letter Spacing
∗ Text Align
∗ Text Decoration
∗ Text Indent
∗ Text Transform
∗ White Space
∗ Word Spacing

CSS: Color

color: value;

Values are of:

∗ color name - example:(blue,black,red...)
∗ hexadecimal number - example:(#ff0000, #000000)
∗ RGB color code - example:(rgb(255, 0, 0), rgb(0, 0, 0))

Example:
color:red;
color:"#ff0000";
color:"#fff";

CSS: Letter Spacing

letter-spacing: value;

Values are of:

∗ normal
∗ length

Example:
letter-spacing:normal;
letter-spacing:5px;

CSS: Text Align

text-align: value;

Values are of:

∗ left
∗ right
∗ center
∗ justify

Example:
text-align:left;
text-align:right;
text-align:center;
text-align:justify;

CSS: Text Decoration

text-decoration: value;

Values are of:

∗ none
∗ underline
∗ overline
∗ line through
∗ blink

Example:
text-decoration:none;
text-decoration:underline;
text-decoration:overline;
text-decoration:through;
text-decoration:blink;

CSS: Text Indent

text-indent: value;

Values are of:

∗ length
∗ percentage

Example:
text-indent:2px;
text-indent:10%;

CSS: Text Transform

text-transform: value;

Values are of:

∗ none
∗ capitalize
∗ lowercase

Example:
text-transform:none;
text-transform:capitalize;
text-transform:lowercase;

CSS: White Space

white-space: value;

Values are of:

∗ normal
∗ pre
∗ nowrap

Example:
white-space:normal;
white-space:pre;
white-space:nowrap;

CSS: Word Spacing

word-spacing: value;

Values are of:

∗ normal
∗ length

Example:
word-spacing:normal;
word-spacing:10px;


CSS FOR FONT PROPERTIES

Font is important part of website so we must manage Font of text using css. Font contain following properties:



∗ Font
∗ Font-Family
∗ Font Size
∗ Font Style
∗ Font Variant
∗ Font Weight

CSS: Font

General formate of font:

font:style weight variantrelative Sizeline height Fonttypeface
Example:
font: italic bold normal small/1.2em Arial, sans-serif;

CSS: Font-Family

Font-Family: value;

Values are of two choices:

∗ family-name
∗ generic family

Example:
font-family: Verdana, sans-serif;

CSS: Font Size

Font Size: value;

Values are of:

∗ xx-large
∗ x-large
∗ larger
∗ large
∗ medium
∗ small
∗ smaller
∗ x-small
∗ xx-small
∗ length
∗ % (percent)

Example:
Font Size:x-large;
Font Size:10px;
Font Size:5%;

CSS: Font Style

font style: value;

Values are of:

∗ normal
∗ itailc
∗ oblique

Example:
Font Style:normal;
Font Style:itailc;
Font Style:oblique;

CSS: Font Variant

font variant: value;

Values are of:

∗ normal
∗ small-caps

Example:
font variant:normal;
font variant:small-caps;

CSS: Font Weight

font weight: value;

Values are of:

∗ lighter
∗ normal
∗ 100
∗ 200
∗ 300
∗ 400
∗ 500
∗ 600
∗ 700
∗ 800
∗ 900
∗ bold
∗ bolder

Example:
font weight:normal;
font weight:bold;
font weight:100;