This file contains hidden or 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> |
This file contains hidden or 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 |
This file contains hidden or 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 |
This file contains hidden or 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): |
This file contains hidden or 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", |
This file contains hidden or 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" | |
}, |
This file contains hidden or 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'}} |
This file contains hidden or 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 |
This file contains hidden or 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 |
This file contains hidden or 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