Skip to content

Instantly share code, notes, and snippets.

<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>
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
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
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):
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",
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"
},
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'}}
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
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
def example_fun(param0, param1):
"""
Does what
Args:
param0:
param1:
Returns:
Describe the return value