blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
add8cfc152244945ade97744288fcc4918b1ff68
SvVoRPy/coursera
/python3_specialization/course04_classes_and_inheritances/week02.py
11,607
4.03125
4
# -*- coding: utf-8 -*- """ Created on Sun Apr 12 11:19:52 2020 @author: svollnhals Python 3 Specialization on Coursera Course 4 Python Classes and Inheritance Week 02 stuff """ # 22.2 Inheriting Variables and Methods import time CURRENT_YEAR = int(time.strftime("%Y")) class Person: def __init__(self, name, yea...
d5b64d247b3547f94ce8c5b02c155539c8f4980f
mylove1/demo
/xzs_data/datamigration/mo2my/test.py
427
3.59375
4
class hello(): def __init__(self): self.a = { "b": [2, 3, ] } def hello(self, sd): self.a["b"].append(sd) print self.a def hel(): for x in range(20): yield x def addadd(x): x += 1 maping = { 'a': 'A', 'b': 'B', 'c': 'C', } column = [...
3d19cd5b83c0ac6ed7f5bd1c8a345dd77ab71026
HyunminHong/linear-regression
/src/OLS.py
4,629
3.9375
4
from src.LinearModel import LinearModel import numpy as np import matplotlib.pyplot as plt class OLS(LinearModel): """ X: an exogenous variable is one whose value is determined outside the model and is imposed on the model y: an endogenous variable is a variable whose value is determined by the model "...
fda05cacfcf4a91b02975306ce8e82967fe2e198
Kratos-28/258349_Daily_Commit
/Session_3_Solved_question/if-elif-else_Solution/Check_data_type.py
425
4.0625
4
number=input() if number.isalpha(): print("Type is String.") elif number=="0": print("Type is Zero()0.") elif number.isnumeric(): print("Type is Integer or real number.") else: try: number=float(number) print("Type is float number.") except: try: number=complex(nu...
98a2e8867abc28d96f66015f47855db89116ea8f
Interloper2448/BCGPortfolio
/Python_Files/murach/exercises/ch06/test_scores.py
1,501
4.0625
4
#!/usr/bin/env python3 def display_welcome(): print("**************************************") print("The Test Scores program") print("Enter 'x' to exit") print("") def get_scores(): scores = [] score_total = 0 while True: score = input("Enter test score: ") if score == "x":...
9c63b9403d43a4082fd9cc80357042b3f2b9fd9b
Vardominator/SorinLab
/misc/bottomUpHierarchicalClustering.py
3,217
4.0625
4
""" Algorithm for Bottom-up Hierarchical Clustering: 1. Make each input its own cluster of one 2. As long as there are multiple clusters remaining, find the two closest clusters and merge them. At the end we'll have one giant cluster containing all the inputs. If we keep ...
d61b152a9f53d2ed90ea5d930d84f9275be1bb5b
jeanbond/lintcode
/single-number-iii/single-number-iii.py
825
3.578125
4
class Solution: ''' Important comment: 2018.08.05 xuwei at home for h3c working; xor and or not are the most important operation in computer world, filled again; please add comment at soon; ''' def singleNumberIII(self, A): ret = [] a, b, xor, loc = 0, 0, 0, 0 #xor all d...
15e133ecc688936e7b85922cbf3241c7c7f992e3
parasmaharjan/Python_DeepLearning
/LAB2/Problem2.py
3,631
3.96875
4
# Creating list of contacts contact_list = [] class Contact: def __init__(self, name, number, email): self.name = name self.number = number self.email = email contact_list.append([self, self.name, self.number]) def display_name(self): return self.name def display...
30e3c3ef0c2dd36005e55420ab8476f1b2034f81
arhankundu99/GUI-Apps
/Pygame/Sorting Algorithms/bubble sort.py
1,743
3.53125
4
import pygame import random pygame.init() arr = [] x = 40 y = 40 width = 20 screen = pygame.display.set_mode((700, 700)) screen.fill((255, 255, 255)) font = pygame.font.SysFont("comicsans", 40) def reset_arr(): for i in range(0, 20): arr.append(100*(random.random()+0.05)) def show_arr(): for i in...
b961171611c5149195bb800f363340ad4b67613b
sureshlodha/Indian-Population-Density
/2011/Data/data-state.py
961
3.828125
4
import pandas as pd # reads data and skips first row, last couple rows couple_rows = [0, 1, 2] df = pd.read_excel(r'A-1_NO_OF_VILLAGES_TOWNS_HOUSEHOLDS_POPULATION_AND_AREA.xlsx', skiprows=couple_rows) df = df.iloc[:-28] # removes last 28 rows # Step 1: remove all rows in col 6 with rural, urban, and subdistr...
688263175b4f1af97c5b432ae82297aa03b5d933
Shreyankkarjigi/Python--Codes
/Problems on Lists/List to dictionary.py
758
4.0625
4
#Code by Shreyank #Github-https://github.com/Shreyankkarjigi #problem ''' input two lists from user one is key and one is value convert the lists into dictionary logic input two lists use zip function to combine both lists use dict() function ''' list_keys=[] list_values=[] r=int(input("Enter range")) for i in rang...
5e753b65e502e63f319b7058ada58c804c2401e6
mbouchet98/ScriptPython
/test.py
605
3.625
4
from tkinter import * from tkinter.messagebox import showinfo fenetre = Tk() #test = Label(fenetre, text='test') #test.pack() #bouton=Button(fenetre, text="Fermer", command=fenetre.quit) #bouton.pack() # tkinter pour lais des logiciel en python. c'est un mode fenetrer. # sa y est je crois que j'adore py...
1a421e5336c5f1c57be3adaa0d5c79301eb5a14a
padmacho/pythontutorial
/objects/fun_return.py
160
3.96875
4
def modify(y): return y # returns same reference. No new object is created x = [1, 2, 3] y = modify(x) print("x == y", x == y) print("x == y", x is y)
e2bddfaf1aa9e10fb9e55ad5e0c78d7c33fb1a89
BramvdnHeuvel/AdventOfCode2018
/day_01/ex2_repetition.py
342
3.5625
4
sum = 0 sum_list = {sum} number_found = False while not number_found: for line in open('input.txt', 'r'): number = line.split('\n')[0] number = int(number) sum += number if sum in sum_list: print(sum) number_found = True break ...
14204cc21245289a64d7c92ef4ad266dfa0e9044
jerekapyaho/eumemberdata
/populate.py
877
3.859375
4
import sqlite3 import csv db_filename = 'eumemberdata.sqlite3' def populate_table(conn, table_name): with open(csv_filename, encoding='utf-8') as csv_file: csv_reader = csv.DictReader(csv_file) columns = ', '.join([column for column in csv_reader.fieldnames]) values = ', '.join([':%s' % c...
2aac70afb9f1a8f0ce836593d7a638c7a0060276
faizsiddiqui/Competitions
/Codechef/Practice-Beginner/ALPHABET.py
292
3.828125
4
# https://www.codechef.com/problems/ALPHABET known = list(input()) words = int(input()) for word in range(words): flag = False for char in input(): if char not in known: print("No") flag = True break if not flag: print("Yes")
c896734a34fda50543f8f3069dc3d55c5fcdd4e0
cheonyeji/algorithm_study
/이코테/구현/q9_문자열압축.py
1,233
3.546875
4
# # 2021-01-26 # 이코테 ch12 구현 문제 Q9 문자열 압축 # https://programmers.co.kr/learn/courses/5/lessons/60057 INF = int(1e9) def cut_str(s, num): i = 0 length = len(s) result = "" while i < length: str1 = s[i : i + num] count = 1 for j in range(i + num, length, num): if str1...
02744102c7e34059b1b17bf469e245dae43c6f3c
ctramm/Python_Training
/Udemy/Section 21/window_size.py
539
3.78125
4
""" Section 21: How to find the size of the window """ from selenium import webdriver class WindowSize: def demo(self): driver = webdriver.Chrome() driver.maximize_window() driver.get("https://letskodeit.teachable.com/p/practice") driver.implicitly_wait(3) height = driver...
3b4902ad73a8463e97f64e63e3877bf6b6fa1273
sbkaji/python-programs
/assignment/20.py
618
4.03125
4
# -*- coding: utf-8 -*- """ Created on Fri Feb 21 01:25:24 2020 @author: Subarna Basnet """ """20.Write a program to check if a year is leap year or not. If a year is divisible by 4 then it is leap year but if the year is century year like 2000, 1900, 2100 then it must be divisible by 400.""" year = int(input("...
9cc4bc120926f61cb57458361059b32f4d2039fa
Dualve/Simple-programms
/fo1.py
6,255
4.34375
4
import math while True: print("""Выбирите нужную операцию: 1) Найти сумму цифр и количество цифр заданного натурального числа. 2) Возвести число в натуральную степень n. 3) Найти количество различных цифр у заданного натурального числа. 4) Найти наибольшую цифру...
cd4076e501314f3d5fe5e563e8730f821fb853db
pingouin84/Mirror_Led
/test.py
4,511
3.8125
4
# Import a library of functions called 'pygame' import pygame from pygame.locals import * from math import pi import Matrice # Initialize the game engine pygame.init() # Define the colors we will use in RGB format BLACK = (0, 0, 0) WHITE = (255, 255, 255) BLUE = (0, 0, 255) GREEN = (0, 255, 0) RED = (255, 0, 0) h =...
cb337e45c437ed7495d7b4c0bab7912f9547bb02
diogodutra/employee_manager_py
/Employee.py
646
3.796875
4
class Employee(object): #public members name = "" id = "" rate_hourly = 0 hours_monthly = 0 #constructor def __init__(self, name, id, rate_hourly, hours_monthly): self.name = name self.id = id self.rate_hourly = rate_hourly self.hours_monthly = hours_monthly #destructor def __del_...
7a2dfb870f4acaf2d27e5c971d705af7504e5d74
swapnilkathane/Practice_3
/list modify.py
280
3.796875
4
L1=[1,2,3,4,5,5,6] b=len(L1) n=0 L2=[] while(n<b): for x in L1: if x in L2: #m=1 #to print duplicate elements only once L2.remove(x) #to remove the duplicate elements in list else: L2.append(x) n+=1 print(L2)
663650b91c2e06351a39e83816848c7ee721530c
RobsonGomes1/SIMULADOR-DE-DADO
/Simulador_de_dados.py
1,290
3.65625
4
try: dados = [ 1, 2, 3, 4, 5, 6, 7 ,8 ,9 ,10] except: print('Error... Invalid code') else: op = 0 while op != 2: print('-' *10, 'Jogando dado', '-' *10) print('Opção: Escrava [1] para jogar '.strip().upper()) print('Opção: Escreva [2] para sair'.strip().upper()) op = int(...
dc1fdecddf0baefd361bb7bd35089cba195dd6fd
rick-62/AdventOfCode2017
/day22/day22.py
3,586
3.546875
4
# day22 import sys class Puzzle(): def __init__(self, test_flag=False): if test_flag: self.nodes = self.load_into_memory("test.txt") else: self.nodes = self.load_into_memory("input.txt") self.infect_count = 0 self.direction = 'N' self.current_no...
806a30de3fb7c1e846d5031b4476ab58e2d959ab
mooja/dailyprogrammer
/challenge89easy.py
1,924
3.984375
4
#!/usr/bin/env python # encoding: utf-8 # Daily Programmer Challenge 89 Easy # # http://www.reddit.com/r/dailyprogrammer/comments/yj2zq/8202012_challenge_89_easy_simple_statistical/ # # March.02.2015 import math def mean(xs): """ mean([ints...]): return the arithmetic mean (average) of the input ...
cd1d0c8890b813b90d1edf21de2555ff70687692
marvely/python_data_structures
/object_sample_code.py
1,365
4.21875
4
class PartyAnimal: x = 0 name = "" def __init__(self, nam): self.name = nam print "I am constructed" def party(self): #<--- first parameter, and at least one self.x = self.x + 1 print self.name, "party count", self.x #def __del__(self): #<---- only happens at the end of the pr...
0e50d8ed71b2789285f689cfb2bb7ea379c15ec0
jawbreakyr/LPTHW-exercises
/Documents/tutorials/python-docs/filteringdecode.py
1,155
3.921875
4
""" filtering an encrypted file(not mine just copied, hopefully to unserstand it and rewrite it the way i will understand to solve the problem.) """ import string file_ = open('solutions.txt', 'r') text = ''.join(file_.readlines()) def get_unique(text): """ gets the "characters" in "text" = solutions.txt ...
f700ccf4344d4a6dfe61291fcdc6dd56e11db4e7
doanthanhnhan/learningPY
/01_fundamentals/02_operators/string.py
795
4.4375
4
# Comparison Operators print('a' < 'b') # 'a' has a smaller Unicode value house = "Gryffindor" house_copy = "Gryffindor" print(house == house_copy) new_house = "Slytherin" print(house == new_house) print(new_house <= house) print(new_house >= house) # Concatenation first_half = "Bat" second_half = "man" full_n...
c15154551319311c0a335ff53022e24a3b2ba546
AdamZhouSE/pythonHomework
/Code/CodeRecords/2604/60889/266188.py
230
4
4
letters = input().strip("[\"]").split("\", \"") target = input() answer = letters[0] for letter in letters: if (letter>target>=answer) or (answer>letter>target) or (target>=answer>letter): answer = letter print(answer)
d94b280b34090c6b8b32e135a107a0671aedc516
rkdntm1/Python_practice
/main.py
913
3.65625
4
# 과제) 목록에 어떤 알파벳이 있는지 소스 짜오기 # ('hong', 'kim', 'lee','park','kim') -> 알파벳 만 # 중복 없는 리스트 형태로 변경 def make_list(*arr): irum = [] for item in arr: if item not in irum: # 중복 없애주기 irum.append(item) return irum # 리스트안의 내용을 합쳐서 str 형태로 변경해주기 def strchanger(lst): k = '' for i in rang...
5fa30bdc896aea2b927487541e253b582c892c52
bhaskarv/LearnPython
/tuples.py
555
4.40625
4
#tuples are like immutable lists they can't be modified list_1=['History','Maths','Physics','CompSci'] list_2=list_1 print(list_1) print(list_2) list_1[0]='Arts' #As can be seen below, adding to list_1 changed list_2 as well print(list_1) print(list_2) #now take a look at a tuple touple_1=('History','Maths','Phisi...
b3bf3455c2283d65c1feebf9a4de642abfbb97df
FrozenLi/prob6
/hashFunction.py
799
3.78125
4
import math class hashFunction: def __init__(self, a, b, p, M): self.a = a self.b = b self.p = p self.M = M def hash(self, x): # using same logic of java.lang.string hashCode function to convert string to int # https://en.wikipedia.org/wiki/Java_hashCode() ...
66c484473e7d17af698ddc31c1bae87ba5d94e28
gauripatil20/LIST
/LIST_24_EVEN.PY
133
3.65625
4
# i=0 # b=[] # while i<10: # num=int(input("enter the number")) # if num%2==0: # b.append(num) # i=i+1 # print(b)
8c5c8f040ee96c22c19d0c782689d6bfd8cdb92d
charansaim1819/Python_Patterns
/ALPHABETS/SMALL_ALPHABETS/x.py
644
3.984375
4
#Shape of small x: def for_x(): """printing small 'x' using for loop""" for row in range(5): for col in range(5): if row%4==0 and col!=2 or col==2 and row not in(0,4): print("*",end=" ") else: print(" ",end=" ") print() de...
59a0986bc6860280e5b198596963b1c26a3731b1
charan2108/pyprocharmprojects
/pythoncrashcourse/Statements/if.py
1,661
4.3125
4
cars = ['audi', 'benz', 'cheverolet', 'etiga','ferrai'] print(cars) print("\n") if cars == 'audi': print(cars.upper()) # adding else statement if cars == 'audi': print(cars.upper()) else: print(cars) # checking for inequality requested_cars = 'mercedes' if requested_cars != 'ferrari': pr...
cce5d172f7a3fd627b6145e9110c0e2b9aca73d2
raxaminhal/Python-Programming-Assignmsnts
/Assignment-1.py
854
3.859375
4
#!/usr/bin/env python # coding: utf-8 # In[3]: import datetime now = datetime.datetime.now() print ("Current date and time : ") print(now) # In[1]: from math import pi r = float(input ("Input the radius of the circle : ")) print ("The area of the circle with radius " + str(r) + " is: " + str(pi * r**2)) # In[2...
873295b24880ac6e13873ecb13eb1a10498efe56
alem-classroom/student-python-introduction-nzekenov
/loops-for/arrayLoop.py
179
4.03125
4
def insert_squares(arr, num): # add square of numbers from 1 to num to the list named arr and return list for i in range(num): arr.append((i+1)*(i+1)) return arr
f3989fc5cb174eb58d3521d0a2d4d6bd7beba61a
andrewsihotang/sisterchatapp
/client.py
5,226
3.59375
4
#menggunakan GUI library Tkinter import tkinter as tk from tkinter import messagebox #untuk socket import socket #untuk thread import threading window = tk.Tk() window.title("Client") username = " " frameAtas = tk.Frame(window) isiUsername = tk.Label(frameAtas, text = "Name:").pack(side=tk.LEFT) #isi name dari cli...
35c92c4e4616af9d58f850523df5b63e1f149e63
CoderLeechou/LeetCode-Python
/015ThreeSum/Ts.py
1,649
3.6875
4
#-*-coding:utf-8-*- class Solution(object): ''' 题意:求数列中三个数之和为0的三元组有多少个,需去重 暴力枚举三个数复杂度为O(N^3) 先考虑2Sum的做法,假设升序数列a,对于一组解ai,aj, 另一组解ak,al 必然满足 i<k j>l 或 i>k j<l, 因此我们可以用两个指针,初始时指向数列两端 指向数之和大于目标值时,右指针向左移使得总和减小,反之左指针向右移 由此可以用O(N)的复杂度解决2Sum问题,3Sum则枚举第一个数O(N^2) 使...
2974668739f32142045c9f3f24db51afadb9c99f
lochappy/video_sequence_arrangement
/video_sequence_arrangement.py
3,564
4.21875
4
''' Author: Loc Truong <ttanloc@gmail.com> Date: 16Jan2021 Brief: This is the video-sequence arrangement algorithm Usage: > python3 video_sequence_arrangement.py -v Path/to/video/file -s Path/to/sequence/file ''' from argparse import ArgumentParser def foobar(video_list, sequence, start_index=0, list_of_selected_...
6d5afe8c12755ca902f5e69642c48cbdd55a1880
Nero5023/Algorithm
/CtCI/17-8.py
860
3.578125
4
# -*- coding:utf-8 -*- class MaxSum: def getMaxSum(self, A, n): # write code here arr = A maxSum = arr[0] start = 0 end = 0 for index in range(1,len(arr)): val = arr[index] if val <= 0: if maxSum < val: maxS...
9cc41854310cbb949fca51ed3e27354cce992a2e
JIghtuse/python-playground
/crash_course/lists/modifying_lists.py
1,722
4.03125
4
guests = ['Dan Simmons', 'Stephen King', 'Robert Sheckley'] print(f"Dear {guests[0]}, please join our dinner today.") print(f"Dear {guests[1]}, please join our dinner today.") print(f"Dear {guests[2]}, please join our dinner today.") cant_make_the_dinner = 'Robert Sheckley' new_guest = 'Neal Stephenson' print(f"\n{can...
20c664415015d09fb3f238572e848d07ce4ceae1
dalq/python-cookbook
/cookbook/one/2SplitArbitrarySequence.py
495
4.3125
4
#从任意长度的可迭代对象中分解元素 record = ('name', 'addr', 'tel', 'tel2') name, addr, *tel = record print(name) print(addr) print(tel) *before, after = [1, 2, 3, 4, 5, 6] print(before) print(after) # 在循环中也好使 record = [('foo', 1, 2), ('bar', 'hello'), ('foo', 5, 6)] def do_foo(x, y): print('foo', x, y) def do_bar(s): pr...
7fc7a858d58bdff03789fde44724402e108f26c2
buptwxd2/leetcode
/Round_1/733. Flood Fill/solution_1.py
1,126
3.53125
4
class Solution: def floodFill(self, image: List[List[int]], sr: int, sc: int, newColor: int) -> List[List[int]]: row = len(image) col = len(image[0]) points = [] target = image[sr][sc] visited = {} def dfs(sr, sc): nonlocal points if sr < 0...
ecb5fdec977cbc92797e94bad8cc5d00fc9d634b
TianqGuo/PythonJavaProblemsSummary
/Tests.py
5,694
3.703125
4
import sys import copy # quick select class solution(object): def quickSelect(self, array, target): if not array: return array if target >= len(array): return sys.minint self.partition(array, 0, len(array) - 1, target) return array[target] def parti...
21a14ace6585cd35bc44035e4e0680bc35d2ceee
thepiyushmalhotra/Introduction-to-Pandas
/8statsoperation.py
832
3.546875
4
import pandas as pd import numpy as np d={'Name':pd.Series(['Akshay','Rajat','Robin','Kapil','James','Cyril']),'Age':pd.Series([25,26,29,27,23,21]),'Rating':pd.Series([4.23,2.35,1.56,3.20,4.62,3.99])} df=pd.DataFrame(d) print df #print "Sum of All the Data Frame",df.sum() #print "Sum of All the Age",df['Age'].sum() pri...
4b290f20b1b41c24a8342b5d25e5c94c8a371afe
kyledhebert/PyZombie
/tests.py
1,439
4.03125
4
import unittest import dice, dice_cup, game, menu, player class DiceCupTest(unittest.TestCase): """Tests for the dice_cup module""" def setUp(self): self.cup = dice_cup.DiceCup() def test_for_six_green_die(self): self.assertTrue(self.cup.number_of_green_dice == 6) def test_for_four_yellow_die(self): self....
5c2a87d2df4e3d71aa260ac9203a788eab34bc2c
sajidazhar/Python_Learning
/odd_even.py
99
3.8125
4
def odd_even(num): if num%2==0: return "even" return "odd" print(odd_even(9))
b1d24de483e6257e3f503a2bb38c01b7a0026e38
JonathanNakandala/advent-2020
/02_1.py
605
3.859375
4
def check_password(min, max, letter, password): letter_count = password.count(letter) if min <= letter_count <= max: return 1 return 0 data_file = open("data/data_02.txt", "r") lines = data_file.readlines() valid_passwords = 0 for line in lines: split_space = line.split(" ") bounds ...
41b8a35c5311c10f292a99c2ef0c63c9c5713fa9
iweyy/WIA2004-Operating-Systems
/Lab 7/file sequential.py
1,478
3.796875
4
maximum = 50 files = [0]*maximum repeat = 1 while repeat == 1: start = int(input (f"Enter the starting block of the files (0-{maximum-1}): ")) while start<0 or start>=maximum: if start>=maximum: print ("Exceed maximum number of file") if start<0: print ("Cannot be a nega...
e6fcf0bd9f21caeacd69ec3e5e80467674d323f7
ChangxingJiang/LeetCode
/1501-1600/1510/1510_Python_2.py
1,440
3.59375
4
# 贪心算法 动态规划 记忆化递归 # O(N×M) M为N开根号 class Solution: # 动态规划 def __init__(self): # 计算范围内的完全平方数 # O(logN) self.square_list = [] now = 1 while True: square = now ** 2 if square <= 10 ** 5: self.square_list.append(square) ...
5c876fb5d5214c71aaf327c7dc4330c760cdb156
KaustabRoyChoudhury/Student-Alarm-Clock
/Alam.py
2,671
3.8125
4
import datetime import winsound import sys from win32com.client import Dispatch import time hour = input("Enter hour : ") min1 = input("Enter Minute : ") sec = input("Enter sec : ") shift = str(input("Enter AM/PM : ")) date_=0 flag = 0 want = input("Want to Set a Date (Y/N) :") if want == "Y" ...
bc231fa3c23e541ac067e3ce4460bce96b2cfa26
kgashok/rps-ai
/src/database.py
2,454
3.546875
4
import psycopg2 import pandas as pd from src.config import config import datetime as datetime import time # returns a given SQL SELECT query to a pandas DataFrame object def query_to_df(query= "SELECT * FROM power_weather LIMIT 15"): params=config() try: conn = psycopg2.connect(**params) ...
d173932243169a2e26cee3feeb07900e735583d9
Astitwa-Agarwal/tathastu_week_of_code
/day1/program4.py
264
3.609375
4
cp,sp = map(int,input('Enter cost price and selling price: ').split()) if(sp>=cp): profit = sp-cp print('Profit is: ',profit) n = int(input('Enter the percentage of profit you wanna increase: ')) sp = sp+ (n*cp)/100 print('The new selling price is:', sp)
822dd30cb07c9c09cbd422bb9b7dcb973932d4ad
JohnyTheLittle/pythonSciPlay
/systems_of_equations.py
251
3.515625
4
import numpy as np from numpy import linalg """ 3x1-2x2+x3=7 x1+x2-2x3=-4 -3x1-2x2+x3=1 """ A = np.array([[3, -2, 1], [1, 1, -2], [-3, -2, 1]]) b = np.array([7, -4, 1]) x = linalg.solve(A, b) print(A) print(b) print(x) print("-------") print(A@x)
53a4c8a72f8e33b5eb89e03d4e5faf7917db3806
UtsavRaychaudhuri/leetcode
/lc-24.py
952
3.65625
4
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def swapPair(self,head,returnthishead,chainthishead): if head is None: return returnthishead.next prev=head head=...
db37a86469bcdec5e4b1415053896450337845b0
decadevs/using-sqlalchemy-folly77folly
/storage/reader_storage.py
457
3.671875
4
from abc import ABC, abstractmethod class Storage(ABC): def __init__(self,*kwargs): self.id = bookid self.booktitle = booktitle self.bookauthor = bookauthor @abstractmethod def create(self, **kwargs): pass @abstractmethod def fetch(self, **kwargs): ...
50b11f3566fdab14eb813da511da2c17a0617f02
matthowe/8queens
/eightQueens.py
2,596
3.953125
4
def createBoard(): board = [["." for _ in range(8)] for _ in range(8)] return board def displayBoard(board): for y in range(8): for x in range(8): print(board[y][x],end='') print() print() def autoPlaceQueen(board): for y in range(8): for x in ran...
6d604dfd46c22f5782f75127a784a5d578196643
S1L1C0N1/Module-5
/loopy_loops.py
882
4.03125
4
def func(): pokemon = ("picachu", "charmander", "bulbasaur") print(pokemon[0]) print("done") (starter1, starter2, starter3) = pokemon print(starter2) print("done") tuple = ("J", "A", "C", "K") print(f"Is i in tuple: {'i' in tuple}") print("done") for x in range(2, 11): ...
c537a6e4722dd1dc7924264bfeac243791e42cab
ptaushanov/SoftuniPythonProgrammingBasics
/SimpleConditions/07.sumSeconds.py
178
3.75
4
first = int(input()) second = int(input()) third = int(input()) sec_sum = first + second + third hours = sec_sum / 60 seconds = sec_sum % 60 print("%d:%02d" % (hours, seconds))
85e39259a786748820457862ec8ee26166248fb2
andri-x99/praxis-academy
/novice/01-03/latihan/classinstance.py
217
3.578125
4
class Dog: kind='canine' def __init__(self,name): self.name = name d=Dog('Johny') # print(d) e=Dog('Zranc') # print(e) f=Dog('Diza') # print(f) print(d.kind) print(d.name) print(e.name) print(f.name)
800c7d600a190a174a6a99a4e7f4bde7f63f515b
heidamn/python_hometasks
/homework03/life_with_classes.py
6,206
3.890625
4
""" Лабораторная работа №3 Игра Жизнь с использованием классов Шоломов Даниил, k3140 ИТМО, 2018 """ import random from copy import deepcopy import pygame from pygame.locals import * class GameOfLife: """класс визуализации и процесса игры""" def __init__(self, width: int = 640, height: int = ...
17fb34e2416a346508a1dc336ea63107f8175aec
solankeganesh777/Python-Basics-for-data-science-project
/Other/Inheritance.py
1,035
4.1875
4
#Python Inheritance #Parent class/Base class class Cars: def __init__(self,brand,model): self.brand=brand self.model=model def printCarDetails(self): print(self.brand) print(self.model) car1=Cars('RR',"Discovery") car1.printCarDetails() #Child class/Deriv...
be696afca26b3e0f8ed3cdcf75240474de5528ca
HJ3EQG/misionTicFundamentosPython
/reto3.py
14,676
3.828125
4
#Bienvenidos Tripulantes Grupo 72, adjunte aqui el codigo del Reto 3, para su evaluación #!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Jun 8 17:02:28 2021 @author: david """ import time import datetime from datetime import date, datetime, time, timedelta contador = 1 contador1 = 1 compras = list...
6e40ab922f7dd75c9cd5253a87a0555ece19a5d6
Vishad89/heyjude
/Python/wip/tictactoe.py
1,885
3.90625
4
import random board = {} end = False win_commbinations = ((0, 1, 2), (3, 4, 5), (6, 7, 8), (0, 3, 6), (1, 4, 7), (2, 5, 8), (0, 4, 8), (2, 4, 6)) def board(): print(' | | ') #print(' ' + board[7] + ' | ' + board[8] + ' | ' + board[9]) print(' | | ') print('------------------') print(' | ...
43a510f678cea4083e67b5204e907c6f7b4b9200
Kaushiksekar/SDE_Prepration
/Python_Specifics/Inheritance/Static_Methods.py
328
3.59375
4
class Robot: __counter = 0 def __init__(self): type(self).__counter += 1 # can also be Robot.self @staticmethod def RobotInstances(): return Robot.__counter print(Robot.RobotInstances()) x = Robot() print(x.RobotInstances()) y = Robot() print(x.RobotInstances()) print(Robot.RobotInsta...
ef63132f9f06b498275e01e4c8e4870684b0a9f0
howard5758/graph_search_problem
/AI_1/Lossy_cannibals.py
1,264
3.53125
4
# Author: Ping-Jung Liu # Date: September 17th 2017 # COSC 76 Assignment 1: Missionaries and Cannibals # Acknowledgement: Professor Devin Balkom for providing the general structure from Lossy_CannibalProblem import Lossy_CannibalProblem from uninformed_search import bfs_search, dfs_search, ids_search # Create a few ...
2a2f1c2d8e67816be819fa73d35847fa82f00636
GermanChiocchia/EjercitacionUdemyMasterClass
/challenges/challenge7.py
225
4
4
prices = {'Peon':100,'Alfil':250,'Caballo':300,'Reina':900, 'Torre':500} product = input('Ingrese una pieza para saber su valor') if product in prices: print(prices[product],end=' $') else: print('Pieza inexistente!')
c105558c54fe6f9050aae0b5862dd28973a876e2
IselaFraire/pu_figura
/figura/tests/features/figura.py
514
3.578125
4
class Figura(object): def __init__(self): self.resultado = 0 def area_rectangulo(self, base, altura): self.resultado = base * altura def area_circulo(self,radius): self.resultado = round(3.1416 * radius ** 2, 2) def area_trapecio(self, base_mayor, base_menor, altura): ...
212da96e99535779b36e7552082439832e7b1fc5
xinmiaoo/leetcode_Aug_3
/0017. Letter Combinations of a Phone Number.py
1,181
3.546875
4
# class Solution(object): # def letterCombinations(self, digits): # """ # :type digits: str # :rtype: List[str] # """ # lookup={"2":"abc","3":"def","4":"ghi","5":"jkl","6":"mno", # "7":"pqrs","8":"tuv","9":"wxyz"} # if digits=="": # return ...
c23e0d9f63ac3a1e33868c1d8e1ef0c921c67923
zero1hac/cp-practice
/hackerrank/algo/grading.py
232
3.8125
4
N = int(raw_input()) while N: grade = int(raw_input()) if grade < 38: print grade else : if ((grade/5 +1)*5 - grade) < 3: print (grade/5 + 1)*5 else: print grade N-=1
1b8247076341aa631691c5663196772003d29ca2
DAyurzana/hello-world
/shop.py
330
3.5625
4
#shop.py def check_money(total_cost, customer_money): if total_cost < customer_money: return True elif customer_money < total_cost: return False #This should print False can_pay = check_money(107, 49) print(can_pay) #This should print True can_pay = check_money(6, 88) print(...
9bc8788394678649f661da18f3990448f3fdb2d6
jinjinfan/Principles_of_Computing
/word_wrangler.py
3,875
3.921875
4
""" Word Wrangler game """ import urllib2 import codeskulptor import poc_wrangler_provided as provided WORDFILE = "assets_scrabble_words3.txt" # Functions to manipulate ordered word lists def remove_duplicates(list1): """ Eliminate duplicates in a sorted list. Returns a new sorted list with the same e...
dd13fc460c04701470f90b07a5dc69336265861e
leithdm/python-proj
/projects/day-25/initial.py
4,349
4.34375
4
import csv import pandas from statistics import mean # 1. using 'import csv' - a basic in-built way to work with csv data with open("weather_data.csv") as data_file: data = csv.reader(data_file) temperatures = [] for row in data: # do not include 'temp' text from the first row if row[1] !=...
bc281f1622eb0b0664ffb140f58c11e8a01bae0d
SSungCh/Algorithm
/SW academy/level1/15.py
115
3.640625
4
num1, num2 = map(int, input().split()) print('''{} {} {} {}'''.format(num1+num2, num1-num2, num1*num2, num1//num2))
2ef0aa20f9042b030a16c36e6f3266b1ea88dc69
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_116/743.py
1,691
3.546875
4
T = int(raw_input()) def search_horizontal(table, sym): cnt = 0 for i in xrange(0,4): for j in xrange(0,4): if (table[i][j] == sym or table[i][j] == 'T'): cnt+=1 else: break if (cnt == 4): return True else: cnt = 0 return False def search_vertical(table, sym...
26c4b3e373226a68b234c49e3b578a0af8c39d4f
yiqin/HH-Coding-Interview-Prep
/Use Python/SpiralMatrix.py
1,348
3.609375
4
class Solution(object): """docstring for Solution""" def spiralOrder(self, matrix): # print(matrix[0][1]) if len(matrix) == 0 or len(matrix[0]) == 0: return [] m = len(matrix) n = len(matrix[0]) marked = [[True for i in range(n)] for j in range(m)] # print(marked) result = [] x = 0 y = 0 ...
cd89488a862d33d91663b74505f4c121cd8defc4
liuxuesong0525/week3
/Quest/Q3.py
383
3.984375
4
#编写程序,生成一个包含20个随机整数的列表, # 然后对其中偶数下标(下标即列表元素的索引)的元素进行降序排列, # 奇数下标的元素不变。(提示:使用切片。) import random list=[] for i in range(20): list.append(random.randint(1,100)) print(list) list[::2]=sorted(list[::2],reverse=True) print("降序排序",list)
452fb9ffa405d0a749d056a2e0b55baf4242aa30
Darshnadas/100_python_ques
/DAY11/day11.43.py
209
3.953125
4
""" Write a program which can filter() to make a list whose elements are even number between 1 and 20 (both included). """ def even(i): return (i%2 == 0) num = filter(even, range(1,21)) print(list(num))
ba0d82fae83685e82090ae27da47f579d668804d
DenisKalinin/python_cns
/homework/lesson 3/2-3.py
1,105
4.28125
4
#3. Написать функцию arithmetic, принимающую 3 аргумента: первые 2 - числа, третий - операция, # которая должна быть произведена над ними. Если третий аргумент +, сложить их; если —, то вычесть; # * — умножить; / — разделить (первое на второе). В остальных случаях вернуть строку "Неизвестная операция". print("Введите ...
744737a4569f510f06825a8e9e0127a2fcd973f6
avish1990/Python
/listcount.py
118
3.703125
4
#!/usr/bin/python mylist = ['spam', 'ham', 'eggs'] #print mylist #new = ', '.join(mylist) for i in mylist: print i
182eac5d5a691cbe145b161a933e1fe978a8a947
pyminsk/py
/ii.py
854
3.734375
4
import random secret = random.randint(1, 99) guess = 0 tries = 0 print ("Эй на палубе! Я Ужасный пират Робертс, и у меня есть секрет!") print ("Это число от 1 до 99. Я дам тебе 6 попыток.") print ("Твой вариант?") print (secret) guess = input while guess != secret and tries < 7: if guess < secret : pr...
67b1f32eab1b09cf22e8ec4997b6e4e3f70fd23a
patruong/Macroeconomy-TermPaper
/TermPaper/codes_and_csv/Python_OBS_kanStrula/CsvOrderReverser.py
813
3.546875
4
""" THIS PROGRAM CALCULATES CORRELATION FOR FORMATED AND SORTED TIME SERIES CREATED FOR ME2720 Macroeconomics for business VT2016 NOTES: Assuming format of data is: Country - Time series (n-times) - avg """ import csv #Read in files rawdata = [] with open('US_CPI_raw_r.csv') as csvfile: reader = ...
08722f05406780cfd19a7d07e26285f0f32aa06e
WoodsChoi/algorithm
/al/al-147.py
1,904
4.3125
4
# 对链表进行插入排序 # medium ''' 对链表进行插入排序。 从第一个元素开始,该链表可以被认为已经部分排序(用黑色表示)。 每次迭代时,从输入数据中移除一个元素(用红色表示),并原地将其插入到已排好序的链表中。 插入排序算法: 插入排序是迭代的,每次只移动一个元素,直到所有元素可以形成一个有序的输出列表。 每次迭代中,插入排序只从输入数据中移除一个待排序的元素,找到它在序列中适当的位置,并将其插入。 重复直到所有输入数据插入完为止。   示例 1: 输入: 4->2->1->3 输出: 1->2->3->4 示例 2: 输入: -1->5->3->4->0 输出: -1->0->3->4->5 来源:力扣(...
9264a644f83df28d0cb439c18a645e66e1ba7a45
ashwani1310/Multiple-Linear-Regression
/multiple_linear_regression_self.py
2,595
4.03125
4
#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ Created on Fri May 5 05:36:04 2017 @author: ashwani """ #The code is based upon the foolowing assumption that the last column of features contain #a categorical data with three categories. #To Import the needed libraries which will help us build our model import ...
59d076f576ade521879c571db4174ba35e4a9676
ZiyaoGeng/LeetCode
/Code/70.py
451
3.671875
4
class Solution: """ def climbStairs(self, n: int) -> int: if n == 1: return 1 if n == 2: return 2 count = self.climbStairs(n - 1) + self.climbStairs(n - 2) return count """ def climbStairs(self, n: int) -> int: if n == 1: return 1 if n == 2: return 2 stairs = [1, ...
52f8c022a404fd745ad13cf7987c0611ebc0b432
daniel10012/python-onsite
/week_04/web_scraping/01_your_page.py
827
3.546875
4
''' Using python's request library, retrieve the HTML of the website you created that now lives online at <your-gh-username>.github.io/<your-repo-name> BONUS: extend your python program so that it reads your original HTML file and returns True if the HTML from the response is the same as the the contents...
ca26b35028dd28008f1b66dd6e36113f2ee4bc12
tuhiniris/Python-ShortCodes-Applications
/patterns2/spiral number pattern.py
468
3.546875
4
''' Pattern: Spiral number pattern: Enter number of rows: 5 555555555 544444445 543333345 543222345 543212345 543222345 543333345 544444445 555555555 ''' n=int(input('Enter number of rows: ')) for row in range(0,2*n-1): for column in range(0,(2*n-1)): min= row if row < column else column min= min...
ffca78a3770e024be87a248b02e0269990e11d55
Aiooon/MyLeetcode
/python/017. 电话号码的字母组合.py
1,468
3.75
4
""" 17. 电话号码的字母组合 给定一个仅包含数字 2-9 的字符串,返回所有它能表示的字母组合。答案可以按 任意顺序 返回。 给出数字到字母的映射如下(与电话按键相同)。注意 1 不对应任何字母。 示例 1: 输入:digits = "23" 输出:["ad","ae","af","bd","be","bf","cd","ce","cf"] 示例 2: 输入:digits = "" 输出:[] 示例 3: 输入:digits = "2" 输出:["a","b","c"] date: 2021年3月26日 """ from typing import List class Solution: def lett...
076ddd08c44f90cb4f054a1c416a44ba96ab8e3e
codeforcauseorg-archive/DSA-Live-Python-Jun-0621
/lecture-14/dicefaces.py
535
3.65625
4
def dice(target, faces): if target == 0: return 1 count = 0 for face in range(1, faces+1): if face > target: break count += dice(target-face, faces) return count def dicepaths(target, faces, solution=[]): if target == 0: print(solution) retur...
c081f9329be6f0be883b9278e4e4c0ec3475d0e9
PangYunsheng8/LeetCode
/剑指offer/对称的二叉树.py
361
3.5625
4
class Solution: def isSymmetric(self, root: TreeNode) -> bool: if not root: return True def recu(t1, t2): if not t1 and not t2: return True if not t1 or not t2 or t1.val != t2.val: return False return recu(t1.left, t2.right) and recu(t1.right, t2.left) ...
de48460c3d7d59d18d47dd272164308122510f15
999Hans/SWE-Academy
/8. 함수/2. 가위바위보.py
496
3.734375
4
a1 = input() a2 = input() x = input() y = input() def win(x1, x2): if (x1 == "가위" and x2 == "바위") or (x2 == "가위" and x1 == "바위"): print("바위가 이겼습니다!") elif (x1 == "가위" and x2 == "보") or (x2 == "가위" and x1 == "보"): print("가위가 이겼습니다!") elif (x1 == "보" and x2 == "바위") or (x2 == "보" and x1 == "...
d5a4ac7be046ee570f6cd657623d9d41c6e6b61f
Aleks8830/PythonPY100
/Занятие1/Практические_задания/task2_1/main.py
229
3.6875
4
input_str = input('Введите строку Hello World: ') print(input_str,type(input_str)) # TODO c помощью функции print рачпечатайте значение переменной input_str и её тип
230fe4d0d7175d67be8cd5f1a62dbbd7c51d2db3
MaphsterB/advent2017
/solvers/day18.py
7,794
3.78125
4
""" --- Day 18: Duet --- You discover a tablet containing some strange assembly code labeled simply "Duet". Rather than bother the sound card with it, you decide to run the code yourself. Unfortunately, you don't see any documentation, so you're left to figure out what the instructions mean on your own. It seems like...
47cebd3b8c92728dda3218dec4936e96e1f5f831
arattha/CodingTest
/백수/코테공부/greedy/Check If a String Can Break Another String.py
1,314
3.625
4
################################################################################ #1433. Check If a String Can Break Another String # #https://leetcode.com/problems/check-if-a-string-can-break-another-string/ # #############################################################################...
e7d267b711545d447783c4b9982d1e89f9d2432c
dementrock/acm
/berkeley_programming_contest_2012/inst.eecs.berkeley.edu/~ctest/contest/test-data/1/subm/make-data
490
3.6875
4
#!/usr/bin/env python # -*-Python-*- import re, sys, random random.seed(sys.argv[1]) D = int(sys.argv[2]) args = map(int, sys.argv[3:]) for NC, NR in zip(args[::2], args[1::2]): print NR roads = set([]) for i in xrange(NR): c1 = c2 = random.randint(1, NC) while c1 == c2 or (c1, c2) in roa...
36efd8c42bfbfd902d0c62aa6ea0d5a8dd0a6eb6
djm158/pygame-bouncing-ball
/ball.py
659
3.84375
4
import pygame class Ball(pygame.sprite.Sprite): """ Ball class attribute: velocity methods: update """ def __init__(self, color, position, radius): # call super class constructor pygame.sprite.Sprite.__init__(self) self.image = pygame.Surface((...
adec411221896366552f1799b15e45e992080360
zikfood/budg-intensive
/day_1/flow_control/task_2/implementation.py
218
3.6875
4
def convert_temperature(value, to_scale): if to_scale == "F": result = value * 9 / 5 + 32 elif to_scale == "C": result = (value - 32) * 5 / 9 else: result = value return result
0cfac75b224420b1bea986625d1b43bcfeeeb1cf
ArkadiyShkolniy/python_lesson_2
/for.py
366
4.125
4
# Циклы For # Простейший цикл For for i in range(10): # range (start, stop, step) print(i) if i == 5: break for i in range(5): answer = input ("Какая марка авто?") if answer == "Volvo": print("Вы правы") break for i in range(10): if i == 9: break if i < 3: continue else: pr...