Friday, March 15, 2019

March --> April post

March --> April Post

  In March, I've done a few lessons about Python Languages. I've also done most of the projects done that were given and suggested to finish. All the projects were similar but all in different field, but are all connected to our daily life in their own ways. Python Language is really convenient, easy to read and to instruct. In the following month, I am going to finish the remaining lessons that are in the Python unit on Codecademy. After I finish, I am going to move onto Java unit. 
  But throughout the break, I am just going to relax and have a good break. 

Thursday, March 14, 2019

Student becomes the teacher

Student becomes the teacher

What this project is about...

This project is a bit challenging, it wants you to take the job of the teacher to teach the class. First of all, they asked you to create a gradebook for all the students, which requires to include the name, homework, quizzes and also test marks in it.
Then it gives you the marks of the students have to plug it into the code, don't forget the decimal points so the grades are stored as float. This is what the whole code looks like:

Then put all the students in a list with the code:
list_name = [1, 2, 3]
After you have the list, you need a hard copy of the grades so that you can go through it faster. So we print out the name, homework, quizzes and test marks of the student using the following code:

Compute a student's average:

On line 31, it calculates the mark with the percentage you want it to take up by multiplying the percentages.
After that, we define the letter grade of the students, using the following code:

Then it's the class average:

Finally, create the function to check the grade of the class overall:


What I learned in this lesson...

  I learned to make functions of calculating marks and average of numbers. Also the format of the function as well. Although this unit includes a lot of code, but in my opinion, this type of code are easy to read and to understand.

Wednesday, March 13, 2019

A DAY AT THE SUPERMARKET

A DAY AT THE SUPERMARKET

What this project is about...

for loops allow us to iterate through all of the elements in a list from the left-most (or zeroth element) to the right-most element.
This loop will run all of the code in the indented block under the for x in a: statement.
Example:
We can also add in the "if" element into this project...
And also the "return" element...
Then it slowly lead me into a exercise named "Your own store". It require me to set up a dictionary with entries and keys in it. Asked me to create a dictionary named "prices"
And then use the same step to create another dictionary named "stock". After that, print out all the inventory information, in this case would be printing the food name, price and the number of it in stock.

Then print the total, to calculate how much I will make by selling the food in stock.
Define a compute bill on to the system so that it calculates how much it takes you to get all the groceries you need. And it looks like this:

What I've learned...

  This project gave me a better understanding of how to use Python Languages in projects. And I now feel more confident about using what I've learned to finish projects.

Tuesday, March 12, 2019

Python Lists and Dictionaries

Python Lists and Dictionaries

What I learned from this project...
Assign items to a list with an expression of the form:
list_name = [item_1, item_2]
Replace: numbers[0]="3"
Then the first number 5 will be replaced by 3

The code used above is the Python index code that I've learned from the lessons from before:
Append: A list doesn't have to have a fixed length. You can add items to the end of a list any time you like!

Slicing Lists and Strings: Think of strings as lists of characters: each character is a sequential item in the list, starting from index 0.

We can also insert items into a list.
Sometimes you need to search for an item in a list.
Example:
Write a statement in the indented part of the for-loop that prints a number equal to 2 * number for every list item.
The result is...All the numbers were multiplied by 2.
If your list is a jumbled mess, you may need to sort() it.
Items can be removed from a dictionary with the del command
Sometimes you need to remove something from a list.







Monday, March 11, 2019

TAKING A VACATION

TAKING A VACATION

What is this project about?
   This project wants me to write out a list of the things and costs that are involved in this trip.
Use:
def-define, in front of all functions
def function(units):
    return $$ * units
other examples!!

There can also be more than one units inside the bracket:


Project Outline in Python & Conclusion

   For the past few days, I've been working on lots of different projects and went through lots of examples. But in all these projects, I've been using the same code as the ones given in the lesson. Now I had a better understanding in the Python Language, and I feel more comfortable using Python Language as well.

   The projects I've went through is about:

  • Tip Calculator
  • Taking a vacation
  • Lists and Dictionaries
  • Shopping at super market
All these require to look up things and also using functions to solve problems. Mainly working with numbers, but I got the basic understanding of format of the codes used in this.

Tuesday, March 5, 2019

Function Junction

Function Junction

What I did today...
Functions are defined with three components:
1. The header, which includes the def keyword, the name of the function, and any parameters the function requires. 
2. An optional comment that explains what the function does.
3. The body, which describes the procedures the function carries out. The body is indented, just like conditional statements.
Example:
Notes: This can be used to solve math questions too.
Type 1:
 Steps: 1. Give instructions ahead using:
def __1__(_2_,_3_ ):
   """__"""
Print "%d to the _1_ of %d is %d." %(_2_, _3_, result)
 Step 2: 
__1__(_2_,_3_) plug in the numbers in 2 & 3.

Type 2:
Instructions given:

Type 3:
There is a Python module named math that includes a number of useful variables and functions, and sqrt() is one of those functions. In order to access math, all you need is the import keyword. When you simply import a module this way, it's called a generic import.
from math import sqrt
type sqrt() to get the square root of a number
The max() function takes any number of arguments and returns the largest one. 
Same with min()
The abs() function returns the absolute value of the number

What I learned today...
   I learned how to use Python Language to do different kinds of math. Steps are listed above. This lesson is really useful for software designers and online architecture designers. As this will accurately shows the math of the numbers, no matter how big the number is.
What I'll be doing tomorrow...
  I will be moving onto the next lesson tomorrow. The next lesson is more about the use of the Python Language that I learned from the past few days. This lesson is using Python Language to look up things in the dictionaries and go through lists.

Friday, March 1, 2019

February-->March Post

   In February, I started taking online lessons on websites like Codecademy and w3schools. And so far I've learn and had the basic understanding of HTML, a bit of C++ and also just started Python Language. I also did quizzes and exercises about what I learned as well, and the results and notes are showed in my past posts.
  Starting in March, I decided to stick with what I'm doing and continue learning from the websites, and I hope I am able to finish learning Java and CSS. But I will be wrapping up what I'm learning right now which is Python Language using the first week. And also do quizzes on those as well.

CONDITIONALS & CONTROL FLOW

Go With the Flow

  • Control flow gives us this ability to choose among outcomes based on what else is happening in the program.
  • Comparators
-Equal to (==)
-Not equal to (!=)
-Less than (<)
-Less than or equal to (<=)
-Greater than (>)
-Greater than or equal to (>=)
-To the power of (**)
Ex:


  • Boolean operators compare statements and result in boolean values. There are three boolean operators:
-and, which checks if both the statements are True;
-or, which checks if at least one of the statements is True;
-not, which gives the opposite of the statement.
Note: As it moves on, the lesson gets trickier. I start to mess up a little bit with all the "not true" "not not false"
  • Pay attention to the indentation before the print statement. This space, called white space, is how Python knows we are entering a new block of code. Python accepts many different kinds of indentation to indicate blocks. In this lesson, we use four spaces but elsewhere you might encounter two-space indentation or tabs (which Python will see as different from spaces).
  • The else statement complements the if statement.
  • elif is short for "else if."
What I learned... 
   I learned the control flow of the Language, but it's kind of hard because it is really easy to have things mixed up as the logic are really similar. And it's just making it hard by saying it in different ways, such as:"False" "Not true" "Not not false".

What I'll be doing tomorrow...
 I will be moving onto another lesson in the Python Language called 

PygLatin



The Datetime Library

The Datetime Library

  • Use datetime to print the date and time in a nice format.
  • EX:


  • Code to print date in the form of mm/dd/yy
print '%02d/%02d/%04d' %(now.month, now.day, now.year)

print hour:minute:second (hh:mm:ss)
print '%s:%s:%s' % (now.hour, now.minute, now.second)

Print mm/dd/yy hh:mm:ss
print '%02d/%02d/%02d %02d:%02d:%04d' % (now.month, now.day, now.year,now.hour, now.minute, now.second)


What did I learn...

   This was a simple lesson, but it was a really useful lesson. I learned how to print the date and time onto the screen using code.

What I'll be doing tomorrow...

  I will be moving onto another lesson tomorrow and it will be about CONDITIONALS & CONTROL FLOW.