|
所在平台: Udemy |
课程主页: https://www.udemy.com/course/python-for-data-science-real-time-exercises/
课程评论:没有评论
本课程“Python For Data Science - Real Time Experience”旨在通过 Jupyter Notebook 平台,以易于理解的方式教授 Python 编程。 课程首先介绍 Python 的基础知识,包括其作为高级、易学、面向对象的语言的特性,以及 Guido van Rossum 的贡献和 Python 在 Web 开发、游戏开发、机器学习和数据科学等领域的广泛应用。课程解释了 Python 的工作原理,即通过解释器将源代码转换为字节码再到机器语言执行。 随后,课程深入讲解了 Python 的核心概念和数据结构: * **变量**:用于存储数据,并可通过名称访问。 * **数据类型**:包括整型 (int)、浮点型 (float)、字符串 (str)、列表 (list)、元组 (tuple)、集合 (set) 和字典 (dictionary)。 * **字符串**:由字符组成,可用单引号或双引号包围。 * **列表**:有序、可变、可包含重复值的有序集合。 * **元组**:有序、不可变、可包含重复值的有序集合。 * **集合**:无序、不可变(但可添加删除元素)、不含重复值的集合。 * **字典**:键值对的无序、可变集合,键必须唯一且不可变。 课程还详细介绍了各种常用函数和操作: * **字符串连接**:使用 `+` 符号合并字符串。 * **换行符**:`/n` 用于另起新行,空 `print()` 用于创建空行。 * **列表函数**:包括 `append()`, `clear()`, `copy()`, `count()`, `extend()`, `index()`, `insert()`, `pop()`, `remove()`, `reverse()`, `sort()` 等,以及使用 `del` 删除切片。 * **元组函数**:`count()` 和 `index()`。 * **集合函数**:`add()`, `clear()`, `copy()`, `difference()`, `difference_update()`, `discard()`, `remove()`, `pop()`, `union()`, `intersection()`, `intersection_update()`, `isdisjoint()`, `issubset()`, `issuperset()`, `len()`, `symmetric_difference()`, `symmetric_difference_update()` 和 `update()`。 * **字典函数**:`clear()`, `copy()`, `get()`, `items()`, `keys()`, `values()`, `pop()`, `popitem()`, `setdefault()`, `update()`, `fromkeys()` 和检查键是否存在。 * **数据类型转换 (Casting)**:将变量从一种数据类型转换为另一种。 * **range()**:用于生成数字序列。 * **函数**:定义和调用可重用代码块,介绍参数、变量参数 `*args`、关键字参数。 * **Lambda 函数**:用于创建单行匿名函数。 * **input() 函数**:用于获取用户输入。 * **索引**:访问序列中的元素,支持正负索引、切片和步长,包括嵌套列表。 * **for 循环**:遍历序列中的元素,以及 `break` 和 `continue` 语句,`for-else` 结构和 `pass` 语句。 * **while 循环**:在条件为真时重复执行代码块,也包括 `break`、`continue`、`while-else` 和 `break`/`continue` 的组合使用。 * **split() 函数**:拆分字符串为列表。 * **map() 函数**:将函数应用于序列中的每个元素。 * **filter() 函数**:根据条件过滤序列中的元素。 * **enumerate() 函数**:在迭代时同时获取索引和值。 * **zip() 函数**:将多个迭代器中的元素组合成元组。 * **unzip 函数**:将 `zip` 对象解压回多个迭代器。 完成本课程后,学习者将能熟练运用 Python 进行数据科学相关的编程任务。
In this course, you will embark on a journey into the world of the Python Programming Language through hands-on coding exercises in Jupyter Notebook, presented in an exceptionally accessible manner.To begin, you will be guided through the installation and initial usage of the Jupyter Notebook environment, setting the stage for an immersive learning experience.Subsequently, we will delve into the various essential topics of Python programming.Lets have a look at some theoretical part (not covered in video lectures).Introduction -Python is a high-level programming language that uses instructions to teach the computer how to perform a task. Python is an easy to learn, powerful programming language.A language which is closer to the human language (like English) is known as a high-level language.Python provides an easy approach to object-oriented programming.Object-oriented is approach used to write programs.Python is a free and open source language i.e., we can read, modify and distribute the source code of Python scripts.It was developed by Guido van Rossum and was released in 1991.Python finds its application in various domains. Python is used to create web applications, used in game development, to create desktop applications, is used in Machine Learning and Data Science.How Python Works ? -We write instructions in Python language.Python is an interpreted language, so there is no need to compiling it.Python programs runs (executed) directly through source code. The source code is converted into Intermediate Bytecode and then Bytecode is converted into the native language of computer (i.e., machine language) internally by Python Interpreter. The code is executed and the output is presented.Python Source Code > Intermediate Bytecode > Machine Language > Code ExecutedWhat is a Program ? - A Program is a set of instructions that tells the computer to perform a specific task. A programming language is the language used to create programs.Eg. When we click on Play button on media player, then there is a program working behind the scene which tells the computer to turn on the music.A built-in function is a function which is predefined and can be used directly. Eg. print()Comments are the pieces of code which are ignored by the python interpreter. Comments are used to make source code easier to understand by other people. Python supports single line comments mean they can cover only one line.The various topics explained in this course video lectures with examples are as follows -1. VARIABLESa = 2 , b = 1.2 , c = ‘Ram', d = lambda (‘any function')# Variables are used to store values. The stored values in the variables can be used later in the programs. We can retrieve them by referring to the variable names.2. DATATYPES IN PYTHONInteger (int), Float , String (str) , List , Tuple , Set , Dictionary3. String - String is a series of characters, surrounded by single or double quotes. Eg. "Hello", ‘Hello999', ‘999'.4. LIST[ int /float / str ] à A = [ 1 , 2 , 3.4 , 3.4, ‘a' , ‘bcd' ]à Collection of data-types, Mutable: Values can be changed , Ordered: Values order will be as it is , Changeable , Allows duplicate values.5. TUPLE( int / float / str ) à B = (1 , 2 , 3.4 , 3.4 , ‘a' , ‘bcd' )àImmutable: Values can't be changed , Ordered: Values order will be as it is , Unchangeable, Heterogeneous Data, Allows duplicate values.6. SET{ int / float / str } à C = { 1 , 2 , 3.4 , 5.6 , ‘a' , ‘bcd' }àValues can't be changed but new values can be added , Unordered: Values order may change , Arrange the items in ascending order, Doesn't allow duplicate values, Un-indexed.7. DICTIONARY{ Key: Value } à D = { K1: 1 , K2: 2 , K3: 3.4 , K4: 5.6 , K5: ‘ab' , K6: ‘bcd' }à Mutable , Unordered , Doesn't allows duplicate keys , Indexed, Keys must be unique & immutable.8. CONCATENATION - Combining Stringsfirst = ‘Data'last = "Science"new = first + ‘ ' + last + ‘ is the combined string'9. "/n" - For next new lineprint("My Name is", "/n" , "My city is ", "/n" ,"My country is")print(‘Delhi') , print(‘') , print(‘Noida') # To create a gap of one line between two strings.10. LIST FUNCTONS< Press ‘Tab' button from the keyboard after typing the list name (A here) to show the available functions >A.append(55) - To add a new value at the end of the list.A.clear( ) - To clear/delete/blank a list.B = A.copy( ) - To create a copy of the list.A.count(5) - To count how many times a value occurs.A.extend(c) - To add a new list in the existing list.A.index(7) - To show the index of a value. # A.index(value, start_index, stop_index)A.insert(3,66) - To insert a new value at a given position.A.pop(3) - To delete a value with the help of index. # A.pop( )A.remove( 55) - To delete a value from the list.A.reverse( ) - To reverse the list.A.sort( ) - To sort the list. # A.sort(reverse=True)del A[ 1: 4 ] - To delete some items from the list.type(A) - To see the type.List Concatenation - A = [1,2,3,4] , B = [5,6,7,8] ; C = A+B = [1,2,3,4,5,6,7,8]11. TUPLE FUNCTONST.count(5) - To count how many times a value occurs.T.index(7) - To show the index of a value.12. SET FUNCTONSS.add(5) - To add a new value 5 in the set.S.clear() - To clear all the elements of the set.S.copy() - To copy a set.S1.difference(S2) - S1-S2 - It shows the elements of set S1 only.S1.difference_update(S2) - It removes all common elements from the set1.S.discard(x) - It will remove an element(x) from the set. If x is not in set, it will not show error.S.remove(x) - It will remove an element(x) from the set. If x is not in set, it will show an error.S.pop() - It deletes the first/random element of the set.S1.Union(S2) - Set1 Set2 - It shows all elements of set1 and set 2.S1.Intersection(S2) - Set1 & Set2 - It shows common elements of set1 and set2.S1.Intersection_update(S2) - Now set S1 will contain only common elements.S1.isdisjoint(S2) - It returns True, if S1 & S2 don't have any common values, otherwise False.S1.issubset(S2) - It returns True, if all elements of S1 are in set S2.S2.issuperset(S1) - It returns True, if all elements of S1 are in set S2, otherwise False.len(S) - It shows the no. of unique elements in the set.S1.symmetric_difference(S2) - S1^S2 - To show the non-common elements from S1 and S2.S1.symmetric_difference_update(S2) - Now set S1 will contain only non-common elements.S1.update([4,5,6]) - To add multiple items, in list/tuple/set form.13. DICTIONARY FUNCTONSD.clear( ) - To delete the dictionary.E = D.copy( ) - To copy a dictionary.D.get(‘K1') - To get the value against a key in the dictionary. If the key is not in dictionary, it will show None, without showing any error.D.items( ) - To show all the items of a dictionary.D.keys( ) - To show all the keys of a dictionary.D.values( ) - To show all the values of a dictionary.D.pop(‘K1') - To delete the key alongwith its index.D.popitem( ) - To delete the last key with value.D.setdefault(‘K3') , D.setdefault(‘K4', value), D[‘K4'] = value - To add a key at the end of the dictionary.D.update(‘E') - To add a new dictionary in the existing dictionary.D.fromkeys(A) - To create a dictionary, using list items as keys. And adding a value to all keys is optional."Key" in D - To check the presence of any element(key) in the dictionary.14. DATATYPE CASTINGConverting a datatype into another.int (1) =>1 - Converting int into intint (3.2) => 3 - Converting float into intint (‘5') => 5 - Converting a numerical string into intint (‘a') => error - Can't convert an alphabetical string into intfloat (3.2) => 3.2 - Converting float into floatfloat (6) => 6.0 - Converting int into floatfloat ("10") => 10.0 - Converting a numerical string into floatfloat (‘b') => error - Can't convert an alphabetical string into floatStr (‘a') => ‘a' - Converting a string into stringstr (1) => ‘1' - Converting an int into stringstr (3.2) => ‘3.2' - Converting a float into string15. RANGE - It creates a sequential list of numbers.range(start value, stop value, step value) , range(0,50,1) , range(1, 50) , range(50)16. FUNCTION - A function is a block of code, which is defined to perform some task. We have call a function to run it whenever required.Parameter: Given at the time of defining function. Ex: def func(a,b)Arguments: Given at the time of calling the function. Ex: func(2,3)def fun_name ( args / parameters ): multiple line statement ,def fun_name ( var1, var2 ): multiple line statementdef new ( 2 , 3 ): c = a + b , return cIf the number of arguments to be passed is not fixed…then we use the Arbitrary Arguments (with *args)Ex: def func(*values): for i in values print(i) # It can take any number of arguments.Keyword Arguments: We can also send the args with key=value syntax.Ex: def new(b,a,c): print("The winner is " , a)new(a= ‘Ram', b= ‘Sham', c= ‘Shiva') ….. O/p will be: The winner is Ram17. LAMBDA FUNCTION à It is a single line function.fun_name = lambda parameters: single line statementEx: sum = lambda a , b: a + b18. INPUT FUNCTION - It takes an input and can save it to a variable.Ex 1: a = input ( ‘Enter your name' ) ,Ex 2: print ( ‘Enter your name' )x = input ( )19. INDEXING - list.index( item ) , list [index value] , list [ start: stop: step ]A.index(25) , A[1] , A [ 1: 20: 2 ] , A [: 4 ] , A[ 2: ] , A [: ]Negative Indexing - A[-1] , A [ 8: 0: -1 ] , A [:: -1 ]String Indexing - A.index( ‘r' ) , A[: 16 ]Nested List - List in a listEx: A = [ [1,2,3] , 4 , 5 , 6 , [ 7,8,9] ]20. FOR LOOP - for val in sequence: body of for loop,Ex 1: for x in [1,2,3,4,5]: print (x) ,Ex 2: for i in ‘banana': print (i)BREAK STATEMENT (For Loop) - To stop the loop at a given condition1) for val in sequence: body of for loop if val == ‘seq_value' , breakEx: for x in [1,2,3,4,5,6,7]:print (x)if x == 5break2) for val in sequence: if val == ‘seq_value' break , print(val)Ex: for x in [1,2,3,4,5,6,7]:if x == 5breakprint(x)CONTINUE STATEMENT (For Loop) - To skip over an iteration1) for x in [1,2,3,4,5]:if x == 4continueprint(x)2) for x in [1,2,3,4,5]:print (x)if x == 4continueBREAK & CONTINUE STATEMENT (For Loop) -Ex: for x in [1,2,3,4,5,6,7]:if x == 5:continueif x == 6:breakprint(x)RANGE FUNCTION -for x in range (6):print (x)ELSE IN FOR LOOP -1) for x in range(6):print (x)else:print (‘loop is finished')2) for x in range(0,6):print (x)if x == 4:breakelse:print(‘loop is finished')PASS STATEMENT - To pass over to the next commands1) for x in [1,2,3,4,5,6,7]:Pass2) for x in [1,2,3,4,5,6,7]:if x == 3:passprint (x)21. WHILE LOOP - A while loop repeats a block of code as long as a certain condition is true.1) i = 0while i < 6:print (i)i = i +12) i = 0while i < 6:i = i +1print (i)BREAK STATEMENT (While Loop) -1) i = 0while i < 6:print (i)if i == 4:breaki = i +12) i = 0while i < 6:if i == 4:breakprint (i)i = i + 1CONTINUE STATEMENT (While Loop) -1) i = 0while i < 6:i = i +1if i == 3:continueprint (i)2) i = 0while i < 6:if i == 3:continueprint (i)i = i +13)i = 0while i < 6:if i == 3:continuei = i + 1print (i)ELSE IN WHILE LOOP -1) i = 0while i < 6:print (i)i = i+1else:print (‘condition ends')BREAK & CONTINUE STATEMENT (While Loop) -i = 0while i < 10:i = i + 1if i = = 3:continueif i = = 9:breakprint (i)22. SPLIT FUNCTIONIt splits a string into a list.Syntax: string.split ( separator , maxsplit )23. MAP FUNCTIONIt takes all items of a list and apply a function to it.Syntax: map( function, iterables ) or map( condition, values )Ex: list ( map ( lambda x: x+1 , [1,2,3,4,5] ) )24. FILTER FUNCTIONIt takes all items of a list and apply a function to it & returns a new filtered list.Syntax: filter( function, sequence )Ex: list ( filter ( lambda x: x%2!= 0 , [1,2,3,4,5,6] ) )25. ENUMERATE FUNCTIONIt is used to display output with index. We can enumerate as list, tuple, set, dictionary.Syntax: enumerate( list )Ex: list ( enumerate (‘apple' , ‘mango' , ‘orange') )26. ZIP FUNCTIONIt is used to zip different iterators(lists) in one.Syntax: z = zip(list1, list2, list3)z = list(z) , print(z)Example: A = [1,2,3] , B = [‘Ram' , ‘Sham' , ‘Shiva'] , C = [‘Delhi', ‘Noida', ‘Agra']z = zip(A, B, C) , z = list(z) , print(z)27. UNZIP FUNCTIONSyntax: list1, list2, list3 = zip(*z)Ex: A, B, C = zip(*z)Embark on this enriching journey and unlock the vast potential of Python programming for diverse applications.