-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModule.py
More file actions
69 lines (38 loc) · 1.5 KB
/
Module.py
File metadata and controls
69 lines (38 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# Module is the file containing code written by someone else which we can install using PIP
# Different types of Modules
'''
Type Description Example
Built-in Pre-installed with Python math, random, os
User-defined Custom module created by you mymodule.py
External Third-party modules (via pip) numpy, pandas, flask
'''
# PIP is a package manager for python , used to install modules
import pyjokes
joke = pyjokes.get_joke()
print(joke)
# We can directly use calculator using this python by just opening terminal and typing python and perform any calc
# This opens REPL or Road Evaluate Print Loop (means this read, then evaluate then print and then move to loop(again))
print(''' This is used to print multiple lines
like i can write like this
i can add more number of lines''')
print("This is a string")
print(56)
import pyttsx3
engine = pyttsx3.init()
engine.say("This is a module which convert text into voice")
engine.runAndWait()
import os
# Get the current working directory
path = os.getcwd()
# OR specify a custom path
# path = "C:/Users/YourUsername/Desktop"
print(f"Contents of directory: {path}\n")
try:
# List all files and directories in the given path
contents = os.listdir(path)
for item in contents:
print(item)
except FileNotFoundError: # There is no need to add this try block in this we can directly use this
print("The specified path does not exist.")
except PermissionError:
print("You do not have permission to access this directory.")