Wednesday, 22 December 2021

Append Value To A Dictionary/Map in Python | Solution to 100 Days Python Challenge in Udemy

 Please find the below code for appending a value to a Python dictionary. In the below program our aim is to add a new entry to the existing python dictionary.

#First one is the existing travel log list

travel_log = [
{
  "country""France",
  "visits"12,
  "cities": ["Paris""Lille""Dijon"]
},
{
  "country""Germany",
  "visits"5,
  "cities": ["Berlin""Hamburg""Stuttgart"]
},
]

#Defining a function that will add a new entry to the existing travel log.

def add_new_country(country,visits,cities):
    #Below we are creating a dictionary that will take parameters from the function
and append to the travel log.
    
    countrydict = {}
    countrydict["country"] = country
    countrydict["visits"] = visits
    countrydict["cities"] = cities
    travel_log.append(countrydict)

#Below we are calling the function that has been created above

add_new_country("Russia"2, ["Moscow""Saint Petersburg"])
print(travel_log)

Output:

Sunday, 12 December 2021

Python Swap Variable Program - Function For Swapping Variable In Python

 Please find the below code for swapping the variable in Python with line by line explanation


a = input("a: ") // This input commands get the value from user for "a" variable
b = input("b: ") // This input commands get the value from user for "b" variable

var =a; // This line of code is to store value of "a" in different variable in order to
facilitate swap.
a = b; //Now value of "b" is stored in "a"
b=var; //The mdofiied value of "a" is now stored in "b"

print("a: " + a) //This one prints the swapped value of "a"
print("b: " + b) //This one prints the swapped value of "b"

Note: the print function is used to print a value
     the input function is used to get the input value from the user

Sunday, 5 December 2021

Solution For Indentation Error: Unexpected Indent Python

 In python "Indentation Error: Unexpected Indent" is a very important error that you should know.


In python, it is very important to not add unnecessary spaces or a tab in front of a code line. That's the main reason these errors are caused.


For example in the below code, if you see the third line there is additional space before the beginning of the print function.


print("String Manipulation")
print('String Concatenation: done with the "+" sign.')
    print('e.g. print("Hello" + "world")')
print("New lines can be created with a backslash and n.")

The simple thing you need to do in order to overcome this Indentation Error: Unexpected
Indent is to remove the additional space in front of line number 3.


Solution:

print("String Manipulation")
print('String Concatenation: done with the "+" sign.')
print('e.g. print("Hello" + "world")')
print("New lines can be created with a backslash and n.")

This will give you a successful output.

Sunday, 19 January 2014

How To Build A Static website | Static Websites Example

PREVIOUS CHAPTER                                                                                            NEXT CHAPTER

How To Build A Static Website |How To Set up a Website On Your Local 

There are lot of ways to create a simple static website. As I said Static Websites are just a website for a shop or company that only gives information and can't be updated form the user end.

Things needed to Build a Static Website

1) You should have some basic knowledge of HTML and CSS. There are websites like w3schools and tutorialspoint helps in developing your knowledge.

2) You need a design and layout for a website to hold contents. CSS will help you to do that.

3) Don't worry if you don't know the basic designs, you can download templates from websites for free and can edit as per your wish. 

Best Software to Build a Website / Static

1) Notepad is enough to build a website. You can do anything with notepad but when you create a website with note pad and you want create a more pages in a website it would become complex in future.

2) So I better suggest you to use Development tools like Dreamweaver which is made specially for building a website.

3) If you are familiar with professional IDE's Likes eclipse or Netbeans then you can use that to build a website.
Note: Usage of PHP will reduce your effort build complex websites.

In the next chapter I will give you teh complete overview of Dynamic website and how to see your website live. In technical terms how to host your website.

PREVIOUS CHAPTER                                                                                            NEXT CHAPTER

Ways To Create Website | Best ways To Create Website

PREVIOUS CHAPTER                                                                                            NEXT CHAPTER

How to write the code for it | Ways To Set Up Code

There are many ways to create a website. You can write a code or you can use CMS portal.

Basic Types Of Websites

Two Basic types of Websites are Static And Dynamic websites.

Static Websites Overview

Static Websites are the one in which the contents are constant and users can't post any request or modify the website. Changes to the website can be done only by the Developer. It just delivers information and very cheap to build and also easy to maintain.

Example For Static Websites

1) Company Websites
2) Corporate Websites.

Dynamic Websites Overview

Dynamic websites are the one in which user can update information from his end. Otherwise the content of the website changes easily i,e. updated by the developer at regular intervals with out any change to the code.
Dynamic websites are complex to build.

Example For Dynamic Websites

1) Most News portals and Informational Websites are Dynamic
2) Blogs

See the next chapter for the ways to build a basic static and Dynamic Websites.

PREVIOUS CHAPTER                                                                                        NEXT CHAPTER

Sunday, 13 October 2013

How just dial works | How Just dial search functions

How Justdial Works Overview

About Justdial


Justdial, founded by V.S.S Mani, is one of the India’s leading local search engines. It’s grown by leaps and bounds, and now caters to over 25 million unique users across 240 cities in India. It employs over 4,000 people and has more than 125,000 SME advertisers today. And behind this successful business is none other than the “open” hand!


Functioning Of Justdial

Justdial relies on open source technology which supports scalability in a seamless manner. Just dial adopted CLAMP Stack, about 300 servers connecting 3500 workstations at just dial, are powered by this CLAMP stack. CLAMP stands for Cloud Flare + LAMP (LINUX, APACHE, MYSQL and PHP).


Significance of CLAMP

Justdail using Cloud Flare to extend the scalability of the LAMP stack from an individual machine to a global network. Cloud Flare cuts the load on a typical LAMP stack web server by nearly 70%. That allows you to put twice the load on a single server the LAMP burning out.


REDHAT AND LINUX

Just Dial chose Red Hat Enterprise Linux (RHEL) to power its servers, Ubuntu on the desktop front, MySQL, PostgreSQL and MongoDB for database management, and WebHuddle for Web conferencing and video conferencing. While performance, security of the platform and trust in Red Hat made Just Dial bet on RHEL, the optimal network stack in Ubuntu won Just Dial’s confidence in the Ubuntu OS. Moreover open source technologies helps in refining the search logic. 


Justdail search Functioning

The company uses a search engine called Sphinx, a standalone search engine, which is a full text search engine written in C code that designed well to integrate with SQL databases on its LAMP architecture that is where non database queries searches gains relevance. The built in drivers helps in fetching the data either via direct connection to MYSQL or PostergeSQL.


Why Open source

Reasons why Just dial Choses an Open Source Platform 
1) Secure 
2) High Performance
3) Flexibility 
4) Cost Efficiency 
5) Scalability 

Open source mainly reduces the cost burden for any concern. if anyone choses Microsoft, they would have bled paying the licensing fees for 4,000 desktops and 200 servers(in justdial). But Justdial paid only Redhat subscription fee and MYSQL’s golden ticket fee, which is minimum when compared to any proprietary vendor.


Maintenance of the infrastructure

Maintenance of such an infrastructure could have been a nightmare, especially with all the innovation embedded into it. With the support of Redhat and Just Dial’s fully equipped IT team, helped Justdial address this challenge without too much trouble.

Tuesday, 1 October 2013

Best Ways To Create Free Website | How To Create Free Professional Website | Tutorial

Steps To Create Good Looking Website : Tutorial

There several ways for creating a free good looking websites. Either you can develop your own website or you can hire a designer for creating a website.

What are the steps for creating a website


1) Set up the code for your website.

2) Test run your website on your local server.

3) Then the next thing you need is, a domain name (www.example.com) to host your website.

4) After that you need a hosting center (Ex:- Godaddy.com) where your website is hosted. Don't worry about hosting I will let you know in the coming chapters. 

 These are the simple basic steps you need to create a website.

Where can you get your domain name ?
There are several website which lets you register your domain for 1 to 5 years. After that you can extend the duration as per your need. 

There are lot of technical and general tactics involved in creating a website. The building and maintenance of website is not as difficult as you and also not as easy you think. I will give you the complete information about running a professional website both in general and technical ways.