blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
717d5182de32647219d29dde6cb6f5298b8ac557
jemg2030/Retos-Python-CheckIO
/ELECTRONIC_STATION/AcceptablePasswordVI.py
3,022
4.15625
4
''' In this mission you need to create a password verification function. The verification conditions are: the length should be bigger than 6; should contain at least one digit, but it cannot consist of just digits; having numbers or containing just numbers does not apply to the password longer than 9; a string should...
9105a12873ac75bf31b13250203e7194a3a2aa84
521tong/PythonChallenge
/PyBank/main.py
1,050
3.890625
4
# First we'll import the os module # This will allow us to create file paths across operating systems import os # Module for reading CSV files import csv # Define path to csv file csvpath = os.path.join('..', 'budget_data.csv') month_count = 0 net_amount = 0 # Convert path into a file with open(csvpath, newline='')...
48f3869d891491aa6b613debd803a508ac811071
saumya470/python_assignments
/.vscode/Challenges/QuizCodeSnippets.py
405
3.8125
4
# class Student: # name='Rohan' # age=16 # s1=Student() # s2=Student() # print(s1.name,end='') # print(s2.name,end='') # class change: # def __init__(self,x,y,z): # self.a=x+y+z # x=change(1,2,3) # y=getattr(x,'a') # setattr(x,'a',y+1) class A: def __init__(self): self.x=1 s...
2274ba88f9d95d1c8f743662c0b4469118b4f996
lachezarbozhkov/adventofcode_2019
/4_passwords.py
1,899
3.59375
4
# https://adventofcode.com/2019/day/4 # six digit password # The value is within the range given in your puzzle input. (372037-905157) # Two adjacent digits are the same (like 22 in 122345). # Going from left to right, the digits never decrease; # second round: # the two adjacent matching digits are not part of a lar...
9d0442a588adb44726c5edc442733cec5f4c6365
dorkk0/Anigma-Project
/PlugBoard.py
1,518
3.5625
4
import sys from Translator import Translator class PlugBoard(Translator): def __init__(self, config): self.permutation = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ") self.setConfig(config) def setConfig(self, config): if len(config) > 10: print("Error, number of pairs in configur...
b73fc80a689005321b1e91c96044ee6006efb37f
nandadao/Python_note
/note/download_note/first_month/day05/exercise04.py
570
3.515625
4
""" 练习: 在列表中[5,6,17,78,34,5] 删除大于10的元素 温馨提示:调试/画图 """ list01 = [5, 6, 17, 78, 34, 5] # for item in list01: # if item > 10: # # 删除的是变量 # # del item # # 漏删(后面元素向前移动) # list01.remove(item) # for i in range(len(list01)): # if list01[i] > 10: # # 错误(删除元素则总数减少)...
76a1fe6b96995368f430ef3228372db68bae6601
PedroVitor1995/Uri
/Iniciantes/Questao1060.py
170
3.6875
4
def main(): qtd = 0 for i in range(6): numero = input('') if numero > 0: qtd += 1 print('%d valores positivos') % qtd if __name__ == '__main__': main()
2adf65a914a48aba52c2ee305f0bf2f19585d6da
charmip09/Python_Training
/TASK2_While_loop_break.py
623
4.03125
4
''' In the previous question, insert “break” after the “Good guess!” print statement. “break” will terminate the while loop so that users do not have to continue guessing after they found the number. If the user does not guess the number at all, print “Sorry but that was not very successful”. ''' counter = 0 while coun...
13a985e9a523a96db5430f72edf64a7bb8883a3e
82-petru/Functions
/List_Functions_19.py
2,342
3.953125
4
# -*- coding: utf-8 -*- """ Created on Wed Oct 30 21:00:58 2019 @author: petru """ n = [1, 3, 5, 16, 8, 9, 11] print(n) #print first element from the list print(n[1]) # multiply the second element of the n list by 5 n[1] = n[1] * 5 n.append(4) n.pop(2) #will remove index mentioned in brakets, just one item n.remove(...
fe24930651b1086ac4792c277f3556e4431241a8
Flame221/test1
/codewars.py
456
4.03125
4
def positive_sum(arr): sum_of_numbers = 0 for i in arr: if i >= 0: sum_of_numbers += i return sum_of_numbers def sum_array(arr): if arr is None or len(arr) < 3: return 0 else: return sum(arr) - max(arr) - min(arr) def validate_pin(pin): if pin.isdigit(): ...
a73687ba74f6d3f9ab1f14a316a2a8f1c8903412
olexxxa/CIS106-Oleksa-Ivankiv
/Session 4/1.5.py
533
3.65625
4
print("Please enter your last name") uN = input() print("Please input number of dependents") dQ = int(input()) print("Please enter your gross income") gI = int(input()) aGI = gI - dQ * 12000 if aGI > 50000: tR = 0.2 iT = aGI * tR else: if aGI >= 0: tR = 0.1 iT = aGI * tR el...
eebe316148171fbb0cbbc048887f8c815538c0a4
moakes010/ThinkPython
/Chapter10/Chapter10_Exercise12.py
478
4.1875
4
''' Exercise 12 Two words are a reverse pair if each is the reverse of the other. Write a program that finds all the reverse pairs in the word list. ''' word_list = ['the', 'brown', 'dog', 'ran', 'down', 'street'] word = 'god' def rev_pair(lword, word): rev_word = word[::-1] if rev_word in lword: r...
95954f086bd18701a0668159f470f8e2a2784d4f
souzaMateus99/Study
/Python/loops.py
115
3.546875
4
# the else clausule is triggered when the loop condition is false i = 0 while i < 10: i += 1 else: print(i)
d38a71e49031cd73380aa81b949b4ae91e924a90
Streich676/PUI2016_cjs676
/HW3_cjs676/assignment_2.py
2,820
3.5
4
# coding: utf-8 # In[1]: from __future__ import print_function, division import pylab as pl import pandas as pd import numpy as np import os as os import zipfile as zp import csv as csv import urllib as ulr get_ipython().magic('pylab inline') get_ipython().system("curl -O 'https://s3.amazonaws.com/tripdata/201...
2e1edcb9652714b663e036149dacc4b86c7cc482
steffemb/INF4331
/Assignement5/scraper.py
2,882
3.546875
4
import re import urllib.request def find_emails(text): """ function that scans a string "text" and returns a list of all "email like" expressions. """ regex = r"([a-zA-Z0-9.#$%&~’*+-/=?‘|{}]+?@[a-zA-Z0-9.#$%&~’*+-/=? ‘|{}_]+?\.[a-zA-Z][a-zA-Z.,_]*[a-zA-Z])" match = re.findall(regex,text) re...
5bcf1663526b25583769be6e788195195200c75d
thanedpon/software2
/timezone2.py
406
3.609375
4
import datetime class timezone(datetime.tzinfo): def __init__(self, name="+0000"): self.name = name seconds = int(name[:-2])*3600+int(name[-2:])*60 self.offset = datetime.timedelta(seconds=seconds) def utcoffset(self, dt): return self.offset def dst(self, dt): ...
ddd8965743d0b00404917ff82f214be6d857e5fc
Sivious/github
/pySolitarie.py
3,520
3.5625
4
#!/usr/bin/env python import os #define constants pOccupied = 'O' pFree = 'F' pProhibited = 'P' mGame = [ ['P', 'P', 'O', 'O', 'O', 'P', 'P'], ['P', 'P', 'O', 'O', 'O', 'P', 'P'], ['O', 'O', 'O', 'O', 'O', 'O', 'O'], ['O', 'O', 'O', 'F', 'O', 'O', 'O'], ['O', 'O', 'O', 'O', 'O', 'O', 'O'], ['P', 'P', ...
a0931c3f4115963a99a097cff2ef1e150adef18b
dos09/PythonTest
/reference_code/functions01.py
1,204
3.75
4
# Functions ########### def inc01 (x): return x + 1 print("inc01(4): " + str(inc01(4))) inc02 = lambda x : x + 1 print("inc02(20): " + str(inc02(20))) print('------------------------------------------') def pass_parameters(_list, _str="default value"): _list.append("new item") _str = "some val" mystr = "...
5303ac5fcf2c0887634ab632a780fddf476655ce
Andi-Pleian/Analiza-Metodelor-de-Sortare
/insertie.py
1,886
3.625
4
import random import time import datetime def gen(limit): l = [] for i in range(0, limit): nr = random.randint(-2147483648, 2147483648) l.append(nr) return l def insertionSort(l): for i in range (1, len(l)): aux = l[i] j = i - 1 while j >= 0 and aux < l[j]:...
6e3c36016351840a5ac8f76ae6cac5c4bb1e55b3
thepros847/python_programiing
/lessons/operators.py
654
4.0625
4
# create a variable x and assign a value 10 x = 10 # create a variable y and assign a value 25 y = 25 print(x+y) print(x-y) print(x/y) print(x*y) print(x**y) # floor division #create a variable and assign a value 12.68 a = 12.68 #create a variable and assign b value 3 b = 3 print(a//b) print(a%b) print(-x)...
0f68caef3e2297d6484ef91b3f585e7ffcdd4d42
Jinalshah12345/ScientificCalculator
/practice.py
1,703
3.515625
4
@staticmethod def calculate_median(l): l = sorted(l) l_len = len(l) if l_len < 1: return None if l_len % 2 == 0: return (l[(l_len - 1) // 2] + l[(l_len + 1) // 2]) // 2.0 else: return l[(l_len - 1) // 2] l = [1] print(calculate_median(l)) l = [3, 1, 2] print(calculate_median(l)) l = [1, 2, 3, ...
dd6baa7c0e5d4f7705891b5c5d1a1a3054157254
nishal18/hackrank_soln
/mini-max sum
452
3.765625
4
#!/bin/python3 import math import os import random import re import sys # Complete the miniMaxSum function below. def miniMaxSum(arr): sm=[] for j in range(len(arr)): s=0 for i in range(len(arr)): if i==j: continue s+=arr[i] sm.append(s) sm...
7262674fc5f0c82fff93dae251283ec0d4ddd617
jtmyers1983/Algorithm-Class-Exercises
/algos/maxsum_iterative.py
558
3.5
4
# Iterative maxsum profits = [-20,50,-30,40,10,5,-50,40] def maxsum_iterative(L): if L==[]: return 0 maxsum = L[0] # look at all possible intervals (beg, end) for b in range(0, len(L)): for e in range(b, len(L)): # compute the current sum in this interval from index b to index e current_sum = 0 for ...
938b911819771c545d0324e230bec4694b0ef0ad
grwkremilek/leetcode-solutions
/python/0700.search-in-a-BST/search_in_BST.py
665
3.890625
4
#https://leetcode.com/problems/search-in-a-binary-search-tree/ # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None def searchBST(root, val): if root is None or root.val == val: return roo...
a1ebe8fcef7e5d619528ecde93acc572f81879ae
sglavoie/code-snippets
/python/user_input/validate_choice.py
388
4.34375
4
def user_says_yes(message=""): """Check if user input is either 'y' or 'n'. Returns a boolean.""" while True: choice = input(message).lower() if choice == "y": choice = True break elif choice == "n": choice = False break else: ...
ef8203aab234297694ad76265bb486195dadfe7e
ramirovazq/algorithmexamples
/merge_sort.py
2,291
3.875
4
''' O(nlgn) MERGE SORT PSEUDOCODE mergesort (A) mergesort(A, 0, len(A)-1) mergesort(A, lo, hi) if (hi-lo <= 0) return mid = (lo + hi) / 2 mergesort(A, lo, mid) mergesort(A, mid+1, hi) C = merge(A[lo:mid], A[mid+1,hi]) copy elements from C back into A ''' from merge import merge, mergethre...
2978f511d35aca211d84f8ee70d6c439b351c7d5
prbarik/My_Py_Proj
/.vscode/method_function_lessions.py
2,029
4.09375
4
# Ex-1 # Write a function that returns the lesser of two given numbers if both numbers are even, but returns the greater if one or both numbers are odd # lesser_of_two_evens(2,4) --> 2 # lesser_of_two_evens(2,5) --> 5 def lesser_function(a,b): if a%2 == 0 and b%2 == 0: return min(a,b) else: ret...
db969dbbd7254968214e1f5c56c41265270013cf
boris-ulyanov/adventOfCode
/2017/day-04/2.py
476
3.84375
4
#!/usr/bin/python def check_phrase(words): sorted_words = [''.join(sorted(w)) for w in words] uniq_words = set(sorted_words) if len(words) == len(uniq_words): return 1 else: return 0 data_file = open('./data', 'r') lines = data_file.readlines() data_file.close() result = 0 for li...
c9d3bdeb76128575427dc1d23046336c7ba7e494
malikyilmaz/Class4-PythonModule-Week6
/Create a subclass of Shape.py
3,874
4.59375
5
""" Create a class named Triangle and Rectangle. Create a subclass named Square inherited from Rectangle. Create a subclass named Cube inherited from Square. Create a subclass named Pyramid multiple inherited both from Triangle and Square. Two dimensional classes (Triangle, Rectangle and Square) should have: * ...
2b77192672bd92df58e2e1272437ebbba9b8ad01
NishaKaramchandani/NaturalLanguageProcessing
/TextSummerization-LexicalChains/lexical_chains_for_summary.py
4,690
3.5625
4
import nltk from nltk.corpus import wordnet File = open("input_text.txt") # open file lines = File.read() # read all lines sentences = nltk.sent_tokenize(lines) # tokenize sentences nouns = [] # empty to array to hold all nouns list_lexical_chains = [] #Extract all the nouns from the input text. for sentence in ...
0ed2ae93334fcbfc9eef794d99c6ec4e56c543a1
luckspt/prog2
/fichas/2_complexidade/complexidade.py
7,173
3.71875
4
import math #1 - Ordene as seguintes funções por taxa de crescimento assintótico: 4 n log n, 2^{10}, 2^{log_{10}n}, 3n + 100log n, 4^n, n^2 + 10n """ 2^{10} O(1) 2^{log_{10}n} O(n^c) => 2^{log_10 n} = 2^{log_2 n / log_2 10} = n^{1 / log_2 10} = n^0,30.. 3n + 100 log n O(n) 4 n lo...
d9ef09458516042eb5a0d9286c1c056eeea54eb7
zanewebb/codebreakerspractice
/Fundamentals/reverse.py
452
4.3125
4
from LinkedList import LinkedList def reverse(linkedlist): cur = linkedlist.head.next prev = None while cur is not None: next = cur.next cur.next = prev prev = cur cur = next linkedlist.head.next = prev return linkedlist if __name__ == "__main__": linked...
e1c27ea48ee5db3379333bff15953908d9dc2e27
amazed01/Polynomial_Multiplication
/main.py
1,820
4.03125
4
from helper import * import math def multiply(x,y): x,y = make_equal_length(x,y) if len(x) == 0: return [0] if len(x) == 1: unit = (x[0] * y[0]) % 10 carry = (x[0] * y[0]) // 10 if carry != 0: return [carry,unit] else: return [unit] print('#####...
3c90d548a6c655f0b5f516d003e79dc565c3acca
DiegoHenriqueSouza/edutech-pr
/notas.py
407
3.890625
4
print("****** MÉDIA ******") primeira_media = int(input("Insira sua primeira nota do bimestre: ")) segunda_media = int(input("Insira sua segunda nota do bimestre: ")) terceira_media = int(input("Insira sua terceira nota do bimestre: ")) quarta_media = int(input("Insira sua quarta nota do bimestre: ")) print("...
90b188a80f691ab05cdc063ffeb54d5eaf3e2441
Pranshu46/Pro-106-Correlation
/Pro-106/student.py
237
3.546875
4
import plotly.express as px import csv with open ("Student Marks vs Days Present.csv") as csv_File: df = csv.DictReader(csv_File) fig = px.scatter(df,x="Roll No",y="Marks In Percentage",color="Days Present") fig.show()
1f5780d5ac883d29f275aa3f23ca8e347bb1075d
CoralieHelm/Python_Functions_Files_Dictionaries_University_of_Michigan
/11_8_Accumulating_the_Best_Key.py
1,430
4.125
4
#June 1 2020 #11.8. Accumulating the Best Key #Check your Understanding #1. Create a dictionary called d that keeps track of all the characters in the string placement and notes how many times each character was seen. Then, find the key with the lowest value in this dictionary and assign that key to min_value. placeme...
9587a54e90fd68da9753c6465e5f9ecd0ed2425d
deepanshusadh/My-ML-projects
/bag of words.py
681
3.515625
4
#!/usr/bin/env python # coding: utf-8 # In[1]: from sklearn.feature_extraction.text import CountVectorizer # In[2]: cv=CountVectorizer() # In[29]: corpus=[ 'She is beautiful', 'World is so cruel', 'I am vegetarian', 'Hell I am in love' ] # In[30]: vectorized_form=cv.fit_transform(corpus)....
e0939ba80da9c7d508c9a5f0a04675f87606d3e8
tideburning/python_test1
/test1bai4/test1bai4.py
763
4
4
import threading # tạo một class con class SummingThread(threading.Thread): #init thực hiện trước, selt là con trỏ this trong java def __init__(self,low,high): #super gọi đến hàm parent của nó super(SummingThread, self).__init__() self.low=low self.high=high self.total=0 def run(self): for i in range(se...
6a7bf1a0eb601cf54e8c8db433ad6bffe8af9a6a
KANUBALAD/macgyver
/MacMaze2D.py
6,130
3.78125
4
import pygame import position as Position import perso as Perso from random import randint from labyManager import LabyManager from constantes import* """laby mean maze, as we have to know""" """declared outside of main () because used in methods""" continuePlaying = True gameEnded = False win = False pygame.init() sc...
01b4aab7e5e8d5b43cd012f4188bdae30a4aad1a
wyaadarsh/LeetCode-Solutions
/Python3/0129-Sum-Root-to-Leaf-Numbers/soln-1.py
713
3.640625
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def sumNumbers(self, root: TreeNode) -> int: self.ans = 0 def dfs(node, val): if node is not None: ...
4a61d1d3a4c05cdf802d25fc5a13bbcd9eeabe6f
superstones/LearnPython
/Part1/week2/chapter10/exercise/common_words_10.10.py
680
4.1875
4
# 10.10常见单词 def count_words(file_name): try: with open(file_name, 'r', encoding='UTF-8') as f: f_read = f.read() contents = f_read.lower().split() except FileNotFoundError: pass # msg = "Sorry, the file " + file_name + " does not exist." # print(msg) ...
5baa23e3a1ce1fde6699de06aa1de7c7972d0710
atheenaantonyt9689/python_programs_part2
/fizz_buzz.py
320
3.984375
4
def fizz_buzz(number): i=1 for i in range(1,number+1): if i%3 ==0 and i%5 ==0: print("FIZZBUZZ") elif i % 3==0: print("FIZZ") elif i %5 ==0: print("BUZZ") else: print(i) number=int(input("enter the limit: ")) fizz_buzz(number)
1c62705b14090b24846a7ae9372b60e4ea611a9c
FrustratedGameDev/project2
/features/9-issue-per-milestone/IssueHandler.py
1,239
3.59375
4
# count num lines with 'action: ' and make a bucket for each 'user: {user-name}' users = {} def countUsers(): with open('../ourRepo.txt') as file: for line in file: if "action :" in line: parts = line.split(',') for part in parts: if "user :"...
7822b2ae1e059df0cc10424b8421db79cfee056d
AntonioMagana/CMPE_131
/LeapYear.py
210
4.21875
4
year = float(input("What year would you like to check")) if year%4 == 0: print("Is leap year") if year%100 == 0 and year%400 == 0: print("Is leap year") else: print("Is not leap year")
72bfa708c91b17dd10b1afa07ddcc50f31c6fdf7
shokokb/personal-study
/env/opt/leetcode/0100/0118_Pascal's_Triangle.py
554
3.5
4
class Solution: def generate(self, numRows: int) -> List[List[int]]: triangle = [] for row_num in range(numRows): row = [None for _ in range(row_num + 1)] row[0] = row[-1] = 1 triangle.append(row) for row in range(numRows): l, r = 1, r...
ea386a3776766ae2548d48297fbdb022cd1f7880
Patelbhavika199926/Patel_CISC610
/Q5.py
338
3.890625
4
import random list = [] upperLimit = 100 for i in range(1, upperLimit): list.insert (i, random.randrange(9999)) print ("Total items inserted into the list:" , len(list)) leastVal = list[0] for i in range(1, upperLimit - 1): if list[i] < leastVal: leastVal = list[i] print("Least value in the ...
0ff5d8864c736903894b8b31880d003258c7178b
karstendick/advent-of-code
/2020/day2/day2.py
426
3.640625
4
valid_passwords = 0 with open('input.txt', 'r') as f: for line in f: min_max, letter_colon, password = line.split() pmin, pmax = [int(c) for c in min_max.split('-')] letter = letter_colon[0:1] num_letters = password.count(letter) if pmin <= num_letters and num_letters <= pmax: ...
647f5d830aff93e5a12790036374d183ab5105a2
emcog/cc_wk5__project_week
/tests/test_address.py
397
3.65625
4
import unittest from models.address import Address class TestAddressClass(unittest.TestCase): def setUp(self): self.address_1 = Address('Knowledge Cottage', 'The Orchard', 'Crail', 'HE3 H11') self.address_2 = Address('Minotaur View', 'The Labyrinth', 'Crete-on-Fife', 'FL1 H07') def test_addres...
c5a1e84f48bcde06f83f9d8112431b310f73e416
satyanshpandey/python-basic
/Factorial.py
245
4.21875
4
def factorial(n): if n==1: return n else: return n*factorial(n-1) num=int(input('enter number:')) print('the factorial is:',factorial(num)) # output:=> # enter number:5 # the factorial is: 120
2f2ef4870d764fd90ffcc5c8cdac7604feeee98e
chaifae/add-videos-to-your-page
/Python_practice/mindstorms.py
929
4.03125
4
import turtle def draw_square(a_turtle): for turn in range(1, 5): a_turtle.forward(100) a_turtle.right(90) def draw_triangle(a_turtle): for turn in range(1, 4): a_turtle.forward(100) a_turtle.right(120) def draw_stuff(): window = turtle.Screen() window....
890f7ff52f9955dda74d40f771d227ddd9280c87
raffmiceli/Project_Euler
/Problem 35.py
1,224
3.515625
4
from math import * from pyprimes import * def isPrime(n): x = 2 if n < 2: return False else: while x <= sqrt(n): if n%x == 0: return False x += 1 return True s = [2] ps = list(primes_below(1000000)) for p in ps: if any([not int(l)%2 for l in str(p...
d6cf4dbb6f731ca020608021cddb9245ef34b563
wojtekidd/Python101
/squares_function.py
160
3.796875
4
def squares(): """""" x = 1 result = "" while x<11: result = result + str(x**2) + " " x += 1 return result print(squares())
df0dac4d17e48dc05e4888c3c92c00fb9f69d8de
felipesantanadev/python
/Lesson 01/01_arithmetic_operators.py
598
4.25
4
# Arithmetic Operators # + (addition) # - (subtraction) # / (division) # * (multiplication) # % (mod -> rest of division) # ** (exponentiation) # // (divides two numbers and rounds down the result to the nearest integer) print(2 + 2) print(7 - 2) print(10 / 2) print(2 * 3) print(17 % 4) pri...
914c9a4d8bf78d45333bc757c6029e323c8b84eb
flaxdev/N-g.datamining
/src/iterators.py
2,195
3.671875
4
from src.geometry import Position class PropertyIterator(): """ Class PropertyIterator Linearly iterates over properties from start to end in n steps """ def __init__(self, iterators): self.iterators = iterators self.steps = sum(map(lambda x: x.steps, iterators)) self._currentIterator = self.i...
a46f929c9bc0c3d15d212d0bec88f08a6331ad29
sadatrafsanjani/MIT-6.0001
/Lec02/for.py
123
3.828125
4
sum = 0 for i in range(5, 11): sum += i print(sum) print("\n") for i in range(1, 10, 3): print(i)
6679d9192b6d528baa62f5f1c307cb199502ab06
sukhvir786/Python-Day-6-Lists
/list19.py
278
4.3125
4
""" 10. Reverse """ L = ['red', 'green', 'blue'] L.reverse() print(L) # Prints ['blue', 'green', 'red'] L = [1, 2, 3, 4, 5] L.reverse() print(L) # Prints [5, 4, 3, 2, 1] L = ['red', 'green', 'blue'] for x in reversed(L): print(x) # blue # green # red
9337aace809834ea80933ce2a056939d81f7d098
liumg123/AlgorithmByPython
/43_左旋转字符串.py
597
3.875
4
# -*- coding:utf-8 -*- """ 汇编语言中有一种移位指令叫做循环左移(ROL),现在有个简单的任务,就是用字符串模拟这个指令的运算结果。对于一个给定的字符序列S,请你把其循环左移K位后的序列输出。例如,字符序列S=”abcXYZdef”,要求输出循环左移3位后的结果,即“XYZdefabc”。是不是很简单?OK,搞定它! """ class Solution: def LeftRotateString(self, s, n): # write code here res='' if n>len(s) or n<0: return s...
e9849c529857c2c3c001c1eca2fd56a083d032f0
cloxnu/AlgorithmLandingPlan
/CodingInterviews/33. 二叉搜索树的后序遍历序列.py
942
3.8125
4
# 遇到后序遍历,先想到把后序反过来,就变成了 根-右-左 # [1, 3, 2, 6, 5] # [1, 6, 3, 2, 5] # 递归解法 def verifyPostorder(postorder: list) -> bool: def recur(left, right): if left >= right - 1: return True for i in range(left, right): if postorder[i] > postorder[right]: for j in range(i, right): ...
a9e847b2dcaa769c2a764d6c107e5f1913e9322e
chemplife/Python
/python_core/json_serialization.py
6,827
3.59375
4
''' JSON: JavaScript Object Notation. Default: Serialization/Deserialization will not execute code so, it is consider safe compared to pickling/unpickling Datatype supported: "string" -> Double Quotes Delimiter And Unicode characters only. Numbers -> 100, 3.14, 3.14e-05, 3.14E+5 -> all are considered floats. No...
0e8b3bf73698f6edd1c5a6b9b8994dc820bdcf80
lic34/leetCoding
/leetcode/longest_substring.py
857
3.625
4
'''https://leetcode.com/problems/longest-substring-without-repeating-characters/submissions/''' class Solution: def lengthOfLongestSubstring(self, s: str, retrun=None) -> int: length_of_sub_str = 0 if s is None: return length_of_sub_str sub_str = str() current_...
9dddb5bc9f8f7a52e7a1db0432b515bb7464e965
Almenon/couchers
/app/backend/src/couchers/utils.py
1,152
3.515625
4
from datetime import datetime, timedelta, timezone import pytz from google.protobuf.timestamp_pb2 import Timestamp utc = pytz.UTC def Timestamp_from_datetime(dt: datetime): pb_ts = Timestamp() pb_ts.FromDatetime(dt) return pb_ts def to_aware_datetime(ts: Timestamp): """ Turns a protobuf Timest...
27fda4cf93689c8a5e416b95c3cd32d92bd3e95b
soo-youngJun/pyworks
/run_turtle/figure2.py
341
3.96875
4
# 도형 그리기 (반복문) import turtle as t t.shape('turtle') # 사각형 그리기 n = 8 for i in range(n): t.forward(100) t.right(360 / n) # 삼각형 그리기 t.color('red') t.pensize(2) for i in range(0, 3): t.forward(100) t.left(120) # 원 그리기 t.color('blue') t.pensize(3) t.circle(50) t.mainloop()
4c4d433057c998587c6321895a70a8d8b8b2ade8
malluri/python
/30.py
503
3.71875
4
""" 30. Take actuual string, soucrce string, destination string. replce first nth occurances of soucestring with destination string of actual string """ str=raw_input("string") source=raw_input("sourcestring") dest=raw_input("destination") n=input("occurence") count=0 s=" " l=len(str)-len(source)+1 for i in range(0,l)...
98f55453c6665bb001fe9c654f3f3e93659b67cc
MandoMirsh/LCalc-Loan_Calculator
/Topics/Elif statement/Calculator/main.py
612
4.0625
4
DIVISION = "/ div mod" first_num = float(input()) second_num = float(input()) operation = input() if operation in DIVISION: if second_num == 0: print("Division by 0!") elif operation == '/': print(first_num / second_num) elif operation == 'mod': print(first_num % second_num) else...
929426d0d621477072c9424248e93a65a979eb4a
davcodee/conjuntos
/Conjuntos.py
2,325
4
4
option = int(input('Seleccciona una opción: ')) conjunto1 = [1,2,4,5,6] conjunto2 = [1,2,4,5,6] def menu(): if (option == 1 ): print('Elementos del cojunto 1') for i in range(len(conjunto1)): print(i) print('Elementos del cojunto 2') for i in range(len(conjunto2)): print(i) ...
506cf0ea8f1d6b34b8fa79db5c93f18705530344
gorsheninii/zed_a._shaw
/Exercise5.py
551
3.921875
4
my_name = "Gorshenin Ivan" my_age = 34 my_height = 173 my_weight = 72.9 my_eyes = "grayish blue" my_teeth = "yellowish" my_hair = "fair" print(f"Let's speak about a human named {my_name}.") print(f"His height is {my_height} sm.") print(f"His weight is {my_weight} kg.") print("Actually this isn't much") print(f"He has ...
866d4a5bf7d1c955ee9fd18467de33ef28435622
clstrni/pythonBrasil
/EstruturaDeDecisao/26.py
231
3.78125
4
liters = float(raw_input('How many liters?\n')) fuel = raw_input('Type of fuel: (A-ethanol, G-gasoline)\n').upper() if (fuel == 'A'): tot = liters * 1.9 elif (fuel == 'G'): tot = liters * 2.5 print "Amount to pay R$%f" % (tot)
4bdf6b0c0861d26fab60b80b32fe60d3c97e1f5e
ShiaoZhuang/Homework-2
/main.py
1,129
4.25
4
# Author: Shiao Zhuang sqz5328@psu.edu def getGradePoint(Grade): if Grade == 'A': Grade = 4.0 elif Grade == 'A-': Grade = 3.67 elif Grade == 'B+': Grade = 3.33 elif Grade == 'B': Grade = 3.0 elif Grade == 'B-': Grade = 2.67 elif Grade == 'C+': Grade = 2.33 elif Grade == 'C':...
a40a436ba2856c2e884069f040daed538844b025
ZabretRok/HW7_Guess_the_secret_number
/secret_game.py
1,435
3.84375
4
import datetime import json import random player = input("Hi, what is your name? ") secret = random.randint(1, 30) attempts = 0 with open("score_list.txt", "r") as score_file: score_list = json.loads(score_file.read()) print("Top scores: " + str(score_list)) top_3 = sorted(score_list, key=lambda x: x['att...
3878d3ce3d9008fed5abcfb77baf709de119e958
clonetwin26/TwitterPoemBot
/src/wordChecker.py
883
3.75
4
#class to hold all functionality between words import urllib2 class WordChecker: #returns true if the two words match, false otherwise #this is accomplished by making a request to http://stevehanov.ca/cgi-bin/poet.cgi?WORD rhymeRequest = "http://stevehanov.ca/cgi-bin/poet.cgi?" def isRhyme(self, word1...
6e2111e9e2bcc729139fab25360d626328b113c1
bshruti7/algorithms
/selectionSort.py
838
4
4
# set the first element as minimum element # find real minimum element # swap with minimum element # proceed with setting second element as new minimum def selection_sort(arr): min_elem_index = 0 while min_elem_index < len(arr)-1: found_min_elem_index = None min_elem = arr[min_elem_index] ...
5ee4734d8d006dd91a13db4332513b7f9f869b73
JoeyDing/PythonWebsite
/TriviaMVA/LoopsModule/LoopsModule.py
2,202
4.375
4
import turtle """ turtle.color('green') turtle.forward(100) turtle.right(90) turtle.forward(100) turtle.right(90) turtle.forward(100) turtle.right(90) turtle.forward(100) turtle.right(90) """ """ turtle.color('green') for step in range(4): turtle.forward(100) #turtle.right(90) #not indented, not a part...
f01c4ed90f57f0ce0eb89f8b99f7789e58c53246
pvperez1/file-management-with-python
/create_file_listings.py
994
3.71875
4
#import necessary libraries from datetime import datetime import os import pathlib #this function will be used later to make .st_mtime #a more readable date format for humans def convert_date(timestamp): d = datetime.utcfromtimestamp(timestamp) formatted_date = d.strftime('%d-%b-%Y') return formatted_date ...
57b2ac2d6ec0bc8f8722a7e3ffe7db9c9101a175
here0009/LeetCode
/Python/SelfDividingNumbers.py
1,347
4.21875
4
""" A self-dividing number is a number that is divisible by every digit it contains. For example, 128 is a self-dividing number because 128 % 1 == 0, 128 % 2 == 0, and 128 % 8 == 0. Also, a self-dividing number is not allowed to contain the digit zero. Given a lower and upper number bound, output a list of every pos...
d160922e4bf0f212b76c094edab2d317697b6616
djphan/Prog-Problems
/Advent-Code/2017/spiralnum.py
3,096
3.609375
4
from itertools import cycle test1 = 1 test2 = 12 test3 = 23 test4 = 1024 inputNum = 277678 # Helper Functions to Make a Grid for Number Spiral def moveRight(x, y): return x+1, y def moveDown(x, y): return x, y-1 def moveLeft(x, y): return x-1, y def moveUp(x, y): return x, y+1 moves = [moveRight, ...
ac8cab96033864051705d021370a3ada16f3efc2
Ratatou2/Algorithm_Interview
/10-2. 배열 파티션1.py
1,331
3.5625
4
# 해당 코드는 박상길 저자의 '파이썬 알고리즘 인터뷰'를 공부하며 적은 내용입니다 # 근데 이렇게 풀다보니 사실 리스트의 짝수번째에 있는 놈들만 더해도 될 것 같다(0부터 시작이니까) # 왜냐면 정렬된 상태에선 항상 짝수번째에 작은 값이 위치하기 때문 def arrayPartition(target_list:list): sum = 0 target_list.sort() for i in range(0, len(target_list)): if i % 2 == 0: sum += target_list[i] r...
149b07f8eaea999a5ac4b9451dca3d1e5a2ae994
lxngoddess5321/python3crawler
/数据存储/JSON存储/CSV存储.py
1,168
3.796875
4
import csv # 引入csv库 with open('data.csv', 'w') as csvfile: # 列表的写入方式 # 初始化写入对象,传入该键柄 # 利用delimiter 可以修改列与列之间的分隔符 writer = csv.writer(csvfile, delimiter='*') writer.writerow(['id', 'name', 'age']) writer.writerow(['10001', 'mike', '18']) writer.writerows(['10001', 'mike', '18']) # wri...
db81e65e39c816cb933d0ded6909835ce0e42b3f
jumbokh/pyclass
/code/jPB371/ch11ok/define_class.py
456
3.859375
4
class Person: #定義方法一:取得姓名和年齡 def setData(self, name, age): self.name = name self.age = age #定義方法二:輸出姓名和年齡 def showData(self): print('姓名:{0:6s}, 年齡:{1:4s}'.format( self.name, self.age)) # 產生物件 boy1=Person()#物件1 boy1.setData('John', '16') boy1.showData() #呼叫方法 boy2=Pers...
324a6169cbce0ffc55d33affba7efa8d73a5871a
DanielBaquero28/holbertonschool-higher_level_programming
/0x0A-python-inheritance/1-my_list.py
229
3.703125
4
#!/usr/bin/python3 class MyList(list): """ Inherits from list. """ def print_sorted(self): """ Prints a list in ascendent order. """ new_list = self.copy() new_list.sort() print(new_list)
0c3810df3877baa04473125eaede0efa91de9d1d
mjtat/Boston_311
/Boston_311/data_pull.py
3,945
3.71875
4
from urllib import request import urllib import json from json import * import pandas as pd class Data_Pull(object): """ This object retrieve Boston 311 data. It is initialized with the following information: url: A CKAN url from data.boston.gov num_records: The number of records to retrieve ...
ed71b218d347cae4816fef856f0ef55764ddf059
antoniorcn/fatec-2019-2s
/djd-prog2/manha-aula4/ordenacao3.py
401
4.15625
4
print("Ordenação de 3 números") n1 = int(input("Digite o 1º numero")) n2 = int(input("Digite o 2º numero")) n3 = int(input("Digite o 3º numero")) if n1 <= n2 <= n3: print(n1, n2, n3) elif n1 <= n3 <= n2: print(n1, n3, n2) elif n2 <= n1 <= n3: print(n2, n1, n3) elif n2 <= n3 <= n1: print(n2, n3, n1) eli...
a538ce131072f3d84017aacef3ebedecfc425f11
TetianaHrunyk/DailyCodingProblems
/challenge97.py
2,630
4.125
4
"""Write a map implementation with a get function that lets you retrieve the value of a key at a particular time. It should contain the following methods: set(key, value, time): sets key to value for t = time. get(key, time): gets the key at t = time. The map should work like this. If we set a key at a particu...
955240d9352665946e2c728014c5613c3579f5d6
th9195/PythonDemo01
/Demo08_String.py
6,397
3.765625
4
str1 = "0123456789" print(str1[2:5:1]) print(str1[2:5:2]) print(str1[2:5]) print(str1[:6]) print(str1[2:]) print(str1[::-1]) print(str1[2::-1]) print(str1[:6:-1]) print(str1[-4:-1:-1]) print(str1[-1:-4:-1]) ''' 字符串的方法 str.find(str, beg=0, end=len(string)) 方法检测字符串中是否包含子字符串 str , 如果指定 beg(开...
db97ae5c53330f0d062b63aa88b0742087e95012
LDPGG/dm
/ZXYJ_GG-master/PyCharm/Wdpc/Wddyzpc.py
1,317
3.546875
4
# Python小白的挣扎 # 大神轻锤 # 小白的第一个爬虫 # 这里导入要先导入BeautifulSoup和requests from bs4 import BeautifulSoup import requests # 这里是你要爬取的网页路径,我这里爬的是糗事百科 url = 'https://www.qiushibaike.com/pic/' # 用requests.get方法获得网页,并把它存储 we_data = requests.get(url) # 用BeautifulSoup 解析网页,用.text方法使得网页可读 soup = BeautifulSoup(we_data.text, 'html.pars...
17c68324bc12d5fc8c823e79bbf533072c5acae3
squashmeister99/PythonProjects
/GuessNumber/GuessNumber/GuessNumber.py
650
4.125
4
import random numberOfAttempts = 0 def main(): print("Hello, what is your name") name = input() number = random.randint(1,20) print('Well, ' + name + ', I am thinking of a number from 1 to 20') for numberOfAttempts in range(6): print("Take a guess") guess = int(input()) i...
992d9d031a59e6c02ec4c781f31eee6a89098097
AvinashBonthu/Python-lab-work
/lab8/lab8.h.py
218
3.71875
4
def count (i,a,c): if i<len(a): if a[i]=='a': c=c+1 i=i+1 count(i,a,c) else: print 'count of a is',c a=raw_input('enter the string') i=0 c=0 count(i,a,c)
0de76d58f7dc4901846617adb97c613aa6300b39
gagigante/Python-exercises
/List 05/12.py
666
4.5
4
# Questão 12. Construa uma função que receba uma string como parâmetro # e devolva outra string com os carateres emba- ralhados. Por exemplo: # se função receber a palavra python, pode retornar npthyo, ophtyn ou # qualquer outra combinação possível, de forma aleatória. Padronize em # sua função que todos os caract...
cf544ebd459055d16d1f6cfb870cb9e50c63faca
Zismo/blessrng
/FirstLess.py
1,727
3.84375
4
#k=x=1 #x=1 #lol = 'программа' #print(f'{x} {k} {lol}', end=';\n') #print('{0}\n{1}'.format(x, k)) #k=-2 #if k>0: # print('Hello world!') #elif k<0: # print('k<0') #else: # print('k=0') #arr = [1,2,3] #for item in arr: # print(item, end=' ') # print() # for item2 in range(len(arr)): # pr...
66453ac89c4a52dfd92b610d5bb988967a749efe
tony-ml/jiuzhangAlgo
/Joe Zheng/week 4/433. Number of Islands.py
2,167
3.8125
4
class Solution: """ @param grid: a boolean 2D matrix @return: an integer """ def numIslands(self, grid): # write your code here # exception # number of rows r = len(grid) if r == 0: return 0 # number of coloumns c = len(grid[0]) ...
c860cb2b48fb157739227c8badd445ed1a7c34d6
MarioPezzan/ExerciciosGuanabaraECurseraPyCharm
/Exercícios curso em video/Exercicios/ex056.py
1,126
3.625
4
media = 0 velho = 0 nom1 = '' mulhermaisvelha = 0 sexom = 0 for c in range(1, 5): print(5*'-', f'{c}° PESSOA', '-'*5) nome = str(input('Nome: ')) idade = int(input('Idade: ')) sexo = str(input('Sexo [M/F]: ')) media += idade if c == 1 and sexo in 'Mm': velho = idade nom1 = nome ...
4324be37533579c20502e30bafe8336c1c24ce5e
yaronlevi1/CDcode
/Python/python_fundamentals/ScoresandGrades.py
417
3.875
4
import random def myfunc(): print ("Scores and Grades") for i in range(10): a = random.randint(60, 100) if a>=60 and a<70: b = "D" elif a>=70 and a<80: b = "C" elif a>=80 and a<90: b = "B" elif a>=90 and a<=100: b = "A" ...
1970947818e8114843d68e881d66197fea737de6
ifosch/advent-of-code
/scratchpad/inputparsing.py
745
4.09375
4
#!/usr/bin/env python filename = 'input.txt' # Open Multiline File and iterate line by line filename = 'input.txt' with open(filename, 'r') as fp: lines = (l.strip() for l in fp) for line in lines: i = int(line) print(line, i) # Open Single Line File and iterate char by char filename = 'inp...
f2d2ce4cdd27d285bff8cb253b1aad7d48fc0f46
sonyarpita/ptrain
/Modules/user_module1_me.py
311
4.09375
4
import swap try: a=int(input("Enter first number: ")) b=int(input("Enter second number: ")) a,b=swap.swape(a,b) print("values after swap= ",a,",",b) except ValueError: print("ValueError:Exception Handler") print("Invalid input: Only integers are allowed") finally: print("Swapped")
d6c5a4ba014cd1388dd4c2334ff2438090019e22
LuuckyG/CS50x
/pset6/cash.py
657
4.0625
4
# Get change input while True: change = input("Change owed: ") try: change = float(change) except: continue # Check if height is in correct range if change > 0.00: # To overcome floating point precision limitations change *= 100 break # Available coins coin...
c33e7b6bb5c7198a3f5fb690f62818274ea78dae
EugenMorarescu/IS211_Assignment9
/nfl_games.py
1,040
3.5
4
from bs4 import BeautifulSoup import urllib.request url = "http://www.footballlocks.com/nfl_point_spreads.shtml" page = urllib.request.urlopen(url) soup = BeautifulSoup(page.read(),features='lxml') #print(soup.prettify()) games = [] table = soup.find("table",{'cols': '4'}) rows = table.findChildren(['tr']...
4a6e262eb3986cc6903fdb75376f633444ecc209
fossnik/python-exercises
/pangram/pangram.py
213
3.703125
4
def is_pangram(sentence): seen = set() for x in sentence.lower(): if x.isalpha(): seen.add(x) alphabet = "abcdefghijklmnopqrstuvwxyz" for c in alphabet: if not c in seen: return False return True
121ac64ba845af4c314b816cae74c7e8da3f7646
loafer18/numBomb
/identifyInteger.py
345
4.25
4
number1 = input("Please input a integer number:") while True: if number1.isdecimal(): print("The number is good to go.") break else: print("Your input was not integer number, please enter int number.") number1 = input("Please input a good int number:") print("Now the ...
8210c2b7fd6e1c300ce46f5daffa6c8f28636dd1
Bhawana3/Data-Structures
/stack/specialStack.py
2,361
4.09375
4
""" Make a special stack class which has same push,pop methods plus one additional method to show minimum value of stack in Time complexity of O(1)""" class Node: def __init__(self): self.value = 0 self.next = None class Stack: def __init__(self): self.top = None def push(self,value): temp = Node()...
36ec82b51c591245d456632e79dfe1afa64804e3
Chrisaor/StudyPython
/GeeksforGeeks/Practice/2. Basic/55.MaximumChar.py
388
3.984375
4
def maximum_char(char1): count_list = list() temp = list() for i in char1: count_list.append(char1.count(i)) max_count = max(count_list) for i in char1: if char1.count(i) == max_count: temp.append(i) return sorted(temp)[0] t = int(input()) for i in range(t): cha...
326c589233b587927aad6cfea19b4eb44fe2aebe
msdnqqy/ML
/西瓜书/K紧邻算法.py
588
3.703125
4
#使用sklearn实现K近邻算法 import numpy as np; from sklearn import datasets; from sklearn.cross_validation import train_test_split from sklearn.neighbors import KNeighborsClassifier #导入花数据集 iris=datasets.load_iris() iris_x=iris.data iris_y=iris.target print(iris_x[:2,:]) #切分验证集和训练集并打乱顺序 x_train,x_test,y_train,y_test=train_te...