forked from canbula/ParallelProgramming
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'canbula:master' into master
- Loading branch information
Showing
71 changed files
with
3,653 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# This workflow will install Python dependencies, run tests and lint with a single version of Python | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python | ||
|
||
name: Week04 Homework | ||
|
||
on: | ||
push: | ||
branches: [ "master" ] | ||
paths: ['Week04/**'] | ||
pull_request: | ||
branches: [ "master" ] | ||
paths: ['Week04/**'] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python 3.12 | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: "3.12" | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install flake8 pytest | ||
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | ||
- name: Lint with flake8 | ||
run: | | ||
# stop the build if there are Python syntax errors or undefined names | ||
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | ||
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide | ||
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | ||
- name: Test with pytest | ||
run: | | ||
pytest -q --tb=no 'Week04/test_awaitme.py' |
Binary file not shown.
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
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
my_list = ["A", "B", "C", "D", "A", "B"] | ||
my_tuple = (1,4,10,3,6,9,2) | ||
my_set = {"A", 2, "B", 3, "C"} | ||
my_dict = {"A" : 3, "B" : 2, "C" : 1} | ||
|
||
def remove_duplicates(my_list): | ||
return list(set(my_list)) | ||
|
||
def list_counts(my_list): | ||
the_list = list(my_list) | ||
the_dict = {} | ||
|
||
for item in the_list: | ||
occurance = the_list.count(item) | ||
the_dict[item] = occurance | ||
return the_dict | ||
|
||
def reverse_dict(my_dict): | ||
the_dict = dict(my_dict) | ||
new_dict = {} | ||
for item in the_dict: | ||
new_dict[the_dict[item]] = item | ||
return new_dict |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
my_list= [1,2,3,4,5] | ||
my_tuple= (1,2,3) | ||
my_set= {1,2,3} | ||
my_dict= {"one" : 1, "two" : 2, "three" : 3} | ||
|
||
def remove_duplicates(my_list: list) -> list: | ||
return list(set(my_list)) | ||
|
||
def list_counts(my_list: list)-> dict: | ||
return {index: my_list.count(index) for index in set(my_list)} | ||
|
||
def reverse_dict(my_dict: dict)-> dict: | ||
return{item: key for key, item in my_dict.items() } |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
my_list = [1,2,3,3,4,5,6] | ||
my_tuple = (7,8,9) | ||
my_set = {"","",""} | ||
my_dict = {"name": "Murat" ,"surname": "Turan","age": 21} | ||
|
||
|
||
def remove_duplicates(my_list): | ||
new_list=[] | ||
for item in my_list: | ||
if item not in new_list: | ||
new_list.append(item) | ||
|
||
return new_list | ||
|
||
def list_counts(my_list): | ||
counter = {} | ||
for i in my_list: | ||
if i in counter: | ||
counter[i] +=1 | ||
else: | ||
counter[i]=1 | ||
return counter | ||
|
||
|
||
def reverse_dict(dictionary): | ||
return {value: key for key, value in dictionary.items()} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
my_list = [1, "Wow", 2.1] | ||
my_tuple = (1, "Wow", 2.1) | ||
my_set = {1, "Wow", 2.1} | ||
my_dict = {1:1, "Wow":"Wow", 2.1: 2.1} | ||
|
||
def remove_duplicates(my_list): | ||
return list(set(my_list)) | ||
|
||
def list_counts(my_list): | ||
return {item: my_list.count(item) for item in my_list} | ||
|
||
def reverse_dict(my_dict): | ||
return {value: key for key, value in my_dict.items()} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
my_int = 2 | ||
my_float = 3.4 | ||
my_bool = True | ||
my_complex = 4 + 6j |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
my_int = 10 | ||
my_float = 10.3 | ||
my_bool = False | ||
my_complex = 10j |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
my_int = 1 | ||
my_float= 3.1 | ||
my_bool= True | ||
my_complex= 2+4j |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
my_int=4 | ||
my_float=0.04 | ||
my_bool=False | ||
my_complex=3+5j |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
my_int = 1 | ||
my_float = 1.0 | ||
my_bool = True | ||
my_complex = 1 + 1j |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
my_list = [3, 6.7, 3, 8, 8, 55, 5, 34, 133, 345, 3456, 2, 5, 43, 2, 2, 1.2] | ||
my_tuple = (3, 12, 65, 43, 12) | ||
my_set = {"Formula1", "Formula2", "Formula3"} | ||
my_dict = {"Day One": 1,"Day Two": 2, "Day Three": 3} | ||
|
||
|
||
def remove_duplicates(my_list) -> list: | ||
return list(set(my_list)) | ||
|
||
def list_counts(my_list) -> dict: | ||
return {element_count: my_list.count(element_count) for element_count in set(my_list)} | ||
|
||
def reverse_dict(my_dict) -> dict: | ||
return {value: key for key, value in my_dict.items()} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
def remove_duplicates(seq): | ||
unique_items = [] | ||
for item in seq: | ||
if item not in unique_items: | ||
unique_items.append(item) | ||
return unique_items | ||
|
||
def list_counts(seq): | ||
item_counts = {} | ||
for item in seq: | ||
if item in item_counts: | ||
item_counts[item] += 1 | ||
else: | ||
item_counts[item] = 1 | ||
return item_counts | ||
|
||
def reverse_dict(d): | ||
reversed_dict = {} | ||
for key, value in d.items(): | ||
reversed_dict[value] = key | ||
return reversed_dict | ||
|
||
# Example Data | ||
my_list = [2, 6, 8] | ||
my_tuple = (4, 6, 9) | ||
my_set = {3, 4, 5} | ||
my_dict = {1: 4, 5: 7, 7: 5} | ||
|
||
#Sample transactions | ||
unique_list = remove_duplicates(my_list) | ||
item_counts_dict = list_counts(my_list) | ||
reversed_dict = reverse_dict(my_dict) | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
my_int = 26 | ||
my_float = 26.30 | ||
my_bool = False | ||
my_complex = 4j |
Oops, something went wrong.