Sunday, April 20, 2025

Python Replace, Split

We can replace one character with another character, in this case 'A' will be replaced with 'Z':


a = "This is A, this is B, this is group ABC"

print(a.replace("A", "Z"))

Multiple character can replace one character, too:


a = "This is A, this is B, this is group ABC"

print(a.replace("A", "RRRRRRRR"))

One word can be replaced with another word:


a = "This is A, this is B, this is group ABC"

print(a.replace("This", "555"))

How to Split String

Function split() will accept specific separator, in this case, just space:


a = "This is A, this is B, this is group ABC"

print(a.split(" "))

Result:


['This', 'is', 'A,', 'this', 'is', 'B,', 'this', 'is', 'group', 'ABC']
>>> 

In this case, we are using comma as separator:


a = "This is A, this is B, this is group ABC"

print(a.split(","))

And now, comma and space:


a = "This is A, this is B, this is group ABC"

for x in a.split(", "):
    print(x)

What you see is "for loop". In this case it is used to print all parts of string if separator is character "i":


a = "This is A, this is B, this is group ABC"

for x in a.split("i"):
    print(x)

Result: 


Th
s 
s A, th
s 
s B, th
s 
s group ABC
>>> 

In this example, we are doing split based on comma and space. After that, all results are sent to upper() function:


a = "This is A, this is B, this is group ABC"

for x in a.split(", "):
    print(x.upper())

Result: 


THIS IS A
THIS IS B
THIS IS GROUP ABC
>>> 

We will talk more about for loops.

How to get and use input from Keyboard is topic of next tutorial.

Python Strings, len, lower, upper

To get string length (number of characters), we will use len() function.

Note: all whitespaces are important:


a = "      Double Quotes"
b = 'Single Quotes         '

print(len(a))
print(len(b))

Result:


19
22
>>> 

a = "Double Quotes"
b = 'Single Quotes'

print(len(a))
print(len(b))

Result:


13
13
>>>

Sometimes it's useful to put length in dedicated variable, so we can use it later:


a = "Double Quotes"
b = 'Single Quotes'

how_a_is_long = len(a)

print(how_a_is_long)

Result:


13
>>>

Even better option is to explain what is happening:


a = "Double Quotes"
b = 'Single Quotes'

how_a_is_long = len(a)

print("How long var a is: ", how_a_is_long)

To transfer all chars to lowercases, we can use lower() function:


a = "Double Quotes"
b = 'Single Quotes'

print(a.lower())
print(b.lower())

Result:


double quotes
single quotes
>>>

Same for uppercases, with upper() function:


a = "Double Quotes"
b = 'Single Quotes'

print(a.upper())
print(b.upper())

Result:


DOUBLE QUOTES
SINGLE QUOTES
>>>

Python Indexing, Space Strip

Two variables with strings are our starting point. To extract characters in specific positions we will use brackets [0], for example, to extract first character.

In Python, and most other programming languages we count from 0, and not from 1, when we talk about positions/indexes.


a = "Double Quotes"
b = 'Single Quotes'

print("First char from a var: ", a[0])
print("First char from b var: ", b[0])

Result:


First char from a var:  D
First char from b var:  S
>>> 

Following same principle, we can get multiple characters, at different positions:


a = "Double Quotes"
b = 'Single Quotes'

print(a[0], a[1], a[2])

print("")

print(b[0], b[1], b[2])

Result:


D o u

S i n
>>> 

We can extract characters in specific range:


print(b[0:7])

Result:


Single 
>>>

Last character in string:


print(b[-1])

Result:


s
>>>

To grab everything, use colons:


print(b[:])

Result:


Single Quotes
>>>

How to Remove Spaces in Strings

If we have a "dirty" string with a lot of unwanted spaces, we can use strip() function:


a = "      Double Quotes"
b = 'Single Quotes         '

print(a.strip())
print(b.strip())

Result:


Double Quotes
Single Quotes
>>>

After we are done, concatenation is possible. Or, some other operation:


a = "      Double Quotes"
b = 'Single Quotes         '

print(a.strip() + " " + b.strip())

Result:


Double Quotes Single Quotes
>>>

Ok, in next tutorial we will play with string length, and how to transform characters (lowercase, uppercase).

Python Casting, int, float, str

This is our starting point, one integer, float, and negative float:


x = 10
y = 12.25
z = -5345345.234234

print("Value of x: ", x, "Type: ", type(x))
print("Value of y: ", y, "Type: ", type(y))
print("Value of z: ", z, "Type: ", type(z))

To transfer all of them in simple integer, we will use int() function:


x = 10
y = int(12.25)
z = int(-5345345.234234)

print("Value of x: ", x, "Type: ", type(x))
print("Value of y: ", y, "Type: ", type(y))
print("Value of z: ", z, "Type: ", type(z))

Sometimes, all we need is bunch of floats:


x = float(10)
y = float(12.25)
z = float(-5345345.234234)

print("Value of x: ", x, "Type: ", type(x))
print("Value of y: ", y, "Type: ", type(y))
print("Value of z: ", z, "Type: ", type(z))

With str() function we can convert numbers to strings:


x = str(10)
y = str(12.25)
z = str(-5345345.234234)

print("Value of x: ", x, "Type: ", type(x))
print("Value of y: ", y, "Type: ", type(y))
print("Value of z: ", z, "Type: ", type(z))

When we have all strings, just concatenate them using plus (+) symbol:


x = str(10)
y = str(12.25)
z = str(-5345345.234234)

print(x + y + z)

Result:


1012.25-5345345.234234
>>> 

What a weird result. Now we can use tab as separator:


x = str(10)
y = str(12.25)
z = str(-5345345.234234)

print(x + "\t" + y + "\t" + z)

Result:


10	12.25	-5345345.234234
>>> 

In next tutorial we will learn how to extract individual characters from strings, and how to remove spaces.

Python Numbers

Python is high level programming language - it will automatically recognize number type in variables:


x = 5
y = 4654655
z = -4656456

print("Value of x: ", x, type(x))
print("Value of y: ", y, type(y))
print("Value of z: ", z, type(z))

Sure, we can use floats. If we need higher precision:


x = 5.00
y = 4654655.123
z = -4656456.435345

print("Value of x: ", x, type(x))
print("Value of y: ", y, type(y))
print("Value of z: ", z, type(z))

It's extremely useful to put result of operations in dedicated variables, so we can use it further:


x = 5
y = 10
addition = x + y

print("Result: ", addition)
print("Type:", type(addition))

If one number in calculation is float, result will be float, too:


x = 5.34
y = 10
addition = x + y

print("Result: ", addition)
print("Type:", type(addition))

Result:


Result:  15.34
Type: <class 'float'>
>>> 

Scientific notation supported by default:


# 5 x 10 on 3

x = 5e3
print(x)

This will work, too:


# 5 x 10 on 12

x = 5E12
print(x)

Result:


5000000000000.0
>>> 

In next tutorial we will convert from one data type to another.

Python Concatenation, Types

To concatenate left side (our custom report) with right side, which is variable that hold string, we will use plus (+) symbol:


name = "John"
lastname = "Snow"
years = "39"

print("Name: " + name)
print("LastName: " + lastname)
print("Years: " + years)

We can also use a comma:


name = "John"
lastname = "Snow"
years = 39

print("Name: ", name)
print("LastName: ", lastname)
print("Years: ", years)

To see with what we are dealing with (data type detection), there's type() function:


name = "John"
lastname = "Snow"
years = 39

"""
print("Name: ", name)
print("LastName: ", lastname)
print("Years: ", years)
"""

print(type(name))
print(type(lastname))
print(type(years))

Result:


<class 'str'>
<class 'str'>
<class 'int'>
>>> 

We are working with two strings (name, lastname) and one number (integer).

Sometimes, we will put result of type() function in dedicated variable, so it can be used in further operations.

We will use that approach all the time:


name = "John"
lastname = "Snow"
years = 39

"""
print("Name: ", name)
print("LastName: ", lastname)
print("Years: ", years)
"""

result = type(name)
print(result)

This will be result in Shell:


<class 'str'>
>>> 

It's so easy to work with numbers in Python. Let's learn about that in next tutorial.

Python Variables, Contexts

Sure, while practicing you can use abstract/short variable names like, x, y, z, a, b, c, and so on:


x = "Actual Data"

print(x)

But, better option is to use variable names that describe what they contain:


name = "John"
lastname = "Snow"

print(name)
print(lastname)

We can use (print in this case) variables one after another - on single line. Make sure to have a comma to separate them:


name = "John"
lastname = "Snow"

print(name, lastname)

Underscores will work as part of variable names, but having a lot of them connected is silly.

Variables can hold numbers, too:


name = "John"
last____name = "Snow"

number = 5
pi = 3.14

print(name, last____name)
print(number, pi)

Mathematical operations can be done directly:


x = 5
y = 10

print(x + y)

We can use one variable multiple times:


x = 5
y = 10

print(x + y + x + y)

For complicated formulas enclose parts in a dedicated parenthesis:


x = 5
y = 10

print((x + x) + (y + y))

We can have numbers treated as letters - if we enclose them in quotes.

In this context, result will be a concatenation of numbers, because they are treated as characters, and not numbers:


x = "5"
y = "10"

print(x + y)

Result when numbers are used as letters:


510
>>> 

Don't worry about contexts, over time they will become intuitive.

In next tutorial we will talk about concatenation and how to detect data types in variables.

Python Comments, DocStrings

If we need to explain part of code a little bit more (internally) we can use comments.

In Python, single-line comments start with hash(#) character.


#This is single-line comment

"""
We can also have explanation
on multiple lines.
Start and end them with 3 quotes.
"""

print("This will be printed") #This will not, bacause it's comment.

When we run it:


This will be printed
>>> 

Python Docstrings

What we see is Python function. Functions are like dedicated workers that will do specific job and nothing else.

In function, we can have short explanation (with 3 quotes aside). They are called "docstrings" because they are very specific "internal documentation" for that one function.

Create them immediately after function name.

For example, we can use them to generate automatic PDF documentation for all functions in our script. Or even, whole site can be based on docstrings, if our script have hundreds of functions.


def first_function():
    """ Brief explanation about func here """
    print("Some Real Operations")

To access docstrings, just target that specific function, and add __doc__ to print command:


def first_function():
    """ Brief explanation about func here """
    print("Some Real Operations")
    
print(first_function.__doc__)

Result:


 Brief explanation about func here 
>>> 

To use any function, just call it with: first_function() - don't forget parentheses. We need them because some functions can grab things in parentheses and do all types of further operations with data you provide.


def first_function():
    """ Brief explanation about func here """
    print("Some Real Operations")
    
first_function()

Result:


Some Real Operations
>>> 

Ok, in next tutorial we will talk more about variables.

Python Syntax, Indentation

In programming, we can create "containers". Official name for some specific "container" is variable.

Variables can contain numbers, words, characters, whole sentences, and so on. Also, we can override things in variables with new things.

Let's create a variable "something", so we can put some data there, for example: "Some String Here".

After that, we will immediately use it - just simple printing, nothing special here:


something = "Some String Here"

print(something)

Result:


Some String Here
>>> 

Python doesn't care about spaces inside parentheses (when we use variables):


print(  something  )

print(      something      )

But space inside quotes is extremely important when we do direct printing. Everything inside quotes is part of usable string. Type and run this code:


print("some string")
print(" some string ")
print("      some string     ")
print(   "      some string     "    )
print(      "some string"    )

Result:


some string
 some string 
      some string     
      some string     
some string
>>> 

Try this to see what's happening:


print("string with more parts")
print("string     with     big     spaces")

In Python, indentation is extremely important. What you see is "if statement". We will use it all the time in programming.


if 5 < 10:
    print("This Will Work")

But this code will not work - because we messed up indentation rules:


if 5 < 10:
print("This Will NOT Work")

So far so good. In next tutorial we will talk about internal code explanations (comments and docstrings).

Python Prompt, CMD, Terminal

Let's learn how to run Python scripts from CMD if you are using machines with Windows.

On Windows 10, click in lower left corner where we have search box. Type "cmd" there and press Enter. This is what will pop-up (in my case):


Microsoft Windows [Version 10.0.18363.959]
(c) 2019 Microsoft Corporation. All rights reserved.

C:\Users\user>

This is default directory for user. To clear screen type "cls" and press Enter.

After that, let's move to place where I have Python installed, using "cd" command. I have Python in "Python38-64" directory inside "root" of my hard drive:


C:\Users\user>cd C:\Python38-64

C:\Python38-64>

Now, what is in that directory ? We will use "dir" command to list content:


C:\Python38-64>dir
 Volume in drive C is New Volume

 Directory of C:\Python38-64

07/30/2020  11:50 AM    <DIR>          .
07/30/2020  11:50 AM    <DIR>          ..
07/30/2020  11:50 AM    <DIR>          ARCHIVE
06/22/2020  04:59 PM    <DIR>          DLLs
05/30/2020  04:27 PM    <DIR>          Doc
06/22/2020  06:04 PM    <DIR>          include
05/30/2020  04:27 PM    <DIR>          Lib
05/30/2020  04:27 PM    <DIR>          libs
05/13/2020  10:43 PM            31,453 LICENSE.txt
07/30/2020  12:00 AM                34 playground.py
05/13/2020  10:42 PM           100,424 python.exe
05/13/2020  10:42 PM            58,952 python3.dll
05/13/2020  10:42 PM         4,208,200 python38.dll
07/27/2020  02:10 PM    <DIR>          Scripts
05/30/2020  04:28 PM    <DIR>          tcl
05/30/2020  04:27 PM    <DIR>          Tools
05/13/2020  10:43 PM           100,880 vcruntime140.dll
05/13/2020  10:43 PM            44,320 vcruntime140_1.dll
               7 File(s)      4,544,263 bytes
              11 Dir(s)  74,980,769,792 bytes free

C:\Python38-64>

That is our listing. Important thing here is python.exe file, and also we see our custom playground.py file. Ok, now we can run our custom python script, with python playground.py


C:\Python38-64>python playground.py
0
1
2
3
4

C:\Python38-64>

After script is executed, you are again in cmd, which means we can continue to run other python scripts (if we have it), or we can just type classical MS-DOS command.

You don't need to use CMD if you don't like typing, working in IDLE is perfectly fine. But knowing how to navigate through system using cmd on Windows, or Terminal on Linux/BSD system is important for programmers.

Ok, in next tutorial we will talk about syntax and indentation in Python.

Python Installation, First Script

Go to python.org and grab Python setup file for your system.

For security reasons, always use official sites to download important setup files. Do not use anonymous FTP servers and torrents. You must be security aware.

While installing Python, make sure that you check PIP and PATH options.

PIP will be used to grab additional modules from Internet with one-line commands, and "having Python in PATH" means that you can run Pythons scripts in terminal/cmd from all parts of system, which will save you a lot of time if you like to work in terminal.

When we are done with installation, we have two options. To use Python shell for short instructions, but better option is to use graphical IDLE - Integrated Development and Learning Environment.

My advice is to use IDLE all the time.

In IDLE, open new file and save it using file name, for example, "playground.py". Just make sure that file extension is ".py"

That is important because you will immediately activate syntax highlighting for python source code, and also, IDLE will pay attention to how you are indenting lines of code, because indentation is important in Python.

Ok, now type this source code in that file you created, and run it with F5. This is line you need to type:


print("Something")

And this is result. Well done.


Something
>>> 

Results are in Python Shell, that's why you see arrows. Sure, you can run print("Something") in Shell, and the thing will work, too. But Shell is not practical for big scripts.

We can print more lines, one after another. Make sure that words inside parentheses are enclosed in quotes.


print("Something")
print("Some string more")
print("3.14")
print("23423423423423")

Let's do something fun. What you see is "for loop" that will print specific number, one after another, in specific range:


for x in range(5):
    print(x)

Result:


0
1
2
3
4
>>> 

Yes, you see 4 as last number, but we are starting from 0, so in total you have 5 numbers printed.

We will talk more about for loops. Don't worry about that for now.

Let's go to next tutorial.

Python Introduction - Why to Learn Python

If there's one thing that I can recommend, it's to learn Python.

Python is high, general purpose programming language that will help you to get job done - in extremely short period of time.

Some people will call it easy. Programming in general is not easy - but Python syntax is almost like plain english, which will help greatly if you are starting programming career with this beautiful language.

Sure, some things need to be done in low level programming languages, where you need to invest considerable amount of time - and this is where Python shines. It's extremely useful in testing and prototyping.

We can use Python in various fields, for example:

  • Security - malware analysis (strings, patterns, etc.)
  • Network testing and metadata acquisition
  • Marketing and sales data analysis
  • Advanced statistic and modeling for specific needs
  • Static/Dynamic website generators where data are in text files, table-type files, or in databases.
  • Electronic, sensors, data acquisition and telemetry
  • Custom Telecommunications equipment testing
  • COM, LPT, USB, etc. port programming and device control.
  • Data and filetype conversions, interfacing with legacy and mainframe systems.
  • Custom Multimedia solutions for small and large operations
  • Scientific research and simulations
  • Intelligence gathering and acquisition

And so on, and so on.

But the most important thing - it's fun to work in Python.

Let's learn it together.

CSS Bootstrap 4 Introduction

Bootstrap is a popular front-end web development framework that provides pre-designed CSS styles and JavaScript plugins for building responsive and mobile-first websites. It was created by Twitter and is now maintained by a large open-source community.

For beginners in CSS, Bootstrap can be a helpful tool because it allows you to quickly create professional-looking websites without having to write custom CSS code from scratch. It provides a wide range of pre-designed components such as buttons, forms, tables, and navigation bars that can be easily added to your web pages. Additionally, Bootstrap is designed to be responsive, which means your web pages will automatically adjust to different screen sizes, making them mobile-friendly.

Using Bootstrap can save you a lot of time and effort when building websites, especially if you are new to CSS and web development. It can help you learn the basics of web development and CSS while creating professional-looking websites. 


<!doctype html>
<html lang="en">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">

    <title>Hello, world!</title>
  </head>
  <body>
    <h1>Hello, world!</h1>

    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
  </body>
</html>

This code includes the Bootstrap CSS and JavaScript files. 

The code includes the required meta tags for character set and responsive design, and a link to the Bootstrap CSS file hosted on a content delivery network (CDN). The title tag sets the document title to "Hello, world!".

The body section of the document includes a heading that says "Hello, world!" and three script tags that load jQuery, Popper.js, and Bootstrap JavaScript files from CDNs.

By including the Bootstrap CSS and JavaScript files, developers can easily create responsive and visually appealing web pages without writing custom CSS and JavaScript code. 


<nav class="navbar navbar-expand-lg navbar-dark bg-dark">

  <a class="navbar-brand" href="#">Navbar</a>

  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>

  <div class="collapse navbar-collapse" id="navbarNav">
    <ul class="navbar-nav">
      <li class="nav-item active">
        <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#">Features</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#">Pricing</a>
      </li>
      <li class="nav-item">
        <a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
      </li>
    </ul>
  </div>

</nav>	

This is a Bootstrap navigation bar, which includes a header with a brand name and a toggler button that displays the navigation links on smaller screens.

The navigation links are organized as a list, with each list item represented by an <li> tag, and each link represented by an <a> tag with the nav-link class.

The navigation bar has a dark background (bg-dark) and uses the navbar-expand-lg class to indicate that it should be expanded on large screens. 


<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">

    <title>Hello, world!</title>
  </head>
  <body>
    
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">

  <a class="navbar-brand" href="#">Navbar</a>

  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>

  <div class="collapse navbar-collapse" id="navbarNav">
    <ul class="navbar-nav">
      <li class="nav-item active">
        <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#">Features</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#">Pricing</a>
      </li>
      <li class="nav-item">
        <a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
      </li>
    </ul>
  </div>

</nav>	
	
    <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
  </body>
</html>

The navbar contains a logo (Navbar), a toggle button to collapse the menu on small screens, and four links: Home, Features, Pricing, and Disabled.

The page will also load three JavaScript files (jQuery, Popper.js, and Bootstrap) from content delivery networks (CDN) to enable dynamic behavior of the navbar. The title of the page is "Hello, world!" which will appear in the browser's title bar.

CSS Html Forms

HTML forms can be styled using CSS. You can use CSS to control the layout, fonts, colors, and other visual aspects of form elements such as input fields, checkboxes, and buttons.


<!DOCTYPE html>

<html>
<head><title>Title</title></head>

<link rel="stylesheet" type="text/css" href="mystyle.css">

<body>

<div class="f">
<form>
	<label>Name: </label>
	<input type="text" id="name" name="name">
	
	<label>Last Name: </label>
	<input type="text" id="lastname" name="lastname">
	
	<input type="submit" value="Submit">	

</form>
</div>

</body>
</html>

This HTML code creates a simple form that includes two input fields for the user's name and last name, along with a submit button.

The form is contained within a div element that has a class of "f", and an external CSS file is linked to the HTML page using the link tag in the head section. 


.f {
	max-width: 500px;
	border: 2px solid black;
	background: yellow;
	padding: 5px;
	margin: 5px;
}

input[type="text"] {
	width: 95%;
	padding: 5px;
	margin: 5px;
	display: block;
}

input[type="submit"] {
	padding: 5px;
	margin: 5px;
	display: block;
}

This CSS code is styling an HTML form with a class of "f" and contains two text input fields and a submit button.

The ".f" class sets a maximum width of 500px, adds a 2px solid black border, and sets a yellow background color with 5px of padding and margin.

The "input[type='text']" selector applies styles to all text input fields, setting the width to 95%, adding 5px of padding and margin, and displaying them as blocks.

The "input[type='submit']" selector applies styles to the submit button, adding 5px of padding and margin, and displaying it as a block.

CSS Vertical Menu


<!DOCTYPE html>

<html>
<head><title>Title</title></head>

<link rel="stylesheet" type="text/css" href="mystyle.css">

<body>

<ul>
	<li><a href="#">Home</a></li>
	<li><a href="#">Products</a></li>
	<li><a href="#">Contact</a></li>
	<li><a href="#">About</a></li>
</ul>

</body>
</html>

Our simple navigation.


body {
	margin: 0px;
	padding: 0px;
}

ul {
	width: 150px;
	list-style-type: none;
	margin: 0px;
	padding: 0px;
	background: black;
	overflow: hidden;
}

li a {
	display: block;
	background: black;
	color:white;
	padding: 5px;
	text-decoration: none;
}

li a:hover {
	background: red;
}

This CSS code will create a vertical navigation menu.

The ul element has a width of 150px and is given a black background color with no bullet points for the list items.

The list items (li) are floated to the left so that they stack vertically, and each anchor (a) element is displayed as a block with a black background, white text, and 5px of padding. When the anchor element is hovered over, it will change its background color to red.

Tkinter Introduction - Top Widget, Method, Button

First, let's make shure that our tkinter module is working ok with simple  for loop that will spawn 5 instances of blank Tk window .  ...