Skip to content
Snippets Groups Projects
Commit ee5037bb authored by Sarah Bradford's avatar Sarah Bradford
Browse files

Adding Loops, Numpy Sympy, Whitespace

parent 8b95fb0b
No related branches found
No related tags found
No related merge requests found
This diff is collapsed.
This diff is collapsed.
%% Cell type:markdown id:950c4fef tags:
# Whitespace Sensitivity
%% Cell type:markdown id:019e60ef tags:
Short Title: Indentation
%% Cell type:markdown id:c61cba51 tags:
# Description
%% Cell type:markdown id:55abe61f tags:
Whitespaces or indedentation act as the spaces at the very start or inside of a code for enhanced readibility in Python. It is used to designate a block of code inside of a program. Any code without indentation or white space is attached to a specific source file. Whitespaces tend to be sensitive due to their ability to completely effect the possibilities of an output of a code or interpretation of a statement ultimately causing an error to pop up.
It is important to understand, whitespace must always be consistant throughout code. So if a programmer starts with 5 spaces, 5 space must be used throughout the remainder of the block of code or else a syntax error will not allow the code to be ran.
%% Cell type:markdown id:f8796bb7 tags:
# Examples
%% Cell type:markdown id:410f3f67 tags:
'' - space
/t - tab
%% Cell type:markdown id:880c1d84 tags:
# Learning Materials
%% Cell type:code id:dfad44a7 tags:
``` python
from IPython.display import YouTubeVideo
YouTubeVideo("vgefSv5k-o4",width=640,height=360, cc_load_policy=True)
```
%% Output
<IPython.lib.display.YouTubeVideo at 0x7ff3796ec7c0>
%% Cell type:markdown id:50fdb729 tags:
10 minutes
%% Cell type:markdown id:4ae1c549 tags:
# Self-Assessment
%% Cell type:markdown id:a2e5459e tags:
Create a code that tests whitespace values.
%% Cell type:code id:80ee2cd9 tags:
``` python
#Put your answer here
# import string
import string
# An input string.
Sentence = "What time does lunch begin at Shaw?"
for i in Sentence:
# determines if whitespace is found in code
if i in string.whitespace:
# Prints the number of whitespace values and its characters
print("printable Value is: " + i)
```
%% Output
printable Value is:
printable Value is:
printable Value is:
printable Value is:
printable Value is:
printable Value is:
%% Cell type:code id:351205d1 tags:
``` python
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment