Sylvia's Very Clever PYTHON Solution

Learn How to Learn - Aprender a Aprender
Post Reply
User avatar
Teacher
Site Admin
Posts: 1843
Joined: Mon Aug 03, 2020 11:57 am

So in programming class we are starting to meld our tidbits into more complex programs, especially those that we already once made in Scratch.  Of course, the geometry that one can play with making some very cool abstract patterns in Python Turtle is another of BOTh Melissa and Sylvia's impressive abilities... I really think somethig with their ALGORITHMIC ART event could combine Python...

But on our route to re-do our Caesar Cipher in Python (which they had done in Scratch already) is to make a simple "string inversion" cipher.

A perfect vehicle to start exploring the while loop (since we have really only seen the for loop up until now).

Here is the official code:
mensaje_original = input("Qué es tu mensaje? ")
descifrado =  ""   
i = len(mensaje_original)  -  1   
while  i >= 0 :
    descifrado = descifrado + mensaje_original      
    i  = i - 1    
print(descifrado)


And then Sylvia sent me:
mensaje="python es muy cool"
mensaje_invertido="".join(reversed(mensaje))
print(mensaje_invertido)

Haha dang.  Sure my point was to teach the while loop but this is definitely a programmer's reply to a teacher!  Three lines, three steps.  Mine has more lines and of coruse the longer the message the longer it would likely take.

Well done Sylvia, really thinking like a programmer!
 
User avatar
Teacher
Site Admin
Posts: 1843
Joined: Mon Aug 03, 2020 11:57 am

This is too cool!  Bump!  What do you guys think?  Qué piensan ustedes?
User avatar
Marcela
Posts: 396
Joined: Thu Oct 07, 2021 8:58 pm

Teacher wrote: Mon Jul 11, 2022 11:31 pm So in programming class we are starting to meld our tidbits into more complex programs, especially those that we already once made in Scratch.  Of course, the geometry that one can play with making some very cool abstract patterns in Python Turtle is another of BOTh Melissa and Sylvia's impressive abilities... I really think somethig with their ALGORITHMIC ART event could combine Python...

But on our route to re-do our Caesar Cipher in Python (which they had done in Scratch already) is to make a simple "string inversion" cipher.

A perfect vehicle to start exploring the while loop (since we have really only seen the for loop up until now).

Here is the official code:
mensaje_original = input("Qué es tu mensaje? ")
descifrado =  ""   
i = len(mensaje_original)  -  1   
while  i >= 0 :
    descifrado = descifrado + mensaje_original      
    i  = i - 1    
print(descifrado)

And then Sylvia sent me:

mensaje="python es muy cool"
mensaje_invertido="".join(reversed(mensaje))
print(mensaje_invertido)
Haha dang.  Sure my point was to teach the while loop but this is definitely a programmer's reply to a teacher!  Three lines, three steps.  Mine has more lines and of coruse the longer the message the longer it would likely take.

Well done Sylvia, really thinking like a programmer!
 
[justify] [/justify]
I’m still impressed by the Sylvia’s solution! I hope to learn a lot from Python and of course learn from Sylvia and Melissa 🤩🤓
Post Reply