week 3
Welcome to My blog this is going to show my progress with python and what went wrong when.
Week 2: I was introduced python, this was my second time using this type of coding (interpreted language), meaning I had no experience using within this area of animation which led me to making many mistakes and learning a new language. For instance, I learned what python number are. These are numeric types in python
"Int=integer whole number positive or negative
Float=Floating point number is a number that is positive or negative containing one or more decimals
Complex= numbers that are written as "the imaginary part"
These are created when you assign
Variable names: These can have short names such as a = age and h= height. Variable name can not start with a number variable, names are case sensitive such as (age, Age and Age) are different variables." https://www.w3schools.com/python/python_numbers.asp There is no date or author for this website (page)
Week 3: Within this week I used w3schools again, while using this website I learned basic python.
Here I was tasked at making a window but only using python, I watched a YouTube video showing a step by step example, which I followed. However, when I tried to run the program I was shown error, I looked for my mistake but I did not identify the error that led to it failing.
Another attempt at making a window. This time I followed the lectures attempt at making a window, despite coping and trying to understand what each variable and command did the window did not appear. Although I noticed my mistake, you can not have spaces for variable names
Week 4
This week I was introduced to python functions and how to create them.
"In Python a function is defined using the def keyword:"
Bellow is an example "Calling a function" I also made it produce todays date 17/10/2022
Arguments: "Arguments are often shortened to args in Python documentations."
"Information can be passed into functions as arguments.
Arguments are specified after the function name, inside the parentheses. You can add as many arguments as you want, just separate them with a comma.
The following example has a function with one argument (fname). When the function is called, we pass along a first name, which is used inside the function to print the full name:" https://www.w3schools.com/python/python_functions.asp There is no date of author for this website (page)
I also used another example here to show the first three days of the week "Monday, Tuesday and Wednesday"
"From a function's perspective:
A parameter is the variable listed inside the parentheses in the function definition.
An argument is the value that is sent to the function when it is called."
"Number of Arguments
By default, a function must be called with the correct number of arguments. Meaning that if your function expects 2 arguments, you have to call the function with 2 arguments, not more, and not less."https://www.w3schools.com/python/python_functions.asp There is no date of author for this website (page)
This is an example of a function where it has the correct number of arguments. It has 2 arguments which is the only number of arguments you can have, it can not go down or up.
Here is an example of a function with 1 or 3 arguments
This function expects 2 arguments, however there is only 1
"Arbitrary arguments, *arg
If you do not know how many arguments that will be passed into your function, add a *
before the parameter name in the function definition.
This way the function will receive a tuple of arguments, and can access the items accordingly:"
"Arbitrary Arguments are often shortened to *args in Python documentations."
Here I made a random number appear between 1-100, by "importing random" and "print(random.randrange(1,100))"
References
Italic words are references "not my own work"
https://www.w3schools.com/python/python_numbers.asp There is no date or author for this website (page)
https://www.w3schools.com/python/python_functions.asp There is no date of author for this website (page)
Leave a comment
Log in with itch.io to leave a comment.