What Is Blockchain?

What Is Blockchain?

What Is Blockchain?

Blockchain is an irrefutably resourceful invention which is practically bringing about a revolution in the global business market. Its evolution has brought with it a greater good, not only for businesses but for its beneficiaries as well. But since it’s revelation to the world, a vision of its operational activities is still unclear. The main question stick in everyone’s mind is – What is Blockchain?

To start with, Blockchain technology serves as a platform that allows the transit of digital information without the risk of being copied. It has, in a way, laid the foundation of a strong backbone of a new kind of internet space. Originally designed to deal with Bitcoin – trying to explain the layman about the functions of its algorithms, the hash functions, and digital signature property, today, the technology buffs are finding other potential uses of this immaculate invention which could pave the way to the onset of an entirely new business dealing process in the world.

Blockchain, to define in all respects, is a kind of algorithm and data distribution structure for the management of electronic cash without the intervention of any centralized administration, programmed to record all the financial transactions as well as everything that holds value.

The Working of Blockchain

Blockchain can be comprehended as Distributed Ledger technology which was originally devised to support the Bitcoin cryptocurrency. But post heavy criticism and rejection, the technology was revised for use in things more productive.

To give a clear picture, imagine a spreadsheet that’s practically augmented tons to times across a plethora of computing systems. And then imagine that these networks are designed to update this spreadsheet from time to time. This is exactly what blockchain is.

Information that’s stored on a blockchain is a shared sheet whose data is reconciled from time to time. It’s a practical way that speaks of many obvious benefits. To being with, the blockchain data doesn’t exist in one single place. This means that everything stored in there is open for public view and verification. Further, there isn’t any centralized information storing platform which hackers can corrupt. It’s practically accessed over a million computing systems side-by-side, and its data can be consulted by any individual with an internet connection.

Durability and Authenticity of Blockchain

Blockchain technology is something that minims the internet space. It’s chic robust in nature. Similar to offering data to the general public through the World Wide Web, blocks of authentic information are stored on blockchain platform which is identically visible on all networks.

Vital to note, blockchain cannot be controlled by a single people, entity or identity, and has no one point of failure. Just like the internet has proven itself as a durable space since last 30 years, blockchain too will serve as an authentic, reliable global stage for business transaction as it continues to develop.

Transparency and Incorruptible Nature

Veterans of the industry claim that blockchain lives in a state of consciousness. It practically checks on itself every now and then. It’s similar to a self-auditing technology where its network reconciles every transaction, known as a block, which happens aboard at regular intervals.

This gives birth to two major properties of blockchain – it’s highly transparent, and at the same time, it cannot be corrupted. Each and every transaction that takes place on this server is embedded within the network, hence, making the entire thing very much visible all the time to the public. Furthermore, to edit or omit information on blockchain asks for a humongous amount of efforts and a strong computing power. Amid this, frauds can be easily identified. Hence, it’s termed incorruptible.

Users of Blockchain

There isn’t a defined rule or regulation about who shall or can make use of this immaculate technology. Though at present, its potential users are banks, commercial giants and global economies only, the technology is open for the day to day transactions of the general public as well. The only drawback blockchain is facing is global acceptance.


What Is Blockchain?

Top 25 Hadoop Interview Questions Prepared by Experts

Top 25 Hadoop Interview Questions Prepared by Experts

1) Compare Hadoop & Spark

                     

Criteria                                           Hadoop                                                   Spark

Dedicated storage                           HDFS                                                     None

Speed of processing                        average                                                excellent

Libraries                                        Separate tools available                        Spark Core, SQL, Streaming, MLlib, GraphX

 

2)    What are real-time industry applications of Hadoop?

Hadoop, well known as Apache Hadoop, is an open-source software platform for scalable and distributed computing of large volumes of data. It provides rapid, high performance and cost-effective analysis of structured and unstructured data generated on digital platforms and within the enterprise. It is used in almost all departments and sectors today.Some of the instances where Hadoop is used:

  • Managing traffic on streets.
  • Streaming processing.
  • Content Management and Archiving Emails.
  • Processing Rat Brain Neuronal Signals using a Hadoop Computing Cluster.
  • Fraud detection and Prevention.
  • Advertisements Targeting Platforms are using Hadoop to capture and analyze click stream, transaction, video and social media data.
  • Managing content, posts, images and videos on social media platforms.
  • Analyzing customer data in real-time for improving business performance.
  • Public sector fields such as intelligence, defense, cyber security and scientific research.
  • Financial agencies are using Big Data Hadoop to reduce risk, analyze fraud patterns, identify rogue traders, more precisely target their marketing campaigns based on customer segmentation, and improve customer satisfaction.
  • Getting access to unstructured data like output from medical devices, doctor’s notes, lab results, imaging reports, medical correspondence, clinical data, and financial data.

 

3)    How is Hadoop different from other parallel computing systems?

Hadoop is a distributed file system, which lets you store and handle massive amount of data on a cloud of machines, handling data redundancy. The primary benefit is that since data is stored in several nodes, it is better to process it in distributed manner. Each node can process the data stored on it instead of spending time in moving it over the network.

On the contrary, in Relational database computing system, you can query data in real-time, but it is not efficient to store data in tables, records and columns when the data is huge.

Hadoop also provides a scheme to build a Column Database with Hadoop HBase, for runtime queries on rows.

 

4)    What all modes Hadoop can be run in?

Hadoop can run in three modes:

  • Standalone Mode: Default mode of Hadoop, it uses local file stystem for input and output operations. This mode is mainly used for debugging purpose, and it does not support the use of HDFS. Further, in this mode, there is no custom configuration required for mapred-site.xml, core-site.xml, hdfs-site.xml files. Much faster when compared to other modes.
  • Pseudo-Distributed Mode (Single Node Cluster): In this case, you need configuration for all the three files mentioned above. In this case, all daemons are running on one node and thus, both Master and Slave node are the same.
  • Fully Distributed Mode (Multiple Cluster Node): This is the production phase of Hadoop (what Hadoop is known for) where data is used and distributed across several nodes on a Hadoop cluster. Sepa rate nodes are allotted as Master and Slave.

 

5)    Explain the major difference between HDFS block and InputSplit.

In simple terms, block is the physical representation of data while split is the logical representation of data present in the block. Split acts a s an intermediary between block and mapper.
Suppose we have two blocks:
Block 1: myTectra
Block 2: my Tect

Now, considering the map, it will read first block from my till ll, but does not know how to process the second block at the same time. Here comes Split into play, which will form a logical group of Block1 and Block 2 as a single block.

It then forms key-value pair using inputformat and records reader and sends map for further processing With inputsplit, if you have limited resources, you can increase the split size to limit the number of maps. For instance, if there are 10 blocks of 640MB (64MB each) and there are limited resources, you can assign ‘split size’ as 128MB. This will form a logical group of 128MB, with only 5 maps executing at a time.

However, if the ‘split size’ property is set to false, whole file will form one inputsplit and is processed by single map, consuming more time when the file is bigger.

 

6)    What is distributed cache and what are its benefits?

Distributed Cache, in Hadoop, is a service by MapReduce framework to cache files when needed. Once a file is cached for a specific job, hadoop will make it available on each data node both in system and in memory, where map and reduce tasks are executing.Later, you can easily access and read the cache file and populate any collection (like array, hashmap) in your code.

Benefits of using distributed cache are:

  • It distributes simple, read only text/data files and/or complex types like jars, archives and others. These archives are then un-archived at the slave node.
  • Distributed cache tracks the modification timestamps of cache files, which notifies that the files should not be modified until a job is executing currently.

 

7)    Explain the difference between NameNode, Checkpoint NameNode and BackupNode.

  • NameNode is the core of HDFS that manages the metadata – the information of what file maps to what block locations and what blocks are stored on what datanode. In simple terms, it’s the data about the data being stored. NameNode supports a directory tree-like structure consisting of all the files present in HDFS on a Hadoop cluster. It uses following files for namespace:
    fsimage file- It keeps track of the latest checkpoint of the namespace.
    edits file-It is a log of changes that have been made to the namespace since checkpoint.
  • Checkpoint NameNode has the same directory structure as NameNode, and creates checkpoints for namespace at regular intervals by downloading the fsimage and edits file and margining them within the local directory. The new image after merging is then uploaded to NameNode.
    There is a similar node like Checkpoint, commonly known as Secondary Node, but it does not support the ‘upload to NameNode’ functionality.
  • Backup Node provides similar functionality as Checkpoint, enforcing synchronization with NameNode. It maintains an up-to-date in-memory copy of file system namespace and doesn’t require getting hold of changes after regular intervals. The backup node needs to save the current state in-memory to an image file to create a new checkpoint.

 

8)   What are the most common Input Formats in Hadoop?

There are three most common input formats in Hadoop:

  • Text Input Format: Default input format in Hadoop.
  • Key Value Input Format: used for plain text files where the files are broken into lines
  • Sequence File Input Format: used for reading files in sequence

 

9)    Define DataNode and how does NameNode tackle DataNode failures?

DataNode stores data in HDFS; it is a node where actual data resides in the file system. Each datanode sends a heartbeat message to notify that it is alive. If the namenode does noit receive a message from datanode for 10 minutes, it considers it to be dead or out of place, and starts replication of blocks that were hosted on that data node such that they are hosted on some other data node.A BlockReport contains list of all blocks on a DataNode. Now, the system starts to replicate what were stored in dead DataNode.

The NameNode manages the replication of data blocksfrom one DataNode to other. In this process, the replication data transfers directly between DataNode such that the data never passes the NameNode.

 

10)    What are the core methods of a Reducer?

The three core methods of a Reducer are: setup(): this method is used for configuring various parameters like input data size, distributed cache. public void setup (context) reduce(): heart of the reducer always called once per key with the associated reduced task public void reduce(Key, Value, context) cleanup(): this method is called to clean temporary files, only once at the end of the task public void cleanup (context)

 

11)    What is SequenceFile in Hadoop?

Extensively used in MapReduce I/O formats, SequenceFile is a flat file containing binary key/value pairs. The map outputs are stored as SequenceFile internally. It provides Reader, Writer and Sorter classes. The three SequenceFile formats are: Uncompressed key/value records. Record compressed key/value records – only ‘values’ are compressed here. Block compressed key/value records – both keys and values are collected in ‘blocks’ separately and compressed. The size of the ‘block’ is configurable.

 

12)    What is Job Tracker role in Hadoop?

Job Tracker’s primary function is resource management (managing the task trackers), tracking resource availability and task life cycle management (tracking the taks progress and fault tolerance). It is a process that runs on a separate node, not on a DataNode often. Job Tracker communicates with the NameNode to identify data location. Finds the best Task Tracker Nodes to execute tasks on given nodes. Monitors individual Task Trackers and submits the overall job back to the client. It tracks the execution of MapReduce workloads local to the slave node.

 

13)    What is the use of RecordReader in Hadoop?

Since Hadoop splits data into various blocks, RecordReader is used to read the slit data into single record. For instance, if our input data is split like: Row1: Welcome to Row2: Intellipaat It will be read as “Welcome to Intellipaat” using RecordReader.

 

14)   What is Speculative Execution in Hadoop?

One limitation of Hadoop is that by distributing the tasks on several nodes, there are chances that few slow nodes limit the rest of the program. Tehre are various reasons for the tasks to be slow, which are sometimes not easy to detect. Instead of identifying and fixing the slow-running tasks, Hadoop tries to detect when the task runs slower than expected and then launches other equivalent task as backup. This backup mechanism in Hadoop is Speculative Execution. It creates a duplicate task on another disk. The same input can be processed multiple times in parallel. When most tasks in a job comes to completion, the speculative execution mechanism schedules duplicate copies of remaining tasks (which are slower) across the nodes that are free currently. When these tasks finish, it is intimated to the JobTracker. If other copies are executing speculatively, Hadoop notifies the TaskTrackers to quit those tasks and reject their output. Speculative execution is by default true in Hadoop. To disable, set mapred.map.tasks.speculative.execution and mapred.reduce.tasks.speculative.execution JobConf options to false.

 

15)    What happens if you try to run a Hadoop job with an output directory that is already present?

It will throw an exception saying that the output file directory already exists.

To run the MapReduce job, you need to ensure that the output directory does not exist before in the HDFS.

To delete the directory before running the job, you can use shell:Hadoop fs –rmr /path/to/your/output/Or via the Java API: FileSystem.getlocal(conf).delete(outputDir, true);

 

16)    How can you debug Hadoop code?

First, check the list of MapReduce jobs currently running. Next, we need to see that there are no orphaned jobs running; if yes, you need to determine the location of RM logs.

  1. Run: “ps –ef | grep –I ResourceManager”
    and look for log directory in the displayed result. Find out the job-id from the displayed list and check if there is any error message associated with that job.
  2. On the basis of RM logs, identify the worker node that was involved in execution of the task.
  3. Now, login to that node and run – “ps –ef | grep –iNodeManager”
  4. Examine the Node Manager log. The majority of errors come from user level logs for each map-reduce job.

 

17)   How to configure Replication Factor in HDFS?

hdfs-site.xml is used to configure HDFS. Changing the dfs.replication property in hdfs-site.xml will change the default replication for all files placed in HDFS.
You can also modify the replication factor on a per-file basis using the

Hadoop FS Shell:[training@localhost ~]$ hadoopfs –setrep –w 3 /my/fileConversely,

you can also change the replication factor of all the files under a directory.

[training@localhost ~]$ hadoopfs –setrep –w 3 -R /my/dir

 

18)    How to compress mapper output but not the reducer output?

To achieve this compression, you should set:

conf.set(“mapreduce.map.output.compress”, true)

conf.set(“mapreduce.output.fileoutputformat.compress”, false)

 

19)    What is the difference between Map Side join and Reduce Side Join?

Map side Join at map side is performed data reaches the map. You need a strict structure for defining map side join. On the other hand, Reduce side Join (Repartitioned Join) is simpler than map side join since the input datasets need not be structured. However, it is less efficient as it will have to go through sort and shuffle phases, coming with network overheads.

 

20)    How can you transfer data from Hive to HDFS?

By writing the query:

hive> insert overwrite directory ‘/’ select * from emp;

You can write your query for the data you want to import from Hive to HDFS. The output you receive will be stored in part files in the specified HDFS path.

 

21)   What companies use Hadoop, any idea?

 Yahoo! (the biggest contributor to the creation of Hadoop) – Yahoo search engine uses Hadoop, Facebook – Developed Hive for analysis,Amazon,Netflix,Adobe,eBay,Spotify,Twitter,Adobe.

 

22)    In Hadoop what is InputSplit?

It splits input files into chunks and assign each split to a mapper for processing.

 

23)    Mention Hadoop core components?

Hadoop core components include,

  • HDFS
  • MapReduce

 

24)    What is NameNode in Hadoop?

NameNode in Hadoop is where Hadoop stores all the file location information in HDFS. It is the master node on which job tracker runs and consists of metadata.

 

25)    Mention what are the data components used by Hadoop?

Data components used by Hadoop are

  • Pig
  • Hive

 


Top 25 Hadoop Interview Questions Prepared by Experts

Windows Powershell Commands for Beginners

Windows Powershell Commands for Beginners

 

Agenda

  • Introduction of Powershell
  • Need of powershell
  • BackGround of Powershell
  • Tools
  • Why its better than alternatives ?
  • Top Most Administrative Powershell Commands
  • Working with Pipeline
  • Selecting, Sorting, Measuring, Exporting, Importing, Converting,     Filtering, Passing Data in Pipeline.
  • Using PSProviders and PSDrives
  • Formatting Output
  • Introduction of WMI (Windows Management Instrumentation)
  • Condition
  • Looping (For/ Eor-each/While)
  • Take user Input
  • Display Output
 Introduction
  • This Shell is Command line based or can be included to GUI.
  • Developed by Microsoft
  • Based on .Net Framework
  • It includes Scripting.
  • Capability to interact with another Windows based Softwares, for instances:-
  • Citrix, SQL, AD, any open APIs like Slack etc.

Designed by Jeffrey Snover, Bruce Payette, James Truher (et al.)
Developer Microsoft
First appeared November 14, 2006

Stable release 5.1.14393 / August 2, 2016; 8 months ago
Preview release 6.0.0 Alpha 17 / March 8, 2017; 35 days ago
Typing discipline Strong, safe, implicit and dynamic
Platform .NET Framework, .NET Core
OS Windows 7 and later, macOS, CentOS, Ubuntu

Filename extensions
•.ps1 (Script)
•.ps1xml (XML Document)
•.psc1 (Console File)
•.psd1 (Data File)
•.psm1 (Script Module)
•.pssc (Session Configuration File)
•.cdxml (Cmdlet Definition XML Document)

What’s Need ?   

  • Microsoft describes PowerShell as “a task-based command-line shell and scripting language… built on the .NET Framework.”  What is so great about PowerShell?  Why should you use it?
  • PowerShell is both a command-line shell and scripting language
  • PowerShell can interact with a dizzying number of technologies.
  • .NET Framework, the Registry, COM, WMI, ADSI.  Exchange, Sharepoint, Systems Center, Hyper-V, SQL.   VMware vCenter,Cisco UCS, Citrix XenApp and XenDesktop.  REST APIs, XML, CSV, JSON, websites, Excel and other Office applications.  C# and other languages, DLLs and other binaries, including *nix tools.
  • PowerShell is object-based.This gives us incredible flexibility.  Filter, sort, measure, group, compare or take other actions on objects as they pass through the pipeline.  Work with properties and methods rather than raw text.
  • Microsoft is putting its full weight behind PowerShell.PowerShell isn’t going away.  It is a requirement in the Microsoft Common Engineering Criteria, and a Server product cannot be shipped without a PowerShell interface.
  • In many cases, Microsoft is building their GUI with the help of Powershell only. Here we can perform more than what we think on GUI.
  • PowerShell also provides a hosting API with which the PowerShell runtime can be embedded inside other applications.

BackGround   

  • Every released version of Microsoft DOS and Microsoft Windows for personal computers has Shell, so till Windows9x, it was relying on Command.com and later on in NT family it came as cmd.exe
  • In 1998, MS launched Cscript.exe to allow compatible scripting languages like Jscript and VBScript.
  •  By 2002 Microsoft had started to develop a new approach to command line management, including a shell called Monad (also known as Microsoft Shell or MSH) 
  • PowerShell version 1 was released on September 26, 2006 , but officially released on Nov 14, 2006.       
  •   PowerShell v2.0 was completed and released to manufacturing in August 2009, as an integral part of Windows 7 and Windows Server 2008 R2
  • On 18 August 2016, Microsoft announced that they had made PowerShell open-source and cross-platform with support for Windows, OS X, CentOS and Ubuntu.
  • The move to open source created a second incarnation of PowerShell called “PowerShell Core”, which runs on .NET Core. It is distinct from “Windows PowerShell”, which runs on the full .NET Framework. Starting with version 5.1, PowerShell Core is bundled with Windows Server 2016 Nano Server.

Inbuilt Tools   

 
Better
•Powershell is better than its legacy alternatives like :-VBScripting, Bash
•Consistent syntax, consistent command structure
•Future-proof through .NET integration
•Support through help and documentation (Get-Help)

Easy to find out any way, just clue is required. (Get-Command “*Service*” )

Get-Help
 
 
         
Top-Most Used
  1.  Navigate the Windows Registry like the file system:cd hkcu:
  2.  Search recursively for a certain string within files:dir –r | select string “searchforthis”
  3.  Find the five processes using the most memory:ps | sort –p ws | select –last 5
  4.  Cycle a service (stop, and then restart it) like DHCP:Restart-Service DHCP
  5.  List all items within a folder:Get-ChildItem – Force
  6.  Recurse over a series of directories or folders:Get-ChildItem –Force c:directory –Recurse
  7. Remove all files within a directory without being prompted for each:Remove-Item C:tobedeleted –Recurse
  8. Restart the current computer:(Get-WmiObject -Class Win32_OperatingSystem -ComputerName .).Win32Shutdown(2)


Collecting information
  •  Get information about the make and model of a computer:Get-WmiObject -Class Win32_ComputerSystem
  •  Get information about the BIOS of the current computer:Get-WmiObject -Class Win32_BIOS -ComputerName .
  • List installed hotfixes — QFEs, or Windows Update files:Get-WmiObject -Class Win32_QuickFixEngineering -ComputerName .Get the username of the person currently logged on to a computer:
  • Get-WmiObject -Class Win32_ComputerSystem -Property UserName -ComputerName .
  • Find just the names of installed applications on the current computer:
  • Get-WmiObject -Class Win32_Product -ComputerName . | Format-Wide -Column 1
  • Get IP addresses assigned to the current computer:Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter IPEnabled=TRUE -ComputerName . | Format-Table -Property IPAddress
  •  Get a more detailed IP configuration report for the current machine:Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter IPEnabled=TRUE -ComputerName . | Select-Object -Property [a-z]* -ExcludeProperty IPX*,WINS*
  •  Find network cards with DHCP enabled on the current computer:Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter “DHCPEnabled=true” -ComputerName .
  •  Enable DHCP on all network adapters on the current computer:
  • Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter IPEnabled=true -ComputerName . | ForEach-Object -Process {$_.EnableDHCP()}

Software management

 
  • Install an MSI package on a remote computer:(Get-WMIObject -ComputerName TARGETMACHINE -List | Where-Object -FilterScript {$_.Name -eq “Win32_Product”}).Install(MACHINEWHEREMSIRESIDESpathpackage.msi)
  • Upgrade an installed application with an MSI-based application upgrade package:
  • (Get-WmiObject -Class Win32_Product -ComputerName . -Filter “Name=’name_of_app_to_be_upgraded'”).Upgrade(MACHINEWHEREMSIRESIDESpathupgrade_package.msi)
  •  Remove an MSI package from the current computer:(Get-WmiObject -Class Win32_Product -Filter “Name=’product_to_remove'” -ComputerName . ).Uninstall()

Machine management

 

 

 

 

  • Remotely shut down another machine after one minute:Start-Sleep 60; Restart-Computer –Force –ComputerName TARGETMACHINE
  •  Add a printer:(New-Object -ComObject WScript.Network).AddWindowsPrinterConnection(“printerserverhplaser3”)
  • Remove a printer:(New-Object -ComObject WScript.Network).RemovePrinterConnection(“printerserverhplaser3 “)
  • Enter into a remote PowerShell session — you must have remote management enabled:enter-pssession TARGETMACHINE
  • Use the PowerShell invoke command to run a script on a remote servers:invoke-command -computername machine1, machine2 -filepath c:Scriptscript.ps1

Multiple Ways to perform One Task 

 
Shutdown a computer
 
Stop-Computer “ComputerName1, Name2”Stop-Computer –computer DC1 –Credential nwtradersadministrator
Shutdown –i (to restart/shutdown bulk of computer in one shot with message)
Restart-Computer “ComputerName1”
Get-wmiobject –class WIN32_OperatingSystem –ComputerName .).Invokemethod(“Win32Shutdown”,0)Or (gwmi Win32_OperatingSystem).Win32Shutdown(0).
1.Log Off   “0”
2.Forced Log Off   “4”
3.Shutdown “1”
4.Forced Shutdown “5”
5.Reboot  “2”
6.ForcedReboot  “6”
7.Power Off  “8”
8.Forced Power Off  “12”
 
Concept of Pipeline ( | )
 
  • Pipelining could almost be described as PowerShell’s signature tune.
  • Piping work almost everywhere in Powershell
  • PowerShell does not pipe text between commands. Instead, it pipes objects.
  • Piping is used for several purposes like:- got a focused result, use output of previous command to further within same line,filtering.
  • PowerShell encourages you to join two statements so that the output of the first clause, becomes the input of the second clause.Example :-  Get-Process
 
 
 
 
Selecting,Sorting,Measuring,Exporting,Importing,Converting,Filtering,…
 
 
Select or Select-Object Get-process | Select ID,ProcessName
 
 
 
 
Sorting
 
  • Sort-Object
 
 
 
Measuring
 
  • Measure-Object / Count
 
 
 
Exporting/ Converting
 
  • Export-csv/
 
 
  • Get-childitem > c:test1.txt
  • Get-childitem | Out-File c:test2.txt 
  • ConvertTo-Html
 
 

ConvertTo-SecureString :- Convert any string into Encrypted form

-AsSecureString :- Take input from user in secure way

$var = Read-Host -AsSecureString

$var1 = ConvertTo-SecureString -SecureString $var

 

Filtering

  • Where-Object
 
 
 
 
Formatting Output
 
 
 
 
 
 
 
Variable ($)
 
  • $var = (get-process).count
  • Windows PowerShell works with objects. Windows PowerShell lets you create variables – essentially named objects – to preserve output to use later. If you are used to working with variables in other shells, remember that Windows PowerShell variables are objects, not text.
  • Variables are always specified with the initial character $, and can include any alphanumeric characters or the underscore in their names.

IF / IF-Else

 
$var = (get-process).countif($var -gt 110)
{
Write-Host “We have $var process in running state “
}
Else {
Write-Host “Number of Processes are less than 100 in count.”
 
 
 
 
Read User Input/Display Output
 
• $var =Read-Host –prompt “Enter your Name:”
 
 
 
Display output:-  Write-Host / Echo / Write-Output
 
 
 
 
Write-Host
 

Write-Host is having more attributes

 

Write-Host –NoNewLine “Counting from 1 to 9 (in seconds):  “

 

foreach($element in 1..9){

 

  Write-Host –NoNewLine  “${element} “

 

  Start-Sleep –Seconds 1

 

}

 

Write-Host “”

Output :-  Counting from 1 to 9 (in seconds):  1 2 3 4 5 6 7 8 9 

 

Write-Output

 

Write-Output should be used when you want to send data on in the pipe line, but not necessarily want to display it on screen.

 

PS C:> Write-Output”test output” | Get-Member

 

This command pipes the “test output” string to the Get-Member cmdlet, which displays the members of the System.String class, demonstrating that the string was passed along the pipeline.

 

 

 

 Loops 

 

  • Looping are required to perform a repeated set of operations for number of times.
  • These above mentioned are three major loop techniques:
  1. For Loop
  2. For-each Loop
  3. While Loop
  4. Do While
 For / For-Each  Loop 
 
 
 

ForEach is specially used to fetch elements from an array

 

 

While/ Do-While Loop 

 

While :-  As long as the condition remains true, PowerShell reruns the {command_block} section.

while($val -ne 10) { $val++ Write-Host $val }

 

Do-While:- First the Command Block will run and then it will check condition

Do {

$val++ Write-Host $val

} while($val -ne 10)

 

Importing 

 

Get-Content :- To Read content from a file (.txt/ .csv /.xlsx)

 

$var = Get-Content -Path .Desktopnames.txt

 

foreach ($i in $var)

 

{

 

Write-Host $i

 

Start-Sleep -Seconds 1

 

  • Import-csv :- To Read Data from csv file $var = Import-Csv -Path .Desktopnames.csv 

 


Windows Powershell Commands for Beginners

Will Python Replace Java?

Will Python Replace Java?

 

According to the IT programming trend, Java is currently more popular than other programming languages in terms of number of jobs, number of existing Java developers and overall usage statics in IT compared to Python. According to the latest usage statistics posted on a popular Technology Survey site, Java is being used by 3.0% websites as a server-side programming language, whereas only 0.2% of websites use Python. However, all the recent reports have highlighted that the usage and popularity of Python is growing drastically compared to Java where the Java usage is coming down year on year.

 

In the below table we could able to see that Java requirement is coming down year on year whereas Python requirement has grown from 200 in 2014 to 6500+ in 2017.

 

Language

2014 April   

2015 April   

2016 April   

2017 April

Java Job Posting for Bangalore City

17000+

17000+

15000+

12000+

Python Job Posting for Bangalore City

200+

500+

3500+

6500+

 

Job Posting Statistics shows python is the only Programming language consistently growing compared to Java which is going down drastically.

So it becomes essential for programmers to understand some of the major differences between these two popular programming languages.

 

Understanding Important Differences between Java and Python

 

Both Java and Python are general purpose programming languages. While the former is a statically typed language wherein the programmers have to declare all variable names explicitly, the latter is looked upon as a dynamically typed language where developers are not required to declare variable names explicitly.

 

Java requires developers to write longer lines of code to accomplish common programming tasks. They also have to put in additional time and effort to organize, maintain and update the Java code base. On the other hand, syntax of Python enables developers to express concepts without writing longer lines of code. It further emphasizes on reusable and readable code generation. Thus, it becomes easier for programmers to maintain and update the code base.

Both the languages have been updated on a regular basis. The programmers can use Java 8 to avail a number of new features including lambda expressions, a new date/time API and a new functional interface. They can further switch from version 7 to version 8 of the programming language without any hassle. But developers often find it daunting to choose between Python 2.x and Python 3.x. Both the versions are being maintained in parallel and hence switching from Python 2.x to Python 3.x is found to be challenging.

 

Java makes it easier for programmers to create portable cross-platform applications. These applications can run on any device on which Java virtual machine (JVM) is running. On the other hand, the developers have to use a Python compiler to convert the code written in Python into code understandable by the specific operating system. As JVM is installed on many devices, the developers can run Java applications on various devices without requiring any specialized tools and compilers.

 

The performance and speed of the two programming languages differ. Many programmers have proved that Java is faster than Python. While it cannot be used to accomplish CPU-intensive tasks, developers often have at their disposal, a number of options to enhance the execution speed of Python. They have to replace Python’s default runtime with CPython, PyPy or Cython to increase the execution speed significantly. On the other hand, the performance of the Java application can be easily optimized without using any additional tools.

 

Along with being a popular web technology, Java is also used widely for developing apps for world’s most popular mobile operating system, i.e., Android. The Android SDK includes a number of standard Java libraries. The developers can easily create Android apps by taking advantage of networking, data structure, graphics, and math libraries. They can even avail a number of tools and frameworks to speed up Android app development. But those into Python development know that it cannot be used for mobile app development directly and exclusively. The developers have to use additional frameworks and tools to use it for mobile app development. Many programmers prefer developing mobile apps with Java to save both time and effort.

 

The reason for Python  is becoming more popular and huge surge in number of requirement year on year is Python become a language of choice for all the current trending Technologies in IT. Python adopted as a language of choice for almost all the domain in IT including Web Development, Cloud Computing (AWS, OpenStack, VMware, Google Cloud, Oracle Cloud, etc.. ), Infrastructure Automation , Software Testing, Mobile Testing, Big Data and Hadoop, Data Science, etc. If the current trends continues Python will become the most sought after language and overtake the number of jobs requirement in next 2-3 years.

To read original post, click here 


Will Python Replace Java?