View pyscript_hello_world.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" /> | |
<script defer src="https://pyscript.net/alpha/pyscript.js"></script> | |
</head> | |
<h1>PyScript Hello World!</h1> | |
<body> | |
<py-script>print("Hello, World!")</py-script> | |
</body> | |
</html> |
View updated_Student_class.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Student(Person): | |
def __init__(self, name, student_id, grade): | |
super().__init__(name, student_id) | |
self.grade = grade | |
def check_in(self, arriving_time): | |
super().check_in(arriving_time) | |
required_time = "08:00" | |
on_time = arriving_time <= required_time | |
# save the data to the database |
View person_superclass.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Person: | |
def __init__(self, name, person_id): | |
self.name = name | |
self.person_id = person_id | |
def load_account(self, amount): | |
# fetch the amount from the server | |
current_balance = 100 | |
current_balance += amount | |
# save the new balance to the server |
View person_two_classes.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Student: | |
def __init__(self, name, student_id, grade): | |
self.name = name | |
self.student_id = student_id | |
self.grade = grade | |
def register_course(self, course): | |
pass | |
def load_account(self, amount): |
View json_python_dumps_sort.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
employee_info = {"name": "John", "age": 35, "city": "San Francisco", "home": "123 Main St.", "zip_code": 12345, "sex": "Male"} | |
print(json.dumps(employee_info, indent=2, sort_keys=True)) | |
# output: | |
{ | |
"age": 35, | |
"city": "San Francisco", | |
"home": "123 Main St.", | |
"name": "John", | |
"sex": "Male", |
View json_python_dumps.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
employee_data = [{"name": "John", "age": 35, "city": "San Francisco"}, {"name": "Zoe", "age": 34, "city": "Los Angeles"}] | |
print(json.dumps(employee_data, indent=2)) | |
# output: | |
[ | |
{ | |
"name": "John", | |
"age": 35, | |
"city": "San Francisco" | |
}, |
View json_python_loads.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
employee_data = json.loads(employee_json_data) | |
print(employee_data) | |
# {'employee0': {'firstName': 'John', 'lastName': 'Smith', 'age': 35, 'city': 'San Francisco'}, 'employee1': {'firstName': 'Zoe', 'lastName': 'Thompson', 'age': 32, 'city': 'Los Angeles'}} |
View docstring_exception.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def quotient(dividend, divisor, taking_int=False): | |
""" | |
Calculate the product of two numbers with a base factor. | |
:param dividend: int | float, the dividend in the division | |
:param divisor: int | float, the divisor in the division | |
:param taking_int: bool, whether only taking the integer part of the quotient; | |
default: False, which calculates the precise quotient of the two numbers | |
:return: float | int, the quotient of the dividend and divisor |
View docstring_example.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def quotient(dividend, divisor, taking_int=False): | |
""" | |
Calculate the product of two numbers with a base factor. | |
:param dividend: int | float, the dividend in the division | |
:param divisor: int | float, the divisor in the division | |
:param taking_int: bool, whether only taking the integer part of the quotient; | |
default: False, which calculates the precise quotient of the two numbers | |
:return: float | int, the quotient of the dividend and divisor |
View doc_string_google.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def example_fun(param0, param1): | |
""" | |
Does what | |
Args: | |
param0: | |
param1: | |
Returns: | |
Describe the return value |
NewerOlder