blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
e32febfa49cea38997e6df377228ec52ddbda590
wslxko/LeetCode
/tencentSelect/number4.py
1,322
3.59375
4
''' 给定一个包括 n 个整数的数组 nums 和 一个目标值 target。找出 nums 中的三个整数,使得它们的和与 target 最接近。返回这三个数的和。假定每组输入只存在唯一答案。 例如,给定数组 nums = [-1,2,1,-4], 和 target = 1. 与 target 最接近的三个数的和为 2. (-1 + 2 + 1 = 2). 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/3sum-closest 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 ''' class Solution: def threeS...
b1b801fbdc5cb7c8580a982fd8a8123bec9ab486
wslxko/LeetCode
/hot100/39. 组合总和.py
1,615
3.84375
4
""" 给定一个无重复元素的数组 candidates 和一个目标数 target ,找出 candidates 中所有可以使数字和为 target 的组合。 candidates 中的数字可以无限制重复被选取。 说明: 所有数字(包括 target)都是正整数。 解集不能包含重复的组合。  示例 1: 输入:candidates = [2,3,6,7], target = 7, 所求解集为: [ [7], [2,2,3] ] 示例 2: 输入:candidates = [2,3,5], target = 8, 所求解集为: [   [2,2,2,2],   [2,3,3],   [3,5] ]   来源:力扣(...
ef279c9c3dec603177e2b5aa1c3761485a4e8aa0
wslxko/LeetCode
/array/number10.py
826
3.984375
4
''' 给定一个数组,将数组中的元素向右移动 k 个位置,其中 k 是非负数。 示例 1: 输入: [1,2,3,4,5,6,7] 和 k = 3 输出: [5,6,7,1,2,3,4] 解释: 向右旋转 1 步: [7,1,2,3,4,5,6] 向右旋转 2 步: [6,7,1,2,3,4,5] 向右旋转 3 步: [5,6,7,1,2,3,4] 示例 2: 输入: [-1,-100,3,99] 和 k = 2 输出: [3,99,-1,-100] 解释: 向右旋转 1 步: [99,-1,-100,3] 向右旋转 2 步: [3,99,-1,-100] 来源:力扣(LeetCode) 链接:https://leetcod...
a9e63fc2b7fa731fee03d8f568d984ca70131ae0
wslxko/LeetCode
/array/number16.py
1,391
3.71875
4
''' 给定一个数组,它的第 i 个元素是一支给定股票第 i 天的价格。 如果你最多只允许完成一笔交易(即买入和卖出一支股票),设计一个算法来计算你所能获取的最大利润。 注意你不能在买入股票前卖出股票。 示例 1: 输入: [7,1,5,3,6,4] 输出: 5 解释: 在第 2 天(股票价格 = 1)的时候买入,在第 5 天(股票价格 = 6)的时候卖出,最大利润 = 6-1 = 5 。 注意利润不能是 7-1 = 6, 因为卖出价格需要大于买入价格。 示例 2: 输入: [7,6,4,3,1] 输出: 0 解释: 在这种情况下, 没有交易完成, 所以最大利润为 0。 来源:力扣(LeetCode) 链接:h...
b6eaf79ef1feab0836e037ed670d833feed41812
wslxko/LeetCode
/hot100/31.下一个排列.py
1,272
3.96875
4
""" 实现获取 下一个排列 的函数,算法需要将给定数字序列重新排列成字典序中下一个更大的排列。 如果不存在下一个更大的排列,则将数字重新排列成最小的排列(即升序排列)。 必须 原地 修改,只允许使用额外常数空间。 示例 1: 输入:nums = [1,2,3] 输出:[1,3,2] 示例 2: 输入:nums = [3,2,1] 输出:[1,2,3] 示例 3: 输入:nums = [1,1,5] 输出:[1,5,1] 示例 4: 输入:nums = [1] 输出:[1] 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/next-permutation 著作权...
803fa874360ac82951c3f7949b55178c3746169f
StampedPassp0rt/courses
/lphw/ex8.py
572
3.75
4
#Exercise 8 #variable that force prints four inputs with %r, kind of a debugger too. formatter = "%r %r %r %r" #printing out 1 through 4 print formatter % (1,2,3,4) #printing out one through four as strings. print formatter % ("one", "two", "three", "four") #forcing the print of Boolean values print formatter % (True...
4b294061e1d73407e814d6ffa93063d72d2d4122
StampedPassp0rt/courses
/mit-6.00.2x/unit-02/rolldie-example.py
343
3.796875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Apr 16 11:37:31 2017 @author: ameetrawtani """ import random def RollDie(): return random.choice([1,2,3,4,5,6]) def testRoll(n=10): result = '' for i in range(n): result = result + 'Roll ' + str(i+1) + ': ' + str(RollDie()) + ...
2cbeee807c751597f8145ec26bf8c0b3e5a52810
data-engineering-lon-1/Alexia
/src/guites.py
8,068
3.546875
4
import tkinter as tk from tkinter import * import mysql.connector as connector import mysql.connector.errors as errors host = "localhost" user = "root" password = "password123" port = "33066" def mysqlconnect(database="app"): try: db_connection = connector.connect( host=host, user=user, passwo...
6af6f8c09de179180408d6ed5ec89fa157fc4742
Lyonmwangi/learn_python
/elif_practice.py
231
3.625
4
a=50 if a==40: print("1-got a true expression value",a) elif a==30: print("2-got a true expression value",a) elif a==50: print("3-got a true expression value",a) else: print("4-got a true expression value",a) print ("goodbye")
114718898f19da87850e0baa1d09c6d2023e00b1
manim-kindergarten/manim_sandbox
/utils/mobjects/angle.py
3,399
3.71875
4
# from @pdcxs from manimlib.imports import * # Usage: Angle(p1, p2, p3) # p1, p2, p3 should be in counterclock order # p2 is the vertex of the angle # is_right: make the angle always be a right angle # not_right: the angle is always NOT a right angle # if is_right and not_right are both false, the angle # will be dra...
72a8594df8fdad92e259e9745822ee9d43a54de4
cjfoster10/realpython
/sql/homework_2.py
680
3.84375
4
import sqlite3 with sqlite3.connect('cars.db') as connection: c = connection.cursor() newCars = [ ('Ford', 'Explorer', 15), ('Ford', 'Focus', 20), ('Ford', 'Mustang', 25), ('Honda', 'Accord', 20), ('Honda', 'Civic', 15) ...
46d32c84fe3d08e24a7522e55723fdd683025792
tongramt/SoftAppsGroup
/Script1.py
3,136
4.1875
4
# The code for part 1: Script 1 # The below code is adapted from code found here: https://www.geeksforgeeks.org/file-explorer-in-python-using-tkinter/ # Python program to create # a file explorer in Tkinter # import all components # from the tkinter library from tkinter import * from tkinter import filedialog import p...
2e9974e68d38a212e138cbd41eb2dc8996757d6e
rajmohd123-cell/PythonFDP
/basic.py
913
3.78125
4
class LLNode: def __init__(self, val, next=None): self.val = val self.next = next def create_linked_list(nums): """ Assumes the list has atleast one element """ head = LLNode(nums[0]) current = head for i in range(1, len(nums)): new_node = LLNode(nums[i]) ...
e5b35bb71eb2561eb28e786654209579564c7f5f
piredins/homework
/homework lecture 2.5.py
613
3.71875
4
from contextlib import contextmanager from datetime import datetime @contextmanager def open_file(file_path, encoding='utf8'): try: time1 = (datetime.now()) print('Время запуска кода в менеджере контекста:', time1) file = open(file_path) yield file finally: file.close time2 = (d...
1b68f58a36594c14385ff3e3faf8569659ba0532
derekcollins84/myProjectEulerSolutions
/problem0001/problem1.py
521
4.34375
4
''' If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. ''' returnedValues = [] sumOfReturnedValues = 0 for testNum in range(1, 1000): if testNum % 3 == 0 or \ testNum ...
5ac9d7093e418997e00e843fd40a47289a2d7d89
derekcollins84/myProjectEulerSolutions
/problem0022/problem22.py
1,177
3.9375
4
''' Using names.txt (right click and 'Save Link/Target As...'), a 46K text file containing over five-thousand first names, begin by sorting it into alphabetical order. Then working out the alphabetical value for each name, multiply this value by its alphabetical position in the list to obtain a name score. For example...
9670dc592f9feb66155096df8e905f5c3bd29057
lov2cod/my_playground
/cs50/dict_challenge.py
877
3.671875
4
import csv sub_data = {} def size_of_data(): return len(sub_data) def update_data(sub_id,new_value): if sub_id in sub_data: sub_data[sub_id] = new_value return sub_data def add_data(sub_id, value): if sub_id not in sub_data: sub_data[sub_id] = value print(f"Sub ID:{sub_id...
fa46678e891f0ab1d1dbbe8a9ca77b83532180d6
Biruk-gebru/acc-projects
/guess game with whie loop.py
344
4.03125
4
import random x=random.randint(1,10) print("guess the value of x.") answer=0 while answer!=x: answer=eval(input("enter your guess:")) if answer > x: print("your guess is too high,guess again:") elif answer==x: print ("YOU got the number:",x) else: print("your guess i...
d7cece82c421a65e9d1c5e1f41d392180aa24505
iadel93/TestRepo101
/test.py
92
3.53125
4
print('Hello World') for i in range(10): print(i) l = [5,6,7] for x in l: print(x)
70cbe08e7ab2ccb89bf2eaf80d344dde051e1ab6
whitewolf23/computer-science
/03_oop/oop_example/person.py
791
3.984375
4
# 공통 속성을 뽑아서 부모 클래스 class Person: def __init__(self, name, age, money): self.name = name self.age = age self.money = money def give_money(self, other, how_much): if self.money > how_much: self.money -= how_much other.money += how_much els...
f37a238f5e9698233992dcda9b44d5b32d537a6a
Emp923/junk-drawer
/python/guesser.py
661
4.0625
4
#!/usr/bin/python3 # Number guesser program by Eric Penrod import random def intro(): print("This program generates a random integer.") print("You must try to guess that integer.") print("You will be given hints after each guess.") def main(): found = False ranNum = random.randint(1,100) # ranNum = 35 # fo...
59609427d2e62f29bb7388f7bd320cb2cf927da3
Sohom-chatterjee2002/Python-for-Begineers
/Assignment-1-Python Basics/Problem 3.py
423
4.15625
4
# -*- coding: utf-8 -*- """ Created on Wed Dec 2 14:23:03 2020 @author: Sohom Chatterjee_CSE1_T25 """ def append_middle(s1,s2): middleIndex=int(len(s1)/2) print("Original strings are: ",s1,s2) middleThree=s1[:middleIndex]+s2+s1[middleIndex:] print("After appending new string in middle: ",m...
c162faab7cf2c9b1a0ece7786f1c0dfe195b8265
Sohom-chatterjee2002/Python-for-Begineers
/Assignment-1-Python Basics/Problem 19.py
497
3.796875
4
# -*- coding: utf-8 -*- """ Created on Sat Dec 12 15:49:43 2020 @author: Sohom Chatterjee_CSE1_T25 """ #Given a Python dictionary, Change Brad’s salary to 8500 #sampleDict = { 'emp1': {'name': 'Jhon', 'salary': 7500}, 'emp2': {'name': 'Emma','salary': 8000}, 'emp3': {'name': 'Brad', 'salary': 6500}} sampleDi...
8e8e1b63125ecf7c15ebb4c7fae1322025e2b143
Sohom-chatterjee2002/Python-for-Begineers
/Assignment-1-Python Basics/Problem 10.py
242
3.796875
4
# -*- coding: utf-8 -*- """ Created on Wed Dec 9 15:43:07 2020 @author: Sohom Chatterjee_CSE1_T25 """ #Unpack the following tuple into 4 variables.Tuple=(10,20,30,40) Tuple=(10,20,30,40) a,b,c,d=Tuple print(a) print(b) print(c) print(d)
8b29ca12d190975f7b957645e9a18b4291e662a1
Sohom-chatterjee2002/Python-for-Begineers
/Assignment 2 -Control statements in Python/Problem 6.py
556
4.15625
4
# -*- coding: utf-8 -*- """ Created on Wed Dec 23 14:25:28 2020 @author: Sohom Chatterjee_CSE1_T25 """ #The set of input is given as ages. then print the status according to rules. def age_status(age): if(age<=1): print("in_born") elif(age>=2 and age<=10): print("child") elif(...
972cc1139d479cd8a369ef66201b5ccb2a326ef0
nipapad/python-experiments
/edabit/puzzlePieces.py
267
3.625
4
list1 = [1,2,3,4,5,6] list2 = [6,5,4,3,2,1] # Holds an iterator object zipped = zip(list1, list2) result = map(sum,zipped) result_list = list(result) if result_list.count(result_list[0]) != len(result_list): print(False) else: print(True)
74955265dcd03ac302245f7176cf464b8ef82ffc
ayushchaudhari/Hacker-Rank
/Coding Challenges/April Code Challenge organized By VIMEET/Day 5 Laurene's new trouble problem/solution.py
116
3.578125
4
m=int(input()) a_list=[] for n in range(m): a_list.append(int(input())) for n in a_list: print(n-1,1)
ea8c192a63775e80e6ce8f9e4821f57059261a57
alison-medeiro/html-para-o-git
/idade.py
84
3.6875
4
idade = int(input("Qual é a sua idade? ")) print("Você tem {} anos".format(idade))
3587ee44ae9bc32009c33cd4c4526e5f63fbce8b
nkmashaev/Courses
/homework4/task05.py
634
4.0625
4
def fizzbuzz(n: int): """ fizzbuzz function takes a number N as an input and returns a generator that yields N FizzBuzz numbers. :param int: size of fizzbuzz sequence :return: generator of fizzbuzz sequence :raise: ValueError """ if not isinstance(n, int): raise ValueError("Err...
42259b902e9518309c4bcf2a5ff4360fe58ba62c
nkmashaev/Courses
/homework7/task02.py
420
3.5
4
from collections import defaultdict from itertools import zip_longest def string_constructor(string: str) -> str: str_list = [] for a in string: if a != "#": str_list.append(a) elif len(str_list) > 0: str_list.pop() return "".join(str_list) def backspace_compare(f...
d6f384f67d2ba4e090b948c68056a24cb785427b
nkmashaev/Courses
/homework7/task01.py
1,025
3.671875
4
from collections import defaultdict from typing import Any example_tree = { "first": ["RED", "BLUE"], "second": { "simple_key": ["simple", "list", "of", "RED", "valued"], }, "third": { "abc": "BLUE", "jhl": "RED", "complex_key": { "key1": "value1", ...
abb1f71c980a72bd23442c1f820d030626742929
nkmashaev/Courses
/homework2/task01.py
5,125
3.9375
4
""" The implementation of the first task. The first task consists of next problems^ 1) Find of 10 longest words consisting from largest amount of unique symbols 2) Find rarest symbol for document 3) Count every punctuation char 4) Count every non ascii char 5) Find most common non ascii char for document """ import o...
7df003f67d880346929f62d80864f345a0efcbcf
natasyaoktv/Tugas-1
/Soal-2.py
175
3.765625
4
r = int(input("Masukkan jari-jari lingkaran: ")) phi = float(3.14) circle = phi * (r * r) print("Luas lingkaran dengan jari jari {} cm adalah {} cm\u00b2".format(r, circle))
553dce7c36bae7bb5b372a4050df7fe2c2a8ed1c
ctir006/Python-and-C-code-submitted-in-HackerRank-contests
/Class_Work_Assignments/DP/Recursive_change..py
277
3.640625
4
import math def recurse_change(money,coins): if money==0: return 0 min_coins=math.inf for i in coins: if money>=i: min=1+recurse_change(money-i,coins) if min_coins>min: min_coins=min return min_coins coins=[6,5,1] print(recurse_change(40,coins))
d06e5dbe79392823f0bac4a3329d2f2a60ac0655
ctir006/Python-and-C-code-submitted-in-HackerRank-contests
/Camel_case.py
96
3.734375
4
str=input() count=1 for i in range(len(str)): if str[i].isupper(): count+=1 print(count)
fccacd3a4799ab9b23a34b5c60f007afd54f7f73
tejaswisunitha/python
/power.py
348
4.28125
4
def power(a,b): if a==0: return 0 elif b==0: return 1 elif b==1: return a elif b%2 == 0: res_even = power(a,b/2) return res_even*res_even else : b=(b-1)/2 res_odd= power(a,b) return a*res_odd*res_odd ...
df364017661771317a83300130834d9eb85332b8
ChornaOlga/pdp-php-1
/pdphelper/test_box.py
13,960
3.8125
4
from unittest import TestCase from box import Box __author__ = 'Alex Baranov' class TestBox(TestCase): """ Set of test for the Box class """ def test_create(self): """ Verify that Box can be created """ rect = Box((1, 2, 3)) self.assertIsNotNon...
413524181632130eb94ef936ff18caecd4d47b06
nikhilroxtomar/Fully-Connected-Neural-Network-in-NumPy
/dnn/activation/sigmoid.py
341
4.1875
4
## Sigmoid activation function import numpy as np class Sigmoid: def __init__(self): """ ## This function is used to calculate the sigmoid and the derivative of a sigmoid """ def forward(self, x): return 1.0 / (1.0 + np.exp(-x)) def backward(self, x): ...
d920445ab4b2d6572d12957b661e741be9187a1c
mitakaxqxq/BeloteDeclarations
/test_deck.py
1,552
3.671875
4
import unittest from deck import Deck from card import Card from magic_strings import * class TestDeck(unittest.TestCase): def test_deck_initialization_is_as_expected(self): expected_deck = [Card(seven, clubs), Card(seven, diamonds), Card(seven, hearts), Card(seven, spades), Card(eight, clubs), Card(eight, ...
9b7d1f23ad1398410b77ab7e03a81cd582053866
jdegrave/Python
/Chap-11-Exercises/Chap11Exercise4.py
3,706
4.375
4
""" Chapter 11 Exercise 4 - Compute the weekly hours for each employee, order in descending order of hours Author: Jodi A De Grave Date: 4/15/2016 """ def get_hours(max_employees, max_days, week): """ Prompts the user to enter the hours for day for each employee, converts the entries to a floa...
eff5a19685ea9a69f0a1b897e0d57984db2eee05
jdegrave/Python
/Chap-07-Exercises/Chap7Exercise3.py
1,711
3.9375
4
class Account: def __init__(self, id : str = 0, balance = 100, annual_interest_rate = 0): """ The constructor that accepts values for the fields :param id: account identifier :param balance: account balance :param annual_interest_rate: annual interest rate; entered as a decim...
dc3150354777b7972b31880b827304414bce406b
RealityCtrl/QuickPython
/Modules/wo.py
939
3.9375
4
"""wo module. Contains function: words_occur()""" #interface functions def words_occur(): """words_occur: count the number of occurrences of words in a fil""" #prompt the user for the name of the file to use file_name = input("Enter the name of the file: ") #Open the file. read the file and store the wo...
f05d5827d9a44c27034d6b64dd4b0d8106040d37
sm2774us/leetcode_hackerrank_codesignal_practice
/dynamic_programming/leetcode/python/leet_code_118.py
2,466
3.765625
4
from typing import List # Iterative Solution # TC: O(N^2) ; SC: O(N^2) class Solution: def generate(self, n: int) -> List[List[int]]: ans = [[1]*i for i in range(1, n+1)] # initialize triangle with all 1 for i in range(1, n): for j in range(1, i): ans[i][j] = ans[i-1][...
a5f84dc8b42d8603837e358733c49023625d63ea
LEllingwood/NCAA_bracket
/4_utility_functions.py
1,634
4.09375
4
from tabulate import tabulate import csv import matplotlib import matplotlib.pyplot as plt # This function allows user to pick a name and get the school's unique id and prints a table view of the complete list of teams. def return_school_info(): school_name = input("Enter a team name: ").title() with open('c...
8d0ef3714f25024d94063ced5ecb35798bb504a4
jgarcia525/sf-airbnb-optimizations
/price-estimator.py
1,740
3.59375
4
import pandas as pd import matplotlib.pyplot as plt from matplotlib import style # makes a new list containing only floats, not lists that # contain lists with only one element/value def removeListComplexity(currentList): newList = list() for x in range(len(currentList)): value = currentList[x] value = value[0...
ded1bee452578116f312ac1b4556bc1f42493b15
viraj-kulkarni952/Country-Predictor-Dashboard-App
/dashboard.py
7,475
3.5625
4
import pandas as pd import streamlit as st import plotly.express as px import plotly.graph_objs as go def app(): st.write(""" # Dashboard """) #Sidebar for Year Filter year_choice=st.sidebar.slider("Choose a year:", 1990, 2015, 2015) country_d...
16b7faf225937b50bfd8b12515cb45ce5f3f6512
Diana-Doe/homework
/modules/dataADT.py
7,835
3.546875
4
''' Module with ADT class. ''' import json from LinkedList import LinkedDict, LinkedList class DataADT: '''Represents data''' def __init__(self): ''' DataADT -> NoneType ''' self.list = LinkedList() self.categories = LinkedList() self.dates = LinkedList() ...
d4f033b157ca926c1ba215f9f031eb9c147e2546
hanxianzhao/leetcode--python
/从排序数组中删除重复项.py
1,354
3.734375
4
''' 给定一个排序数组,你需要在原地删除重复出现的元素,使得每个元素只出现一次,返回移除后数组的新长度。 不要使用额外的数组空间,你必须在原地修改输入数组并在使用 O(1) 额外空间的条件下完成。 示例 1: 给定数组 nums = [1,1,2], 函数应该返回新的长度 2, 并且原数组 nums 的前两个元素被修改为 1, 2。 你不需要考虑数组中超出新长度后面的元素。 示例 2: 给定 nums = [0,0,1,1,1,2,2,3,3,4], 函数应该返回新的长度 5, 并且原数组 nums 的前五个元素被修改为 0, 1, 2, 3, 4。 你不需要考虑数组中超出新长度后面的元素。 ''' def removeDupli...
528fd699459c14fed86cdbf97cfbb9e0c9edde5e
hanxianzhao/leetcode--python
/层序遍历二叉树.py
1,182
3.5
4
''' 给定一个二叉树,返回其按层次遍历的节点值。 (即逐层地,从左到右访问所有节点)。 例如: 给定二叉树: [3,9,20,null,null,15,7], 3 / \ 9 20 / \ 15 7 返回其层次遍历结果: [ [3], [9,20], [15,7] ] ''' ''' 超过70.25% ''' class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: d...
36fc8d1cb13ce05e46b6f6116d94b4e48188a827
hanxianzhao/leetcode--python
/设计问题-最小栈.py
1,470
4.0625
4
''' 设计一个支持 push,pop,top 操作,并能在常数时间内检索到最小元素的栈。 push(x) -- 将元素 x 推入栈中。 pop() -- 删除栈顶的元素。 top() -- 获取栈顶元素。 getMin() -- 检索栈中的最小元素。 示例: MinStack minStack = new MinStack(); minStack.push(-2); minStack.push(0); minStack.push(-3); minStack.getMin(); --> 返回 -3. minStack.pop(); minStack.top(); --> 返回 0. minStack.getMin();...
6ea44bb3fbddd489882f20bdd392b13096a98760
hanxianzhao/leetcode--python
/K个一组翻转链表.py
1,436
3.828125
4
''' 给出一个链表,每 k 个节点一组进行翻转,并返回翻转后的链表。 k 是一个正整数,它的值小于或等于链表的长度。如果节点总数不是 k 的整数倍,那么将最后剩余节点保持原有顺序。 示例 : 给定这个链表:1->2->3->4->5 当 k = 2 时,应当返回: 2->1->4->3->5 当 k = 3 时,应当返回: 3->2->1->4->5 说明 : 你的算法只能使用常数的额外空间。 你不能只是单纯的改变节点内部的值,而是需要实际的进行节点交换。 ''' ''' 执行用时: 68 ms, 在Reverse Nodes in k-Group的Python3提交中击败了98.79% 的用户 ''' class ListNod...
a567984ae73c6eb4a893dcf0a1ba5a9823d3776c
hanxianzhao/leetcode--python
/有效的山脉数组.py
824
3.859375
4
''' 给定一个整数数组 A,如果它是有效的山脉数组就返回 true,否则返回 false。 让我们回顾一下,如果 A 满足下述条件,那么它是一个山脉数组: A.length >= 3 在 0 < i < A.length - 1 条件下,存在 i 使得: A[0] < A[1] < ... A[i-1] < A[i] A[i] > A[i+1] > ... > A[B.length - 1] 示例 1: 输入:[2,1] 输出:false 示例 2: 输入:[3,5,5] 输出:false 示例 3: 输入:[0,3,2,1] 输出:true ''' ''' 超过78% ''' def func(A): a = -1 ...
339ecc7f0d448b6079f4f61e1f2be9a05c25d565
lukasz-ortyl/16072019_1
/People.py
2,154
3.9375
4
class Person: def __init__(self, name): self.name = name @property def description(self): return "I am person. My name is {}.".format(self.name) class Student(Person): def __init__(self, name): super().__init__(name) class Doctor(Person): def __init__(self, name, salary): ...
fca8d5354a9bb42359a0be8760e26192aacd8b71
Webkunx/integrals
/Integrals.py
3,293
3.765625
4
from math import pow, sqrt, pi , sin """ f - function in integral , a - bottom limit, b - top limit, n - number of steps, """ f1 = lambda x: pow(x, 2)*sqrt(16 - pow(x,2)) f2 = lambda x , y: 12*y*sin(2*x*y) def wrapper(res, er): print(f'Result calculated w/ my method:{res},\ difference w/ real result:{e...
fd6541032678d0628e550f61d41a159710579f1c
AlliesAgainstCOVID/Vulnerablity-Calculator-
/Covid_AGRAJ-master/Gender_Code.py
2,652
3.65625
4
import numpy as np import pandas as pd from matplotlib import pyplot as plt from sklearn.linear_model import (LinearRegression) def gender_data(a): df = pd.read_csv("Covid_AGRAJ-master/GenderCOVID-19DeathsData.csv") df.drop(df[df['Sex'] != user].index, inplace = True) # Dropping death counts data for other gender gro...
8e96a6fcac5695f7f0d47e1cf3f6ecef9382cbbf
janvanboesschoten/Python3
/h3_hours_try.py
275
4.125
4
hours = input('Enter the hour\n') try: hours = float(hours) except: hours = input('Error please enter numeric input\n') rate = input('Enter your rate per hour?\n') try: rate = float(rate) except: rate = input('Error please enter numeric input\n')
ed98b46454cb7865aadfe06077dff076dfd71a73
mujtaba4631/Python
/FibonacciSeries.py
308
4.5625
5
#Fibonacci Sequence - #Enter a number and have the program generate the Fibonacci sequence to that number or to the Nth number. n = int(input("enter the number till which you wanna generate Fibonacci series ")) a = 0 b = 1 c = a+1 print(a) print(b) for i in range(0,n): c = a+ b print(c) a,b=b,c
bc57bde9b1b37e9c61cf1b8e9bf4563f5f3fa1a3
MatheusBuenoNardi/exercicios
/metros para cm e mm.py
205
3.921875
4
n1 = float(input('Digite um número em metros, ex 4.5:')) cm = int(n1*100) mm = cm*10 print('O seu número em metros, transformado em cm é igual á {}cm e esses cm, em mm é {}mm'.format(cm, mm))
4c99cd87da23da776fff6f9f56348488be10e8d5
zzb15997937197/django-study
/mysite/polls/python_study/dict_demo.py
1,917
4.28125
4
dict_data = {"age": 23, "name": "张正兵"} # 1. items()方法,返回字典的所有键值对,以列表的形式返回可遍历的元组数组 items = dict_data.items() for i in items: print(i) # 2. key in dict 判断键是否在字典里 if "age" in dict_data: print("age is in dict") else: print("age is not in dict") # 3. 可以直接根据键来拿到对应的值 print(dict_data["age"]) # 4. keys()方法,返回该字典的...
1d713170867cbc0a458d3f404fa385cf327b2c5e
AltheFlyer/ECHacks-2018
/plotter.py
1,774
3.71875
4
import sqlite3 import datetime import matplotlib.pyplot as plt from sqlite3 import Error def createTable(db_file, tableName, conn): try: # conn = sqlite3.connect(db_file) c = conn.cursor() values = (tableName) c.execute('CREATE TABLE IF NOT EXISTS plantplants(time TEXT PRIMARY KEY, t...
8594a70297e1b4eead035a61a603a849684c9550
wolfessential/Homework--Lists-
/Program6 Presidents and Deficits.py
4,076
4.1875
4
#!/usr/bin/env python3 #Names: James Wolf #Date: 10/30/2017 #Program6 Presidents and Deficits #diplay menu def displayMenu(): flag = True while flag: print() print("Deficit List") print("\tList - List the Presidents.") print("\tShow - List the Deficits.") print("\tAdd...
e0274ffe2e3f25268c16d2d5cae9484994913f06
anjali-goyal/Guvi
/larg.py
211
3.578125
4
no=list(map(int,input().split())) if no[0]>no[1]: if no[0]>no[2]: print(no[0]) else: print(no[2]) else: if no[1]>no[2]: print(no[1]) else: print(no[2])
93b3333da4d858b1e37a0877c807648204685d92
leeejin/python_
/Assignment_7weeks/이수진_과제7.py
566
3.84375
4
import turtle #1번 t= turtle.Turtle() t.shape('turtle') def cCircle(r): t.penup() t.goto(0,-r) t.pendown() t.circle(r) t.penup() t.home() t.pendown() return r print(cCircle(100)) print(cCircle(70)) print(cCircle(40)) #2번 def number2(x): y="" while x>0: y=str(x%2)+y ...
9802e59ff55033fe68edde3d48636d2ea29dec0f
leeejin/python_
/Assignment_6weeks/while&random.py
563
3.578125
4
#while문 n=1 sum=0 while n<=10: sum=sum+n n=n+1 print("1~10까지의 합:",sum) n=1 sum=0 while sum<=500: n=n+1 sum=sum+n print("1~",n,"까지의 합:",sum) #random함수 import random n=0 while n!=4: n = random.randint(0,9) print(n) #random함수 예제 print("1~100사이의 숫자를 맞추시오") count=0 n=0 idk = random.randint(1,100) ...
1bd13b7ee2926aa9d6ff628a73e29670df365db0
leeejin/python_
/Assignment_5weeks/6W_ex2.py
172
3.765625
4
year = int(input('연도 입력:')) if year % 4 == 0 and year % 100 !=0 or year % 400 ==0 : print(year,'년은 윤년') else: print(year,'년은 윤년이 아님')
2704776a68a38df97a4da6804cac97f4091b5bad
leeejin/python_
/Assignment_5weeks/6W_ex3.py
261
3.65625
4
n1 = int(input('자연수1:')) n2 = int(input('자연수2:')) if n1>n2: print('목:',n1/n2,'나머지:',n1%n2) if n2==0: print('Divide by zero') if n2>n1: print('목:',n2/n1,'나머지:',n2%n1) if n1==0: print('Divide by zero')
e5ac62bf94ebed61c325625e82010ca8bfa5866f
lusan/Seismic-activity-monitor--SAM-
/ManipulateData.py
813
3.6875
4
#csv is pretty fun to work with, we just need the latitude and longitude for #each earthquake. #This code will attempt at extracting only the latitude and longitude #Open the earthquake data file data_file = open('C:\Python27\Py Pro\SAM\dataset.csv') #Create emmpty lists for the latitudes and longitudes. lats, lons =...
407292d2ade8b8e522fb9e405cbbe599d4f6e2d8
lusan/Seismic-activity-monitor--SAM-
/SplittingData.py
989
3.78125
4
#The US government maintains a set of live feeds of earthquake-related data from recent seismic events #For this project I will use a dataset that contains all seismic events over the last #seven days, which have a magnitude of 1.0 or greater. #In my project I will be parsing a file in the csv format also known as #co...
6f174ec937772f9b9896995c9bb1093fb97234f2
Carlos-Alberto-Gallego-Benitez/interfaces_garficas_python
/imgen en interfaz.py
669
3.609375
4
from tkinter import * #importamos la libreria de tkinter para crear interfaces root = Tk() #creamos la interfaz root.title("Carlos Python") #nos permite darle un titulo a la interfaz root.resizable(1,1) #nos permite controlar las margenes de interfaz root.iconbitmap("dr4.ico") #con esta linea le damos la imagen de...
efa386834b4abbbc7db92129b275892b22ca1178
Carlos-Alberto-Gallego-Benitez/interfaces_garficas_python
/Buttointerfaz.py
1,950
4.03125
4
from tkinter import * #importamos la libreria de tkinter para crear interfaces root = Tk() #creamos la interfaz root.title("Carlos Python") #nos permite darle un titulo a la interfaz def Sumar(): #creando metodo sumar if(var1.get()==""): resultado.set("llene el campo uno") elif(var2.get()==""):...
bbbdd61104379bc3d36231a61fd9fedf1dc3a77c
Oath-of-the-Peach-Garden/Zhang-Fei
/Level1/question16to20.py
1,850
3.765625
4
# 16) 문자열 내 마음대로 정렬하기 # https://programmers.co.kr/learn/courses/30/lessons/12915 # 20분 고민하고 아닌것같아서 다른방법 모색 # 1트 # def solution_16(strings, n): # answer = [] # dict_s = {} # set_answer = {} # for s in strings: # dict_s[s] = s[n] # d_values = list(dict_s.values()) # d_values....
34ed88335ee54f4e5bc0e860cee23ba146188c4e
Oath-of-the-Peach-Garden/Zhang-Fei
/Level2/lv2_q10.py
544
3.5625
4
# 10) 행렬의 곱셈 # https://programmers.co.kr/learn/courses/30/lessons/12949 def solution(arr1, arr2): answer = [] for i, a1 in enumerate(arr1): tmp_arr = [] for j in range(len(arr2[0])): tmp = 0 for k in range(len(arr2)): a = a1[k] #...
108d56e2b0df4e64e7a1d1f2c076d1043cc22e15
philipwerner/data-structures
/src/test_merge_sort.py
1,249
3.625
4
"""Test module for merge_sort.""" import pytest from merge_sort import merge_sort sb_list = [1, 2, 3, 4, 5, 6, 7, 8, 9] bs_list = [9, 8, 7, 6, 5, 4, 3, 2, 1] uo_list = [56, 3, 78, 79, 34, 22, 87, 1, 23] short = [19, 3] three_list = [19, 56, 5] one_list = [9345] def test_merge_sort_with_numerical_ordered_list(): ...
d1eb780079162d3320041c6983921fed9d5b17cd
philipwerner/data-structures
/src/bubble_sort.py
987
3.578125
4
"""Bubble sort module.""" def b_sort(ilist): """Bubble sorting function.""" if isinstance(ilist, list): for numbers in range(len(ilist) -1, 0, -1): for i in range(numbers): if ilist[i] > ilist[i + 1]: num_holder = ilist[i] ilist[i] = ...
0756d9cfa339f77fccd5e824fb2c4142dbc72be2
Dan-Elioth/Examen-Unidad-1
/Antecedente del examen/Ejercicio2.py
495
3.65625
4
print("Buen dia") #Variables salariomin=930 #Datos de entrada puntos=int(input("Ingrese los puntos que obtuvo por su desempeño laboral:" )) salariomin=int(input("Ingrese el sueldo minimo:\nTeniedo en cuenta que el salario minimo en el Perú es de=930\n")) #Proceso if puntos>=50 and puntos<=100: bonofinal=salariomin*0...
2ddc4abc64069852fdd535b49a26f5712463f14a
nathanandersen/SortingAlgorithms
/MergeSort.py
1,122
4.25
4
# A Merge-Sort implementation in Python # (c) 2016 Nathan Andersen import Testing def mergeSort(xs,key=None): """Sorts a list, xs, in O(n*log n) time.""" if key is None: key = lambda x:x if len(xs) < 2: return xs else: # sort the l and r halves mid = len(xs) // 2 ...
daaa289679afe0ecba042f00db39f0953ad55859
tdiede/coding_problems
/hackbright_challenges.py
14,943
4.25
4
# These are the coding challenges I have worked through. # medium, below # # Concepts: Dictionaries, General # def is_anagram_of_palindrome(word): # """Is a word an anagram of a palindrome? # >>> is_anagram_of_palindrome("a") # True # >>> is_anagram_of_palindrome("ab") # False #...
41931c7f28c35995653995bb5f38902b691435ff
AnichkaAleksanyan/homework
/homework35.py
240
3.65625
4
class Max: def __init__(self,myList): self.myList = myList def get_max_dif(self): newList = [myList[i]-myList[i+1] for i in range(len(myList)-1)] return max(newList) myList = [2, 4, 1, 0] a = Max(myList) print(a.get_max_dif())
2a99a40ba7a5c9eb700eea197b8f30e5dfeae8ee
AnichkaAleksanyan/homework
/homework25.py
1,087
3.765625
4
file1 = open("file1.txt","x") file1.write("Hello my name is Ani") file2 = open("file2.txt","w") file2.write("I em from Yerevan") file3 = open("file3.txt") print(file3.read()) file4 = open("file4.txt") print(file4.read()) file5 = open("file5.txt") print(file5.read()) file = open("file1.txt") for row in file: ...
f411f0f867d7188d9ccc94b6455ed3995b5350ef
jay-0625/snfl-startup
/20210406/09.py
167
3.671875
4
valueA=int(input("input first value: ")) valueB=int(input("input second value: ")) print ("{}과 {}의 합은 {}입니다." .format(valueA, valueB, (valueA+valueB)))
3377b70aef5e6afef368146c09d7ace66c64a2d4
jay-0625/snfl-startup
/20210406/03.py
126
3.765625
4
valueA=int(input("input first value: ")) valueB=int(input("input second value: ")) output=int(valueA+valueB) print (output)
e5ebc6664d8a478eb57917d1d4932237926dbb2e
jay-0625/snfl-startup
/20210406/11.py
242
3.921875
4
valueA=float(int(input("input first value: "))) valueB=float(int(input("input second value: "))) valueC=float(int(input("input third value: "))) print ("{}, {}, {}의 평균: {}" .format(valueA, valueB, valueC, ((valueA+valueB+valueC)/3)))
00ae39c14eeb5224571007738176968c6084e49a
fancycheung/LeetCodeTrying
/easy_code/TwoPointers/283.movezeros.py
1,009
4.0625
4
#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ @author:nali @file: 283.movezeros.py @time: 2018/9/4/下午5:26 @software: PyCharm """ """ Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements. Example: Input: [0,1,0,3,12] Output: [1,3,1...
9271a8d0178b59232e546ca5bad73065dbbd285f
fancycheung/LeetCodeTrying
/hard_code/4.medianoftwosortedarray.py
1,183
3.78125
4
#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ @author:nali @file: 4.medianoftwosortedarray.py @time: 2018/8/27/上午9:01 @software: PyCharm """ """ comment here """ import sys reload(sys) sys.setdefaultencoding("utf8") def findMedianSortedArrays(nums1, nums2): """ :type nums1: List[int] :type nums2:...
614d2f3dfc383cf24fd979bb2918bef80fda3450
fancycheung/LeetCodeTrying
/easy_code/Linked_List/876.middleofthelinkedlist.py
1,180
4.15625
4
#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ @author:nali @file: 876.middleofthelinkedlist.py @time: 2018/9/3/上午9:41 @software: PyCharm """ """ Given a non-empty, singly linked list with head node head, return a middle node of linked list. If there are two middle nodes, return the second middle node. Exam...
9d9f02dacbf5444bdb52e007c8487859925acf42
sakuma17/PythonTraining
/0203/turtle_race/race.py
967
3.53125
4
import random import turtle ts=[] def setup(): global ts startline=-620 screen=turtle.Screen() screen.setup(1290,720) screen.bgpic('pavement.gif') t_y=[-40,-20,0,20,40] t_color=['blue','cyan','magenta','pink','green'] for i in range(len(t_y)): t=turtle.Turtle() t.shape...
aaae225ce128d60a26bcafc47898baa6fa09f55d
sakuma17/PythonTraining
/my_kame_chan.py
317
4.09375
4
import turtle while True: num=int(input('亀ちゃんに何角形を描いてもらう?(3以上の半角整数)>>')) if(num>=3): break t=turtle.Turtle() t.shape('turtle') if num%2==0: t.left(90) else: t.right(180) for _ in range(num): t.right(360/num) t.forward(100) turtle.mainloop()
888795768259d981db7a30ff6212bb1667cc4d92
sakuma17/PythonTraining
/0218/str_lesson.py
568
3.65625
4
import string letters=string.ascii_letters width=int(input('幅>>')) row_list=list() for i in range(0,len(letters),width): chars=letters[i:i+width] print(chars) row_list.append(chars) print() row=int(input(f'何行目(1~{len(row_list)})>>'))-1 print(row_list[row]) """ count=0 for char in letters: print(char,en...
a1b033719573a0465477e7da65649a4dd7d724a0
sakuma17/PythonTraining
/0204/python_j/jyanken.py
400
3.59375
4
import random hands={0:'グー',1:'チョキ',2:'パー'} while True: you=int(input('手を入力[0:グー,1:チョキ,2:パー]>>')) pc=random.randint(0,2) print(f'あなたは{hands[you]},PCは{hands[pc]}') if you==pc: print('あいこ') continue elif (you-pc+3)%3==2: print('あなたの勝ち') else: print('あなたの負け') br...
2e3ae2b6f4c5776b6fca5dc62f198465b5a4dc82
sakuma17/PythonTraining
/0204/python_j/bingo.py
1,078
3.65625
4
import random table=[] COINS=200 TW=3 def createTable(): global table table=[[random.randint(0,9) for j in range(TW)] for i in range(TW)] for row in table: print(row) def countBingoLine(): global table vertical=[[table[j][i] for j in range(TW)] for i in range(TW)] cross=[[table[j][j] if i==0 el...
4e2ef817bd967563c72eadc6728f80a74cd661b7
sakuma17/PythonTraining
/0201/dictLesson.py
584
4.1875
4
dict1=dict() #空のdict dict1['apple']='りんご' dict1['orange']='みかん' print(dict1) print(len(dict1)) dict1['banana']='ばなな' del dict1['orange'] print(dict1) print(dict1['apple']) # 指定したキーのバリューを取得 #print(dict1['pine']) #無いのでerror print(dict1.get('pine')) #Noneを返す print(dict1.get('banana')) #ばなな if 'apple' in dict1: pr...
963bb363e66c32610f504af1403d3830249db35e
sakuma17/PythonTraining
/0129/code1_11.py
369
3.859375
4
age=24 print('浅木先輩の今年の年齢は') print(age) age=age+1 print('来年は') print(age) age=age+1 print('再来年は') print(age) ''' name=input('あなたの名前を入力してください>>') print('おお'+name+'よ、そなたが来るのを待っておったぞ!') ''' x=10 print(type(x)) price=input('料金を入力>>') print(type(price))
075e71f5ce4babd49ccad7883285139abdbe7b9c
sakuma17/PythonTraining
/0204/python_j/dice1.py
252
3.765625
4
import random num=int(input('サイコロを何回ふる?>>')) dices=[random.randint(1,6) for _ in range(num)] """ nums=list() for _ in range(num): nums.append(random.randint(1,6)) """ print(dices) print('合計は{}でした'.format(sum(dices)))
0fd24e4dbfc26052e43d6b7a110912b7f81c5afc
sakuma17/PythonTraining
/games/shiritori.py
709
3.84375
4
print('しりとりスタート!'),print('しりとり') word_set=set() count=0 word='しりとり' while True: count+=1 print(f'{count}ターン目です。') last_char=word[len(word)-1:] word=input(f'[{last_char}]で始まる平仮名を入れてください:') if word[len(word)-1:]=='ん': print('これは[ん]で終わる単語です。あなたの負けです。') break if word[0:1]!=last_char...
3fa5033d814359da34cfea5135882365dcb7eb23
FengYusheng/data-structure-and-algorithm
/Algorithms/python3/chapter2_sort/test.py
3,798
3.59375
4
# -*- coding: utf-8 -*- import sys import random import unittest from sort2 import * class TestSort(unittest.TestCase): def test_selection_sort(self): data = ['S', 'O', 'R', 'T', 'E', 'X', 'A', 'M', 'P', 'L', 'E'] sorted_data = selection_sort(data) for i in range(len(sorted_data)-1): ...
94d5e1a1270df692b23ea4da0eb91fa968bb8308
WizLuvFromMars/python-tools-poligon
/3.4.py
592
3.609375
4
"""list of common VLANs.""" def int_in_list(a_list): """Convert a_list elements to int type.""" counter = 0 for elem in a_list: a_list[counter] = int(elem) counter += 1 COMMAND1 = "switchport trunk allowed vlan 1,3,10,20,30,100" COMMAND2 = "switchport trunk allowed vlan 1,3,100,200,300" ...
1a2c0e5eb174b5a0e0765adb4a91b25c98645fcf
arteev/stepik-course-python
/week-3/week-3-7-step3.py
304
3.90625
4
dic = set([input().lower() for _ in range(int(input()))]) text = set() for y in [x.split() for x in [input() for _ in range(int(input()))]]: text.update(y) printed = set() for word in text: if word.lower() not in dic and word.lower() not in printed: print(word) printed.add(word)
3f22d6543bcf3a57be6de92bf126a33667c6563c
ktp-forked-repos/euler
/problem088/problem088.py
2,008
4
4
""" A natural number, N, that can be written as the sum and product of a given set of at least two natural numbers, {a1, a2, ... , ak} is called a product-sum number: N = a1 + a2 + ... + ak = a1 × a2 × ... × ak. For example, 6 = 1 + 2 + 3 = 1 × 2 × 3. For a given set of size, k, we shall call the smallest N with this...
99dddd51f626d8f59d7627694fb10164bb5db665
ktp-forked-repos/euler
/problem089/problem089.py
1,509
3.671875
4
""" For a number written in Roman numerals to be considered valid there are basic rules which must be followed. Even though the rules allow some numbers to be expressed in more than one way there is always a "best" way of writing a particular number. For example, it would appear that there are at least six ways of wri...
814834b5f2a274cd90269606e4bc8e569b84f293
javivi595/practica3
/Practica 3/P3E7.py
638
3.921875
4
#P4E7 JAVIER DURAN Pide una fecha, valida si es una fecha correcta y en caso # de serlo le he añadido al ejercicio que cambie el mes alfabeticamente. dia=int(input("Introduce un día:")) mes=int(input("Introduce mes:")) año=int(input("Introduce el año:")) mesalpha={1:"Enero",2:"Febrero",3:"Marzo",4:"Abril",5...