Skip to content

Fixed some typos #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/2-basicPython.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
# input options
# let's see how can we enter the data into the program

print("Example demonstating keyboard input\n")
print("Example demonstrating keyboard input\n")

a1 = input("Raw input, text or number\n")
print("type: ",type(a1),", value: ",a1)
Expand Down Expand Up @@ -114,10 +114,10 @@
# def <name>(<params>):
def printStr(s="",n=1):
""" A comment string with triple \" as the first line of a function definition
is called docstring. It is useed to comment on the function's function.
is called docstring. It is used to comment on the function's function.
The docstring can be read by the member __doc__, in this case: printStr.__doc__
Our function will accept 2 paramters c and n and will print the string s for n times
We initialize the paramters with and empty sting \"\" and 1, so if a parameter
Our function will accept 2 parameters c and n and will print the string s for n times
We initialize the parameters with an empty string \"\" and 1, so if a parameter
is left out, the default value will be used
"""
# we have to indent all instructions following the function definition
Expand All @@ -133,7 +133,7 @@ def printStr(s="",n=1):
# we print the docstring:
print("\ndocstring: ",printStr.__doc__)
# let's call out function
s,n = eval(input("Which string and how often"))
s,n = eval(input("Which string and how often? "))
printStr(s,n)
print("\n")

Expand Down Expand Up @@ -163,7 +163,7 @@ def printStr(s="",n=1):
nf = np.array(c,"float")
print("Variable nf (numpy) is: ",nf)

# there are a few more differences to lists, e.g on multiplication
# there are a few more differences to lists, e.g. on multiplication
print("Multiply the list by 2 give a list with twice as many items: \n",2*c)
print("Multiply the array by 2 multiplies the elements: ",2*nc)
print("With numpy arrays we have to use the append function to get longer arrays")
Expand All @@ -178,11 +178,11 @@ def printStr(s="",n=1):
nt = np.fromstring(b,"uint8")
# a more correct way is to convert to a byte array, then to a buffer
nt = np.frombuffer(bytearray(b,"utf-8"),"uint8")
print("Variable nt from ",b," as unisgned integer array (uint) is: ",nt)
print("Variable nt from ",b," as unsigned integer array (uint) is: ",nt)

###########################################
# so far, we've dealt with individual items and lists and their np eqivalent, arrays
# a single list turns into an array with a single dimentsion
# a single list turns into an array with a single dimension
# we can also have more dimensions, for example two
# a 2D array is widley know as a table

Expand Down