Monday, December 16, 2019

Python program to demonstrate all stack operations using a doubly linked list

Write a python program to demonstrate all stack operations using a doubly linked list  :


Answer:

class Node:
 
    def __init__(self, data):
        self.data = data # Assign data
        self.next = None # Initialize next as null
        self.prev = None # Initialize prev as null       
         

class Stack:
    # Function to initialize head 
    def __init__(self):
        self.head = None

    def push(self, data):
 
        if self.head is None:
            self.head = Node(data)
        else:
            new_node = Node(data)
            self.head.prev = new_node
            new_node.next = self.head
            new_node.prev = None
            self.head = new_node
             

    def pop(self):
 
        if self.head is None:
            return None
        else:
            temp = self.head.data
            self.head = self.head.next
            self.head.prev = None
            return temp
 
 

    def top(self):
 
        return self.head.data
 
 

    def size(self):
 
        temp = self.head
        count = 0
        while temp is not None:
            count = count + 1
            temp = temp.next
        return count
           
    def isEmpty(self):
 
        if self.head is None:
           return True
        else:
           return False
             

    def printstack(self):
         
        print("stack elements are:")
        temp = self.head
        while temp is not None:
            print(temp.data, end ="->")
            temp = temp.next         
         
 
       
if __name__=='__main__': 
 

  stack = Stack()
 
  print("Stack operations using Doubly LinkedList")
  stack.push(4)
 

  stack.push(5)
 

  stack.push(6)
 

  stack.push(7)
 
  stack.printstack()
 

  print("\nTop element is ", stack.top())
 

  print("Size of the stack is ", stack.size())
 

  stack.pop()
 

  stack.pop()
   


  stack.printstack()
   

  print("\nstack is empty:", stack.isEmpty())




Output:
Stack operations using Doubly LinkedList
stack elements are:
7->6->5->4->
Top element is  7
Size of the stack is  4
stack elements are:
5->4->
stack is empty: False

Python program to create a list of tuples from given list having number and its cube in each tuple

Write a python program to create a list of tuples from given list having number and its cube in each tuple:


Answer:

list1 = [1, 2, 7, 8]
res = [(val, pow(val, 3)) for val in list1]
print(res)

Output:
[(1, 1), (2, 8), (7, 343), (8, 512)] 

Saturday, December 14, 2019

Break bulk cargo

 Break bulk cargo :

 Break bulk cargo is transported in bags, boxes, crates, drums, or barrels. Unit loads of items secured to a pallet or skid are also used, break bulk cargo or general cargo are goods that must be loaded individually, and not in inter-modal containers nor in bulk as with oil or grain. Ships that carry this sort of cargo are called general cargo ships.

There are many sorts of break bulk cargo but among them are:

Bagged cargo:
Bagged cargo (e.g. coffee in sacks) is stowed on double dunned and kept clear of the ship's sides and bulk heads.
Bags are kept away from pillars and stanchions by covering it with matting or waterproof paper.


Baled goods:
Baled goods are stowed on single dunnage at least 50 mm (1.97 in) thick. The bales must be clean with all the bands intact.
Stained or oily bales are rejected. All fibers can absorb oil and are liable to spontaneous combustion.
As a result, they are kept clear of any new paintwork. Bales close to the deckhead are covered to prevent damage by dripping sweat.


Barrels and casks:
Wooden barrels are stowed on their sides on "beds" of dunnage which keeps the middle of the side (the bilge) off the deck and they are stowed with the bung at the top.
To prevent movement, wedges called quoins are put in on top of the "beds".
Barrels should be stowed fore and aft and not athwart ships.
Once the first tier has been loaded the next tier of barrels fits into the hollows between the barrels, this is known as stowing "bilge and cant-line".
Barrels which are also known as casks or tuns are primarily use for transporting liquids such as wine, water, brandy, whiskey, and even oil.
They are usually built in spherical shape to make it easier to roll and have less friction when changing direction.

Corrugated boxes:
Corrugated box design is the process of matching design factors for corrugated fiberboard boxes with the functional physical, processing and end-use requirements.
Packaging engineers work to meet the performance requirements of a box while controlling total costs throughout the system.
Corrugated boxes are stowed on a good layer of dunnage and kept clear of any moisture.
Military and weather-resistant grades of corrugated fiberboard are available.
They are not over-stowed with anything other than similar boxes.
They are frequently loaded on pallets to form a unit load; if so the slings that are used to load the cargo are frequently left on to facilitate discharge.


Wooden shipping containers:
Wooden boxes or crates are stowed on double dunnage in the holds and single dunnage in the 'tween decks. Heavy boxes are given bottom stowage.
The loading slings are often left on to aid discharge.

Drums:
Metal drums are stowed on end with dunnage between tiers, in the longitudinal space of the ship

Paper reels:
Reels or rolls are generally stowed on their sides and care is taken to make sure they are not crushed.

Motor vehicles:
Automobiles are lifted on board and then secured using lashings. Great care is taken to prevent damage.
Vehicles are prepared by removing hazardous liquids (gasoline, etc.).
This is in contrast to ro-ro (roll-on/roll-off) vessels where vehicles are driven on and off the ship under their own power.

Steel girders:
Any long heavy items are stowed fore and aft. If they are stowed athwart ships they are liable to shift if the ship rolls heavily and pierce the side of the ship.

Cargo - Transportation - Mode of transport - Freight

Cargo meaning, goods carried on a ship, aircraft, or motor vehicle, which is the transportation of bulk cargo.

Transportation is used for moving of people, animals, and other goods from one place to another.

List of cargo types:
1. Break bulk cargo or General cargo
2. Bulk cargo (Bulk dry cargo)
3. Bulk liquid cargo
4. Container cargo
5. Neo-bulk cargo
6. Passenger cargo
7. Project cargo
8. Refrigerated cargo
9. Roll-on/roll-off cargo


Break Bulk:
Concerns cargo that is carried in drums, bags, pallets or boxes. Such ships are typically geared.

Neo Bulk:
Concerns cargo where each pre-packaged unit is accountable such as lumber (bundles), paper (rolls), steel and vehicles.

Containerized:
The growth of container shipping required the creation of a new general cargo category where the cargo is being carried in container load units.

Liquid bulk:
The majority of the liquid bulk being carried is petroleum LNG (Liquefied Natural Gas) represents an emerging segment.
Liquid bulk ships are commonly referred as tankers.

Dry Bulk:
Concerns a wide variety of materials such as coal, iron ore, grains bauxite and sand.


The term cargo is also used in case of goods in the cold-chain,
because the perishable inventory is always in transit towards a final end-use,
 even when it is held in cold storage or other similar climate-controlled facility.
The term freight is commonly used to describe the movements of flows of goods being transported by any mode of transportation.

The means of transport, on the other hand, refers to the vehicles necessary for transport according to the chosen mode i.e. airplane, ship, truck and rail.
Each mode of transport has a fundamentally different technological solution, and some require a separate environment.
Each mode has its own infrastructure, vehicles, and operations.

Mode of transport:
Mode of transport is a term used to distinguish between different ways of transportation or transporting people or goods.

The different modes of transport are
1. Air,
2. Water,and
3. Land transport, which includes Rails or railways, road and off-road transport.
Other modes also exist, including pipelines, cable transport, and space transport.
Human-powered transport and animal-powered transport are sometimes regarded as their own mode, but never fall into the other categories.

Friday, December 13, 2019

Write a program in python to Find Reverse of a Number

Write a program in python to Find Reverse of a Number

# Python Program - Find Reverse of a Number

print("Enter 'x' for exit.");
num = input("Enter any number: ");
if num == 'x':
    exit();
try:
    number = int(num);
except ValueError:
    print("Please, enter a number...");
else:
    rev = 0;
    while number > 0:
    rev = (rev*10) + number%10;
    number //= 10;
    print("Reverse of entered number =",rev);

Write a program in python to Calculate Circumference of Circle


Write a program in python to Calculate Circumference of Circle


# Python Program - Calculate Circumference of Circle

print("Enter 'x' for exit.");
rad = input("Enter radius of circle: ");
if rad == 'x':
    exit();
else:
    radius = float(rad);
    circumference = 2*3.14*radius;
    print("\n Circumference of Circle =",circumference);

Write a program in python to Calculate Perimeter of Square

Write a program in python to Calculate Perimeter of Square


# Python Program - Calculate Perimeter of Square

print("Enter 'x' for exit.");
side = input("Enter side length of square: ");
if side == 'x':
    exit();
else:
    slength = int(side);
    perimeter = 4*slength;
    print("\nPerimeter of Square =", perimeter);

From Side Hustle to Main Income: 7 Proven Ways to Make Money Online in 2025

  From Side Hustle to Main Income: 7 Proven Ways to Make Money Online in 2025 Introduction: The New Era of Earning – Why 2025 is Your Year t...