Skip to content

Commit 31b87c3

Browse files
committed
Initial Commit
0 parents  commit 31b87c3

File tree

401 files changed

+112929
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

401 files changed

+112929
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
.DS_Store
3+
.idea
4+

app.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
def letter_changes(your_text):
2+
i = 0
3+
str1 = ""
4+
while i < len(your_text):
5+
x = your_text[i]
6+
if x.isalpha():
7+
str1 = str1 + str(chr(ord(x) + 1))
8+
else:
9+
str1 = str1 + x
10+
i += 1
11+
12+
return str1
13+
14+
15+
# keep this function call here
16+
print(letter_changes(str(input('Enter Your Name : '))).strip())

lesson1/__init__.py

Whitespace-only changes.

lesson1/factorialProgram.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Three ways to use library function.
2+
import math
3+
print("Factorial of 5 is ", math.factorial(5))
4+
5+
from math import factorial
6+
print("Factorial of 6 is ", factorial(6))
7+
8+
from math import factorial as fac
9+
print("Factorial of 7 is ", fac(7))

lesson1/hello_world.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
print('Hello World')
2+
print('To comment use # in the python')
3+
# i will not print
4+
# \n new line
5+
print("\nInstruction:\ni. To download the python go to https://www.python.org/downloads/")
6+
print('ii. REPL - Read Evaluate Print Loop is a python cmd/terminal line program')
7+
print('iii. Exit the REPL using ctrl+z in windows and ctrl+d in mac/linux')
8+
print('iv. To import any module in python : ')
9+
print("\t\ti. import moduleName")
10+
print("\t\tii. from module import name")
11+
print("\t\tiii. from module import name as shortName")
12+
print('v. To know the methods use python help method as below ')
13+
print("\t\t>>> help() or help(math)")
14+
print('vi. To use any library function import library.')
15+
print("\tEX:")
16+
print("\t\ti. import math")
17+
print("\t\tii. from math import factorial")
18+
print("\t\tiii. from math import factorial as fac")
19+
print("\nNext check factorial program to know more about importing library >> ".upper())
20+
21+

venv/bin/Activate.ps1

Lines changed: 231 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
1+
<#
2+
.Synopsis
3+
Activate a Python virtual environment for the current Powershell session.
4+
5+
.Description
6+
Pushes the python executable for a virtual environment to the front of the
7+
$Env:PATH environment variable and sets the prompt to signify that you are
8+
in a Python virtual environment. Makes use of the command line switches as
9+
well as the `pyvenv.cfg` file values present in the virtual environment.
10+
11+
.Parameter VenvDir
12+
Path to the directory that contains the virtual environment to activate. The
13+
default value for this is the parent of the directory that the Activate.ps1
14+
script is located within.
15+
16+
.Parameter Prompt
17+
The prompt prefix to display when this virtual environment is activated. By
18+
default, this prompt is the name of the virtual environment folder (VenvDir)
19+
surrounded by parentheses and followed by a single space (ie. '(.venv) ').
20+
21+
.Example
22+
Activate.ps1
23+
Activates the Python virtual environment that contains the Activate.ps1 script.
24+
25+
.Example
26+
Activate.ps1 -Verbose
27+
Activates the Python virtual environment that contains the Activate.ps1 script,
28+
and shows extra information about the activation as it executes.
29+
30+
.Example
31+
Activate.ps1 -VenvDir C:\Users\MyUser\Common\.venv
32+
Activates the Python virtual environment located in the specified location.
33+
34+
.Example
35+
Activate.ps1 -Prompt "MyPython"
36+
Activates the Python virtual environment that contains the Activate.ps1 script,
37+
and prefixes the current prompt with the specified string (surrounded in
38+
parentheses) while the virtual environment is active.
39+
40+
41+
#>
42+
Param(
43+
[Parameter(Mandatory = $false)]
44+
[String]
45+
$VenvDir,
46+
[Parameter(Mandatory = $false)]
47+
[String]
48+
$Prompt
49+
)
50+
51+
<# Function declarations --------------------------------------------------- #>
52+
53+
<#
54+
.Synopsis
55+
Remove all shell session elements added by the Activate script, including the
56+
addition of the virtual environment's Python executable from the beginning of
57+
the PATH variable.
58+
59+
.Parameter NonDestructive
60+
If present, do not remove this function from the global namespace for the
61+
session.
62+
63+
#>
64+
function global:deactivate ([switch]$NonDestructive) {
65+
# Revert to original values
66+
67+
# The prior prompt:
68+
if (Test-Path -Path Function:_OLD_VIRTUAL_PROMPT) {
69+
Copy-Item -Path Function:_OLD_VIRTUAL_PROMPT -Destination Function:prompt
70+
Remove-Item -Path Function:_OLD_VIRTUAL_PROMPT
71+
}
72+
73+
# The prior PYTHONHOME:
74+
if (Test-Path -Path Env:_OLD_VIRTUAL_PYTHONHOME) {
75+
Copy-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME -Destination Env:PYTHONHOME
76+
Remove-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME
77+
}
78+
79+
# The prior PATH:
80+
if (Test-Path -Path Env:_OLD_VIRTUAL_PATH) {
81+
Copy-Item -Path Env:_OLD_VIRTUAL_PATH -Destination Env:PATH
82+
Remove-Item -Path Env:_OLD_VIRTUAL_PATH
83+
}
84+
85+
# Just remove the VIRTUAL_ENV altogether:
86+
if (Test-Path -Path Env:VIRTUAL_ENV) {
87+
Remove-Item -Path env:VIRTUAL_ENV
88+
}
89+
90+
# Just remove the _PYTHON_VENV_PROMPT_PREFIX altogether:
91+
if (Get-Variable -Name "_PYTHON_VENV_PROMPT_PREFIX" -ErrorAction SilentlyContinue) {
92+
Remove-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Scope Global -Force
93+
}
94+
95+
# Leave deactivate function in the global namespace if requested:
96+
if (-not $NonDestructive) {
97+
Remove-Item -Path function:deactivate
98+
}
99+
}
100+
101+
<#
102+
.Description
103+
Get-PyVenvConfig parses the values from the pyvenv.cfg file located in the
104+
given folder, and returns them in a map.
105+
106+
For each line in the pyvenv.cfg file, if that line can be parsed into exactly
107+
two strings separated by `=` (with any amount of whitespace surrounding the =)
108+
then it is considered a `key = value` line. The left hand string is the key,
109+
the right hand is the value.
110+
111+
If the value starts with a `'` or a `"` then the first and last character is
112+
stripped from the value before being captured.
113+
114+
.Parameter ConfigDir
115+
Path to the directory that contains the `pyvenv.cfg` file.
116+
#>
117+
function Get-PyVenvConfig(
118+
[String]
119+
$ConfigDir
120+
) {
121+
Write-Verbose "Given ConfigDir=$ConfigDir, obtain values in pyvenv.cfg"
122+
123+
# Ensure the file exists, and issue a warning if it doesn't (but still allow the function to continue).
124+
$pyvenvConfigPath = Join-Path -Resolve -Path $ConfigDir -ChildPath 'pyvenv.cfg' -ErrorAction Continue
125+
126+
# An empty map will be returned if no config file is found.
127+
$pyvenvConfig = @{ }
128+
129+
if ($pyvenvConfigPath) {
130+
131+
Write-Verbose "File exists, parse `key = value` lines"
132+
$pyvenvConfigContent = Get-Content -Path $pyvenvConfigPath
133+
134+
$pyvenvConfigContent | ForEach-Object {
135+
$keyval = $PSItem -split "\s*=\s*", 2
136+
if ($keyval[0] -and $keyval[1]) {
137+
$val = $keyval[1]
138+
139+
# Remove extraneous quotations around a string value.
140+
if ("'""".Contains($val.Substring(0,1))) {
141+
$val = $val.Substring(1, $val.Length - 2)
142+
}
143+
144+
$pyvenvConfig[$keyval[0]] = $val
145+
Write-Verbose "Adding Key: '$($keyval[0])'='$val'"
146+
}
147+
}
148+
}
149+
return $pyvenvConfig
150+
}
151+
152+
153+
<# Begin Activate script --------------------------------------------------- #>
154+
155+
# Determine the containing directory of this script
156+
$VenvExecPath = Split-Path -Parent $MyInvocation.MyCommand.Definition
157+
$VenvExecDir = Get-Item -Path $VenvExecPath
158+
159+
Write-Verbose "Activation script is located in path: '$VenvExecPath'"
160+
Write-Verbose "VenvExecDir Fullname: '$($VenvExecDir.FullName)"
161+
Write-Verbose "VenvExecDir Name: '$($VenvExecDir.Name)"
162+
163+
# Set values required in priority: CmdLine, ConfigFile, Default
164+
# First, get the location of the virtual environment, it might not be
165+
# VenvExecDir if specified on the command line.
166+
if ($VenvDir) {
167+
Write-Verbose "VenvDir given as parameter, using '$VenvDir' to determine values"
168+
} else {
169+
Write-Verbose "VenvDir not given as a parameter, using parent directory name as VenvDir."
170+
$VenvDir = $VenvExecDir.Parent.FullName.TrimEnd("\\/")
171+
$VenvDir = $VenvDir.Insert($VenvDir.Length, "/")
172+
Write-Verbose "VenvDir=$VenvDir"
173+
}
174+
175+
# Next, read the `pyvenv.cfg` file to determine any required value such
176+
# as `prompt`.
177+
$pyvenvCfg = Get-PyVenvConfig -ConfigDir $VenvDir
178+
179+
# Next, set the prompt from the command line, or the config file, or
180+
# just use the name of the virtual environment folder.
181+
if ($Prompt) {
182+
Write-Verbose "Prompt specified as argument, using '$Prompt'"
183+
} else {
184+
Write-Verbose "Prompt not specified as argument to script, checking pyvenv.cfg value"
185+
if ($pyvenvCfg -and $pyvenvCfg['prompt']) {
186+
Write-Verbose " Setting based on value in pyvenv.cfg='$($pyvenvCfg['prompt'])'"
187+
$Prompt = $pyvenvCfg['prompt'];
188+
}
189+
else {
190+
Write-Verbose " Setting prompt based on parent's directory's name. (Is the directory name passed to venv module when creating the virutal environment)"
191+
Write-Verbose " Got leaf-name of $VenvDir='$(Split-Path -Path $venvDir -Leaf)'"
192+
$Prompt = Split-Path -Path $venvDir -Leaf
193+
}
194+
}
195+
196+
Write-Verbose "Prompt = '$Prompt'"
197+
Write-Verbose "VenvDir='$VenvDir'"
198+
199+
# Deactivate any currently active virtual environment, but leave the
200+
# deactivate function in place.
201+
deactivate -nondestructive
202+
203+
# Now set the environment variable VIRTUAL_ENV, used by many tools to determine
204+
# that there is an activated venv.
205+
$env:VIRTUAL_ENV = $VenvDir
206+
207+
if (-not $Env:VIRTUAL_ENV_DISABLE_PROMPT) {
208+
209+
Write-Verbose "Setting prompt to '$Prompt'"
210+
211+
# Set the prompt to include the env name
212+
# Make sure _OLD_VIRTUAL_PROMPT is global
213+
function global:_OLD_VIRTUAL_PROMPT { "" }
214+
Copy-Item -Path function:prompt -Destination function:_OLD_VIRTUAL_PROMPT
215+
New-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Description "Python virtual environment prompt prefix" -Scope Global -Option ReadOnly -Visibility Public -Value $Prompt
216+
217+
function global:prompt {
218+
Write-Host -NoNewline -ForegroundColor Green "($_PYTHON_VENV_PROMPT_PREFIX) "
219+
_OLD_VIRTUAL_PROMPT
220+
}
221+
}
222+
223+
# Clear PYTHONHOME
224+
if (Test-Path -Path Env:PYTHONHOME) {
225+
Copy-Item -Path Env:PYTHONHOME -Destination Env:_OLD_VIRTUAL_PYTHONHOME
226+
Remove-Item -Path Env:PYTHONHOME
227+
}
228+
229+
# Add the venv to the PATH
230+
Copy-Item -Path Env:PATH -Destination Env:_OLD_VIRTUAL_PATH
231+
$Env:PATH = "$VenvExecDir$([System.IO.Path]::PathSeparator)$Env:PATH"

venv/bin/activate

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# This file must be used with "source bin/activate" *from bash*
2+
# you cannot run it directly
3+
4+
deactivate () {
5+
# reset old environment variables
6+
if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then
7+
PATH="${_OLD_VIRTUAL_PATH:-}"
8+
export PATH
9+
unset _OLD_VIRTUAL_PATH
10+
fi
11+
if [ -n "${_OLD_VIRTUAL_PYTHONHOME:-}" ] ; then
12+
PYTHONHOME="${_OLD_VIRTUAL_PYTHONHOME:-}"
13+
export PYTHONHOME
14+
unset _OLD_VIRTUAL_PYTHONHOME
15+
fi
16+
17+
# This should detect bash and zsh, which have a hash command that must
18+
# be called to get it to forget past commands. Without forgetting
19+
# past commands the $PATH changes we made may not be respected
20+
if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
21+
hash -r
22+
fi
23+
24+
if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then
25+
PS1="${_OLD_VIRTUAL_PS1:-}"
26+
export PS1
27+
unset _OLD_VIRTUAL_PS1
28+
fi
29+
30+
unset VIRTUAL_ENV
31+
if [ ! "${1:-}" = "nondestructive" ] ; then
32+
# Self destruct!
33+
unset -f deactivate
34+
fi
35+
}
36+
37+
# unset irrelevant variables
38+
deactivate nondestructive
39+
40+
VIRTUAL_ENV="/Users/yusuf/Documents/PycharmProjects/SampleCodes/venv"
41+
export VIRTUAL_ENV
42+
43+
_OLD_VIRTUAL_PATH="$PATH"
44+
PATH="$VIRTUAL_ENV/bin:$PATH"
45+
export PATH
46+
47+
# unset PYTHONHOME if set
48+
# this will fail if PYTHONHOME is set to the empty string (which is bad anyway)
49+
# could use `if (set -u; : $PYTHONHOME) ;` in bash
50+
if [ -n "${PYTHONHOME:-}" ] ; then
51+
_OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-}"
52+
unset PYTHONHOME
53+
fi
54+
55+
if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then
56+
_OLD_VIRTUAL_PS1="${PS1:-}"
57+
if [ "x(venv) " != x ] ; then
58+
PS1="(venv) ${PS1:-}"
59+
else
60+
if [ "`basename \"$VIRTUAL_ENV\"`" = "__" ] ; then
61+
# special case for Aspen magic directories
62+
# see http://www.zetadev.com/software/aspen/
63+
PS1="[`basename \`dirname \"$VIRTUAL_ENV\"\``] $PS1"
64+
else
65+
PS1="(`basename \"$VIRTUAL_ENV\"`)$PS1"
66+
fi
67+
fi
68+
export PS1
69+
fi
70+
71+
# This should detect bash and zsh, which have a hash command that must
72+
# be called to get it to forget past commands. Without forgetting
73+
# past commands the $PATH changes we made may not be respected
74+
if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
75+
hash -r
76+
fi

0 commit comments

Comments
 (0)