Wiki
FlickrLeetcode
  • 💞Artificial Intelligence
    • ⚙️Midjourney vs Stable Diffusion
    • ⚙️Creative QR Codes with ControlNet
      • ⚙️How to generate a QR Code
      • ⚙️Collect prompt
      • ⚙️clip skip
      • ⚙️AUTOMATIC1111
      • ⚙️Edge detection and human pose detection
    • ⚙️Stable Diffusion
    • ⚙️What is 'token' and 'turbo'?
    • ⚙️Today's learning--LangChain
      • ⚙️Prompt
    • ⚙️LLM Parameters Demystified
    • ⚙️What is Cohere playground?
    • ⚙️DALL-E
    • ⚙️How to use AI to learn something that you don't know?
    • ⚙️Diffusers
    • Boosting Algorithms in machine learning, part 1:AdaBoost
  • 💞GitHub
    • ✅How to add a issue of the code with GitHub?
    • ✅How to edit code?
    • ✅How to use GitHub Desktop
    • ✅How to review in GutHub?
  • 💞Lastest concepts for me
    • 🪅Pandas DataFrame
    • 🪅Choosing between loc and iloc
  • 💞Need to remember
    • 🔢An article for leetcode
    • 🉑two types of group work
    • 🍒What is hashtag#?
    • 🐝Week6_APD
    • 🦋API
    • 🎼BFF
  • 💞Python
    • 🐍argument & parameter
    • 🐍"{:.2f}"
    • 🐍Timeit in Python
    • 🐍Today's learning--Pylint
    • 🐍Split and Strip in Python
    • 🐍Getter and Setter in Python
    • 🐍"import json" in Python
    • 🐍Open CSV file in Python
    • 🐍print(f"An error occurred: {e}")
  • Page
  • 🪅command-line
  • 💞DataVisualization
    • 🪅How to choose plot type
  • 💞DataCleaning
    • 🪅Some basic code of data_cleaning
  • 💞Java
    • 🍡difference use between ArrayList and HashMap in Java
    • 🍡ArrayList & LinkedList
    • 🍡assertFalse(App.checkInputNumber(1,0))
      • 🍡HashSet
    • 🍡iterator
    • 🍡Java concept of assignment 1
    • 🍡Week6_Java
    • 🍡serializable
  • 💞Mark something that easily to forget
    • 🙉Mark something
    • 🙉How to edit cover picture from "Flickr" using "URL" in GitBook?
  • 💞VS Code
    • ✖️Install a project in VS Code
    • ✖️What should do after editing the code of one branch?
    • ✖️How to create a branch in VS code?
    • ✖️How to debug?
Powered by GitBook
On this page
  • def gpa(self,student_id:str) -> float:
  • What is the purpose of the "self" parameter in Python class methods
  • "def display_results(self) -> None:" and "def display_results(self):"
  • Difference between "list" and "dictionary"
  • print(title[:-1]). [-1] in python
  • print(k,end="") and print(k,end="{:>12}".format(""))

Was this helpful?

Edit on GitHub
  1. Python

argument & parameter

The difference between argument and parameter

PreviousBFFNext"{:.2f}"

Last updated 1 year ago

Was this helpful?

Arguments and parameters are two terms that are often used interchangeably, but they have different meanings in programming. Here are the differences between argument and parameter:

  • Parameter: A parameter is a variable in a function definition that acts as a placeholder for a value that will be passed to the function when it is called. It is a part of the function's signature and defines the type and number of values that the function expects to receive.

  • Argument: An argument is a value that is passed to a function when it is called. It is the actual value that is assigned to the parameter of the function. Arguments are passed to a function in the order that the parameters are defined.

In summary, a parameter is a variable that is defined in a function, while an argument is the value that is passed to that parameter when the function is called.

def gpa(self,student_id:str) -> float:

The function definition "def gpa(self, student_id:str) -> float" means that it is a Python function that takes in two arguments: "self" and "student_id", where "self" refers to the instance of the class and "student_id" is a string argument. The "-> float" part of the definition specifies that the function returns a floating-point number (a decimal number). In other words, the function calculates and returns the GPA (grade point average) of the student with the given ID.

What is the purpose of the "self" parameter in Python class methods

In Python, the "self" parameter is used in class methods to refer to the instance of the class. It is always the first parameter in a method definition and is passed implicitly when the method is called on an instance of the class. The "self" parameter allows access to the attributes and methods of the class within the method. It is used to differentiate between instance variables and local variables within the method. The use of "self" makes the code more readable and explicit, as it clearly indicates that the method is being called on an instance of the class

"def display_results(self) -> None:" and "def display_results(self):"

the former specifies the return type of the function, while the latter does not. The "-> None" in the first example indicates that the function does not return anything.

Difference between "list" and "dictionary"

A list[] is an ordered collection of elements, and each element can be accessed using its index. A dictionary{}, on the other hand, is an unordered collection of key-value pairs, and each value can be accessed using its key.

print(title[:-1]). [-1] in python

In Python, "print(title[:-1])" means to print the "title" string without its last character.

The square brackets[] are used to slice the string, and the colon: inside the brackets indicates that we want to slice the string. The ":-1" part of the code specifies the range of the slice, where the first colon indicates the start of the slice, and the "-1" indicates the end of the slice. In Python, negative indices are used to count from the end of the string, so "-1" refers to the last character of the string. Therefore, "title[:-1]" returns a new string that contains all the characters of the "title" string except for the last one. Finally, the "print()" function is used to display the resulting string on the console.

print(k,end="") and print(k,end="{:>12}".format(""))

By default, the "end" parameter is set to "\n", which means that a newline character is printed at the end of the output. However, by setting the "end" parameter to an empty string, we can print the output without a newline character.

The "{:>12}" part of the code is a string formatting expression that specifies how the spaces should be formatted. The ">" character indicates that the spaces should be right-aligned, while the "12" indicates the width of the field, which is 12 characters. Finally, the empty string "" is used to fill the field with spaces.

💞
🐍
1
2
3
4
1
2
3
1
2
3
5