Texts from Your BFF (and other Python skills)

Our first guest hacker y'all!!
















Welcome Marissa, a kitty mom and #datalover, to the DBD crew!

Hey all,


My name is Marissa and I’m going to introduce you all to Python.


Python is a cool coding language because it is used in so many applications. This is because Python is super diverse and is considered a cross-platform application. For example, Python is used by top applications such as Reddit and Spotify. Although Reddit and Spotify do not solely use Python to run their app, both apps rely heavily on the way it handles large dynamic memory.


Python is known as an OOL (object oriented language) This basically means thatdatawritten in a line of code work together to perform a calculation or an action. Other OOL programming languages are Java, R and SQL.


Let's do it!


This week we will cover basicdatatypes and input statements.Let’s start by introducing the three most commondatatypes; strings, floats and int. (kinda sounds like crafts - or have I been in quarantine too long??)

  • Strings begin with quotes “and end with quotes“. Strings can be written with numbers and letters. Think of strings as sentences in an email that are wrapped in quotes.

  • Int (abbreviated for integer) is a numeric data type that does not contain a decimal.

  • Float is another numeric data type in Python that has a decimal point.

Luckily, Python is like, super smart, and is able to infer whatdatatype you need your variable to be based on the input. 

Hello? Hello?


Input statements are statements that prompt a response from the user. A basic way to think about input statements is a question and answer.

--

Think about a user response as replying to a text message.


Vanessa: Hey Riss, Do you want to go out for cocktails? Drinks are half off


Marissa: Hey girl! Yes I’m coming with you guys! I get off work at 5.

--

*Keep in mind, in Python the code is run one line at a time.*


Similar to an input statement, Vanessa’s requesting a response from Marissa on whether or not she wants to join for cocktail hour.  Think of Vanessa’s invite as a user input prompt.


Cocktail_invite =input(str(“Do you want to go out for cocktails?”))


And think of Marissa’s response as the user response.


Riss_answer =“yes”


Note:Cocktail_invite andRiss_answer are variables. input is the function and str is defining the data type and "Do you want to go out for cocktails?" is the prompt. 


💄 More about Input Statements 💅


Input statements in any coding language is important, especially when it comes to input validation. Input validation is where there is a *correct* user response to the prompt. Similar to how a key unlocks a door.


Let’s say your favorite facial wash is on sale at Sephora. (Major win because I was almost out 😬). Since everyone is shopping online these days, you decide to log on. But wait! You totally forgot your password to your account. Luckily there is an alternative way to log in where a simple 5 digit code (58369) is sent directly to your phone as a text. Thank goodness for modern technology, right? This is where input validation statements come in. Think of the code as a key to unlock the door that is your Sephora account.

Similar to the input statement we saw with Vanessa and my conversation, a prompt is in place and it requires a user response of some sort. However, this time there is only one right answer.


"""An Automated code will be sent"""

code=58369

code_validation =int(input("please enter the five digit code"))

if code_validation==58369:

print("Thank you. Your web browser will be redirected shortly.")

if code_validation !=58369:

print("That is not the correct code.")


In the code above, you can see that the input statement will not accept any other answer other than the code 58369, you will not gain access to your account unless what you type matches the code that was sent to you.


🖶 Print Statements 


The code above introduces something called a print statement.


Print statements are a simple way to check if your code is working. Print statements are also a way to check on the validations as well. So the result of the last line in code is "That is not the correct code."

This is just the beginning to Python's capabilities! Next we'll cover importing data and a real world use case. We know you can't wait. 😉

A little more about Marissa:


Marissa is a Rhode Island native who enjoys the beach way more than she should️. 🏖 She also happens to be a part-time fashion model who enjoys drawing, cooking and learning new and different skills! Shout out to self taught Python-ers!


Thanks for sharing your knowledge, Marissa!! 🙌

FOLLOW US

NAVIGATE

  • Facebook - Black Circle
  • Instagram - Black Circle
  • Twitter

DUMB BLONDE DATA | AUSTIN, TX

OUR MISSION

To provide our online community with accessible, engaging resources for improving data skill sets in a refreshing way.