blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
2e80109811c17a80fea98d970307850d64edd302
Dragonriser/DSA_Practice
/LinkedLists/LinkedListCycle.py
454
3.859375
4
#QUESTION: #Detect if a linked list has a cycle. #Using 2 pointers- fast and slow. In a circle they will eventually meet each other, hence cycle is detected. #CODE: class Solution: def hasCycle(self, head: ListNode) -> bool: slow = fast = head while fast and fast.next: slow = slow.next ...
9ef0a45a11579a6bb459fbf54bf0092c7c020b7e
Dragonriser/DSA_Practice
/Dynamic Programming/UniquePaths.py
1,961
3.9375
4
#QUESTION: A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram below). How many possible unique paths are there...
75b4292c4e85d8edd136e7bf469c60e9222e383f
Dragonriser/DSA_Practice
/Binary Search/OrderAgnostic.py
847
4.125
4
""" Given a sorted array of numbers, find if a given number ‘key’ is present in the array. Though we know that the array is sorted, we don’t know if it’s sorted in ascending or descending order. You should assume that the array can have duplicates. Write a function to return the index of the ‘key’ if it is present in ...
cace5ce20518d3711b51f563ba7741437f5f6a8f
Dragonriser/DSA_Practice
/LinkedLists/MiddleOfList.py
485
4.09375
4
#QUESTION: #Find the middle of the Linked List. #Method 1: #Just traverse the entire list, to find length. Then return node at length / 2 #Method 2: #Have 2 pointers. One traverses 2 nodes at once, while the other traverses one. By the time the faster one reaches the end, the slower one will reach the middle. #CODE:...
d6b9c248126e6027e39f3f61d17d8a1a73f687b0
Dragonriser/DSA_Practice
/LinkedLists/MergeSortedLists.py
877
4.1875
4
#QUESTION: #Merge two sorted linked lists and return it as a new sorted list. The new list should be made by splicing together the nodes of the first two lists. #APPROACH: #Naive: Merge the linked Lists and sort them. #Optimised: Traverse through lists and add elements to new list according to value, since both lists...
ce4647c1adbd85de6d94d35e511f81a44c8c351f
Dragonriser/DSA_Practice
/Bit Manipulation/MissingNumber.py
985
3.546875
4
#QUESTION: Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array. #Follow up: Could you implement a solution using only O(1) extra space complexity and O(n) runtime complexity? #CODE: class Solution: def missingNumber(self, nums: L...
17855bcea6c00238e952b01112236d4a0bebda6d
CodecoolBP20161/python-pair-programming-exercises-2nd-tw-mikloci
/listoverlap/listoverlap_module.py
418
4.09375
4
def listoverlap(list1, list2): c = [] for i in list1: for j in list2: if i == j: if j not in c: c.append(j) return c def main(): a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] b = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] c = listoverlap(a,...
80c2632c8dc49c71fe182f7f83344830abb797e6
343829084/python_practice
/OrderedDict.py
544
3.875
4
from collections import OrderedDict class FILOOrderDict(OrderedDict): def __init__(self, capacity): super(FILOOrderDict, self).__init__() self.capacity = capacity def __setitem__(self, key, value): containsKey = 1 if key in self else 0 OrderedDict.__setitem__(self, key, value) ...
ba947707a49493ec0f39d013704c18e49f2aa857
julianje/Bishop
/build/lib/bishop/Agent.py
10,234
3.890625
4
# -*- coding: utf-8 -*- """ Stores information about agent and comes with supporting methods to sample random agents. """ import random import numpy as np class Agent(object): def __init__(self, Map, CostPrior, RewardPrior, CostParams, RewardParams, Capacity=-1, Minimum=0, SoftmaxChoice=True, SoftmaxAction=Tru...
bc8483b86c4d416130f367249ffe0df98a5d07e6
julianje/Bishop
/Bishop/Map.py
18,887
3.96875
4
# -*- coding: utf-8 -*- """ Map class. Maps are a essentially an abstraction on top of MDPs that make it move intuitive to interact with the planner. """ import numpy as np import sys import math class Map(object): def __init__(self, ObjectLocations=[], ObjectTypes=[], Organic=[], SurvivalProb=1, ObjectNames=[...
f0438d1379df6974702dc34ef108073385a3877e
Nightzxfx/Pyton
/function.py
1,069
4.1875
4
def square(n): """Returns the square of a number.""" squared = n ** 2 print "%d squared is %d." % (n, squared) <--%d because is comming from def (function) return squared # Call the square function on line 10! Make sure to # include the number 10 between the parentheses. square(10) ------------------------...
2677119db01d3fd1d41347277081543c738d20b3
sad786/Python-Practice-Programs
/Python/Palindrome.py
334
4.09375
4
''' palindrome number is the number if we reverse the sequence of the digits then we will get the same number ''' x = int(input("Enter any number = ")) n = x res = 0 while n>0: t = int(n%10) n = int(n/10) res = res*10+t if res==x: print(x,"is palindrome number") else: print(x,"is not palin...
8b5cfaf02f500a4eab9704acd41d533236095ef3
maelys/Images_downloader
/database_manager.py
1,303
3.734375
4
import sqlite3 class DatabaseManager: CREATE_TABLE = "CREATE TABLE IF NOT EXISTS photos (photo_id PRIMARY KEY, user_name text, tags text, upload_date text, vote text, avg text);" INSERT_QUERY = "INSERT INTO photos (photo_id, user_name, tags, upload_date, vote, avg) VALUES (?, ?, ?, ?, ?, ?);" ...
17dddfaf05ed5f17df5de99738bea1c8f0b3c6cb
ludwigflo/ml_utils
/src/ml_utils/data_utils/data_split.py
2,981
4.03125
4
import random def data_split(num_data: int, train_data: float, val_data: float, shuffle: bool = True) -> tuple: """ Computes the indices for a training, validation and test split, based on the total number of data. The test data are the remaining data, which have not been assigned to training or val...
087d90c8f10870f8efa7882d4341501eeb4c9f57
Wasylus/lessons
/lesson22.py
1,053
3.734375
4
# test.assert_equals(nth_fib(3), 1, "3-rd Fibo") # test.assert_equals(nth_fib(4), 2, "4-th Fibo") # test.assert_equals(nth_fib(5), 3, "5-th Fibo") # test.assert_equals(nth_fib(6), 5, "6-th Fibo") # test.assert_equals(nth_fib(7), 8, "7-th Fibo") # def fib(n): # pass # def fib(n): # raise NotImplement...
12188e81219abc09fc9e995f00ec54a52b605166
Wasylus/lessons
/lesson12.py
1,117
4.4375
4
# print(int(bmi)) # # 1. What if bmi is 13 # # 2. What if bmi is 33 # if bmi <= 18: # print("Your BMI is 18, you are underweight.") # elif bmi >= 22: # print("Your BMI is 22, you have a normal weight.") # elif bmi >= 28: # print("Your BMI is 28, you are slightly overweight.") # elif bmi >= 33: ...
698acc83f10059e5905a491a162a63e6ab518c07
Wasylus/lessons
/lesson27.py
1,233
3.90625
4
# TODO: This method needs to be called multiple times for the same person (my_name). # It would be nice if we didnt have to always pass in my_name every time we needed to great someone. class Person: def __init__(self, my_name): self.name = my_name def greet(self, your_name: str) -> s...
8a2d42da1ecc91edeb91370f73cc4cf75137df54
kokowhen/my_Learning_Notes
/Python/Codes/list_pra.py
2,104
3.953125
4
namelists=[1,2,3,"小明","k"] #数据的操作:增、删、改、查、排、反 i=0 for namelist in namelists: while i<5: namelists.append("jeffery") #append是在列表的末尾增加元素,默认把增加的对象当作一个元素 i+=1 b=[90,100] namelists.append(b) print(namelists) print(namelists[2:8:3]) namelists.extend(b) #extend是把a列表里的元素逐一增加到b列表的末尾 namelists.insert(4,"ja...
b4f6c409b78ec37ec8d0848556502085b9059111
kokowhen/my_Learning_Notes
/Python/Codes/pra_729.py
953
3.734375
4
#向函数传递列表 def greet_users(names): for name in names: msg = "Hello,"+ name +"!" print(msg) usernames = ["hannah","ty","margot","Jeffery"] greet_users(usernames) #在函数中修改列表 #传递任意数量的实参 #1.结合使用位置实参和任意数量实参 def song(author,*songname): print("{}'s song :\n{}".format(author,songname)) song("zhoujielun","J","K","l")#所...
553e1903b680207d1c0e956b7b881692609834a3
OJ13/Python
/Udemy/Iniciantes/condicionais.py
400
4.1875
4
numero = 1 if(numero == 1): print("Numero é igual a um") if(numero == 2) : print("Número é igual a Dois") numero = 3 if(numero == 1): print("Numero é igual a um") else: print("Número não é igual a um") nome = "Junior" if("z" in nome) : print("Contém 'Z' no nome") elif("o" in nome) : print(...
79a5a20c451782ce716bc8e2ec9ab797d4fed101
OJ13/Python
/Udemy/python&MySql/exercicios.py
1,236
3.890625
4
#Baskara #a2 + bx + c #(-b +- sqtr(b2-4ac))/2 from math import sqrt a = int(input("Digite o valor de a: ")) b = int(input("Digite o valor de b: ")) c = int(input("Digite o valor de c: ")) delta = b**2 - 4*a*c raiz_delta = sqrt(delta) x1 = (-b + raiz_delta)/(2*a) x2 = (-b - raiz_delta)/(2*a) print("x1 = %f" %x1) pri...
4b7f9a4c23369576bb69b8dc891165bb07802736
Rohitkumar3796/PYTHON_CODES
/PYTHON_CODES.py
32,095
3.9375
4
# HOW CAN WE CONVERT STRING VALUE TO INT str1="Hello World!" int_=''.join(map(str,map(ord,str1))) print(int(int_)) # -------------------------------------------------------------------- txt = "one one was a race horse, two two was one too." x = txt.replace("one", "three", 3) #here 3 means how much time "one is re...
c7eed0a9bee1a87a3164f81700d282d1370cebdb
philuu12/PYTHON_4_NTWK_ENGRS
/wk1_hw/Solution_wk1/ex7_yaml_json_read.py
835
4.3125
4
#!/usr/bin/env python ''' Write a Python program that reads both the YAML file and the JSON file created in exercise6 and pretty prints the data structure that is returned. ''' import yaml import json from pprint import pprint def output_format(my_list, my_str): ''' Make the output format easier to read ...
411a705b9688e6d9ff0e46ed66546ab0fe8184f6
PeteCoward/teach-python
/easy_crypto/lesson1/test_task3.py
561
3.515625
4
from .task3 import get_next_letter def test_get_next_letter(): ''' get the next letter in the alphabet cycling from Z to A ''' assert get_next_letter('A') == 'B', "the next letter after A should be B" assert get_next_letter('M') == 'N', "the next letter after M should be N" assert get_next_letter('Z')...
98ca62e618892837f9750bbbb16b0aec2128672b
PeteCoward/teach-python
/easy_crypto/lesson2/task3.py
227
3.984375
4
''' # TASK 3 - write a function to shift an array of bytes by caesar shift ''' def shift_byte_array(byte_array, shift): table = bytearray([(i + shift) % 256 for i in range(0, 256)]) return byte_array.translate(table)
201923fe72c91c891a2b8f7b0a05a7be55fe6fb5
Sharpeon/Tic-Tac-Toe-Online
/game.py
2,092
3.671875
4
import random class Game: def __init__(self, id) -> None: self.id = id self.turnP1 = random.choice([True, False]) self.rows = 3 self.cols = 3 self.grid = [[-1 for i in range(self.cols)] for j in range(self.rows)] # 2d arrays are weird in python... self.last_winner =...
ebc2bad584302fc5e3dd0a5993619f8c0c50e1c8
kirkbroadbelt/Python
/homework8.py
4,004
4.09375
4
# ST114: Homework 8 # Name: Kirk Broadbelt # Instructions: # In this assignment, we will practice using sorting and list comprehensions. # # A Python file homework8.py has been provided for you. You will need to # edit it and push it to your ncsu repo: # 'https://github.ncsu.edu/your-Unity-ID/you-Unity-IDST114...
9868eb19f13a3590ef0592456a1f4da332eda4ea
kirkbroadbelt/Python
/Final For Statistical Programming/linear_regression.py
5,269
3.640625
4
import numpy as np from scipy import stats import matplotlib.pyplot as plt from math import nan class SLR: def __init__(self, data): """ (SLR, Data) -> NoneType Create a new simple linear regression object from data, with data data, intercept beta0, and slope beta1. """ ...
96d7d761a9593d39c6d389de8c1dc506d61ef9b4
AASHMAN111/Addition-using-python
/Development/to_run_module.py
1,800
4.125
4
#This module takes two input from the user. The input can be numbers between 0 and 255. #This module keeps on executing until the user wishes. #This module can also be called as a main module. #addition_module.py is imported in this module for the addition #conversion_module.py is imported in this module for the co...
3e1b22ddeeea67da7f853215adaad5fc1490f157
ashish-bisht/leetcode_solutions
/57InsertInterval.py
649
3.921875
4
def insert_interval(intervals, new_interval): intervals.append(new_interval) intervals.sort() last_interval = intervals[0] res = [] for cur_interval in intervals[1:]: if cur_interval[0] <= last_interval[1]: last_interval[1] = max(cur_interval[1], last_interval[1]) else:...
da7678263f8f702a94c4ac8931943eee3436643e
ashish-bisht/leetcode_solutions
/5_longest_palindromic_substring.py
546
3.984375
4
def longest_palindromic_substring(string): ans = "" for i in range(len(string)): even = helper(string, i, i+1) odd = helper(string, i, i) ans = max(ans, even, odd, key=len) return ans def helper(string, left, right): while left >= 0 and right < len(string): if string[l...
ea93293c04c9cfd10a89bafde61c2453d4a035ab
ashish-bisht/leetcode_solutions
/1047remove_adjacent.py
236
3.984375
4
def remove_adjacent(string): stack = [] for ch in string: if stack and stack[-1] == ch: stack.pop() else: stack.append(ch) return ("").join(stack) print(remove_adjacent("abbaca"))
afa94a2794f02b1d8e55ea839a118a8de33276fa
ashish-bisht/leetcode_solutions
/394_decode_strings.py
721
3.71875
4
def decode_strings(string): cur_num = 0 cur_string = "" stack = [] for ch in string: if ch == "[": stack.append(cur_string) stack.append(cur_num) cur_string = "" cur_num = 0 elif ch.isnumeric(): cur_num = cur_num*10 + int(ch) ...
e4f00a45ffcd90311ef055f9aeac82db427e6f11
ashish-bisht/leetcode_solutions
/767.py
808
3.703125
4
def reorganise_string(string): import heapq from collections import Counter temp = list(string) count = Counter(temp) heap = [] for key, val in count.items(): heapq.heappush(heap, (-val, key)) res = [] val2 = -1 while heap: val1, key1 = heapq.heappop(heap) if...
5ba0d99e2b4c267c6e12a807b432825e465f8d57
ashish-bisht/leetcode_solutions
/389find_diffrence.py
256
3.84375
4
def find_diffrence(str1, str2): ans = 0 for ch in str1 + str2: ans ^= ord(ch) return chr(ans) print(find_diffrence("abcd", "abcde")) print(find_diffrence("", "y")) print(find_diffrence("a", "aa")) print(find_diffrence("ae", "aea"))
6e612e12a95e18c856a114f4602f9f49621bdf82
ashish-bisht/leetcode_solutions
/1209remove_adjacent.py
628
3.796875
4
def remove_adjacent(string, k): stack = [] for ch in string: print(stack) if len(stack) >= k and stack[-1] == ch: temp = "" for _ in range(k): if stack[-1] != ch: break cur = stack.pop() temp += cur ...
07de9ce5b5a0797592990f74153cc04296cc3547
jj1993/comp-sys
/smallnetwork.py
8,059
3.65625
4
import matplotlib.pyplot as plt import numpy as np import random import copy class Car(object): def __init__(self, edge, route, speed): self.edge = edge self.route = route self.pos = 0 self.speed=speed self.age = 0 self.aveSpeed = 0 # Visualisation point x, y...
1b188ae6f0a2d386265e42f72dac95089d02761f
ivy12138/driving
/driving.py
326
4.09375
4
country=input('where are you from?') age=int(input('how old are you?')) if country=='Taiwan': if age>=18: print('Yes,you can') else: print('No') elif country=='America': if age>=16: print('Yes,you can') else: print('No') else: print('you can only enter Taiwan or Ameri...
22b14040226a8e15bf326b88b673be6ada073258
yelinjo18/2021_PL_HW
/2021_PL_HW1/hw1_3.py
948
3.875
4
''' 과제 3 / 리스트를 Merge Sort로 정렬하라 - 입력은 input()을 통해 받을 것 - 입력은 리스트의 요소들이다 Input : 100 23 31 123 435 642 1 Output : [1, 23, 31, 100, 123, 435, 642] ''' #Merge Sort def MergeSort(list): if len(list)<=1: return list else: m_i=int(len(list)/2) # Recursion pre=Merg...
868ad4369cd64f877f4ea35f1a85c941aa9c7409
SaketJNU/software_engineering
/rcdu_2750_practicals/rcdu_2750_strings.py
2,923
4.40625
4
""" Strings are amongst the most popular types in Python. We can create them simply by enclosing characters in quotes. Python treats single quotes the same as double quotes. Creating strings is as simple as assigning a value to a variable. """ import string name = "shubham" print("Data in upper case : ",name.upper(...
12b2d25976624a786d7879b8895192d940e57f55
SaketJNU/software_engineering
/rcdu_2750_practicals/rcdu_2750_Calculater.py
1,381
3.9375
4
class Calculator(): def __init__(self): pass def addition(sefl,number, number2): return number+number2 def mult(self, number, number2): return number*number2 def sub(self, number, number2): return number-number2 def div(self, number, number2): return ...
8e238c386f0ef9c942d41fd5dfa79f245b6789e2
SaketJNU/software_engineering
/data_cleaning/read_all_json_new.py
579
3.546875
4
import json from clean_csv_data import list_all_files def read_json(file_name): with open(file_name) as f: file_data = json.load(f) print("_______________________ For file {} Data are following".format(file_name)) for k, v in file_data.items(): print("For Date {}, Price is {}".format(k, v...
0c41a027ed056aa70174f751ceb64314525af0fe
yhesper/PyniverseText
/tp2/planetClass.py
1,901
3.546875
4
import math ################################################# # Helper functions ################################################# import random class Planet(object): def __init__(self,x,y,r,l2): #x and y may changes self.x=x self.y=y+15 #r , l and never changes self.r=...
5aa142cf5cd874b3b1fd1b9f1b497354b99ecda7
echen67/Computer-Graphics
/p2a_object/p2a_object/p2a_object.pyde
10,163
3.640625
4
# Animation Example #Emily Chen time = 0 # use time to move objects from one frame to the next def setup(): size (800, 800, P3D) perspective (60 * PI / 180, 1, 0.1, 1000) # 60 degree field of view def draw(): global time time += 0.01 camera (0, 0, 100, 0, 0, 0, 0, 1, 0) # position the ...
a458281c5714e31e1b00a3b6bc9dc68fa9ca25f8
BME-AI-STUDY/BME_AI_STUDY-21_1
/3주차/answer3.py
3,026
3.6875
4
def check1(): ans = input("정답을 입력하시오") if ans == 'max,index': print('무야호~') else: print('오답') def check2(): ans = input("정답을 입력하시오") if ans == "OXXO": print("무야호~") else: print("떙!") def check3(): ans = input("정답을 입력하시오") if ans == "교차엔트로피" or an...
682b42e3089a87c4b24c8ee528e663bdfb466fd5
shubham3000/python_turtle
/circle/circle.py
335
3.90625
4
import turtle turtle.bgcolor("black") turtle.pensize(1.5) turtle.speed(0) for i in range(6): for colours in ["red","blue","yellow","orange","green","purple","cyan"]: turtle.color(colours) turtle.circle(100) #radius of circle turtle.left(10) #angle shift for each circle turtle.hideturtle(...
7bbe18daf81dabb7aa2ddb7f20bca261734a17d8
dodooh/python
/Sine_Cosine_Plot.py
858
4.3125
4
# Generating a sine vs cosine curve # For this project, you will have a generate a sine vs cosine curve. # You will need to use the numpy library to access the sine and cosine functions. # You will also need to use the matplotlib library to draw the curve. # To make this more difficult, make the graph go from...
572da56c0611e09c0e3c8d00ad81f8780e457ec9
ta100rik/HU-Huiswerk
/canvas/8/Py8.4_dictenfiles.py
633
3.671875
4
def ticker(filename): File = open(filename) ticker = {} for line in File: line = line.split(':') totalname = line[0] shortname = line[1].rstrip() ticker[shortname] = totalname return ticker def searchticker(searchvalue,filename): tickersdic = ticker(filename) res...
347c9b8ad2d52b3262a628fc960dce056171a85c
ta100rik/HU-Huiswerk
/canvas/7/py7.3_list&number.py
1,095
3.84375
4
invoer = "5-9-7-1-7-8-3-2-4-8-7-9" # making a list of the input list = invoer.split('-') # sorting the list to make it readable list.sort() # defining templates for later on template = "gesorteede lijst van ints = {}" template2 = "Grootste getal: {} en Kleinste getal: {}" template3 = "Aantal getallen: {} en som van de...
efa8e8bad596287953e1afdc8a4afb2b7bb5a1ce
ta100rik/HU-Huiswerk
/canvas/6/py6.4_filesschrijven.py
1,130
3.9375
4
# unlimited loop import datetime while True: # userfunctioncall = int(input('\nWhat do you want to see?\n1. insert a new runner\n2. Show all runners\n Insert the number of choose\n'))#asking the user for the function # looking if the user has the right number else it will print that it is not if userfun...
477830aa55a40a28ccd67afb831cf387bf567537
ta100rik/HU-Huiswerk
/canvas/9/Py9.3_ASCI.py
372
4.03125
4
def code(string): word = '' for char in string: dec = ord(char) + 3 new_value = chr(dec) word = word + new_value return word gebruiker = input('Give me your name plz: ') Startstation = input('Where do the user starts: ') endstation = input('Where do the users stops: ') combine = ge...
cbb9ba081b16f0e1be200044b62eb1905b85e63a
matvey-mtn/advent-of-code
/python/day_2/password_validator_pt2.py
671
3.90625
4
f = open("test_input.txt", "r") def validate(input_line): chunked = input_line.split() # get min and max first_and_last = chunked[0].split("-") first_occur = int(first_and_last[0]) - 1 last_occur = int(first_and_last[1]) - 1 # get char char = chunked[1].replace(":", "") # get passwo...
590f50b1aa83ab13a28949a109a004acca0b1ab7
VerleysenNiels/Project_Computervisie
/label_images.py
1,970
3.5
4
""" Utility script for labeling painting corners. Run this with the right settings for the folder to read and the csv to write and it will show every image in turn. When it shows an image, click the four corners (only the first four are recorded, so do it right) and then press any button to go to the n...
68d606253d377862c11b0eaf52f942f6b6155f56
DimaSapsay/py_shift
/shift.py
349
4.15625
4
"""" function to perform a circular shift of a list to the left by a given number of elements """ from typing import List def shift(final_list: List[int], num: int) -> List[int]: """perform a circular shift""" if len(final_list) < num: raise ValueError final_list = final_list[num:] + final_list[...
630d6de3258bef33cfb9b4a79a276d002d56c39c
VictoryWekwa/program-gig
/Victory/PythonTask1.py
205
4.53125
5
# A PROGRAM TO COMPUTE THE AREA OF A CIRCLE ## # import math radius=float(input("Enter the Radius of the Circle= ")) area_of_circle=math.pi*(radius**2) print("The Area of the circle is", area_of_circle)
6e173ae8b17ac4af50fdebb3fb48e857fa3159da
KiemNguyen/data-science
/data-analysis-and-visualization /data-cleaning/Challenge - Cleaning Data.py
1,056
4
4
## 3. Exploring the Data ## import pandas as pd avengers = pd.read_csv("avengers.csv") avengers.head(5) ## 4. Filtering Out Bad Data ## import matplotlib.pyplot as plt true_avengers = pd.DataFrame() avengers['Year'].hist() true_avengers = avengers[avengers["Year"] > 1960] ## 5. Consolidating Deaths ## def calcu...
9ff86358248bb89b4c5390a3c8e8b0bb3bc2bb45
KiemNguyen/data-science
/summarizing-job-data/Summarizing Job Data.py
1,392
3.640625
4
## 2. Introduction to the Data ## import pandas as pd all_ages = pd.read_csv("all-ages.csv") recent_grads = pd.read_csv("recent-grads.csv") print(all_ages.head(5)) print(recent_grads.head(5)) ## 3. Summarizing Major Categories ## import numpy as np # Unique values in Major_category column. print(all_ages['Major_ca...
377634aaf2e80aba479808236f2b49f2fbea6845
rockomatthews/Dojo
/Python/scoresAndGrades.py
476
3.890625
4
import random def grades(students): for x in range(0, students): score = random.randint(60, 100) if score >= 60 and score < 70: print "Score: ", score,"; Your grade is D" elif score >= 70 and score < 80: print "Score: ", score,"; Your grade is C" elif score >...
30f766189335d229a23333fc40acb3df39f6e509
rockomatthews/Dojo
/Python/multiplesSumAverage.py
287
4.09375
4
for count in range(1, 1000, 2): print count for count in range(5, 1000000, 5): print count sum = 0 a = [1, 2, 5, 10, 255, 3]; for element in a: sum += element print sum sum = 0 a = [1, 2, 5, 10, 255, 3]; for element in a: sum += element avg = sum/len(a) print avg
a47e1bea7cd89173b07847f8b6ba3309e8a5a341
chessleensingh/sudoku_solver
/sudoku_solver_1.py
6,554
3.515625
4
# -*- coding: utf-8 -*- import numpy as np import time class Sudoku_node: data = None center = None val_avail = None def __init__(self, data): self.data = data puzzle_1d = [0,6,0,8,0,0,0,5,4,0,0,0,0,0,0,0,3,0,0,2,4,0,9,0,8,0,6,0,0,6,0,1,3,0,0,0,0,0,0,5,0,9,0,0,0,0,0,0,6,4,0,1,0,0,3,0,5,0,...
776435c8431a83db3aca92842ca6b11c9554be56
mohammed-qureshi/Bank
/bank.py
934
3.875
4
class User: def __init__(self, name, age): self.name = name self.age = age def __str__(self): return f"name = {self.name}, age = {self.age}" class Bank(User): def __init__(self, name, age, balance): super().__init__(name, age) self.balance = balance...
ee08f2ee20612f5f5911065803f2824beb11d1c9
NagaTaku/atcoder_abc_edition
/ABC044/b.py
143
3.5
4
s = input() res = 'Yes' for i in range(len(s)): hantei = s.count(s[i]) if hantei%2 == 1: res = 'No' break print(res)
8e89064e68022c83a38a3811b70e784a126debcd
NagaTaku/atcoder_abc_edition
/ABC168/a.py
195
3.75
4
n = int(input()) if n%10 == 2 or n%10 == 4 or n%10 == 5 or n%10 == 7 or n%10 == 9: print('hon') elif n%10 == 0 or n%10 == 1 or n%10 == 6 or n%10 == 8: print('pon') else: print('bon')
e527a551b17d706c206afc1285fe6c319aabbeda
NagaTaku/atcoder_abc_edition
/ABC066/b.py
197
3.546875
4
s = input() s_len = len(s) for i in range(1, int(s_len/2)+1): s = s[:-2] half = int(len(s)/2) s_mae = s[:half] s_ato = s[half:] if s_mae == s_ato: break print(len(s))
50d3c9773fbeca17dfae09df2f46b57cd507275c
NagaTaku/atcoder_abc_edition
/ABC062/b.py
324
3.53125
4
h, w = map(int, input().split()) a = [] for i in range(h): a.append(input()) ans = [] topdown = "" for i in range(w+2): topdown = topdown + "#" for i in range(h): a[i] = "#" + a[i] + "#" ans.append(topdown) for i in range(h): ans.append(a[i]) ans.append(topdown) for i in range(h+2): print(ans[...
212bd26c0ebb4139eab60ea9d64ddf542e8368fd
NagaTaku/atcoder_abc_edition
/ABC046/a.py
217
3.765625
4
a,b,c = map(int, input().split()) if a == b and b == c: print(str(1)) elif (a == b and a != c) or (a == c and a != b) or (a != b and b == c): print(str(2)) elif a != b and b != c and a != c: print(str(3))
5503ffdae3e28c9bc81f7b536fc986bf46913d34
jocogum10/learning_data_structures_and_algorithms
/doubly_linkedlist.py
1,940
4.21875
4
class Node: def __init__(self, data): self.data = data self.next_node = None self.previous_node = None class DoublyLinkedList: def __init__(self, first_node=None, last_node=None): self.first_node = first_node self.last_node = last_node def insert_at_end(self...
f45d49a14960ddbab0693c8ab02badf2ae1fd70b
jocogum10/learning_data_structures_and_algorithms
/countdown.py
150
3.5
4
def countdown(number): print(number) if number == 0: # base case pass else: countdown(number-1) countdown(10)
9d8201904553de2ece7e8fd3bc52a54548f96f8b
emelyalonzo/vaccination-system
/phase-1/dlist.py
7,717
4
4
# -*- coding: utf-8 -*- """ First, we must implement the class Node to store the nodes. In addition to the element and the reference to the next node, the class includes a reference, **prev**, to the previous node. """ class DNode: def __init__(self,elem,next=None,prev=None ): self.elem = elem self.next = n...
63f36d415be02e5f70247cc14470f96ac3cb6e2b
m3xw3ll/RockPaperScissors
/main.py
4,898
3.5625
4
# Icons are under creative commons license by Cristiano Zoucas from the Noun Project # His work is available under https://thenounproject.com/cristiano.zoucas/ from tkinter import * from PIL import Image, ImageTk from tkinter import font from functools import partial import random BACKGROUND = '#e0e0e0' def update_u...
f9b9480cc340d3b79f06e49aa31a53dbea5379f5
abilash2574/FindingPhoneNumber
/regexes.py
377
4.1875
4
#! python3 # Creating the same program using re package import re indian_pattern = re.compile(r'\d\d\d\d\d \d\d\d\d\d') text = "This is my number 76833 12142." search = indian_pattern.search(text) val = lambda x: None if(search==None) else search.group() if val(search) != None: print ("The phone number is "+val(s...
49e8d98d43bd848f61f35c3fdce6caebf87948f2
kabitakumari20/List_Questions
/daignol.elmint.py
215
3.65625
4
a=[[1,2,3],[4,5,6],[7,8,9]] i=0 j=0 c=[ ] while i<len(a): b=a[i][j] j=j+1 c.append(b) i=i+1 print(c) # 1,5,9 # a=[[4,5,6],[7,8,9],[10,11,12]] # i=0 # j=2 # while i<len(a): # print(a[i][j]) # j=j-1 # i=i+1
9103df329de4f8b0a8e89aaec2c17d8b31df529f
kabitakumari20/List_Questions
/row_cloum.py
265
3.765625
4
row=int(input("enter the row=")) cloum=int(input("enter the cloum=")) i=1 a=1 list1=[] while i<=row: b=a j=1 list2=[] while j<=cloum: list2.append(b) j=j+1 b=b+1 list1.append(list2) i=i+1 a=a+cloum print(list1)
7cfc609c407bd5531caeb049e809fbf6ccf7ec7e
1789479668/DIP-Homework
/Histogram-Equalization/show_hist.py
634
3.59375
4
from PIL import Image import matplotlib.pyplot as plt import numpy as np import sys def main(): # image filename = sys.argv[1] im_matrix = np.array(Image.open(filename).convert('L')) # create a histogram of the image hist = np.zeros(256) count = 0 for row in im_matrix: for gray_data...
ddf2124551bc9a6c08f4e1d4b4347c6cd1a3cb91
gogoamy/repository1
/type.py
2,561
4.125
4
# -*- coding: utf-8 -*- # Number类型(int, float, boolean, complex) print('Number类型(int, float, boolean, complex)') a = 10 print('整形(int) a = ',a) b = 20.00 print('浮点型(float) b = ',b) c = 1.5e11 print('浮点型,科学计数法(float) c = ',c) d = True ...
120ffe29ab10d7b33f42c301e52c2f0c45a3e499
ShivamBhosale/CTCI_Self_Practice
/Chapter_1/P01_practice.py
397
3.828125
4
""" Is Unique """ def isUnique(str1): sorted_str = sorted(str1) last_character = None for charz in sorted_str: if charz == last_character: return False last_character = charz return True print(isUnique("Helo")) """ is Unique in a pythonic way """ def isUnique_pythonic(str2...
b6626631ba1cbf87a2c93bdeeb06eaf139202a97
GoncharovArtyom/python-yandex-praktikum
/service1_fulltext_search/task1_debug/main.py
2,757
3.890625
4
from typing import Optional class Matrix: """ Код нашего коллеги аналитика Очень медленный и тяжелый для восприятия. Ваша задача сделать его быстрее и проще для понимания. """ def __init__(self): self.data = [] self.size = 1 def matrix_scale(self, scale_up: bool): """...
ea8af9fd3352dc49621bdb706672635ba756962e
abhishekpandya/Python---Data-Strutures
/ReverseDoublyLinkedList.py
259
4.0625
4
## Reverse doubly linked list def reverse(head): temp=None p=head while p is not None: temp = p.prev p.prev = p.next p.next = temp p = p.prev if temp is not None: head = temp.prev return head
96c33e195af17073b722e3c9a861be5d3e5d63de
abhishekpandya/Python---Data-Strutures
/BracketsChecker.py
654
3.875
4
### Check for brackets def checkBrackets(s): lst=[] previousBracket = "" for char in s: if char == "{" or char == "(" or char == "[" and len(lst)>=0: lst.append(char) previousBracket = char elif previousBracket == "[" and char == "]" or previousBracket == "(" and cha...
d40ce6c4c585ac147dc2112e3b49c897b1f3fdc1
abhishekpandya/Python---Data-Strutures
/BinaryStrings.py
393
3.5625
4
## Generate all binary strings for ex 1?1 -> 101 , 111 ( Replaces ? with 0 and 1) def binaryStrings(s,index): if index==len(s): print(s) return if s[index]=='?': s=s[:index]+"0"+s[index+1:] completeStrings(s,index+1) s=s[:index]+"1"+s[index+1:] completeStrings(s,...
4c7becf4f5583de6c814c831f58bbc82107082e8
andresmiguel/hacker-rank-exs
/statistics/day0_Weighted_Mean.py
356
3.578125
4
n = input() numbers = [] weights = [] line = input() numbers = list(map(lambda x: int(x), line.split(" "))) line = input() weights = list(map(lambda x: int(x), line.split(" "))) weightAndNumberSum = 0 weightSum = sum(weights) for idx, number in enumerate(numbers): weightAndNumberSum += number * weights[idx] pr...
d8e66b7676addfb742698f8057a2dbe59d9991c5
DamirKozhagulov/python_basics_homework
/home_tasks_1/practical_work_1_4.py
571
4.15625
4
# 4) # Пользователь вводит целое положительное число. Найдите самую большую цифру в числе. # Для решения используйте цикл while и арифметические операции. number = input('Введите целое положительное число: ') print(len(number)) result = [] i = 0 while i < len(number): num = number[i] result.append(num) i +...
3305479f970d922cc09a4eb0216375bca2b194e9
DamirKozhagulov/python_basics_homework
/Lesson16/game.py
1,548
3.71875
4
import random def game(): number = random.randint(1, 100) # print(number) userNumber = None count = 0 levels = {1: 10, 2: 5, 3: 3} level = int(input("Выберите уровень сложности(1, 2 или 3) : ")) max_count = levels[level] userCount = int(input('Введите колич...
3f33affe4552cc0e2aa22542e3eb4051fcca8eaf
beajmnz/IEDSbootcamp
/theory/06-Pandas/PD2.py
2,155
3.59375
4
#! /usr/bin/python3 # -*- coding: utf-8 -*- """ Created on Mon May 10 16:56:09 2021 @author: Bea Jimenez <bea.jimenez@alumni.ie.edu> """ """ Write on your console: url = 'https://raw.githubusercontent. justmarkham /DAT8/master/ chipotle.tsv chipo = pd.read_csv url , sep = t') For these data: 1. have a look to the fir...
be8b2ea14326e64425af9ee13478ec8c97890804
beajmnz/IEDSbootcamp
/pre-work/pre-work-python.py
1,135
4.3125
4
#! /usr/bin/python3 # -*- coding: utf-8 -*- """ Created on Fri Apr 23 17:39:23 2021 @author: Bea Jimenez <bea.jimenez@alumni.ie.edu> """ #Complete the following exercises using Spyder or Google Collab (your choice): #1. Print your name print('Bea Jimenez') #2. Print your name, your nationality and your job in 3 di...
a992508b6236cb8c683ff8813c2a6655401040de
beajmnz/IEDSbootcamp
/theory/02a-Data Types and Variables/DTV1.py
296
3.890625
4
#! /usr/bin/python3 # -*- coding: utf-8 -*- """ Created on Tue May 4 15:59:40 2021 @author: Bea Jimenez <bea.jimenez@alumni.ie.edu> """ """ Programming challenge DTV.1 """ number1 = int(input("please write one number: ")) number2 = int(input("please write another number: ")) print("\nthe sum is",number1+number2)
a77aed14d5edc7d79f698bb2968cd92524dbd8a1
beajmnz/IEDSbootcamp
/theory/06-Pandas/PD3.py
2,372
3.640625
4
#! /usr/bin/python3 # -*- coding: utf-8 -*- """ Created on Mon May 17 15:26:05 2021 @author: Bea Jimenez <bea.jimenez@alumni.ie.edu> """ """ With the chipo data: 1. How many items are more expensive than 10$? 2. What is the price of each item when only 1 item is bought? 3. Sort by the name of the item 4. What was th...
28e93fcc30fca3c0adec041efd4fbeb6a467724e
beajmnz/IEDSbootcamp
/theory/03-Data Structures/DS6.py
452
4.34375
4
#! /usr/bin/python3 # -*- coding: utf-8 -*- """ Created on Wed May 5 18:24:27 2021 @author: Bea Jimenez <bea.jimenez@alumni.ie.edu> """ """ Write a Python program to count the elements in a list until an element is a tuple. Input: [10,20,30,(10,20),40] Output: 3 """ Input = [10,20,30,(10,20),40] counter = 0 for ...
e29dcf2e71f5f207a18e22067c0b26b530399225
beajmnz/IEDSbootcamp
/theory/02b-Flow Control Elements/FLOW3.py
468
4.125
4
#! /usr/bin/python3 # -*- coding: utf-8 -*- """ Created on Wed May 5 13:03:37 2021 @author: Bea Jimenez <bea.jimenez@alumni.ie.edu> """ """ Write a Python program that asks for a name to the user. If that name is your name, give congratulations. If not, let him know that is not your name Mark: be careful because the...
50882249dd72e984296a90ec327947e2536a9034
beajmnz/IEDSbootcamp
/theory/06-Pandas/PD1.py
1,243
3.75
4
#! /usr/bin/python3 # -*- coding: utf-8 -*- """ Created on Mon May 10 17:13:26 2021 @author: Bea Jimenez <bea.jimenez@alumni.ie.edu> """ """ For Boston data: 1. show the names of the variables and a brief summary of them 2. extract the first 10 rows 3. extract the rows 4 th and 5 th with the last 4 variables 4. extra...
5570ef99771116d22a8852b5f756f403891d668d
beajmnz/IEDSbootcamp
/theory/02a-Data Types and Variables/DTV7.py
320
3.890625
4
#! /usr/bin/python3 # -*- coding: utf-8 -*- """ Created on Tue May 4 17:24:17 2021 @author: Bea Jimenez <bea.jimenez@alumni.ie.edu> """ """ Write a Python program to reverse the following wrong text. Example: "aserpme ed otutitsni". Expected result: "instituto de empresa" """ wrongText = "aserpme ed otutitsni" righ...
4d8087d998cdad9646eb40cf110388bd5aab0f48
beajmnz/IEDSbootcamp
/theory/02a-Data Types and Variables/DTV8.py
442
4.09375
4
#! /usr/bin/python3 # -*- coding: utf-8 -*- """ Created on Tue May 4 17:37:20 2021 @author: Bea Jimenez <bea.jimenez@alumni.ie.edu> """ """ Ask for a number and for a text. Write a program that prints the text the number of times specified """ text = input("please write some text: ") text = text + "\n" # we add a b...
7b93ba6fe50685ece8dad9473027ba0d343856b2
edutilos6666/CL_Uebung2
/Uebung2/Aufgabe2.py
1,136
4.03125
4
# Aufgabe 2 ############################### # Entwickeln Sie ein Programm, welches vom Nutzer eingegebene Woerter # alphabetisch sortiert ausgibt. Der Ntzer soll dazu bis zu 5 Woerter # eingeben koennen. # Hinweis: Da wir bisher noch keine Listen behandelt haben, speichern # Sie die Woerter in verschiedenen Variablen...
2198fde045a0f392956cb2b62ede50504c028ecd
edutilos6666/CL_Uebung2
/Hausaufgabe4/Test.py
1,557
3.75
4
filename = "foo.txt" with open(filename , "w") as f : f.write("edu\n"); f.write("tilos\n"); f.write("pako\n"); with open(filename, "r") as f: print("<<content of " + filename + ">>") for line in f: line = line.strip() print(line) with open(filename , "a") as f: f.write("new_...
9df482d4d9b2ad4b4ae132086efbcabeed9ca5a0
jkbockstael/adventofcode-2017
/day06_part2.py
532
3.625
4
# Advent of Code 2017 - Day 6 - Memory Reallocation - Part 2 # http://adventofcode.com/2017/day/6 import re from day06_part1 import reallocate, reallocate_until_cycle def cycle_length(memory): initial = memory[:] steps = 0 while True: memory = reallocate(memory[:]) steps = steps + 1 ...
93baa56efd9fc968519ec76d5d696d1669cb9848
muyang-feng/homework
/zhangna/exercise_string_list.py
1,477
3.75
4
#1.创建一个函数,除去字符串前面和后面的空格 def blank(): strl = ' aa bb cc ' print(strl) str2 = strl.replace(" ", "") print(str2) blank() # 2.输入一个字符串,判断是否为回文 string = input('请输入一个字符串:') str_len = len(string) i = 0 while i <= str_len / 2: if string[i] == string[str_len-i-1]: count=1 i=i+1 else:...
f4d8bdaa7f10d34a1ee0d489757795c30c547243
narenbac/Python_Exercises
/exercise3.py
17,137
4.46875
4
#Problems on strings: #1. Write a Python program to calculate the length of a string. ''' print('calculate the length of a string.') s=input('Enter a string:') print('length of given string is:',len(s)) ''' #2. Write a Python program to count the number of characters (character frequency) in a string. # Sample String...
37b2d8a716c5e5a130cf1761e92a65ea3a517ab7
JovieMs/dp
/behavioral/strategy.py
1,003
4.28125
4
#!/usr/bin/env python # http://stackoverflow.com/questions/963965/how-is-this-strategy-pattern # -written-in-python-the-sample-in-wikipedia """ In most of other languages Strategy pattern is implemented via creating some base strategy interface/abstract class and subclassing it with a number of concrete strategies (as ...
6fecada7427819fa3f4cb90ad70fc02d4d8405d0
pedroogarcez/pip
/src/ultralytics/utils/general.py
1,081
3.828125
4
# General utils def colorstr(*input): # Colors a string https://en.wikipedia.org/wiki/ANSI_escape_code, i.e. colorstr('blue', 'hello world') *args, string = input if len(input) > 1 else ('blue', 'bold', input[0]) # color arguments, string colors = {'black': '\033[30m', # basic colors 'red'...
f7ec32f5eca38094be3343b2e4d54fac7e2c5839
devBubo/helpfulfunctions
/helpfulfunctions.py
2,190
3.828125
4
from random import * from math import * #complex unit sqrt(-1) i = 1j j = 1j #average of the list def avg(list): sum_list = 0 n = 0 for i in list: sum_list+=i n+=1 return sum_list / n #round number to closest integer def round(num): if float(num)-int(float(num))<0.5 : return ...