aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Python/.idea/workspace.xml31
-rw-r--r--Python/Beginner training/Caeser Cypher.py32
-rw-r--r--Python/Beginner training/Tasks.py22
3 files changed, 60 insertions, 25 deletions
diff --git a/Python/.idea/workspace.xml b/Python/.idea/workspace.xml
index 7b14add..78082d3 100644
--- a/Python/.idea/workspace.xml
+++ b/Python/.idea/workspace.xml
@@ -2,6 +2,7 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="fa33c027-ed35-40de-9bbc-c9cf5acfc8e7" name="Default Changelist" comment="">
+ <change afterPath="$PROJECT_DIR$/Beginner training/Caeser Cypher.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Beginner training/Tasks.py" beforeDir="false" afterPath="$PROJECT_DIR$/Beginner training/Tasks.py" afterDir="false" />
</list>
@@ -31,7 +32,7 @@
<property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" />
<property name="ToolWindowRun.ShowToolbar" value="false" />
<property name="ToolWindowServices.ShowToolbar" value="false" />
- <property name="last_opened_file_path" value="$PROJECT_DIR$/Beginner training/Tasks.py" />
+ <property name="last_opened_file_path" value="$PROJECT_DIR$/Beginner training/Caeser Cypher.py" />
<property name="restartRequiresConfirmation" value="false" />
<property name="settings.editor.selected.configurable" value="com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable" />
</component>
@@ -52,7 +53,7 @@
</list>
</option>
</component>
- <component name="RunManager" selected="Python.Tasks">
+ <component name="RunManager" selected="Python.Caeser Cypher">
<configuration default="true" type="CompoundRunConfigurationType">
<toRun name="Basic synthax config" type="PythonConfigurationType" />
<toRun name="2 Pets config" type="PythonConfigurationType" />
@@ -82,6 +83,27 @@
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
+ <configuration name="Caeser Cypher" type="PythonConfigurationType" factoryName="Python" folderName="Beginner training" nameIsGenerated="true">
+ <module name="Python" />
+ <option name="INTERPRETER_OPTIONS" value="" />
+ <option name="PARENT_ENVS" value="true" />
+ <envs>
+ <env name="PYTHONUNBUFFERED" value="1" />
+ </envs>
+ <option name="SDK_HOME" value="C:\Users\Kamen\GitHub_repos\Self-learning\Python\venv1\Scripts\python.exe" />
+ <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/Beginner training" />
+ <option name="IS_MODULE_SDK" value="false" />
+ <option name="ADD_CONTENT_ROOTS" value="true" />
+ <option name="ADD_SOURCE_ROOTS" value="true" />
+ <option name="SCRIPT_NAME" value="$PROJECT_DIR$/Beginner training/Caeser Cypher.py" />
+ <option name="PARAMETERS" value="" />
+ <option name="SHOW_COMMAND_LINE" value="false" />
+ <option name="EMULATE_TERMINAL" value="false" />
+ <option name="MODULE_MODE" value="false" />
+ <option name="REDIRECT_INPUT" value="false" />
+ <option name="INPUT_FILE" value="" />
+ <method v="2" />
+ </configuration>
<configuration name="Classes" type="PythonConfigurationType" factoryName="Python" folderName="Beginner training" nameIsGenerated="true">
<module name="Python" />
<option name="INTERPRETER_OPTIONS" value="" />
@@ -190,6 +212,7 @@
<list>
<item itemvalue="Python.Game test" />
<item itemvalue="Python.Tasks" />
+ <item itemvalue="Python.Caeser Cypher" />
<item itemvalue="Python.Exam 2" />
<item itemvalue="Python.Exam 1" />
<item itemvalue="Python.Classes" />
@@ -199,12 +222,12 @@
<component name="ServiceViewManager">
<option name="allServicesViewState">
<serviceView>
- <option name="contentProportion" value="0.3296" />
+ <option name="contentProportion" value="0.1248" />
<treeState>
<expand>
<path>
<item name="services root" type="e789fda9:ObjectUtils$Sentinel" />
- <item name="com.intellij.execution.services.ServiceModel$ContributorNode@53a38bba" type="d2cb1801:ServiceModel$ContributorNode" />
+ <item name="com.intellij.execution.services.ServiceModel$ContributorNode@59e06fae" type="d2cb1801:ServiceModel$ContributorNode" />
</path>
</expand>
<select />
diff --git a/Python/Beginner training/Caeser Cypher.py b/Python/Beginner training/Caeser Cypher.py
new file mode 100644
index 0000000..b951e39
--- /dev/null
+++ b/Python/Beginner training/Caeser Cypher.py
@@ -0,0 +1,32 @@
+lower = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
+upper = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
+
+while True:
+ key = abs(int(input("Type a key (0 - 26): ")))
+ while key > 26:
+ key -= 26
+
+ msg = input("Type a message: ")
+ decoded = [] ; encoded = []
+
+ for c in msg:
+ try:
+ decoded.append(lower[lower.index(c) - key])
+ encoded.append(lower[lower.index(c) + key])
+ except:
+ try:
+ decoded.append(upper[upper.index(c) - key])
+ encoded.append(upper[upper.index(c) + key])
+ except:
+ decoded.append(c)
+ encoded.append(c)
+
+ print(end="Decoded message: ")
+ for c in decoded:
+ print(end=c)
+ print()
+
+ print(end="Encoded message: ")
+ for c in encoded:
+ print(end=c)
+ print("\n") \ No newline at end of file
diff --git a/Python/Beginner training/Tasks.py b/Python/Beginner training/Tasks.py
index d60a8bf..3ba4354 100644
--- a/Python/Beginner training/Tasks.py
+++ b/Python/Beginner training/Tasks.py
@@ -65,28 +65,8 @@ def Factoriel():
print(final_int)
-def CaesarCypher():
- while True:
- key = input("Type a key: ")
- msg = input("Type a message: ")
-
- decoded = [] ; encoded = []
- for c in msg:
- decoded.append(c - key)
- encoded.append(c + key)
-
- print(end="Decoded message: ")
- for c in decoded:
- print(end=c)
- print()
-
- print(end="Encoded message")
- for c in encoded:
- print(end=c)
-
#Divide()
#Histogram()
#NumberMatrix()
-#Factoriel()
-CaesarCypher() \ No newline at end of file
+#Factoriel() \ No newline at end of file