Back

Sanskar

Keen Learner and Exp... • 27d

Day 9 of learning python as a beginner. Topic: string slicing and manuplating. Strings are immutable i.e. they cannot be changed or modified however we can create a new string using the old one. Strings are made up of letters which can be indexted (counted in whole numbers). String slicing uses these numbers to find the letter on that specifinc position and creates a new string based on the result. (I hope I explained it correctly it is kind of confusing 😅). Based on this knowledge I create an encrypter-decrypter which can use string slicing to encrypt and decrypt your message. I used while loop to make it infinite and used functions to store logic of encryption and decryption in it. During the process I got introduced to functions like chr and ord. Before explaining them let me tell you about unicode - it is a standard that assigns a unique code number to every character from every language, symbol, emoji, and script in the world - so that the computers can store, display, and process text consistently. I have added a first layer of encryption by reverting the word and then using unicode to shift the letter by one. encrypted_word = chr(ord(letter) + 1) here ord converts every letter to its unicode and then add 1 to it (essentially it this line changes the letter to next letter by 1 for example a to b, b to c, etc). On the other hand chr converts the new unicode to the letter example if 65 is A, then 65 + 1 = 66 which is B. By reconstructing this process in backward I decrypt to find the original message. I hope I was able to explain this code well fell free to ask any question regarding the code (your questions help me develop a better undestanding of my code). I would also appreciate any suggestions and advices to improve my code. And here's my code and its result.

Reply
5

More like this

Recommendations from Medial

Image Description

Kimiko

Startups | AI | info... • 4m

the four-letter code to selling anything:

1 Reply
19
Image Description

Aayushi Yadav

Founder of Peheno • 4m

Niket Raj Dwivedi Harsh Dwivedi bro I can't post my idea on showcase I have a 7 letter name and 22 letter tagline still help me out

4 Replies
1

Sanskar

Keen Learner and Exp... • 1m

Day 1 of learning python as a beginner. Topic: Variables and Datatypes Variables are like containers which are used to store various datatypes in it. These datatypes includes string, Integer (whole number), floating point (decimal numbers), boo

See More
Reply
3
Image Description
Image Description

Kritarth Mittal • Soshals

Founder, Soshals | C... • 1y

I was feeling depressed so I sat down to write code and get my mind off of things. It's 7 in the morning, I have changed about 800+ lines of code and life's good again. I keep forgetting tech is the true god.

3 Replies
5

Rakshak Gupta

 • 

Quixy • 11m

There is programming called sonic pi which makes music with code Basically which means piano lyrics converted to code when I was exploring the sonic pi there were no code snippets for the songs what if with the help of the AI if we train the piano

See More
Reply
3
Image Description

Gaurav Malvi

Hey I am on Medial • 1m

Hey everyone👋, This is my first post. Just want to share that I am developing a simple multiplayer game kinda like skribble.io. Two letter of word will be given first and last letter and player has to guess any valid word using those letter, whoe

See More
2 Replies
1
6
Image Description
Image Description

Amar

 • 

YouTube • 3m

Steve Jobs couldn’t code, but he built Apple. Elon Musk doesn’t code much, but he builds the future. Evan Spiegel didn’t know how to code, but he built Snapchat. I don’t know how to code either but I know the rest. The ideas, the vision, the hustle.

See More
6 Replies
9
1
Image Description

Alok

Student • 9m

hey I want to create a picture that can be scanned and display the code or link stored on that design like QR code but I don't want to use QR art or QR code , I want just to make a picture scannable so that when people scan that Picture and the messa

See More
1 Reply
6
Image Description
Image Description

Armaan Nath

Startups | Product • 11m

🚀 7th offer letter for this year. This time I think it's time to work now.

4 Replies
3

Download the medial app to read full posts, comements and news.