0% found this document useful (0 votes)
4 views

1 - Basics

This document serves as an introductory guide to coding, specifically focusing on Python. It includes sections on basic data types, print statements, variables, and practice exercises to reinforce learning. Additionally, it provides resources for attendance, Discord, Google Classroom, and Codecademy sign-ups.

Uploaded by

rwjmj6kfmz
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

1 - Basics

This document serves as an introductory guide to coding, specifically focusing on Python. It includes sections on basic data types, print statements, variables, and practice exercises to reinforce learning. Additionally, it provides resources for attendance, Discord, Google Classroom, and Codecademy sign-ups.

Uploaded by

rwjmj6kfmz
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

Basics

Ice Breakers

Introduce yourself!

Say your name, grade, and something you would want


to learn about coding or use coding for.
Attendance
Form: bit.ly/mcodeattendance

(Use MCPS Account)


Join the Discord and the Google Classroom!
Discord: https://discord.gg/wDEmV7MVXM

Google Classroom Code: ayojbyk


Sign up for Codecademy:
At codecademy.com:
Click on My Home
Sign up for Codecademy:
Click on Workspaces Make a Python 3 Workspace
The Workspace

Files
Here

Code goes The Console


here
Data:

There are four basic types of data you can work with in python.

Integer / Float String Boolean

Integers are whole Strings are text values, The boolean is a


numbers, floats are and can hold almost true/false value.
decimals. any character.
Syntax:
Syntax: Syntax:
True
42 “Text here”
3.14 ‘More text here’ False
Practice:
Make a number between 1 and 100

Make a three-sentence story out of strings (no ideas? Describe a pickle)

Print if the following statement is true or false in the console: You can surround a string
with single and double quotes interchangeably.

Make a shape using multiple strings stacked on top of one another. (Triangle, square,
empty square, smiley face if you’re feeling spicy).
Practice:
Make a number between 0 and 1, then print the number that is 10 times that.

Describe Cabin John in a couple strings.

Print if the following statement is true or false in the console: boolean values have to be
capitalized

Make a shape using multiple strings stacked on top of one another. (Triangle, square,
empty square, smiley face if you’re feeling spicy).
Print() Statement:

Function: Syntax:

print(“This is a message”)
The print() statement
prints a value in the
console.

This value can be text, a Output:


number, or a boolean
(true/false).
This is a message
Practice:

EZ: Print 3 strings describing the classroom

EZ: Print 3 numbers divisible by 10

MD: Print how many desks are in the classroom using one print statement. (Commas
separating the number and strings)

CH: Print the current date on one line using multiple print statements
Practice:

EZ: Print 3 strings describing an interesting pet

EZ: Print 3 numbers divisible by 7

MD: Print how many windows are in the classroom using one print statement. (Commas
separating the number and strings) Output should be: Number of windows is 2

CH: Ask the user for their name and say hello to them. (You may need to use input())
ASCII Art:

Code:
Different Print statements print
on different lines.

You can use this to make art


out of characters and letters.

This is called ASCII art


(because it uses ASCII
characters).
Output:
“Look,
a bird!”
Operators:
How it works: It’s just math.

The operators:
+ Addition
- Subtraction
* Multiplication
/ Division
% Modulo (Remainder)

You can just use them in code:


Variables:

Variables are containers that store data. You take a value and give it a name.

It can be thought of as a box with a label that you store something in:

Referencing the name of the variable will reference it’s value. The value also can
change.
Variables:

Variables are declared as such:

name = Value

The name must not have spaces, and has to start with a letter.

Some languages require the type of data to be declared before the name. This is not the case in
Python.

player_level = 42

print(player_level)

In here, a variable named “player_level” is created to store the level “42” (an int). It can then be printed,
which will print the value stored.
Also worth a mention:

None/Null:

The Null value is an empty value.

It can be considered as a placeholder or “unassigned.”

Syntax changes from language to language, but in Python it is “None.”

← None

← Setting an empty variable


Practice:

EZ: Put a number, word, and boolean into a variable

EZ: Make a set of variables describing a chair (material, legs, etc.)

EZ: Make some variables for various ASCII shapes or drawings. (Now how do you include
a multi-line ASCII as one variable?)

MD: Print out the date using some variables for the various parts, and change them a bit.
(Now how do you print the numbers and slashes together?)

CH: Make a little mad libs program (just a couple sentences) where you ask the user for
various words and adjectives then give them a story. (Now how do you take those inputs?)
Practice:

EZ: Save your name, age, and if you can code in two languages into three variables

EZ: Make a set of variables describing a table (material, legs, etc.)

EZ: Draw a square, triangle, and trapezoid with ASCII art. (Then try it with one print
statement each).

MD: Ask the user to input the day, month, and year, then print the date in the standard
format MM/DD/YY.

MD: Ask the user for their name, grade, and favorite color then print out a short description
using those variables.

CH: Ask the user for a Celsius temperature value and print the Fahrenheit counterpart
(now how do you take the string input and make it a number?)
Practice:

Given a number, print the difference between that number and 21.

Take in a user’s string and print that string surrounded by “<<>>” (EX: bear → <<bear>>)

Given a string, print that string three times. For a challenge, take an input number and print
it that many times.

Given two strings, combine them into a phrase separated by a space.

Ask the user for their eye color, hair color, and favorite color and print a short description
of them using those.

CH: Using a date in MLA format, change it to a MM/DD/YY and DD/MM/YY format.

You might also like