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
81e05620193c87173705ff76e08730a4a780fdda
ravenannn/Python-Projects
/Python-Tests/FunctionsInVariables.py
148
3.75
4
def getSum(num1,num2): answer = num1 + num2 print("The answer is {}.".format(answer)) getSum(2,4) myAdd = getSum print(myAdd) myAdd(2,6)
6115e892db326b25fabe97b7fb3b5a2b9e9e9077
Dhruvik-Chevli/Code
/CodeChef/brladder.py
354
3.5
4
x=int(input()) for _ in range(x): a,b=map(int,input().split()) if a%2==0 and (b==2*(a/2+1) or b==2*(a/2-1)): print('YES') elif a%2!=0 and (b==2*(a//2)+3 or b==2*(a//2)-1): print('YES') elif a%2!=0 and b==a+1: print('YES') elif a%2==0 and b==a-1: print('YES')...
5b70dae3bf878d5ba2b5ec9dee471abe73ff80b3
Dhruvik-Chevli/Code
/CodeChef/longseq.py
286
3.625
4
x=int(input()) for _ in range(x): r=input() z=0 o=0 for i in r: if i=='0': z=z+1 elif i=='1': o=o+1 if z>1 and o>1: break if z==1 or o==1: print('Yes') else: print('No')
f1c3321956c174310ff8d9cdfee5fb55554e6fbe
ravikirangb/PYTHON-2-Session_2_Assignments
/PYTHON - 2_Assignment_2.1.py
322
3.953125
4
# -*- coding: utf-8 -*- """ Created on Sat Jun 16 18:42:17 2018 @author: 1000091 Write a program which accepts a sequence of comma-separated numbers from console and generate a list. """ import os, sys InString = input('Give sequence of comma-separated numbers:') List = InString.split(',') print(List) ...
d47418067292c67f49a1f837860bade4810ddd2b
Algomaster0628/AddingUptoK
/AddingUptoK.py
327
3.5
4
def addToK(n,k): # Returns numbers which adds upto K using greedy algorithm. x = 0 y = len(n) - 1 while y != 0: if n[x] + n[y] == k: return str(n[x]) + " and " + str(n[y]) + " adds up to K." elif n[x] + n[y] > k: y -= 1 elif n[x] + n[y] < k: x += 1 y -= 1 z = addToK([2,3,4,5],9) pr...
f3ceeaf9926b5f98e58e745fa0199f1da5b0ca76
diloanusi/Python-Projects
/Property Tax GUI.py
5,451
4.0625
4
#Iloanusi, Dabeluchukwu #HW 05 #Property Tax #assessment value = 60% of actual value #Ex. If an acre of land is valued @ $10,000, its assessement value is $6,000 #Property tax = $0.75 for each $100 of the assessment value #Ex. Tax of the acre assesed at $6,000 will be $45.00 #Write GUI program that displays the assess...
4b963a44bca15d3d973db67e3fd1ebb79e4b23a9
diloanusi/Python-Projects
/Wi-Fi Diagnostic Tree.py
1,568
3.8125
4
#Wi-Fi Diagnostic Tree #program that leads a person through the steps of fixing a bad Wi-Fi connection #welcome message print("Welcome to Wi-Fi Diagnostics") print("Reboot the computer and try to connect") answer = str(input("Did that fix the problem? Yes or No: ")) #set rules depending on yes or no if(answer == 'No')...
10d92d99b47dd34f5f3854b5b23a1cfff605d861
arpitbbhayani/sepy
/sepy/part_08.py
524
3.625
4
def build_term_frequency(documents): """Given list of documents, return term frequency map Documents is a list of document and each document is { "id": "12312", "title": "Some title of a document", "body": "a gigantic body of the document", "tokens": ["hi", "i", "m", "harry", "pott...
13c74146e8e9036207ea43b324608648df6ff5de
Rohan19Ch/HackerrankProblemSolving
/fullCountingSort.py
1,027
3.65625
4
def countSort(arr): length = len(arr) maxim = int(arr[0][0]) for i in range(length): arr[i][0] = int(arr[i][0]) for i in range(length//2):#replace as per question arr[i][1] = "-" for i in range(length):#to find maximum index if arr[i][0] > maxim: maxim = ...
584bc49b10132029a12d922b0308e2dece3d7fc9
Rohan19Ch/HackerrankProblemSolving
/ClimbingTheLeaderboard.py
471
3.765625
4
def climbingLeaderboard(ranked, player): setRanked = [] for i in ranked: if i not in setRanked: setRanked.append(i) player.sort(reverse = True) rankList = [] j = 0 for i in range(len(player)): while j<len(setRanked) and player[i]<setRanked[j]: j+=1 rank = j+1 rankList.append(rank) ne...
ad83480cc9fc2d09271f1dbdc07f1bf36aa50a47
Spagettileg/file_io
/write.py
233
3.515625
4
f = open('newfile.txt', 'a') # opens the data.txt file for 'a' append & stored in 'f' file handle. lines = ['Hello','World','Welcome','To','File IO'] text = '\n'.join(lines) f.writelines(text) f.close() # close our file handle = f
c920dc42f3546ee3f28b90c5a8781252ebab9eae
souzaluuk/CG-2019.2
/utils.py
730
3.765625
4
import datetime as dt import statistics as st import math def quartis(values): meio = len(values)//2 Q1 = st.median(values[:meio]) Q2 = st.median(values) Q3 = st.median(values[meio:]) # print('Quartis:') # print('Q1:',Q1) # print('Q2:',Q2) # print('Q3:',Q3) return [Q1,Q2,Q3] ...
ba1ede0e85257ef52e821b92b0efb9d495d4be93
Yasir-Tariq/Ebay-WebscrapingusingPython
/ebay-webscrapping.py
2,117
3.515625
4
from urllib.request import urlopen as ureq #module for getting html data from bs4 import BeautifulSoup as b #module for parsing html data import re #module for regular expression import math #module for mathematical expression base_url = "https://www.ebay.com/sch/i.html?_from=R40&_nkw=" request = input('Enter keyword...
91b76d6a6b7d754688ef9de81cfb5500b567a6a7
HassanAllawati21/SimpleClock
/ClockProject.py
372
3.53125
4
from tkinter import * from tkinter.ttk import * from time import strftime root1 = Tk() root1.title("Clock") def time(): string = strftime('%I:%M:%S %p') label.config(text=string) label.after(1000, time) label = Label(root1, font=("Old London", 150), background = "black", foreground = "gold"...
2b37540519efa945f434855be03805f4cff25c41
liaoyajun/python_learn
/002_input.py
186
3.875
4
print('Who are you?') name = input() print('Hello, ' + name + '! Nice to meet you!') print('How old are you?') age = int(input()) print('Oh, you were born in ' + str( 2020 - age) + '.')
bc7de2277244a2f1c71a2bd49dacc88dd4de4893
liaoyajun/python_learn
/009_list.py
937
3.84375
4
print('------------------------------------------') print(range(1,10), type(range(1,10))) print(list(range(1,10)), type(list(range(1,10)))) print('------------------------------------------') l = [365, 'everyday', 0.618, True] print('l') print(l) l.append(1024) print('\nl.append(1024)') print(l) del l[0] print('\nde...
75c73f29a1d3949271c6790cb85498e50cc327a6
TannerS/IOMultiThreadedQueuesv2
/TestThread.py
359
3.5625
4
import threading class TestThread (threading.Thread): queue = None max = None def __init__(self, queue, max): super(TestThread, self).__init__() self.max = max self.queue = queue def run(self): for i in range(0, self.max): self.queue.enqueue(i + 1) ...
5619bb7b5f7e25c6644270c25d6aac41cc50d4c2
Jaime1323/programacion1
/laboratorio1/ejercicio2.py
174
3.546875
4
#jaime paredes mora #programa2 saldo_i=("introdusca saldo: ") an1=(saldo_i+((4*saldo_i)/100)) an2=(saldo_i+((8*saldo_i)/100)) an3=(saldo_i+((12*saldo_i)/100)) print (an1,an2,an3)
1ffdb9606d2ed14e37116c6a52ba86e1597ceb04
jasleenjerusha/imdb-webscraping-selenium
/imdb.py
997
3.65625
4
from selenium import webdriver #importing webdriver from selenium.webdriver.common.keys import Keys import os #importing the os module fd=open("MovieInfo.txt","w+") #opening text file for writing #driver = webdriver.Chrome('/home/jerusha/chromedriver_linux64(1)/chromedriver')#opening browser driver = webdriver.Chrom...
1a1aa663bb8dbdde70c1fba35066f3dd5e8947da
yisongtung/dreamPI
/exam5.py
93
3.765625
4
n = 0 for i in range(1,101): n += i print("The sum of numbers 1 to 100 is:") print (n)
ce2e3bb3632ee243ccff36fbe907c6965e84146f
harshit1210/python
/vehicle.py
637
3.84375
4
#vehicle class vehicle: speed=0 def __init__(self,wheels): self.wheels=wheels if(self.wheels>=4): print('big vehicle') else: print('two wheeler') def start(self): vehicle.speed=vehicle.speed+20 print(vehicle.speed) def accelert(self,increase): vehicle.speed=vehicle.speed+increase print(vehicle...
ee6ee5efbffb829ef00521a6903aa8e1b03289a0
harshit1210/python
/function.py
262
3.71875
4
#function def add(a,b,c): out=a+b+c return out def add(a,b): out=a+b return out def add(a,b,c,d): out=a+b+c+d return out x=add(1,2) print(x) y=add(1,2,3) print(y) z=add(1,2,3,4) print(z) u=add(1,2,3,4) print(u) v=add(1,2,3) print(v) w=add(1,2) print(w)
5630d0eb0e89a2eb34fabe47eb38019076d391db
scottmacri/bitsnbytes
/episodes/ep8/person.py
1,245
3.8125
4
import pickle class Person: def __init__(self, f_name, l_name, street, city, state, zip, phone): self.f_name = f_name self.l_name = l_name self.street = street self.city = city self.state = state self.zip = zip self.phone = phone def __str__...
f8d999d714a1426a027eeddb9704c38bd2fb066c
HYuHY/Programming_school_HH
/2nd_level_selection_tropic_island.py
7,589
4.0625
4
""" Solution for the task 'Tropic Island' Full task description in: The Task_2nd_level_selection_tropic_island.mhtml Created on 09 oct. 2017. @author: HYuHY """ # island is a list of lists # island = [ # [2, 2, 2], # [2, 1, 2], # [2, 1, 2], # [2, 1, 2] # ] import json import os import pprint im...
066875069f51b12ccc7b3ee01a78dc7d2fd8bbb3
olahsymbo/booking-prediction
/Preprocess.py
1,434
3.796875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # dependencies import pandas as pd from sklearn.preprocessing import LabelEncoder from sklearn.utils import resample class Preprocess: # class constructor def __init__(self, data): self.data = data # a function to convert data from cat...
061c6f95b31336b72a2a7ac49d64517ff06c980c
firdy94/python_mini_projects
/Polygon Area Calculator/shape_calculator.py
1,502
3.78125
4
class Rectangle: def __init__(self, width, height): self.width = width self.height = height def __repr__(self): return f'Rectangle(width={self.width}, height={self.height})' def set_width(self, val): self.width = val def set_height(self, val): self.height = val...
d777e0940a294266ff2fe9758b9e942095431a64
NattaWon/GMI2BT_Laboration_2
/Program.py
1,875
4.0625
4
import json import csv_data import json_data persons = json_data.read_file() def main(): while True: print(70 * "-") choice = input("\t\tWelcome, please choose a menu\n\n" "\t\t1. Read in Original file (person.csv)\n" "\t\t2. Show JSON-dat...
76aa764d3cfd5d7a71bf24eb2fb748a299bfa1cf
feebsilvaa/solyd-curso-intro-python
/lista-dicionario.py
189
3.65625
4
lista = ['abacaxi', 'laranja', 'abacate'] lista2 = [1, 2, 3, 4, 5, 6] print(lista) print(lista2) print(lista[2]) dicionario = { 'a': 'valor a', 'b': 'valor b' } print(dicionario)
e47b5fa5379c0bbb9de2e0d72bb8bcb0dd3fbf92
Praveen758092/test
/section4_challenge.py
314
3.953125
4
print('Please choose any of the options below') choice='-' while True: if choice=='1': break elif choice in '1234': print('you have choosen {}'.format(choice)) else: print('1.one') print('2.two') print('3.three') print('4.four') choice=input()
c82b8da5b34697bc8b9a1ed72b37495ac8a985b6
yu-podong/python_basic
/math/Test_module.py
595
4.0625
4
# Chapter 6-2 #파이썬 모듈 #Module : 함수, 변수, 클래스 등 파이썬 구성 요소 등을 모아놓은 파일 # sys.path에 원하는 모듈의 경로를 등록 -> 다른 파일에서 사용 가능 == C의 include와 비슷? def add(x, y): return x + y def subtract(x, y): return x - y def multiply(x ,y): return x * y def divide(x, y): return x / y def power(x, y): return x ** y...
ec7f55a632d090aea1ee93467bde69725f070345
mesaykk/Module-4---Transforming-Data
/PCA/assignment2_helper.py
3,768
3.671875
4
import math import pandas as pd from sklearn import preprocessing # A Note on SKLearn .transform() calls: # # Any time you transform your data, you lose the column header names. This actually makes complete sense. There are essentially two # types of transformations, those that change the scale of your features, and t...
2e46deb5c7b82b1959dfbd845b1fe052de2def71
austinwallace/myfirstpython
/firstProject.py
388
4.09375
4
first_name = input('What is your first name? ') last_name = input('What is your last name? ') print ("Hello %s %s!" % (first_name, last_name)) noun = input('Please provide a noun: ') verb = input('Please provide a verb: ') adjective = input('Please provide an adjective: ') noun2 = input('Please provide a second noun...
257ebe84ec1b6ef1e5815858fde1fdf29237cd99
cjrzs/MyLeetCode
/独一无二的出现次数.py
1,094
3.6875
4
""" coding: utf8 @time: 2020/10/28 8:22 @author: cjr @file: 独一无二的出现次数.py 题目链接:https://leetcode-cn.com/problems/unique-number-of-occurrences/ """ from typing import List from collections import Counter class Solution: def uniqueOccurrences(self, arr: List[int]) -> bool: """ 先统计个数,然后去重,看剩下的是否还与原个数一样...
618ce38bd54da9e02e5b86001603ac2cf59f1cf4
cjrzs/MyLeetCode
/LeetCode周赛/2020-08-16第202场周赛/存在连续三个奇数的数组.py
877
3.75
4
""" coding:utf8 @Time : 2020/8/16 20:00 @Author : cjr @File : 存在连续三个奇数的数组.py 给你一个整数数组 arr,请你判断数组中是否存在连续三个元素都是奇数的情况:如果存在,请返回 true ;否则,返回 false 。 示例 1: 输入:arr = [2,6,4,1] 输出:false 解释:不存在连续三个元素都是奇数的情况。 示例 2: 输入:arr = [1,2,34,3,4,5,7,23,12] 输出:true 解释:存在连续三个元素都是奇数的情况,即 [5,7,23] 。 提示: 1 <= arr.length <= 1000 1 <= ar...
82eb8e5b0416938d32fc49c221a4d18cf78a2bb1
cjrzs/MyLeetCode
/最小基因变化.py
1,320
3.65625
4
""" coding: utf8 @time: 2020/11/22 17:09 @author: cjr @file: 最小基因变化.py https://leetcode-cn.com/problems/minimum-genetic-mutation/ """ from typing import List from collections import deque class Solution: def minMutation(self, start: str, end: str, bank: List[str]) -> int: set_bank = set(bank) coun...
e0d3e210c7463c28ae250de98c98f548e45b18a1
cjrzs/MyLeetCode
/二叉树的最大深度.py
1,540
3.953125
4
''' coding:utf8 @Time : 2020/4/3 0:41 @Author : cjr @File : 二叉树的最大深度.py 题目连接:https://leetcode-cn.com/problems/maximum-depth-of-binary-tree/ ''' # Definition for a binary tree node. class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: ...
05b6f5c8a280b8a06671f0b7e1147364380d421f
cjrzs/MyLeetCode
/灯泡开关2.py
1,171
3.640625
4
""" coding: utf8 @time: 2021/2/28 22:50 @author: cjr @file: 灯泡开关2.py 题目链接:https://leetcode-cn.com/problems/bulb-switcher-ii/ """ class Solution: """ 仔细分析,其实本题状态有限 m = 0 只有一种状态 m = 1 可能有1, 2, 3, 4 各执行一遍四种状态 m = 2 可能有0, 1, 2, 3, 14, 24,34七种状态, 因为先1,再2,其实和执行一次3状态一样,先1再3其实和执行一次2状态一样,最后先2再3就相当于执行一次...
8f9a15b996d4576886e23b0b07e39540f767be99
cjrzs/MyLeetCode
/移掉K位数字.py
1,002
3.625
4
""" coding: utf8 @time: 2020/11/15 12:17 @author: cjr @file: 移掉K位数字.py 题目链接:https://leetcode-cn.com/problems/remove-k-digits/ """ class Solution: def removeKdigits(self, num: str, k: int) -> str: """ 本题需要知道在什么情况下可以删掉元素 从左往右遍历的时候,当前元素比前一个元素小的时候,删除掉前一个会使整体变最小! :param num: :pa...
1045cff0cce963fa728dd835717731fa7d764b9d
cjrzs/MyLeetCode
/有序矩阵中第K小的元素.py
2,021
3.75
4
''' coding:utf8 @Time : 2020/7/2 16:06 @Author : CJR @File : 有序矩阵中第K小的元素.py 本题链接:https://leetcode-cn.com/problems/kth-smallest-element-in-a-sorted-matrix/ ''' from typing import List class Solution: def kthSmallest(self, matrix: List[List[int]], k: int) -> int: """ 将二维矩阵变成一维矩阵之后,从小到大排序好 ...
84958c74bdd2134c0ec49b649a298fbc66c2a150
cjrzs/MyLeetCode
/二叉树的中序遍历.py
1,498
3.828125
4
""" coding: utf8 @time: 2020/11/2 22:24 @author: cjr @file: 二叉树的中序遍历.py 题目链接:https://leetcode-cn.com/problems/binary-tree-inorder-traversal/ """ from typing import List # Definition for a binary tree node. class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left =...
27fa12edcc61b191f4eee074de9f0ddb04990cc0
cjrzs/MyLeetCode
/位运算操作/颠倒二进制位.py
500
3.6875
4
""" coding: utf8 @time: 2020/12/10 11:16 @author: cjr @file: 颠倒二进制位.py 题目链接:https://leetcode-cn.com/problems/reverse-bits/ """ class Solution: def reverseBits(self, n: int) -> int: res = 0 for i in range(31, -1, -1): # 取最后一位左移i位 tmp = (n & 1) << i # 加到结果 ...
134a72d4bd4ca94b8e3a0d2d7c5a4f6b83bf9480
cjrzs/MyLeetCode
/重要的算法模板/排序算法模板/冒泡排序.py
667
4.28125
4
""" coding: utf8 @time: 2020/12/8 17:18 @author: cjr @file: 冒泡排序.py """ # 冒泡排序使用当前元素与下一个元素做比较,把符合条件的后移一位或者不动, # 这样每次都会把最大或者最小的数放在最后一个位置。 # 重复这种排序思路。就可以从后到前的排序好数组。 def bubble_sort(nums): n = len(nums) for i in range(n - 1): for j in range(n - i - 1): if nums[j] > nums[j + 1]: ...
bb773ffbbde427ab066bd54ab3b143f9932c4dbc
cjrzs/MyLeetCode
/LeetCode周赛/2020-07-11第30场双周赛/三次操作后最大值与最小值的最小差.py
1,041
3.984375
4
''' coding:utf8 @Time : 2020/7/11 23:44 @Author : cjr @File : 三次操作后最大值与最小值的最小差.py 给你一个数组 nums ,每次操作你可以选择 nums 中的任意一个数字并将它改成任意值。 请你返回三次操作后, nums 中最大值与最小值的差的最小值。 示例 1: 输入:nums = [5,3,2,4] 输出:0 解释:将数组 [5,3,2,4] 变成 [2,2,2,2]. 最大值与最小值的差为 2-2 = 0 。 示例 2: 输入:nums = [1,5,0,10,14] 输出:1 解释:将数组 [1,5,0,10,14] 变成 [1,1,0,1,1] 。...
4acb324c9468dbe5cc4df7174927a795c9bfd7f4
cjrzs/MyLeetCode
/最大子序和.py
1,149
3.78125
4
''' coding:utf8 @Time : 2020/3/2 0:19 @Author : cjr @File : 最大子序和.py 题目链接:https://leetcode-cn.com/problems/maximum-subarray/ ''' class Solution: """ 题解思路: 1、定义变量tmp来存储当前的子串和,定义变量max_存储最大和 2、从第二个元素遍历数组。 3、如果当前子串和加上此时元素的值(i)大于当前子串和,那么最大值记录更新成前子串和+当前值 同时当前存储的子串和(tmp)也要更新成前子串和+当前值。 4、如果前子串和加上此...
6867c0171caa0f004f1cc73e1d89ae96225ad760
cjrzs/MyLeetCode
/路径总和2.py
1,105
3.671875
4
""" coding: utf8 @time: 2020/9/26 17:49 @author: cjr @file: 路径总和2.py 题目链接:https://leetcode-cn.com/problems/path-sum-ii/ """ from typing import List # Definition for a binary tree node. class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: ...
5fd4ec9579b34e0e2a1bd5e17af1525f6c64a5b9
cjrzs/MyLeetCode
/二分法/658. 找到 K 个最接近的元素.py
855
3.5625
4
""" coding: utf8 @time: 2021/4/9 16:48 @author: cjr @file: 658. 找到 K 个最接近的元素.py 给定一个排序好的数组 arr ,两个整数 k 和 x ,从数组中找到最靠近 x(两数之差最小)的 k 个数。返回的结果必须要是按升序排好的。 整数 a 比整数 b 更接近 x 需要满足: |a - x| < |b - x| 或者 |a - x| == |b - x| 且 a < b   示例 1: 输入:arr = [1,2,3,4,5], k = 4, x = 3 输出:[1,2,3,4] 示例 2: 输入:arr = [1,2,3,4,5], k = 4, x ...
2113fada452d0dd9e2763d38a289e4f1f9a90468
cjrzs/MyLeetCode
/路径总和.py
819
3.859375
4
''' coding:utf8 @Time : 2020/4/18 22:56 @Author : cjr @File : 路径总和.py 本题链接:https://leetcode-cn.com/problems/path-sum/ ''' # Definition for a binary tree node. class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def hasPathSum(self, ...
73dda98226900411ec7737b3dbd2487c58561e5b
cjrzs/MyLeetCode
/LeetCode周赛/2021-03-28第234场周赛/还原排列的最少操作步数.py
1,507
3.578125
4
""" coding: utf8 @time: 2021/3/28 17:15 @author: cjr @file: 还原排列的最少操作步数.py 给你一个偶数n,已知存在一个长度为 n 的排列 perm ,其中perm[i] == i​(下标 从 0 开始 计数)。 一步操作中,你将创建一个新数组arr,对于每个i: 如果 i % 2 == 0 ,那么 arr[i] = perm[i / 2] 如果 i % 2 == 1 ,那么 arr[i] = perm[n / 2 + (i - 1) / 2] 然后将 arr​​ 赋值​​给 perm 。 要想使 perm 回到排列初始值,至少需要执行多少步操作?返回最小的 非零 操...
03809acc3282ed4712509ff5579a74670dcc4f14
cjrzs/MyLeetCode
/Acwing/排序/quick_sort.py
942
3.90625
4
""" coding: utf8 @time: 2021/1/16 11:49 @author: cjr @file: quick_sort.py 1、分解成子问题 左小右大的话,如果当前i值比分割值大就停止移动i,如果当前j值比分割值小就停止移动j。 然后交换i, j对应的值。 2、递归处理子问题 以j为分界线分成两段。 3、合并递归的结果。(在快排中不需要这一步骤) """ def quick_sort(nums, l, r): if l >= r: return x, i, j = nums[l], l - 1, r + 1 while l < r: while ...
262cc24fde99113fe8f9e8a89bbbcba3a221782a
cjrzs/MyLeetCode
/Fizz Buzz.py
558
3.765625
4
""" coding: utf8 @time: 2020/10/29 17:54 @author: cjr @file: Fizz Buzz.py 题目链接:https://leetcode-cn.com/problems/fizz-buzz/ """ from typing import List class Solution: def fizzBuzz(self, n: int) -> List[str]: res = [] for i in range(1, n+1): if i % 3 == 0 and i % 5 == 0: ...
57a1f3b98f0341e5895302c6ebe88bb2d91b1d9b
cjrzs/MyLeetCode
/两两交换链表中的节点.py
1,066
3.78125
4
""" coding:utf8 @Time : : 2020/10/22 13:53 @Author : CJR @File : 两两交换链表中的节点.py """ from typing import List # Definition for singly-linked list. class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next class Solution: def swapPairs(self, head: ListNode) -> ListNode:...
76e01c327ca29bcbd3e136b1e6aa4479e6c90d60
cjrzs/MyLeetCode
/爬楼梯.py
611
3.96875
4
''' coding:utf8 @Time : 2020/3/15 22:06 @Author : cjr @File : 爬楼梯.py 题目链接:https://leetcode-cn.com/problems/climbing-stairs/ ''' class Solution: """ 其实就是斐波那契数列的应用。 首先n=1时候有一种方法。n=2时候有两种方法, 以此类推,n可以转换成n-1和n-2之和, 即:f(n) = f(n-1) + f(n-2) 其实简单理解就是从第三个数开始,第三个数等于前两个数之和!!! """ def climbStairs...
18065bf9c77d829601aed1d9dda5ccc2b398add4
cjrzs/MyLeetCode
/扫雷游戏.py
1,415
3.734375
4
""" coding:utf8 @Time : 2020/8/20 23:13 @Author : cjr @File : 扫雷游戏.py 题目链接:https://leetcode-cn.com/problems/minesweeper/ """ from typing import List class Solution: def updateBoard(self, board: List[List[str]], click: List[int]) -> List[List[str]]: if board[click[0]][click[1]] == 'M': # 踩到了地雷,直接更新并返回 ...
ec473881999eb1003de09331ef54885ecd660cc6
cjrzs/MyLeetCode
/每日温度.py
1,089
3.875
4
''' coding:utf8 @Time : 2020/6/11 23:00 @Author : cjr @File : 每日温度.py 题目链接:https://leetcode-cn.com/problems/daily-temperatures/ ''' import typing class Solution: def dailyTemperatures(self, T: typing.List[int]) -> typing.List[int]: # 可以维护一个存储下标的单调栈,从栈底到栈顶的下标对应的温度列表中的温度依次递减。 # 如果一个下标在单调栈里,则表示尚未找到下一...
3b4bcb33f036c47cfe3809993d504adea36ddacc
cjrzs/MyLeetCode
/字母异位词分组.py
558
3.6875
4
""" coding: utf8 @time: 2020/11/1 21:24 @author: cjr @file: 字母异位词分组.py 题目链接:https://leetcode-cn.com/problems/group-anagrams/ """ from typing import List class Solution: def groupAnagrams(self, strs: List[str]) -> List[List[str]]: """ 排序 使用字典的get方法载入排序后相同元素。 :param strs: :re...
7d916879b5591ec6ae10e5428ea71437b66513ac
cjrzs/MyLeetCode
/字符串中的第一个唯一字符.py
468
3.578125
4
""" coding: utf8 @time: 2020/12/24 0:31 @author: cjr @file: 字符串中的第一个唯一字符.py 题目链接:https://leetcode-cn.com/problems/first-unique-character-in-a-string/ """ import collections class Solution: def firstUniqhar(self, s: str) -> int: if not s: return -1 counts = collections.Counter(s) ...
8687f7172be44d976b14dd984e47223df3c66283
cjrzs/MyLeetCode
/二叉树的序列化与反序列化.py
2,291
3.71875
4
''' coding:utf8 @Time : 2020/6/16 23:19 @Author : cjr @File : 二叉树的序列化与反序列化.py 题目链接:https://leetcode-cn.com/problems/serialize-and-deserialize-binary-tree/ ''' # Definition for a binary tree node. class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None...
49100fdc0db6aa79a53c31ab8b5f580f92a2275e
cjrzs/MyLeetCode
/按奇偶排序数组2.py
839
3.546875
4
""" coding: utf8 @time: 2020/11/12 8:23 @author: cjr @file: 按奇偶排序数组2.py 题目链接:https://leetcode-cn.com/problems/sort-array-by-parity-ii/ """ from typing import List class Solution: def sortArrayByParityII(self, A: List[int]) -> List[int]: """ 这道题简单的思路,可以直接遍历然后另外开一个数组存结果 但是也可以原地转换 :p...
56e2b72e2a8e88ea8701162241b0739bc8cd5fd6
cjrzs/MyLeetCode
/动态规划/回文子串.py
946
3.515625
4
""" coding: utf8 @time: 2020/11/29 19:24 @author: cjr @file: 回文子串.py 题目链接:https://leetcode-cn.com/problems/palindromic-substrings/ """ class Solution: def countSubstrings(self, s: str) -> int: if not s: return 0 n = len(s) dp = [[False] * n for _ in range(n)] count = 0 ...
38d6c576c8beab3a24255ae5e2c7c6ed31ae3292
Vidile/trabalhos_de_algoritmosI
/GABRIELQ9.py
2,370
3.90625
4
import time global Fila def gera_fila(): #Gera a fila global Fila Fila= [] def fila_vazia(f): #Função que serve para ser usada como checagem da fila, auxilia outras funções return len(f)==0 def obter_frente(f): #Função que me diz o proximo da fila if not fila_vazia(f): print(f[0...
911fb018b7cf905502c0f96acd7710571d95967a
Vidile/trabalhos_de_algoritmosI
/GabrielQ5.py
1,428
3.90625
4
import random def lista_de_nomes(): #Função que gera a lista de tuplas de maneira randomica l = [] t =tuple() dmenor ={'nome'} dmaior={} for i in range (1,101):#For que gera os dias e os meses mes = random.randint(1,12) if mes ==2: dia = random.randint(1,28) ...
d43e549c0380a79baa76e6fe741dbb54b5d499b8
ygongdev/CTCI
/python27/problem_4.py
547
3.84375
4
def canBePalindrome(str): charDict = {} for s in str: if s not in charDict: charDict[s] = 1 else: charDict[s] = charDict[s] + 1 oddFlag = False for s in str: if charDict[s] % 2 != 0: if oddFlag: return False else: oddFlag = True return True def main(): assert canBePalindrome("aabb"...
e508f0ca1e3cb77beeb5150b0c7dc7e79d281c2c
fbreuer/partition-analysis-data
/benchmark-support/methods/1/metric_reader.py
1,037
3.703125
4
# -*- coding: iso-8859-1 -*- def total_time(output): if output==[]: return "-" for line in output: if "total time taken" in line: return line.split()[-1] def sc(output): if output==[]: return "-" for line in output: if "symbolic cones computation took" in line: ...
75a559f10b32c64c8cb52c6c7670a72fe81c7ef0
shadoxsas/Lotto
/LOTTO.py
2,554
3.875
4
# import import random # checking input while True: errors = 0 try: wybor = list(map(int, input("Enter 6 numbers from 1 to 50: ").split())) except ValueError: print("Not all entered values are numbers.") else: if len(wybor) != 6: print("Exactly 6 numbers should be g...
c173d2ee361714f3123931693a364b950bc22d93
maxchv/PythonKids
/homeworks/homework02/hw02.py
622
3.984375
4
# Домшанее задание. Создать игру "Камень, ножницы, бумага" # 1. Компьютер загадывает случайное число от 1 до 3 # которое помещается в переменную computer # Выводится меню выбора для пользователя print('1 - Камень') print('2 - Ножницы') print('3 - Бумага') # 2. Считать число введенное игроком и сохранить в пере...
070c8673c05423a9d72fae77e5f8ccb4b55e23f8
maxchv/PythonKids
/lessons/lesson02/while.py
67
3.59375
4
i = 0 while i < 10: print("i =", i) i = i + 1 print('end')
4a424c3fac3195d04f07884a411f066bbf055ad3
maxchv/PythonKids
/Part2/python_10-04_Pokedex_resources/Club Leader Resources/pokedex-finished-with-images.py
2,804
3.78125
4
from random import * import tkinter from pokeapi import * smallFont = ["Ariel" , 10] mediumFont = ["Ariel" , 14] bigFont = ["Ariel" , 24] #function to display data for a pokemon number def showPokemonData(): #get the number typed into the entry box pokemonNumber = randint(1,178) #use the function above t...
b201d156f7612f3e9084a6e3848eb31fb17325d3
ihzarizkyk/LearnPython3byIhza
/app/LoginSederhana.py
506
3.734375
4
""" Author : Mochammad Ihza Rizky Karim """ user = ("admin") varpass = ("ihza") count = 1 while count <= 3: username = input("Masukkann Username anda : ") password = input("Masukkan Password anda : ") if (username == "admin" and password == "ihza"): print("Anda Berhasil Login") break ...
1f48c373c1c17182d8b0b116337b795cf2b1dad9
ihzarizkyk/LearnPython3byIhza
/oop/1.py
407
3.65625
4
''' Author : Mochammad Ihza Rizky Karim ''' class bio(): def __init__(self,names,age,height): self.names = names self.age = age self.height = height def isi(self): print("Nama : ",self.names,",Umur : ",self.age,",Tinggi : ",self.height) bio1 = bio("Ihza",19,166) bio2 = bio("Rizky",20,167) bio1.isi() bio2....
363b66a3eea62c2eb5ec6435146e2d4bc62ad6a3
ihzarizkyk/LearnPython3byIhza
/oop/8.py
783
3.765625
4
''' Author : Mochammad Ihza Rizky Karim ''' # Magic Methods class OrangTua(): def __init__(self,nama): self.nama = nama def __repr__(self): return "Nama Orang Tua saya : {}".format(self.nama) def __add__(self,lainnya): return self.nama + lainnya ortu1 = OrangTua("Budi") print(ortu1) print(ortu1 + " And...
ddc9163a7341bb1c7e06b8942d847881546522f1
LyalkaO/Lyalka_python2018
/Lyalka_python2018/hw_w3/multiple_of_3_5.py
94
3.8125
4
def solution(number): m = [x for x in range(number) if x%3==0 or x%5==0] return sum(m)
44720fe03f3fd08f4e3878fcaab2ee58be0d9600
vkobinski/tarefa5
/q1.py
1,864
4
4
class Atleta: def __init__(self): self.__altura = float(input("Insira sua altura: ")) self.__peso = int(input("Insira seu peso: ")) self.__idade = int(input("Insira sua idade: ")) self.__imc = self.calcular_imc() print(self.__imc) if(self.verificar_imc() == 1): ...
087bf0aa7da511aaa4ab68ed7f590d43f46ec504
zhucuicuia/TEST4
/zcca.py
760
3.84375
4
/bin/python # -*- coding: UTF-8 -*- class Student: 'ѧĻ' stu_count=0 stu_count_male = 0 stu_count_female= 0 def __init__(self,stu_no,name,stu_class,male,female,stu_count): self.name = name self.stu_no = stu_no self.stu_class=stu_class self.male=male self.female...
71df86debf16e2e8e5e69772cfda16be2d689b51
rajeshkumarsinha/Python-Workspace
/Tuples.py
491
4
4
## ##a=('rajesh','kumar','sinha','suyash') ## ## ##for words in a: ## for letters in words: ## print(letters,end='') ## print() ## ## ##y=3 ## ##def fun(x): ## global y ## y+=2 ## x+=1 ## ##fun(3) ##print(y) #you can't change the values in the tuple ##tup=() ## ##for i in range(1,10): ## tup=t...
41d040469c6ea5db22e98e2e6f8eae949a473f4c
rajeshkumarsinha/Python-Workspace
/Class.py
578
3.828125
4
class animal(object): def __init__(self,name,t): self.name=name self.type=t def getname(self): return self.name def gettype(self): return self.type #Operator OverLoading #OverRiding Methods def __add__(self,s): return self.name+s def __int__(self): ...
cbb5c36b4fac49d2ab12e2a0ce414c0a0f9bfa96
raghavgithub2020/pythonSeleniumTesting
/pythonBasics/Demo.py
205
3.859375
4
# Number data types print ("hello") a = 3 b = 4 c = a+b print("sum of a+b is", c) d, e, f = 5, 6.5, "testing" srt = "hi doing" print("{} {}".format("value of e is", e)) print(type(e)) print(type(f))
da0e60d7a825529d1792293cebd8dde7a66e5528
akljohny/madlabs-teachcode-solutions
/solution1919.py
105
3.84375
4
num = 0 for counter in range(1,6): if counter % 2 == 0: num += counter else: print(num)
6d7c847e7dc283cd740d49c8902144971dd20563
akljohny/madlabs-teachcode-solutions
/solution1212.py
269
4.09375
4
if 5 < 6: print("Hi, welcome to this Game") else: print("You're not in the Game") for i in range(1): if i != 3: print("Google speaks Python") else: continue i=0 while i < 2: if i <= 2: print("You have made it !") i = i+1
a36f2f037a8c5a4eff17efe306d4a3b9e5c0f95b
akljohny/madlabs-teachcode-solutions
/solution1313.py
360
3.703125
4
numOne = 0 numOne *= 1 #Modify this statement numTwo = 50 numTwo += 2 #Modify this statement numThree = 40 numThree -= 2 #Modify this statement numFour = 20 numFour *= 2 #Modify this statement numFive = 80 numFive /= 4 #Modify this statement numSix = 100 numSix %= 10 #Modify this statement print(numOne, numT...
9f23dfd26d145b18e5f19715a76e2d84cd5f3bed
akljohny/madlabs-teachcode-solutions
/solution3232.py
84
3.5
4
a = int(input()) b = int(input()) sum = lambda x,y: (x**2) + (y**2) print(sum(a,b))
cd42de33078f685a8334dc35d2e8dca7b454062b
Marlysson/URI-Judge-Online
/Iniciante/prog1064.py
278
3.90625
4
# -*- coding :utf8 -*- numeros = [] for i in range(6): numero = float(input()) numeros.append(numero) positivos = [numero for numero in numeros if numero > 0] print('{} valores positivos'.format(len(positivos))) print('{:.1f}'.format(float(sum(positivos)/len(positivos))))
ae35fe5b481d4f89aab20ce7f9d53f3a34b00ac9
Marlysson/URI-Judge-Online
/Iniciante/prog1072.py
208
3.640625
4
vezes = int(input()) dentro,fora = 0,0 for i in range(vezes): numero = int(input()) if 10 <= numero <= 20: dentro += 1 else: fora += 1 print('{} in'.format(dentro)) print('{} out'.format(fora))
53c3bd30521df0850a371d7d8f8a5d578fe53d69
karambaq/AI_first
/state.py
675
3.609375
4
class State: def __init__(self, value, operation=None, parent=None): self.value = value self.operation = operation self.parent = parent def __repr__(self): return f"{self.operation or ''}={self.value}" def reverse_op(self): if self.operation[0] == '/': ...
e032c2c010ceeb1b2076565d661ed179d6166688
mmesas3699/grexco
/grexco/scripts/verifica_excel.py
2,406
3.5
4
import pyexcel as pe def index_columnas(cantidad_columas): n = 0 while n < cantidad_columas: yield n n = n + 1 def verifica_formato_excel(archivo, formato): """ Verifica que el archivo contenga todos los datos m Recibe como parametros: archivo = str('ruta/de...
bccc52efbc0f1a5ecbed40dd894f708571ee4d18
kevin71104/Algorithm
/HW0/b03901026.py
2,489
4.09375
4
import sys def operation1(input_string): ''' input arg: input_list: string format data read from input file e.g. "1 2 3 4 5" output: output_list: a list of integers e.g. [1, 2, 3, 4, 5] ''' # Please finish this function here. ##################################### str1 = input_string.split(' ') output...
6b0e9b9051a6aea81c39cc6099200f4f4a616484
Amansinghal318/simple-multiple-linear-regression
/simple_regression_aman.py
1,157
3.625
4
# -*- coding: utf-8 -*- """ Created on Fri Dec 29 11:04:30 2017 @author: dell 1 """ import numpy as np import matplotlib.pyplot as plt import pandas as pd #import dataset dataset=pd.read_csv('Salary_Data.csv') X=dataset.iloc[:,:-1].values Y=dataset.iloc[:,1].values #splitting the training and test set from sklearn.cr...
35220b9de43ea89d442aaffac0d0e77eb2e3ff95
nwthomas/Sprint-Challenge--Data-Structures-Python
/names/binary_search.py
343
3.765625
4
def binary_search(list, target): if len(list) == 0: return -1 low = 0 high = len(list) - 1 while low <= high: guess = (low + high) // 2 if list[guess] == target: return 1 elif list[guess] > target: high = guess - 1 else: low = g...
cf8469e3b3e375bf361f3d3f5e1b74ed0a4741e7
LydmilaOvchinnikova/task_1
/calc.py
896
4.09375
4
#почему == а не is? #а можно без километрового elif? #считается ли обработкой некорректного результата ошибка, если первое значение - не число, а какой-то бред? #считается ли обработкой некорректного результата ошибка, если делим на 0? result = int(input ('vvedite pervoe chislo ')) if result is int: print("ок") m ...
3f9f28e504e80d7a04fb13f7750d12c873a063a0
xdyxiang/pythonlearn
/python_base/digui.py
574
4.15625
4
# 遍历一个盘符下的所有文件(包括子文件夹、文件) import os def getFile(path): try: filelist = os.listdir(path) # 得到该文件夹下的所有文件 for file in filelist: file = os.path.join(path, file) # 将文件名和路径结合起来 if os.path.isdir(file): getFile(file) # 在这里如果判断一个文件是文件夹,那么就会再次调用自己 ...
8cce0718f95b51f071cc7b66eac2fadcda7c36a4
zhaihongle/zhaihongleck1
/06-day/08输入和输出作业-1.py
511
3.859375
4
year = 365 day = 24 hour = 60 minute = 60 一年有 = year*day*hour*minute print("一年有%s"%一年有+"秒") print("*"*30) km = 1000 m = 100 cm = 10 一公里等于 = km*m*cm print("一公里等于%s"%一公里等于+"毫米") print("*"*30) print("编译型语言先翻译完在执行,解释型一遍翻译一遍执行") print("*"*30) print(2+6*(1.4+1)) print("*"*30) print((3+9)**6) print("*"*30) print(2*(4-5*5)...
3ed0ae3d533d8221b386e01b14247e6ad9d3f241
zhaihongle/zhaihongleck1
/07-day/7练习.py
266
3.703125
4
h =int(input('请输入身高')) s =int( input('请输入身价')) y =int( input('请输入颜值分')) if h >=180 and s >= 1000000 and y > 99: print('你是高富帅') elif s > 99: print('帅') elif h < 160 and s < 100 and y < 60: print('你是矮挫')
7b490c03bede5f58a4a049334884137107d988e3
zhaihongle/zhaihongleck1
/14-day/7瑞年函数版.py
191
3.796875
4
def s_year (year): if year%400 ==0 or (year%4==0 and year%100!=0 ): print('瑞年') else: print('平年') while True: year = int(input('年份')) s_year(year)
d463c87286bfe621fb95ab70f89c5e3e4cab740e
zhaihongle/zhaihongleck1
/00源哥代码.py/08day/2-BMI身高值.py
342
4.0625
4
height = float(input("请输入身高(m)")) weight = float(input("请输入体重(公斤)")) bmi = weight/height**2 if bmi < 18.5: print("瘦成狗") elif bmi >= 18.5 and bmi < 25: print("正常") elif bmi >= 25 and bmi < 28: print("过重") elif bmi >=28 and bmi <32: print("肥胖") elif bmi >= 32: print("严重肥胖")
fee783d7a658db2e9b480fc8d6ece8c238e48fc8
zhaihongle/zhaihongleck1
/kaodanci.py
1,231
3.515625
4
import random import time list=["薛栋炎","刘瑞涛","娄雪嫚","张轩轩","郑成峰","郝竟良","张晨波","王晓俊","刘明松","崔利艳","尹天","张圆","那思源","韩月瑞","王保轩","贾纪闯","翟宏乐","崔健","杨振亚","闫子雄","梁文琦","李冰","陈怡杰","韩迪","周肸","张世豪","李双双","李明瑞","王淋","于奇林","吴金航","王含青","王润泽"] print("班级总人数:%d人"%len(list)) print("正在合理计算中\n") time.sleep(3) i = random.randint(0,len(list)-1) ...
f627fd430e8f7c1ddeac4a28cbb7254930707a90
zhaihongle/zhaihongleck1
/00源哥代码.py/3-test/07day/7-逻辑运算.py
205
3.9375
4
money = float(input("请输入身价")) age = int(input("请输入年龄")) if money >= 3 and age >= 18: print("开心的吃鸡") elif money < 3: print("穷逼") else: print("回家写作业")
b579c1a9ae06f99c2ff3ef8ee982d4535bbcf4e8
zhaihongle/zhaihongleck1
/00源哥代码.py/09day/11-for循环求和.py
387
3.6875
4
while True: start = int(input("请输入一个数字:")) end = int(input("请输入一个数字:")) sum = 0 if start < end: for i in range(start,end+1): print(i) sum = sum+i print(sum) break else: print("输入有误") # 如果输入有误,请重新输入,直到输入正确为止 """ sum1 = 0 while start <= end: sum1= sum1+start start+=1 print(sum1) """
0ae9f901bd168f6d4b56d2efe9fd33d89f161b1d
zhaihongle/zhaihongleck1
/00源哥代码.py/08day/1-银行取钱.py
412
3.5625
4
account = "123456" #这是字符串的123456 pwd = "123456" money = 999999 i_acc = input("请输入账号") i_pwd = input("请输入密码") if i_acc == account and i_pwd == pwd: i_money = float(input("请输入取款金额")) if money >= i_money: print("取了%.02f元,剩余%.02f"%(i_money,money-i_money)) else: print("账户余额不足") else: print("账户登录错误") ...
c46bbcc96d9a0599c722d32884f4bfaebaab5c12
zhaihongle/zhaihongleck1
/00源哥代码.py/3-test/11day/1-列表作业.py
652
3.71875
4
persons = ["laowang","laosong","laozhang"] for i in persons: print("我邀请%s共进晚餐"%i) #来不了 print("%s不能来了"%persons[0]) list = [4,5,6,7] persons[0]= "laoliu" for i in persons: print("我邀请%s共进晚餐"%i) #找到更大的餐桌,我要加人 persons.insert(0,"laozhao") persons.insert(2,"laoli") persons.append("laosun") persons.append("ali...
13c2c7e9dce0af587661b6ed03bbb988c7c2da3a
GoldL/fish
/app/libs/helper.py
466
3.90625
4
# -*- coding: utf-8 -*- # @Time : 2020/4/2 上午11:41 # @Author : iGolden # @Software: PyCharm def is_isbn_or_key(word): # isbn13 13个0-9的数字组成 # isbn10 10个0-9数字组成,含有一些'-' isbn_or_key = 'key' if len(word) == 13 and word.isdigit(): isbn_or_key = 'isbn' short_q = word.replace('-', '') if ...
e9aeeb6bc9141be4d01134cb94c7241c3fd3097f
Tay-CA/Estudos-em-Python_Comparar-Valores
/Comparar valores.py
610
4
4
#Sistematização #Função é comparar os valores A e B while True: A = int(input('Digite o valor de A:')) B = int(input('Digite o valor de B:')) if A > B: #Se A for maior que B continue elif A==B: #Senão se A for igual a B print (A, 'e', B,'Valores de A e B iguais!') cont...