PYTHON ESSENTIALS 2
MODULE 1 :
1. From mod import fun
2. [Link]()
3. dir()
4. compiled python code
5. are executed once (implicitly)
6. __name__
7. Entity c from module b from package a
8. 1
9. There are millions of possible combinations and the exact ouput
cannot be predicted.
10. The system function from the platform module returns a string
with your OS name , the version function from the platform module
returns a string with your OS version.
11. __pycache__
12. Tell a unix or unix-like OS how to execute the contents of a
python file.
13. Show
14. Locally installed packages.
15. It needs a working internet connection to work , it searches
through all PyPl packages
16. It allows the user to install a specific version of package , it
installs a package per user only when the –user option is specified.
17. Its performed by the install command accompanied by the -U
option.
18. Pip uninstall package.
MODULE 2:
1. Some of the instructions from this block may not be executed.
2. Must be the last one
3. BaseException
4. Will stop the program when var!=0
5. Some
6. Indexerror , importerror.
7. Short for American standard code for information interchange.
8. A form of encoding Unicode code points.
9. Like ASCII but much more expansive.
10. 1
11. 2
12. X
13. Abcabcabcxyz
14. False
15. Raises a value error exception
MODULE – 3:
1. Stack
2. Object=class()
3. A.__init__(self)
4. The code will raise an attribute error exception
5. 2
6. 3
7. True
8. It will raise an exception
9. It will print b
10. It will print true
11. It will print b
12. It will print a
13. It will print 1
14. It will print bcac
15. It will print 3
16. It will print ex
17. It will print abc
MODULE 4 :
1. Lambda
2. The lambda function can accept any number of arguments , the
lambda function can evaluate only one expression
3. Foo=tuple(map(lambda x:x*x,my_list))
4. Foo=tuple(filter(lambda x:x>1,my_tuple))
5. It will print ace
6. It will print ++++++
7. It will print *
8. r , r+
9. file exists
10. bytearray(b’\x100\x100\x100’)
11. it prints the path to the pictures directory
12. [‘large’,’small’,’medium’]
13. 345 days , 0:00:00
14. 19/November/27 11:27:22
15. A
16. 0123456
FINAL TEST:
1) fun()
2)A list of all the entities residing in the math module
3)pyc
4)cba
5)_main_
6)entity C from module b from package a
7)not more than one except block will be executed
8)a
9)is valid because open returns an iterable object
10)the code will cause a syntax error
11) will stop the program when var==0
12)will print 1
13)will print 2
14)will print r
15)will print 1.3
16) object=Class(1,2)
17)3
18)False
19)The code will print False
20)the screen
21)The code will print 1
22)The code will raise an exception
23)The code will print b
24)The code will print 3
25)The code will print ++++++
26)The code will print abc
27)The code will print *
28)one character from the stream
29)read the file line by line
30)The readinto() method
31)pip--version,pip3--version
32)pip uninstall packagename
33)foo=map(lambda num:num**2,numbers)
34)foo=list(filter(lambda x:x%2,numbers))
35)A
36)The code will print the path to the created directory
37)Hardware identifier, operating system name
38)11:27:22
39)28 days, 20:00:00
40)Sun Mon Tue Wed Thu Fri Sat