Skip to content

Instantly share code, notes, and snippets.

View elowy01's full-sized avatar

Ernesto Lowy elowy01

  • Biofidelity
  • Cambridge, UK
View GitHub Profile
@elowy01
elowy01 / issues.txt
Last active February 22, 2022 16:25
# temp workaround for screen changing manually set window title when you change
# of directory
export PROMPT_COMMAND="" # this has to be done everytime you open a new tab
"""
https://www.statology.org/chi-square-test-of-independence-python/
Example: Chi-Square Test of Independence in Python
Suppose we want to know whether or not gender is associated with political party preference.
We take a simple random sample of 500 voters and survey them on their political party preference.
The following table shows the results of the survey:
Republican Democrat Independent Total
Male 120 90 40 250
https://www.hackerrank.com/challenges/py-set-discard-remove-pop/problem
Solution:
n = int(input())
s = set(map(int, input().split()))
for _ in range(int(input())):
elms= input().split()
if len(elms)>1:
eval(f"s.{elms[0]}({elms[1]})")
"""
Given the names and grades for each student in a class of students, store them in a nested list and print the name(s) of any student(s) having the second lowest grade.
Note: If there are multiple students with the second lowest grade, order their names alphabetically and print each name on a new line.
Example
The ordered list of scores is , so the second lowest score is . There are two students with that score: . Ordered alphabetically, the names are printed as:
alpha
#Converting a string representation of a list into an actual list object
fruits = "['apple', 'orange', 'banana']"
import ast
fruits = ast.literal_eval(fruits)
fruits
['apple', 'orange', 'banana']
fruits[1]
'orange'
# setting class attributes dynamically with variable number of arguments and kwargs:
class Bar(object):
def __init__(self, **kwargs):
self.__dict__.update(kwargs)
bar = Bar(a=1, b=2)
print(bar.b)
# And if you want to allow only a certain attributes:
# how to make a function to return multiple values, Read article on:
https://note.nkmk.me/en/python-function-return-multiple-values/
# get creation and last modification time of a file or directory
import os.path, time
print("Last modified: %s" % time.ctime(os.path.getmtime("test.py")))
print("Created: %s" % time.ctime(os.path.getctime("test.py")))
# enter a list of numbers from command line
numbers = list(map(int, input().split()))
print(numbers)
Tutorial from:
https://docs.aws.amazon.com/lambda/latest/dg/with-s3-example.html?trk=em_a134p000006wD7CAAU&trkCampaign=psc-2021-lambda-blog-S3&sc_channel=em&sc_campaign=GLOBAL_PM_GS_lambda-getting-started_20210500_&sc_medium=em_376711&sc_outcome=Product_Marketing&sc_content=AWS_Webpage&mkt_tok=MTEyLVRaTS03NjYAAAF_Wi-O7zXNHlvkSLZpeRfvdykye68CXxb8jDmEjsnW9cSVoVtVe0IEZ_nvT-tx4ag61Fm8RvrG_BlY7wfkMN8-RODWVmvzRwuN6H-d9JBQ8JwZ14TbrDq0
1) Create a Bucket and upload a file in it
Dashboard-->S3-->Create Bucket
Give name and select your AWS region
Leave defaults
Now, upload a file from your system to the bucket using the console
2) Create the Lambda function
Open the Functions page on the Lambda console.