A

@antonioortegajr

products.py

Python
3 years ago
import json data = {"products":[{"id":1,"title":"iPhone 9","description":"An apple mobile which is nothing like apple","price":549,"discountPercentage":12.96,"rating":4.69,"stock":94,"brand":"Apple","category":"smartphones","thumbnail":"https://i.dummyjson.com/data/products/1/thumbnail.jpg","images":["https://i.dummyjson.com/data/products/1/1.jpg","https://i.dummyjson.com/data/products/1/2.jpg","https://i.dummyjson.com/data/products/1/3.jpg","https://i.dummyjson.com/data/products/1/4.jpg","htt

data_basics_exercise.py

Python
3 years ago
import json # JSON string is our data data_string = '{"name": "Antonio", "current_age": 44, "current_year": 2023, "birth_year": 1978, "age_first_computer": 8}' # deserializes into dict # and returns dict. data = json.loads(data_string)

shapes.py

Python
3 years ago
# We are using the libraires below # We can import a package and give a shorter name. # plt is an example import matplotlib.pyplot as plt import numpy as np # now we can access (and chain) functions in the library via dot notation # Below we employ the library functions style and use() passing an argument plt.style.use('_mpl-gallery-nogrid')

debug2.py

Python
3 years ago
import numpy as np # this is broken someplace a = np.arange(15).reshape(3, 5) attributes_of_a = [ a.shape, a.ndim, a.dtype.name, a.itemsize, a.size,

debug1.py

Python
3 years ago
#This is broken testing = "work" if testing in ["work": print("Working.") else: print("Broken")

random_gene

Python
3 years ago
import random bases = ['a', 't', 'c', 'g'] sequenceList = [] for n in range(0, 25000): sequenceList.append(random.choice(bases)) chromosome = "".join(sequenceList) print(chromosome)

data_basics_exercise

Python
3 years ago
import json # JSON string is our data data_string = '{"name": "Antonio", "current_age": 44, "current_year": 2023, "birth_year": 1978, "age_first_computer": 8}' # deserializes into dict # and returns dict. data = json.loads(data_string)

data_basics

Python
3 years ago
import json # JSON string is our data data_string = '{"name": "Antonio", "current_age": 44, "current_year": 2023, "birth_year": 1978, "age_first_computer": 8}' # deserializes into dict # and returns dict. data = json.loads(data_string) # loops. Lets print out all the keys and values in our data

basics_exercise

Python
3 years ago
# Create your own basics file with some basic math # Basics exercise: https://www.mycompiler.io/view/K8ZhHX8Hkku # Add a variable named with a number value # Add a function named over_hundred that accepts an argument named data """ As the name implies we just want to know how much over a hundred this is. this work my be usefully over and over again so we capture the process in a function with an argument

basics

Python
3 years ago
# This is a simple example you can run # Most examples will have notes like this. # declare a variable sentence = True def my_function(data): return data + "!!!"

hello

Python
3 years ago
message = hello from python" # Print text from variable message print(message)