blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
47115e590894e88e12ec51d274170e521bcc21a9
CrisPirat/devsu-jam-2021-preclasificatory
/Question02.py
1,906
3.625
4
def sumOfElement(numbers, number): sum = 0 for n in numbers: if n != number: sum += n return sum def searchMaximum(numbers): max = numbers[0] for n in numbers: if max < n: max = n return max def searchMinimum(numbers): min = numbers[0] for n in n...
e6a0c9d85682741a71ef06d321855c8fa9aff4f3
zenubis/LeetCodeAnswers
/04-Daily/20210211/20210211.py
1,280
4.21875
4
# Valid Anagram # https://leetcode.com/explore/challenge/card/february-leetcoding-challenge-2021/585/week-2-february-8th-february-14th/3636/ # Given two strings s and t , write a function to determine if t is an anagram of s. # Example 1: # Input: s = "anagram", t = "nagaram" # Output: true # Example 2: # Input: s =...
0b4d18c2aca539bbc7aa918cf2220b8f6b872610
ngzhaoming/Kattis
/Difficulty 4.1/Rock Paper Scissors/RockPaperScissors.py
1,327
3.609375
4
counter = 0 def isDraw(onePlay, twoPlay): if onePlay == twoPlay: return True return False def isWin(onePlay, twoPlay): if onePlay == "rock" and twoPlay == "scissors": return True elif onePlay == "scissors" and twoPlay == "paper": return True elif onePlay == "paper" and twoP...
1ce729c324238a194cb2a30495e7cd64fe693c6f
MokkeMeguru/dsa
/aoj/merge_sort.py
1,026
3.84375
4
import sys import math import copy from typing import Tuple, List, Union input = sys.stdin.readline def merge(left, right): result = [] compare = 0 while len(left) > 0 and len(right) > 0: compare += 1 if left[0] <= right[0]: result.append(left[0]) left = left[1:] ...
9d652a046432b5d06e06d77dafcf360145d8ecba
NaveenSingh4u/python-learning
/basic/python-oops/calculator.py
574
3.859375
4
class Calculator: # Note: 1. staticmethod is used for creating utility # 2. Do not pass self param in static method @staticmethod def add(x, y): return x + y; @staticmethod def sub(x, y): return x - y; @staticmethod def mul(x, y): return x * y; @staticmethod de...
f1fd18ffa7100ad090b25338f8bc4dccd1b460dc
nengen/pythRSQL
/homework1/wayOfTheProgram.py
480
3.640625
4
#source = http://greenteapress.com/thinkpython2/html/thinkpython2002.html print("Hello world!") constant = 4/3 pi = 3.14 radius = 5 volumeOfSphere = float( constant * pi * radius**3) print(volumeOfSphere) priceOfBook = 24.95 discount = 0.4 shippingCostsFirstCopy = 3 shippingCostsRest = 0.75 amountOfCopiesSold = 60...
3a280a04d0334a5b7bfbcb662629462b608e1377
m-RezaFahlevi/we_still_learning_gitGithub
/pythonFiles/web_scraping.py
774
3.578125
4
from urllib.request import urlopen from bs4 import BeautifulSoup from urllib.error import HTTPError from urllib.error import URLError #I think, it is good to write a program in the term of #Object-Oriented Programming :) class WebScraping: def __init__(self, someUrl): self.someUrl = someUrl def getUrl...
98c01701c1918ecd23f3a3d68e89f0b0c80447ca
olegzinkevich/programming_books_notes_and_codes
/numpy_bressert/ch02_scipy/sparse_matrix.py
1,483
3.8125
4
# h sparse matrices (разреженная матрица) # WithNumPy we can operatewith reasonable speeds on arrays containing 106 elements. # Oncewe go up to 107 elements, operations can start to slowdown and Python’smemory # will become limited, depending on the amount of RAM available. What’s the best # solution if you need to wo...
21a44f17b75a3397ca787e169817783415d809c9
annaQ/annaWithLeetcode
/buildTree.py
1,793
3.984375
4
# Definition for a binary tree node class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: # @param inorder, a list of integers # @param postorder, a list of integers # @return a tree node def buildTree(self, inorder, postorder): if len(inorder) == 0 or ...
b9313069019d3c542026ed567e80bdc209b14729
vinod77-sudo/Python-Fundamentals-B_12
/testclass_1.py
491
3.5
4
#!/usr/bin/env python # coding: utf-8 # In[1]: class Animal: """A simple function of dog""" def __init__(self,name,age): """About the intro""" self.name=name self.age=age print("success fully completed ") def sit(self): """about sitting position of dog""" p...
4a3f9b74cfad2f7118c006c911b8c75fbc5a9f92
ErikMurt/Automate-the-boring-stuff
/isPhoneNumber.py
921
4.1875
4
### Checking if string is a phone number def isPhoneNumber(text): if len(text) != 12: # Checking if number is 12 symbols long return False for i in range(0, 3): # Checking if first 3 symbols are numbers if not text[i].isdecimal(): return False if text[3] != '-': #...
25b8c48a515cf7302313e14792e770ca8f16ca9c
TerryLun/Code-Playground
/Leetcode Problems/lc628e.py
1,408
4.125
4
""" 628. Maximum Product of Three Numbers Given an integer array, find three numbers whose product is maximum and output the maximum product. Note: The length of the given array will be in range [3,104] and all elements are in the range [-1000, 1000]. Multiplication of any three numbers in the input won't exceed the...
240e71f340b33b9235adcee42b0ba1228ae5bad2
than5466/advent_of_code
/day_15/main.py
7,817
3.515625
4
#!/usr/bin/env python3 import random import queue class Graph(): def __init__(self): self.vertices = {} self.tested_direction = {} self.not_explored = set() self.input = 0 self.current_vertice = [0,0] self.Goal = None self.output = None self.previo...
a08fec99b4d6413bf279bbd6bd30d8d3bb8ed820
rajan596/python-hacks
/Tut-2-classes.py
657
4.125
4
#!/usr/bin/python3 # classes class calculator: def addition(x,y): return x+y def subtraction(x,y): return x-y def mult(x,y): return mult def divide(x,y): if y==0: print("Error") return -1 else: return x/y print(calculator...
7137c8e1d31b94aa1d52333665f2178db0e5b875
hj8239ka45/python_test
/python/Tkinter窗口/basic_Tkinter_5_scale.py
1,257
3.671875
4
## 2018/01/12 basic_Tkinter_5 ## scale import tkinter as tk window = tk.Tk() window.title('my window') window.geometry('300x150') l = tk.Label(window,bg='yellow',width=20,text='') l.pack() #v(隨意假設)自動由scale擷取,因為scale有get value功能 def print(v): l.config(text='you have selected'+v) #從5~11,方向,length pix...
8a19fb662b00b0d8c0059117effacbb3278c4eb2
vkn84527/100-days-coding-challenge
/2. Add Two Numberslist.py
922
3.640625
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode: a=[] b=[] node=l1 node2=l2 while ...
e05c7afb4c868a3e9951d5a6937b98a139993897
nothingtosayy/Number-Guessing-Computer-
/main.py
898
3.90625
4
#Number guessing (Computer) import random as rd user_number = int(input()) lower_bound = 1 #set by user to computer to check within these limits, your wish any number u can fix as upper_bound upper_bound = 1000 #set by user to computer to check within these limits,your wish any number u can fix as upper_bound comp_numb...
f75d20526df452fbc8185e0de183acb9eee09711
g10guang/offerSword
/app/idea/sum_solution.py
1,802
3.84375
4
# -*- coding: utf-8 -*- # author: Xiguang Liu<g10guang@foxmail.com> # 2018-05-03 15:55 # 题目描述:https://www.nowcoder.com/practice/7a0da8fc483247ff8800059e12d7caf1?tpId=13&tqId=11200&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking class Solution: def Sum_Solution(self, n): """ ...
5aeb7227c5a657ab0ae6f1858527ccfdb64bc866
yhoazk/hckrnk
/katas/AoC/2019/d1/day1b.py
813
3.78125
4
from fuel_calc import fuel_calc # calculate the fuel needed to take the fuel def fuel2fuel(mass): if mass == 0: return 0 else: m = fuel_calc(mass) # print("mass fuel: {}".format(m)) return m + fuel2fuel(m) def non_rec_fuel2fuel(mass): tot = 0 mass = (mass // 3) - 2 # o...
776e70d1d6f09e0c4aa901f4814fb3ff3192c653
theresaneate/codewithmosh
/exercises_3.02_accessinglists.py
957
4.34375
4
#!/usr/bin/env python3 # https://codewithmosh.com/courses/423295/lectures/6781740 numbers = list(range(20)) print(numbers) print(numbers[0]) print(numbers[-1]) numbers[4] = 100 print(numbers) for n in numbers: print(n) newrange = tuple(range(3, 6)) print("\nNaughty tuple. Range from 3 to 6:") print(type(newrang...
e8f31e13e04282d5b79fb4e73f39ec359d2172d4
RoshikDiana/home_work_python
/Lesson_1/task_5.py
1,570
4.03125
4
# Запросите у пользователя значения выручки и издержек фирмы. # Определите, с каким финансовым результатом работает фирма # (прибыль — выручка больше издержек, или убыток — издержки больше выручки). # Выведите соответствующее сообщение. # Если фирма отработала с прибылью, вычислите рентабельность выручки (соотношение п...
0232bd5969437545300c86b123795da4f6844f5c
gracekim17/studyCS
/LearnPython/madlibs.py
266
4.03125
4
color = input("Enter a color: ") plural_noun = input("Enter a plural noun: ") celebrity = input("Enter a celebrity name: ") print("Roses are " + color.lower()) print(plural_noun.lower().capitalize() + " are blue") print("I love " + celebrity.lower().capitalize())
06b4e593ebf992b1cf67c7f09c276324f0fcc43b
cvmsprogclub/2016-cyoas
/adventure1234567890.py
5,189
4.15625
4
print("You are stranded on a island") print("press a to climb a tree") print("press b to start swimming") print("press c to scope the island") print("press d to drink coconut water") user_choice = input() if user_choice == "c" : print("you scope the island") print("you find flint") print("Do you wa...
6415717d86462c5c0e2d68b41a49f0fb97489f87
aimuch/AITools
/PreProcess/video2pic1.py
4,141
3.5
4
# -*- coding: utf-8 -*- ### Author : Andy ### Last modified : 2019-05-15 ### This tool is used to split videos into images(video_folder/video.h264) ### ----------------EXAMPLE------------------- ### python3 video2pic1.py \ ### home/andy/data/train/video_folder \ ### home/andy/data/train/output_folder --cuts 1 --s...
f21d46f6627e29b6421470569b5ee2a7ec92b955
flcavqueiroz/caelum
/jogos/forca.py
4,414
3.5
4
import random def jogar(): titulo() palavra_secreta = carrega_palavra_secreta() letra_acertada = inicializa_letra_acertada(palavra_secreta) print(letra_acertada) acertou = False errou = False num_erros = 0 while(not errou and not acertou): chute = pede_chute() ...
bec2b42406ca14abccfe079908f6de82b0650598
emmelles/cs101_into-comp-sci
/14-04_freq_analysis.py
466
3.5625
4
#!/usr/bin/env python alphabet=list("abcdefghijklmnopqrstuvwxyz") def freq_analysis(message): freq_list=[] for x in alphabet: freq_list.append(list(message).count(x)*1.0/len(list(message))) return freq_list #Tests print freq_analysis("abcd") #>>> [0.25, 0.25, 0.25, 0.25, 0.0, ..., 0.0] print f...
37d57210f6dc895094b3728cc632d09eeb028b28
Katy-katy/titanic_machine_learing_python_pandas_sklearn
/work.py
14,241
3.640625
4
""" Working skript for the project "Titanic" Author : Ekaterina Tcareva Date : 8rd March 2016 Our goal is to build a prediction on surviving Titanic passengers. We have some information about passengers (train.csv): PassengerId -- A numerical id assigned to each passenger. Survived -- Whether the passenger survived (...
0deb240a7d0b582e9615a067cfd0cdab4ad0a1f7
JerryHu1994/LeetCode-Practice
/Solutions/82-Remove-Duplicates-from-Sorted-List-II/python.py
1,008
3.6875
4
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def deleteDuplicates(self, head): """ :type head: ListNode :rtype: ListNode """ dummy = ListNode(-1) ...
d01713b1064b03b26b9be3b08ffb55fcde97bf28
vladimir713/Fibonnachi
/main.py
791
3.90625
4
#!/usr/bin/env python3 #---------------------------------------------------------------- # Вычисление ряда четных чисел Фибоначи тремя разными способами #----------------------------------------------------------------- def f(n): a = [0, 1] for i in range(2, 3*n): a.append(a[i-2]+a[i-1]) return [i for i in a if ...
0a167778505ac8c7a38d727ff4cec68dbd82fab0
shahpranaf/python-blockchain
/assignment/assignment1.py
328
3.71875
4
name = "Pranav" age = 29 def print_data() : print("My name is: " + name + " age is: " + str(age)) def print_data_arg(name, age) : print("My name is: " + name + "-" + str(age)) def decades_calc(time) : #return time//10 return int(int(age)/10) print_data() print_data_arg("abc", 20) print(decades_calc...
8f173acfa5bbe93895862b5d8882a43e9db7e757
stacygo/2021-01_UCD-SCinDAE-EXS
/04_Regular-Expressions-in-Python/04_ex_1-12.py
377
4
4
# Exercise 1-12: Replacing negations movies = "the rest of the story isn't important because all it does is serve as a mere backdrop for the two stars to share the screen ." # Replace negations movies_no_negation = movies.replace("isn't", "is") # Replace important movies_antonym = movies_no_negation.replace("importa...
8352e19238706a429c4d9822742554af4200b576
chinitacode/Python_Learning
/Tencent_50/46_Longest_Common_Prefix.py
7,222
3.921875
4
''' 14. Longest Common Prefix [Easy] Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string "". Example 1: Input: ["flower","flow","flight"] Output: "fl" Example 2: Input: ["dog","racecar","car"] Output: "" Explanation:...
23d8562ec8a10caa237d4544bb07cfefbb6fcd7f
harjothkhara/computer-science
/Sprint-Challenge--Data-Structures-Python/names/binary_search_tree.py
2,610
4.1875
4
class BinarySearchTree: # a single node is a tree def __init__(self, value): # similar to LL/DLL self.value = value # root at each given node self.left = None # left side at each given node self.right = None # right side at each given node # Insert the given value into the tree ...
d72640be1a32dbc51ebc7266e4f921b314a19c0c
Ebuyuktas/python-3-Hafta-Odev
/soru2.py
633
3.765625
4
#3. Hafta 2. Soru #Sayı Tahmin Programı sayi = 15 tahmin = 0 deneme_sayisi = 0 while sayi != tahmin: try: tahmin = int(input("Tahmininizi söyleyin(1-100 arası): ")) deneme_sayisi += 1 if tahmin > 100 or tahmin < 0: print("Lütfen doğru aralıkta tahmin giriniz.") ...
16fec28fb80d03b58f3d0bb6edf90323339e7819
sachinlalms/python
/venv/Scripts/methodoverhiding.py
624
4.09375
4
#Inheritance class BaseClass: def __init__(self): print("Base Init") def set_name(self,name): self.name=name print("Base Class Set_name") class Subclass(BaseClass): def __init__(self): super().__init__() print("Sub class init") #constuctor over_riding def set_n...
3b1398758f13f3dfa5b312e3e4029cc659bdc215
nicksmd/leet-code
/Lets-code/566. Reshape the Matrix.py
974
3.5625
4
class Solution(object): def matrixReshape(self, nums, r, c): """ :type nums: List[List[int]] :type r: int :type c: int :rtype: List[List[int]] """ n = len(nums) m = len(nums[0]) if n*m != r*c: return nums else: o...
5bfcc5d8111b437bb000b126d49cf7ec9e218af0
septyandy08/basic_python
/break_test.py
222
4.03125
4
text = input() while True: if text == "start": print("Starting program...") elif text == "stop": print("Program has stopped...") break print("text: {}".format(text)) text = input()
a71cac88bc7ffd231e8a54b91b951d0348feab6d
Jason-Custer/100-days-of-code
/basic-calculator/basic-calculator.py
1,143
4.25
4
# Calculator Program # Variables: x = 1 y = 1 # Functions: 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 functions = { "+": add, "-": subtract, "*": multiply, "/": divide, } def calculator(): from...
126909f88af62f2c36a64448f815f04172e2b4a9
samisaf/Learning-Data-Science
/Machine Learning - Coursera/models.py
4,656
3.71875
4
import numpy as np import scipy.io import scipy.optimize def LogisticRegression(X, y, theta0=None, reg=0, optimizer='builtin', niter=100): """ RETURNS theta/weights by fitting a logistic model using X (sample, features), and y labels. INPUT X: 2D array of m rows, and n cols (m, n) representing model s...
d06bfc23f9b3fb4fab5d91e6767c443d05528f8f
VaibhavDhaygonde7/Coding
/Python Projects/P75MathsFunction.py
770
3.984375
4
class Math(): @staticmethod def squrt(n): return n * n @staticmethod def cuberoot(n): return n * n * n class Square(Math): def __init__(self, side): self.side = side def areaofsquare(self): return Math.squrt(self.side) class Rectangle(Math): def __init__(s...
c58386ffcd94ddf39a7c892837c493b4d517f75e
PhucNguyen12038/PythonLearning
/School-works/sessions/session17/final2.py
1,287
3.796875
4
fname = 'concert.txt' #fn = input("Please enter filename: ") cl = input("What is your class? ") nt = int(input("How many tickets do you want? ")) dic = {} array = [] ffile = open("concert.txt") i = 0 for line in ffile: spl = line.strip().split(" ") place = spl[0] seat = spl[1] list_seat = list(seat) ...
0d00cf5415800c8f94ffd3337e82a9801747a407
iewaij/algorithm
/Assignment/exam/sample_question/fibonacci_leq.py
679
4.34375
4
""" Given a positive number, print out all Fibonacci numbers smaller or equal to that number. For example, given the number 11 the program should print out: 1 1 2 3 5 8. The next Fibonacci number would be 13 which is already larger than 11. """ fibonacci_dict = {1:0, 2:1, 3:1} def fibonacci_saved(n: int) -> list: ...
7ef903f6ce906d807faf28a7f8988a92af7c2c45
MartinCastellano/training
/hackerrank/Quartiles.py
379
3.765625
4
from statistics import median n = input() lista = list(map(int, input().split(" "))) lista.sort() q2 = median(lista) listaq1 = [] listaq3 = [] for i in range(len(lista)): if lista[i] < q2: listaq1.append(lista[i]) if lista[i] > q2: listaq3.append(lista[i]) q1 = median(listaq1) q3 = media...
85a04c61a8c552237b296840a94af3b13c0d9117
bucknercd/exception
/binmath.py
1,526
3.734375
4
from Errors import OperatorException import sys def binmath(b1,op,b2): valid_len1 = len(b1) valid_len2 = len(b2) count1 = 0 count2 = 0 valid = '01' valid_ops = ['+','-','*','^'] for i in b1: if i in valid: count1+=1 for i in b2: if i in valid: count2+=1 if valid_len1 != count1 or v...
3c7b7f63f4c72841a0280fa4baae51f91eae1410
danamulligan/APTsPython
/ps2/Pancakes.py
1,650
3.734375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Oct 12 18:34:23 2018 @author: danamulligan """ """ def minutesNeededs(numCakes, capacity): nice = 0 time = 0 if capacity > numCakes: nice = numCakes % capacity - 1 for n in range(nice-1): time += 5 for k in ra...
f605a0033a6bd08a53ac0b48e83c04336200f318
sreyansb/Codeforces
/codeforces1102A.py
76
3.53125
4
n=int(input()) sumi=(n*(n+1))>>1 if sumi&1: print(1) else: print(0)
0bb916cf5958dbc4dd12ef479c10f9db0a202dfb
cthurmond/Python-Practice
/dictdiff.py
1,081
3.5625
4
# *** MY CODE *** # Fixed brackets after looking at his code. def dictdiff(d1, d2): diffdict = {} error_dict = "" for key in d1: try: if d1[key] != d2[key]: diffdict[key] = [d1[key], d2[key]] except KeyError: diffdict[key] = [d1[key], "none"] for ...
ba97ad138cd4905e2f4f017060b68a61f8464543
UWPCE-PythonCert-ClassRepos/Self_Paced-Online
/students/joshua-bone/lesson9/mailroom_oo.py
3,344
3.671875
4
# Joshua Bone - UW Python 210 - Lesson 9 # 03/01/2019 # Assignment: Mailroom, Object Oriented from donors import Donors from formatter import Formatter MAIN_MENU = ("Welcome to the Mailroom!", "", "Please select from the following options:", "(S)end a Thank You", "(...
7063e537dc951dc39526a7082fa79c75b421409c
jay6413682/Leetcode
/Sliding_Window_Maximum_239.py
12,554
3.578125
4
import heapq class Solution: def maxSlidingWindow(self, nums: List[int], k: int) -> List[int]: """ 暴力法 brutal force, sliding window 超出时间限制 这道题最暴力的方法就是 2 层循环,时间复杂度 O(n * K)O(n∗K)。 空间复杂度:o(n) """ res = [] i = 0 n = len(nums) while i < n - k + 1: ...
45da857b688fcb9edee9dde7cadbe0e289dc648b
digital-diplomat/Project-Eurler
/is_prime.py
328
3.6875
4
import math def is_prime(n): if n == 2: retuen True if n % 2 == 0: return False else: t = math.sqrt(n) for i in range(2, int(t)+1): if n % i == 0: return False return True # assert is_prime(2) == True # This this assertion fails! #mf...
eebe39bb4c56822dafb04d67e05d43870a2bdf69
polyglotm/coding-dojo
/coding-challange/leetcode/easy/~2022-02-28/1967-number-of-strings-that-appear-as-substrings-in-word/1967-number-of-strings-that-appear-as-substrings-in-word.py
809
3.9375
4
""" 1967-number-of-strings-that-appear-as-substrings-in-word leetcode/easy/1967. Number of Strings That Appear as Substrings in Word Difficulty: easy URL: https://leetcode.com/problems/number-of-strings-that-appear-as-substrings-in-word/ """ from typing import List class Solution: def numOfStrings(self, patterns...
6cfb86f079559d29b50cc6e9a19ab946f55fdb47
naomatheus/daily-interview
/number_of_cousins.py
737
4.1875
4
# Given a binary tree and a given node value, return all of the node's cousins. # Two nodes are considered cousins if they are on the same level of the tree with different parents. You can assume that all nodes will have their own unique value. Here's some starter code: class Node(object): def __init__(self, value,...
d1989b88aa280ff822400b25149e2a96b4f616e5
balamurugan2405/python
/Day-2 operaters & contitional statement/numeric to alphabet.py
359
3.859375
4
n=int(input("Enter the number")) if(n==1): print("one") elif(n==2): print("Two") elif(n==3): print("Three") elif(n==4): print("Four") elif(n==5): print("Five") elif(n==6): print("Six") elif(n==7): print("Seven") elif(n==8): print("Eight") elif(n==9): print("nine")...
4bf64aee181afa563809e3a3bd650e7b8be1f72f
AhmedRaafat14/CodeForces-Div.2A
/510A - FoxAndSnake.py
1,771
4.03125
4
''' Fox Ciel starts to learn programming. The first task is drawing a fox! However, that turns out to be too hard for a beginner, so she decides to draw a snake instead. A snake is a pattern on a n by m table. Denote c-th cell of r-th row as (r, c). The tail of the snake is located at (1, 1), then it's body extends to...
24fe8b3a3f880ab645926bbf1863a6af775284c0
scottOrban/HW24
/HW24.py
5,345
3.984375
4
class Node: def __init__(self,data): self.data=data self.next = None class linkedList: def __init__(self): self.head = None def append(self, data): newNode=Node(data) if self.head==None: self.head=newNode return else: ...
04e5b42a2cdde2a3b8d0e3dcb686459e726b99a1
AlvisonHunterArnuero/EinstiegPythonProgrammierung-
/char_code_calculation.py
806
4
4
# --------------------------------------------------------------------------------------------- # Find all ASCII code from string characters, add them, change 7 for 1, substract both amount # and return is final result # Made with ❤️ in Python 3 by Alvison Hunter - March 30th, 2021 # JavaScript, Python and Web Developm...
cb27999583e43ff68bb6ad131f9318454e85fb15
Matth0s/Lista-2
/Exercicio 2.py
1,270
4.375
4
''' Esse programa calcula os numeros impares da sequencia de Fibonacci Aluno: Matheus Moreira do Nascimento DRE: 119042060 Curso: Matemática Aplicada Disciplina: Topicos da Matemática Aplicada A ''' print("................................................................................\n") print("Esse programa calcula ...
3341d459cfa048dea63da945d0857e19588e636d
DanayaDarling/cs114
/spacedungeon02d.py
2,563
4
4
import random print(' ~~~~~~~~~****** Welcome Traveler ******~~~~~~~~~') print(' ~~~~~~~~~~~****** to Space Dungeon ******~~~~~~~~~~~') print('') print(" Who dares to enter the dungeon?") name = input() print(" Foolish " + str(name) + " you will soon meet your end!") pri...
87a785d30626b09cabe2acb498918b70cae5dfc6
KartikKannapur/Algorithms
/00_Code/01_LeetCode/201_BitwiseANDofNumbersRange.py
900
3.609375
4
""" Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers in this range, inclusive. For example, given the range [5, 7], you should return 4. """ class Solution(object): def rangeBitwiseAnd(self, m, n): """ :type m: int :type n: int :rtype: in...
48fbf337e42f2a0a79b9bb235b04083b9b66c48d
GnarGnar/cst205
/fizzbuzz.py
236
4.15625
4
number = int =0 for number in range(0,100): if(number%3==0 and number%5==0): print(number) print("FizzBuZZ") elif(number%3==0): print(number) print("Fizz") elif(number%5 ==0): print(number) print("Buzz")
ee643fb4b87d155386285ca1fca14a14757a64c8
Ryan-Brooks-AAM/cleverprogrammer
/Learn-Python/exercise8_dict.py
808
4.25
4
phone_book = {"John": "444-222-4444", "Billy": "444-222-1111"} # get johns number print(phone_book['John']) # get billys number print(phone_book['Billy']) movies = {"Shawshank Redemption": 9.7, "The God Father": 8.0} for k in movies.keys(): print(f"{k} received a score {movies[k]}") fruit = { "banana": 1...
ef0c993d803d31f8d75407cdb951ad7111266e24
Church-17/python_tools
/goldbachConjecture.py
906
3.546875
4
def prime(n: int): if n == 2 or n == 5: return True if n%2 == 0 or n%5 == 0: return False sqrt = int(n**.5) + 1 for div in range(3, sqrt, 10): if n%div == 0: return False for div in range(7, sqrt, 10): if n%div == 0: return False ...
3674ee24d236b3948c5b0943106efab86ef0046d
danrodaba/Python_PixelBlack
/Python_PixelBlack/Aprende con Alf/02 Condicionales/03division.py
748
4.09375
4
''' Escribir un programa que pida al usuario dos números y muestre por pantalla su división. Si el divisor es cero el programa debe mostrar un error. ''' try: dividendo = int(input('Introduce el dividendo (número entero): ')) divisor = int(input('Introduce el divisor (número entero): ')) if divisor == 0: ...
1f273bd983bac04963a4a2710346b0bc21a731b2
Skylake101/Python-Practice-2-Attack-of-the-Turtle
/CarlsonLProject2.py
5,771
4.1875
4
""" Author: Luke Carlson Python has a built in turtle you can use to draw simple objects, I experiment with it here """ import turtle turtle.speed(9999999) """ I made turtle ludicrously fast for my own amusement """ turtle.width(5) turtle.penup() turtle.goto(250,-220) #This is the start...
1675e0d47312cc48810f1c31556ad1509d3c25ce
aslam7825/python
/beginner/Sum of Natural numbers.py
72
3.625
4
i=int(input("")) sum=0 while(i > 0): sum=sum+i i=i-1 print(sum)
cffb4ff6b4206574c31fb0206cc3882b6816d114
srinidhi136/python-app
/Anonymous_Functions.py
123
3.890625
4
##lambda function is called inline function Also called as anonymous function f= lambda x: x*2 #print(f()) print(f(2))
1a6018aa994b7a32f7a3e2a78b84449a48e6c09a
vic111/python
/find_name.py
564
3.953125
4
#一个用于查找你的姓名是否在表中 #进行姓名的补全 name = {'Adam','Alex','Amy','Bob','Boom', 'Candy','Chris','David','Jason', 'Jasonstatham','Bill'} while(1): i_name = input ('请输入你的姓名').title() fname = [] for i in name: if i[0:len(i_name)] == i_name: fname.append (i) if len (fname) == 0: ...
46ef39be63e41ee5cbfb89067bb09585b4b6bb68
tttgm/code-snippets
/python-basics/using_jupyter_for_slides.py
554
3.53125
4
### USING JUPYTER NOTEBOOK AS SLIDES ### """ To create a slideshow using a jupyter notebook is easy. First, prepare notebook as slides via View -> Cell Toolbar -> Slideshow. Then, mark each cell as a 'slide', 'sub-slide', 'note', or to be skipped (i.e. not shown). Save notebook. """ # To initiate slideshow (prese...
57338d20fddb3759b2ec32fcf084638186df11db
chadleytan/Projects
/automated puzzle solving/word_ladder_puzzle.py
4,968
3.875
4
from puzzle import Puzzle class WordLadderPuzzle(Puzzle): """ A word-ladder puzzle that may be solved, unsolved, or even unsolvable. """ def __init__(self, from_word, to_word, ws): """ Create a new word-ladder puzzle with the aim of stepping from from_word to to_word using wor...
158a5c4174cd6cec3ca49069f0402fbfdf927315
Xitog/teddy
/teddypy/layeredmap.py
11,551
3.671875
4
"""A map with different layers.""" import json from traceback import print_exc from sys import stdout def pretty_json(data, level=0, indent=4): "Pretty print some JSON." content = '' if isinstance(data, dict): content += '{\n' level += 1 count = 0 for key, val ...
2dcf550070ecb3685b7988334da9a67c4c3b306f
stupidchen/leetcode
/src/leetcode/P117.py
903
3.921875
4
# Definition for binary tree with next pointer. # class TreeLinkNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None # self.next = None class Solution: def __add_new_node(self, queue, tail, new_node, depth): if new_node is not None: ...
87dd68fff4fa625ff895bdabb33ad40c62a23abb
alanlucena/python-basic
/desafios/num_double_triple_expo.py
392
4.15625
4
#Algoritmo para ler um número e mostrar seu dobro, triplo e raiz quadrada number = int(input('Escolha o número: ')) double= numero*2 triple= numero*3 expo= numero**0.5 print('\nO número escolhido foi: {}\n' 'O dobro do valor do número escolhido é: {}\n' 'O triplo do valor do número escolhido é {}\n' 'A raiz quadrada...
22cc7357bb63e4cae5bc752e3bd7f27f132f2053
dgarciag1/practicanumerico
/NumSolutions/public/methods/cubic_spline.py
3,607
3.59375
4
import math import numpy as np import sympy as sm import sys import strToMatrix def cubic_spline(table): try: table = strToMatrix.strToMatrix(table) x_vector = table[0].tolist() y_vector = table[1].tolist() except: print("Error: check type of input values") sys.exit(1) ...
e844ae0b889e6b908e46d6f760d59492f4ee4354
Gluke92/python-practice
/algorithm-practice/Algorithm-types/linked-lists.py
269
3.890625
4
# Linked List exploration obj1 = {'a': True} obj2 = obj1 obj1['a']= 'booya' del obj1 obj2 = 'hello' # print(obj1) print(obj2) #Python is garbage collected. #if we delete the value the pointer is pointing to, #the objects will be undefined and need #to be reassigned
7492b254dac117f1c0a01e9d0099a024d84eb607
mindcurry/InterviewBit
/Level 2/Arrays/Spiral Order Matrix II.py
1,355
3.875
4
''' Given an integer A, generate a square matrix filled with elements from 1 to A2 in spiral order. Input Format: The first and the only argument contains an integer, A. Output Format: Return a 2-d matrix of size A x A satisfying the spiral order. Constraints: 1 <= A <= 1000 Examples: Input 1: A = 3 Output...
3ae36b41307f1f23f8e9d1dc02a6f8448dc97933
hiteshpindikanti/Coding_Questions
/LeetCode/water_trap.py
1,744
3.578125
4
def maximum(arr, start, end) -> int: max_val = 0 index = start if start < end: while start < end: if arr[start] > max_val: index = start max_val = arr[start] start += 1 elif end < start: while start > end: if arr[start] ...
88f8aea2cfaef6ac6d12259dffda88e9a48a9607
MeghaSHooli/Python
/Import_KT.py
1,356
4.0625
4
""" Demonstration of some of the features of the import """ import datetime # Create some dates print("Creating Dates") print("==============") date1 = datetime.date(1999, 12, 31) date2 = datetime.date(2000, 1, 1) # Today's date today = datetime.date.today() print(date1) print(date2) print("") # Compare dates...
55b15715733d8b941a95f9d5653f8de933a1f0f1
Saswati08/Data-Structures-and-Algorithms
/LinkedList/detect_loop_in_linked_list.py
547
3.71875
4
class node: def __init__(self, val): self.data = val self.next = None def detectLoop(head): #code here if head == None: return False if head.next == None: return False slow = head fast = head.next while(fast != None and fast.next != None): if slow == ...
87165f7e10563baa2168a1b86d9158d23791fb14
TwitterDataMining/TopicBasedSimilarity
/data_preprocessing/read_data.py
6,851
3.546875
4
""" read date for a tv show and prepare for topic modelling, uses the collections for specific show ie. input : collection name, path to unique users list process : reads from collection output : - csv file of preprocessed tweets - one line per user - csv file of preprocessed tweets - one line = usern...
19b19f260fbfbba1cebdb23d18d8e521bce30582
leobang17/algorithms-assignment
/Algorithms_Midterm/Algorithms_Midterm.py
8,000
3.8125
4
import random import time import matplotlib.pyplot as plt import sys N1 = 100 N2 = 1000 N3 = 10000 def random_array_creator(arr1, arr2, arr3): arr1.append(random.sample(range(1, N1 + 1), N1)) arr2.append(random.sample(range(1, N2 + 1), N2)) arr3.append(random.sample(range(1, N3 + 1), N3)) return...
4cbe4f038d3f425eb7669b782f5c53058e2dce65
ferdi-oktavian/Python
/TURTLE/turtle2.py
725
3.578125
4
import turtle import random from turtle import * fer = turtle.Turtle() fer.speed(0) fer.width(5) colors = ['red', 'green', 'blue', 'purple', 'pink'] def up(): fer.setheading(90) fer.forward(100) def down(): fer.setheading(270) fer.forward(100) def left(): fer.setheading(180) ...
d0174ee39ca9a736fa7e7df94667a7a47714a5c3
EgorPopelyaev/pystudy
/projects/skeleton/FirstProject/firstCalc.py
439
3.859375
4
from sys import argv script, value1, value2 = argv def add(val1, val2): return int(val1) + int(val2) def dif(val1, val2): int_val1 = int(val1) int_val2 = int(val2) if (int_val1 > int_val2): return int_val1 - int_val2 else: return int_val2 - int_val1 addition = add(value1, value2) print "The sum of input ...
f4deb01d9afb80c69e91ed5d68ccaa4a9e315946
shri-datta-madhira/LeetCode
/Sum of All Odd Length Subarrays.py
542
3.953125
4
""" Given an array of positive integers arr, calculate the sum of all possible odd-length subarrays. A subarray is a contiguous subsequence of the array. Return the sum of all odd-length subarrays of arr. """ class Solution: def sumOddLengthSubarrays(self, arr: List[int]) -> int: s = 0 for i in ...
9fe5ec2bf4b8dcb7ec2d04ca5fd5c1590a2724e1
bunnyxx/python
/password fetcher.py
860
4.1875
4
#! python3 # pw.py - password program import pyperclip password = {"email": "homura", "discord": "kyouko", "youtube": "madoka"} accountName = str(input("Account name? ")) def passwordObtainer(account): if account == "quit": print("Thank you for using pwmanager") elif account in password: pyperclip.copy(pa...
2bfe84dacf7afff99e123e448444d01c2c61df05
insomn14/CTFtime2020
/TAMUctf_2020/Reversing/RUSTY_AT_REVERSING/solve.py
347
3.734375
4
def decrypt(a1): v3 = 228 for i in range(len(a1)): v2 = v3 v3 = a1[i] a1[i] = chr(a1[i]^v2) return a1 flag = [0x83, 0xea, 0x8d, 0xe8, 0x85, 0xfe, 0x93, 0xe1, 0xbe, 0xcd, 0xb9, 0xd8, 0xaa, 0xc1, 0x9e, 0xf7, 0xa8, 0xce, 0xab, 0xce, 0xa2, 0xfd, 0x8f, 0xfa, 0x89, 0xfd, 0x84, 0xf9] pri...
5b96b3ddcc2765aafbb02d61bec76bd8d23d15cd
sachinjose/Coding-Prep
/CTCI/Tree & Graph/q.4.11.py
1,381
3.8125
4
import random class Node: def __init__(self,item): self.item = item self.left = None self.right = None self.size = 1 def get_size(self): return self.size def get_item(self): return self.item def getRandomNode(self): if(self.left): leftSize = self.left.get_size(); else: leftSize = 0 inde...
65b988532fa8eb321d2e8342f7bf2fc0b635f5dd
huangbow/INF553
/Assignment2/Huang_Bowen_multiply.py
1,007
3.59375
4
import MapReduce import sys mr=MapReduce.MapReduce() def mapper(record): #get matrix, string key=record[0] #get i x=record[1] #get j y=record[2] #get value val=record[3] for k in range(5): if key=="a": mr.emit_intermediate((x,k),(key,y,val)) elif key=="b": mr.emit_intermediate((k,y),(key,x,val)) d...
ab8b86f7a59bc1fb3999fcd17172e73cfe586747
gabriellaec/desoft-analise-exercicios
/backup/user_020/ch152_2020_04_13_20_16_20_476223.py
284
3.5625
4
def verifica_preco(nome, livros, cores): nome = input("Insira o nome do livro: ") livros = {} cores = {} if nome in livros: nome = livros[nome] print('{0}' .format(cores)) else: print("O livro {0} não existe!" .format(nome))
3cd4958c717d440738bb03decddcf49a9077de39
learner-wming/mypython_leaning
/判断和循环.py
2,881
3.546875
4
# for i in range(1,10): # for j in range(1,i+1): # print(i,"X",j,"=",i*j,end=" ") # print() # #九九乘法表 # for h in range(1,4): # print("黄红绿") # h=h+1 # for r in range(4,31): # print(" 红绿") # r=r+1 # for g in range(31,36): # print(" 绿") # g=g+1 # # #打印红...
e2e0a21b8ca9b6fa66a087ade8de453fcdc6e6f6
BasharOumari/ddmin-algorithm
/ddmin_alg/ddmin.py
3,103
3.53125
4
import itertools as iters import argparse n = 2 checkNValues = [] parser = argparse.ArgumentParser(description="`\n Usage python ddmin.py -s <sequence> -f <fail_input>") parser.add_argument("-s", type=list, dest="sequence", help="ints or chars sequence ") parser.add_argument("-f", dest="fail", help="The expected fail...
0684b6121c8e514a72c8a3cb3a4db9a7e061f76a
Kanres-GH/Pokolenie-Python-Stepik
/Условный оператор/Логические операции/Ход короля (X).py
191
3.796875
4
x1 = int(input()) y1 = int(input()) x2 = int(input()) y2 = int(input()) if (x1+1==x2 or x1-1==x2 or x1==x2) and (y1+1==y2 or y1-1==y2 or y1==y2): print('YES') else: print('NO')
caa7be05c568257af04df61927bcdc32a081a5cb
guhaiqiao/SmartCar
/Smartcar_PC/extdata.py
1,958
3.59375
4
######################## # 此模块包含读取外部数据文件的相关类 ######################## class Graph: def __init__(self): self.x = [] self.y = [] self.line = [] self.point_num = 0 def read(self, file): self.line = [] f = open(file, 'r') info = f.readlines() self....
b47e7b5bd3b221619f8a9ef3b589f0a7b2890be9
alvinoum/project1_count
/name7.py
1,540
4
4
# Ask for user's name and display is back # Ask user for a number input n, then count from 0 to n on the screen # Learn and use the best practice coding standards and conventions # Modify the program to count by 2s or some other incrment # Sanitize all input and test to verify! # And error-checking and graceful error h...
b7b65f2b16d791e431a749ef923a3886c642a97a
OnsJannet/holbertonschool-web_back_end
/0x00-python_variable_annotations/2-floor.py
203
3.90625
4
#!/usr/bin/env python3 ''' takes a float n as argument and returns the floor of the float as an int ''' import math def floor(n: float) -> int: ''' Return floor of n.''' return math.floor(n)
19f725d96b264e36cf979735636ea2fae87848b5
mikaav/Learn-Python
/For10.py
207
3.828125
4
# Дано целое число N (> 0). Найти сумму 1 + 1/2 + 1/3 + ... + 1/N (вещественное число). n = int(input()) s = 0 for i in range(1, n + 1): s += 1 / i print(s)
91f101e7c55e1bed760e22b33919cdf4c96ec59e
Palheiros/Python_exercises
/elif_categ_preco.py
452
3.84375
4
# Programa 4.7 - Categoria x Preço usando elif categoria = int(input("Digite a categoria do produto (1 a 5): ")) if categoria == 1: preço = 10 elif categoria == 2: preço = 18 elif categoria == 3: preço = 23 elif categoria == 4: preço = 26 elif categoria == 5: preço = 31 else: pr...
55dc54610d53dfc091415c60e8b663887a8a7185
greenfox-zerda-lasers/bednayb
/week-03/day-04/43.py
351
3.859375
4
filename = 'alma.txt' # create a function that prints the content of the # file given in the input fname = "cv-anakin.txt" num_lines = 0 num_words = 0 num_chars = 0 with open(fname, 'r') as f: for line in f: print(line) words = line.split() num_lines += 1 num_words += len(words) ...
708e46fc404c1f65edfadf4eede6627242b35b10
LizzieDeng/kalman_fliter_analysis
/docs/cornell CS class/lesson 25. Advanced Error/demos/read5.py
703
4.1875
4
""" A simple application to show off try-except This one shows off putting an error into a variable. Author: Walker M. White (wmw2) Date: October 28, 2017 (Python 3 Version) """ def main(): """ Get some input from the user """ try: value = input('Number: ') # get number from user ...
64dbc6a1c55d6d975b718184b2dac5addba130cc
oybektoirov/Project-Euler
/P7_10001st_prime.py
404
3.765625
4
def n_prime(limit): num = 7 prime_list = [2, 3, 5] while True: if is_prime(num, prime_list): prime_list.append(num) if len(prime_list) == limit: return prime_list[-1] num += 2 def is_prime(num, prime_list): for i in prime_list: ...
7d7964ed6704e81c532f13430df28dc8ca1a11b7
hualuohuasheng/AutomationTestFramework_appium
/testspace/matplotlib/die.py
302
3.578125
4
# -*- coding:utf-8 -*- from random import randint class Die(): def __init__(self,num_sides=6): self.num_sides = num_sides def roll(self): return randint(1,self.num_sides) die = Die() results = [] for roll_num in range(100): results.append(die.roll()) print(results)