PYTHON AND HADOOP BASICS PROGRAMMING FOR BEGINNERS - 2 BOOKS IN 1 - Learn Coding Fast PYTHON AND HADOOP Crash Course, A… (TAM SEL J KING [SEL, TAM]) (Z-Library)
Author: TAM SEL & J KING [SEL, TAM]
Python
No Description
📄 File Format:
PDF
💾 File Size:
2.4 MB
48
Views
0
Downloads
0.00
Total Donations
📄 Text Preview (First 20 pages)
ℹ️
Registered users can read the full content for free
Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.
📄 Page
1
(This page has no text content)
📄 Page
2
(This page has no text content)
📄 Page
3
PYTHON AND HADOOP BASICS PROGRAMMING FOR BEGINNERS J KING
📄 Page
4
PYTHON INTRODUCTION PYTHON HISTORY AND VERSIONS FIRST PYTHON PROGRAM PYTHON VARIABLES PYTHON DATA TYPES PYTHON KEYWORDS PYTHON LITERALS PYTHON OPERATORS PYTHON COMMENTS PYTHON IF-ELSE STATEMENTS PYTHON LOOPS PYTHON FOR LOOP PYTHON WHILE LOOP PYTHON BREAK STATEMENT PYTHON CONTINUE STATEMENT PYTHON STRING
📄 Page
5
PYTHON TUPLE HADOOP INTRO BIG DATA WHAT IS HADOOP HADOOP MODULES STARTING HDFS FEATURES AND GOALS OF HDFS YARN HADOOP MAPREDUCE MAPREDUCE - DATA FLOW MAPREDUCE API MAPREDUCE - WORD COUNT EXAMPLE MAPREDUCE CHAR COUNT EXAMPLE HBASE HBASE INTRO HBASE READ
📄 Page
6
HBASE WRITE RDBMS VS HBASE HBASE EXAMPLE HIVE INTRO HIVE ARCHITECTURE HIVE DATA TYPES HIVE - CREATE DATABASE HIVE - DROP DATABASE HIVEQL - OPERATORS HIVEQL - FUNCTIONS
📄 Page
7
PYTHON BASICS PROGRAMMING FOR BEGINNERS J KING
📄 Page
8
PYTHON INTRODUCTION Python is a programming language that is general purpose, dynamic , high level, and interpreted. To develop applications, it supports Object-Oriented programming approach. Learning is simple and easy, and provides lots of high-level data structures. Python is yet a powerful and versatile scripting language that is easy to learn, making it attractive for application development. With its interpreted nature, Python's syntax and dynamic typing make it an ideal language for scripting and quick application development. Python supports multiple styles of programming including object-oriented, imperative, and functional or procedural styles. Python is not intended to operate in a given area, such as web programming. This is why it is known as the language of multipurpose programming because it can be used with web, enterprise, 3D CAD etc. We don't have to use data types to declare variable because it's typed dynamically so that we can write a=10 to assign an integer value in an integer variable. Python Features Python makes the development and debugging fast because the compilation step is not included in the development of Python, and the edit-test-debug cycle is very fast. Compared with other programming languages Python is easy to learn. Its syntax is direct and much the same as the English language. The semicolon or curly-bracket is not used, and the indentation defines the block of code. It is the recommended language for beginners in the programming. Using a few lines of code Python can perform complex tasks. A simple example, you simply type print("Hello World”) to the hello world program. It'll take one line to execute, while Java or C will take multiple lines.
📄 Page
9
Python History and Versions Guido Van Rossum at CWI in The Netherlands began implementing Python in December 1989. Guido Van Rossum published the code (labeled version 0.9.0) to alt.sources in February 1991. Python 1.0 was released in 1994, with new features such as lambda, map, filter, and reduce. Python 2.0 has added new features such as list understandings and garbage collection systems. Python 3.0 (also called "Py3 K") was released on December 3, 2008. It had been designed to correct the language's fundamental flaw. Python Version List Python Version Released Date Python 1.0 January 1994 Python 1.5 December 31, 1997 Python 1.6 September 5, 2000 Python 2.0 October 16, 2000 Python 2.1 April 17, 2001 Python 2.2 December 21, 2001 Python 2.3 July 29, 2003 Python 2.4 November 30, 2004 Python 2.5 September 19, 2006
📄 Page
10
Python 2.6 October 1, 2008 Python 2.7 July 3, 2010 Python 3.0 December 3, 2008 Python 3.1 June 27, 2009 Python 3.2 February 20, 2011 Python 3.3 September 29, 2012 Python 3.4 March 16, 2014 Python 3.5 September 13, 2015 Python 3.6 December 23, 2016 Python 3.7 June 27, 2018 Python 3.8 October 14, 2019 To download the latest Python release, please visit the link https:/www.python.org/downloads/
📄 Page
11
First Python Program In this section, we 're going to discuss Python 's basic syntax, and run a simple program to print Hello World on the console. Python provides us with two modes of running a program: Using Interactive interpreter prompt Using a script file Interactive interpreter prompt Python gives us the functionality to execute the Python statement at the interactive prompt one by one. In the case where we are concerned about the output of every line of our Python programme. Open the terminal (or command prompt) and type python (python3, if you have both Python2 and Python3 installed on your system) . It will open the following prompt where we can execute the statement in Python and check its impact on the console. Using a script file
📄 Page
12
The interpreters prompt is good at running the individual code statements. We can't write the code on the terminal anytime . Our code must be written into a file that can be executed later. To do this, open a notepad editor, create a file named first.py (Python used the.py extension) and write the following code into it. print ("hello world" ); #here, we have used print() function to print the message on the console. Run the following command on the terminal $ python3 first.py
📄 Page
13
Python Variables Variable is a name used to refer to the location of a memory. Also known as an identifier and used for holding value. In Python, we don't need to specify the variable type, because Python is an inferior language and is smart enough to get the type of variable. Variable names can be a group of letters and digits, but must start with a letter or an underscore. Using lowercase letters for name of the variable is recommended. Rahul and rahul are both two different variables. Identifier Naming Variables - example of identifiers .To identify the literals used in the program an Identifier is used. The rules for naming an identifier are set out below. The variable must have an alphabet or underscore (_) as its first character. All characters except the first character can be lower-case(a-z), upper-case (A-Z), underscore, or digit (0-9) alphabets. The name of the identifier shall not contain any white space or any special character!, (@,#,%,^, &, *). The name of the identifier must not be similar to any keyword set in the language. Identifier names are case sensitive; my name, for example, and MyName is not identical. Declaring Variable and Assigning Values Python does not bind us to declare a variable before we use it in the app. It enables us to create a variable in the time required. In Python we do not need to declare explicitly variable. That variable is declared automatically when we assign any value to the variable. The operator equal (=) is used to assign value to a variable.
📄 Page
14
Object References When we declare a variable it's necessary to understand how the Python interpreter works. The process of treating variables differs slightly from many other programming languages. Python is a highly object-oriented programming language; therefore, each data item belongs to a specific class type. Consider example below. print("John" ) OUTPUT John The object in Python creates an integer and displays it to the console. We created a string object in the preceding print statement. Let's check its type using the built-in type() function in Python. type("John" ) OUTPUT <class 'str'> Object Identity In Python, each object created uniquely identifies with Python. Python ensures no two objects will have the same identifier. The Id() function built- in is used to identify the identifier of the object. Consider example below. a = 50 b = a print(id(a)) print(id(b)) # Reassigned variable a a = 500 print(id(a)) Output: 140734982691168
📄 Page
15
140734982691168 2822056960944 We assigned both b = a, a and b points to the same object. When we checked by the Id() function the same number was returned. We reassign a to 500; then the new object identifier was referenced. Variable Names We've already discussed how to declare the valid variable. Variable names may be uppercase, lowercase (A to Z, a to z), digit (0-9), and underscore ( ). Consider the following example of names for the valid variables. name = "Devansh" age = 20 marks = 80.50 print(name) print(age) print(marks) OUTPUT Devansh 20 80.5 Consider the following example name = "A" Name = "B" naMe = "C" NAME = "D" n_a_m_e = "E" _name = "F" name_ = "G" _name_ = "H" na56me = "I"
📄 Page
16
print(name,Name,naMe,NAME,n_a_m_e, NAME, n_a_m_e, _name, name_,_name, na56me) OUTPUT A B C D E D E F G F I We declared a few valid variable names such as name, name , etc. in the above example. But it is not recommended, because it can create confusion when we try to read code. To make code more readable, the name of the variable should be descriptive. Multiple Assignment In a single statement, which is also called multiple assignments, Python allows us to assign a value to multiple assignments. Multiple assignments can be applied in two ways, either by assigning one value to multiple variables or by assigning multiple values to multiple variables. Consider example below. Assigning single value to multiple variables x=y=z= 50 print(x) print(y) print(z) Output 50 50 50 Assigning multiple values to multiple variables: a,b,c= 5 , 10 , 15 print a print b print c OUTPUT 5 10 15
📄 Page
17
Python Data Types Variables can hold values, with each value having a data-type. Python is a dynamically typed language; therefore when declaring it, we don't need to define the type of variable. Implicitly the interpreter binds the value to their type. a = 5 The variable a holds the value of integer five, and we have not defined its type. Python interpreter will interpret variables as a type of integer automatically. Python allows us to check what type of variable the program uses. Python gives us the type() function, which returns the type of the passed variable. Consider the example below to define the values of various types of data and to check their type. a=10 b= "Hi Python" c = 10.5 print (type(a)) print (type(b)) print (type(c)) OUTPUT <type 'int'> <type 'str'> <type 'float'> Standard data types A variable can hold a variety of values. For instance, the name of a person has to be stored as a string while its Id has to be stored as an integer. Python provides different standard data types on each of them which define the storage method. Below you will find the data types defined in Python. 1. Numbers
📄 Page
18
2. Sequence Type 3. Boolean 4. Set 5. Dictionary Numbers Number numbers store numeric values. The integer, float, and complex values belong to a data-type of Python Numbers. Python gives the type) (function for knowing the variable's data type. Similarly the function isinstance() is used to check that an object belongs to a certain class. Python creates Number objects when a variable has a number assigned. For instance; a = 5 print ( "The type of a" , type(a)) b = 40.5 print ( "The type of b" , type(b)) c = 1+3j print ( "The type of c" , type(c)) print ( " c is a complex number" , isinstance(1+3j,complex)) OUTPUT The type of a <class 'int'> The type of b <class 'float'> The type of c <class 'complex'> c is complex number: True Sequence Type String The sequence of characters represented in quotation marks can be defined as the string. In Python, we can define a string by using single, double, or
📄 Page
19
triple quotes. Python's string handling is a straightforward task, since Python provides built-in functions and operators to perform string operations. In the case of string handling, the operator + is used to combine two strings, as the "hello"+" python operation returns "hello python." The example below illustrates Python string. EXAMPLE 1 str = "string using double quotes" print (str) s = '' '''A multiline string''' print (s) OUTPUT string using double quotes A multiline String EXAMPLE 2 str1 = 'hello learnpython' #string str1 str2 = ' how are you' #string str2 print (str1[0:2]) #printing first two character using slice operator print (str1[4]) #printing 4th character of the string print (str1*2) #printing the string twice print (str1 + str2) #printing the concatenation of str1 and str2 OUTPUT he o hello learnpythonhello learnpython hello learnpython how are you
📄 Page
20
List Python lists are similar to C arrays. However, the list may contain data of various types. The items stored in the list are separated by a comma(,)(and inside square brackets[]. To access list data, we may use slice [:] operators. The concatenation operator (+) and the repeat operator (*) works with the list in the same way as the strings worked. EXAMPLE list1 = [1, "hi" , "Python" , 2] #Checking type of given list print (type(list1)) #Printing the list1 print (list1) # List slicing print (list1[3:]) # List slicing print (list1[0:2]) # List Concatenation using + operator print (list1 + list1) # List repetation using * operator print (list1 * 3) OUTPUT [1, 'hi', 'Python', 2] [2] [1, 'hi'] [1, 'hi', 'Python', 2, 1, 'hi', 'Python', 2] [1, 'hi', 'Python', 2, 1, 'hi', 'Python', 2, 1, 'hi', 'Python', 2]
The above is a preview of the first 20 pages. Register to read the complete e-book.