Advertisement
uopspop

Untitled

Sep 19th, 2018
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.40 KB | None | 0 0
  1. Learning Journal Unit 2
  2. In the reading assignment, I learn some more fundamental concepts in Python, including variables, expressions and statements and etc.
  3. When I was learning how to use variables in Python, I found there is no need to declare the type of variables when I create a variable. The interpreter in Python will automatically evaluate what data type to assign to that variable. I’m not used to this coding style since I’ve used Java for a while. Though, it does resonate with my experience with JavaScript in which I use var keyword for every variable. It’s actually very convenient to write codes without specifying types for every variable. I understand more about one of the advantages of Python we discussed in Unit 1: quick development. It’s really efficient to write a simple demo by using interpreted languages such as Python.
  4. When I was reading the expressions and statements in Python, all concepts and codes are logically predictable. Therefore, it becomes easier to understand and to use for my Writing Assignment. While I was learning all the sub-chapters such as script mode, the order of operations, string operations, comments and debugging, there was one small thing that surprises me. The statement ‘Spam’*3 results in ‘SpamSpamSpam’, because in Java there are no such operators for String type. Somehow, Python treats the operator for String similarly the way it treats numerals by multiplying a base by 3. If I’m asked to say if there is something I’m not so familiar with, I would say it’s the difference between interactive mode and script mode. It’s very convenient to write Python right away in interactive mode since I can get the result line by line instantly. While in Python I have the second option which is script mode, I have to save a script file first and then execute it. The behavior of script is in some way more like what I do in Java. I write everything in one or many files and then I execute those files to see the result at once.
  5. In the Discussion Forum, I learned the naming style of Python. My source mainly comes from the PEP8 style guide. There are two main principles for variable naming – using lowercases and underscores. Regarding using lower cases and underscores, I concur with these rules since in Java it’s common that people use lowercases and underscores to name their variables. Nonetheless, in PEP8, there is one more suggestion which discourages the use of camel case. From my experience in Java, I use camel case more than underscores for variable names when I need to connect several words in a variable name. I might have to adapt to a new habit of coding when I use Python. It’s always beneficial to me by comparing the difference between the languages I’ve used and the languages I’m learning.
  6. In the Writing Assignment, it’s the first time I wrote a complete script file in Python. I gradually get used to using indentation to indicate code blocks. It produces a very neat code without all those verbose syntaxes I see in Java. Also, in this assignment, I got the chance to practice naming convention for variables in Python. I tried to name my variables with lowercases and using underscores to separate words in a variable name. Overall, I really like the final code of Python. It’s so clean and easy to understand. Also, it saves lots of my time because I don’t need to type many things such as variable types.
  7. words: 586
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement