Hack My Planet

Day 22

Function Exercise

Write a Python function that takes a list and returns a new list with unique elements of the first list.
Sample List : [1,2,3,3,3,3,4,5]
Unique List : [1, 2, 3, 4, 5]

Passwords

  • Your passwords are the first 3 letters of your Pi hostname reversed, then pi183
    • Ex. awesomepi == ewApi183
  • Change your passwords with the passwd command
passwd pi

Cryptography

  • Test your programs by encrypting and decrypting messages
  • Send them to each other remotely with SCP (secure copy)
    • scp user@host1:source_file user@host2:destination
    • If it's localhost, then you don't need the first part before the colon (:)
    • Ex. scp ~/Documents/file.txt pi@10.4.6.1:~/Desktop
  • Transfer the encrypted message and OTP used to encrypt it, then decrypt the message sent to you!

Make a Chatting Robot

  • amixer cset numid=3 2
  • sudo apt-get install espeak
  • Create a chatbot.py file in your python_work directory
    • import os, time
    • time.sleep(1) function makes the program pause for 1 second
def robot(text):
    os.system("espeak ' " + text + " ' ")

 

robot("Hello how are you doing today?")

Make a Chatting Robot

sudo nano /usr/share/alsa/alsa.conf 

change the line "pcm.front cards.pcm.front"
   to "pcm.front cards.pcm.default"

Using your Chatbot

Example:

robot("What is your name?")

name = input("What is your name? ")

robot("Nice to meet you " + name)


time.sleep(1)


# more spoken questions and inputs

Using your Chatbot

  • Switch seats with the person next to you and use their chatbot.py program.
  • Add comments to their code (with #) to give them suggestions where you see fit.
  • Remove 1 line of code before switching back, then see if you can fix your broken code!

Hack My Planet Day 20: Chat Bot

By jtheadland

Hack My Planet Day 20: Chat Bot

  • 600