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
da0fb19424fe49848a173ab772349e42a0bad1cf
Sid2697/MIT-6.00.1x
/Week3/Problem1.py
197
3.546875
4
def isWordGuessed(secretWord,lettersGuessed): secret = list() i=0 for letter in secretWord: if letter in lettersGuessed: i+=1 if len(secretWord)==i: return True else: return False
f21ac8b47c8225e1d0d9057c492b4d9d5d364595
Sid2697/MIT-6.00.1x
/Week5/Spell.py
1,113
3.84375
4
class Spell(object): def __init__(self, incantation, name): self.name = name self.incantation = incantation def __str__(self): return self.name + ' ' + self.incantation + '\n' + self.getDescription() def getDescription(self): return 'No description' d...
794728bfb8479903cca02076038f70f918fc80d8
Sid2697/MIT-6.00.1x
/Week2/Problem2.py
322
3.703125
4
balance = 3558 annualInterestRate = 0.15 monthlyInterestRate = annualInterestRate/12 a=balance monthlyFixedPayment = 0 while balance > 0: balance = a monthlyFixedPayment += 10 for month in range(12): balance -= monthlyFixedPayment balance += balance*monthlyInterestRate print('Lowest Payment:',monthlyFixedPayment...
268a08debd1dd7cf26375f30d3c1f7358c5ca85a
acrainier1/phase-one-assessment
/ANSWER_4_5/app/location.py
1,846
3.796875
4
# Alex C - location.py class class Location(): def __init__(self, address=""): self.address = address def __repr__(self): return f"Location: {self.address}" class Person(): def __init__(self, first_name, last_name): self.first_name = first_name self.last_name = last_nam...
63aea9d48b8073003241c9dca084c9b007f152f8
cerchiariluiza/CodigosScrapsCompiladosPython
/2websites/exp3.py
391
3.96875
4
import re # Definindo o padrão usando circunflexo # "^" = Início da string padrao = "E" # No findall encontra 2 ocorrências de Esta e Espero #padrao = "^E" # Forçando retornar somente se estiver no início da string texto = "Esta é uma aula de Python.\n Nesta aula vamos falar sobre expressões regulares.\n Espero que g...
e1a43c971d54ebf66a83828c6bf36da7cdb78147
cerchiariluiza/CodigosScrapsCompiladosPython
/2websites/expressao0.py
735
3.921875
4
import re pattern = re.compile(r"(segunda|terça|quarta|quinta|sexta)-feira") sambadotrabalhador = "Na segunda-feira eu não vou trabalhar Na terça-feira não vou pra poder descansar Na quarta preciso me recuperar Na quinta eu acordo meio-dia, não dá Na sexta viajo pra veranear No sábado vou pra mangueira sambar Domingo ...
fa9c8c6e17be75a23a323a3664bc155a039b234f
cerchiariluiza/CodigosScrapsCompiladosPython
/2websites/expressao3.py
571
3.796875
4
import re padrao = re.compile(r".ato") texto = ("Eu tenho um Gato que corre de RATO," "foge para o MATO, aí eu pego o sapato " "e bato ele no ato.") resultado = re.search(padrao, texto) print(resultado) texto = ("Eu tenho um Gato que corre de RATO," "foge para o MATO, aí eu pego o sapato " ...
254e45fa8691086569eae9d1a3da763329c06475
cerchiariluiza/CodigosScrapsCompiladosPython
/3expressoesReg/exp4.py
370
3.859375
4
import re # Definindo o padrão usando barra invertida # "\" = Caractere de escape #padrao = "." # Qualquer caracter, exceto quebra de linha padrao = "\." # Localiza ocorrências do caractere ponto texto = r"Esta é uma aula de Python.\n Nesta aula vamos falar sobre expressões regulares.\n Espero que goste.\n" resultad...
904d9fc0538859fc8ef7fb8a9f90fc11a35b388d
clagger/footballrobots
/football_robots/player/decision_tree.py
19,349
3.890625
4
from football_robots.player.player import * from football_robots.utility_functions.utils import calc_init_position_ball def decide_action(player: Player): """ man made decision tree to decide which action to take for a better picture please read the technical documentation :param player: Player; player ...
9223798077de0fee71c3cc1a98c15455abf11de9
gbusquim/IA-2019.1
/IA - Trabalho 1/IA-Trabalho1-BuscaLocal.py
8,003
3.609375
4
import math import copy import random as rand #classe Rota -> guarda cada rota do trajeto class Route: def __init__(self, total_distance, nodes,current_capacity): self.total_distance = total_distance self.nodes = nodes self.current_capacity = current_capacity #classe saving -> g...
17b0b58b6f8758bb6619c8e555133e79e3456a58
PXTgh/magicVowels
/magicv.py
2,608
4
4
############################################################################ # # Magical Subsequence of Vowels # by Aditya Kothari (https://github.com/Madaditya/magivvowels) # # ############################################################################ import sys import re usage = ''' Error : Invalid no of argume...
d6c30d2048e7e815b9550b05e2abe1966c7d4332
probuse/prime_numbers
/prime_numbers_.py
810
4.15625
4
def prime_numbers(n): "Generate prime numbers between 0 and n" while isinstance(n, int) and n > 0: prime = [] def is_prime(number): "Tests if number is prime" if number == 1 or number == 0: return False for num in range(2, number): ...
2d195bd9e64a571692a80213e75beddf8235052c
ironboxer/leetcode
/python/214.py
983
4.15625
4
""" https://leetcode.com/problems/shortest-palindrome/ Given a string s, you are allowed to convert it to a palindrome by adding characters in front of it. Find and return the shortest palindrome you can find by performing this transformation. Example 1: Input: "aacecaaa" Output: "aaacecaaa" Example 2: Input: "abc...
44d8f41eea8a564d20dc148a17ff74c8b8bcdae9
ironboxer/leetcode
/python/692.py
1,603
3.578125
4
""" https://leetcode-cn.com/problems/top-k-frequent-words/ 692. 前K个高频单词 给一非空的单词列表,返回前 k 个出现次数最多的单词。 返回的答案应该按单词出现频率由高到低排序。如果不同的单词有相同出现频率,按字母顺序排序。 示例 1: 输入: ["i", "love", "leetcode", "i", "love", "coding"], k = 2 输出: ["i", "love"] 解析: "i" 和 "love" 为出现次数最多的两个单词,均为2次。 注意,按字母顺序 "i" 在 "love" 之前。 示例 2: 输入: ["the", ...
735861333dd5cee3e484b9ecfb31a4805656c6ea
ironboxer/leetcode
/python/44.py
5,428
4.21875
4
""" https://leetcode.com/problems/wildcard-matching/ Given an input string (s) and a pattern (p), implement wildcard pattern matching with support for '?' and '*'. '?' Matches any single character. '*' Matches any sequence of characters (including the empty sequence). The matching should cover the entire input string...
87dd10746652a2cbc39e5f5da64a103ecda268f4
ironboxer/leetcode
/python/217.py
1,482
3.859375
4
""" https://leetcode.com/problems/contains-duplicate/ Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every element is distinct. Example 1: Input: [1,2,3,1] Output: true Example 2...
cb378565395b3b1a698c5b2d79f182ef0e9c7df0
ironboxer/leetcode
/python/772.py
2,765
3.515625
4
""" https://leetcode-cn.com/problems/basic-calculator-iii/ 772. 基本计算器 III 实现一个基本的计算器来计算简单的表达式字符串。 表达式字符串只包含非负整数, +, -, *, / 操作符,左括号 ( ,右括号 )和空格 。整数除法需要向下截断。 你可以假定给定的字符串总是有效的。所有的中间结果的范围为 [-2147483648, 2147483647]。 进阶:你可以在不使用内置库函数的情况下解决此问题吗? 示例 1: 输入:s = "1 + 1" 输出:2 示例 2: 输入:s = " 6-4 / 2 " 输出:4 示例 3: 输入:s = "...
3a6d6e10b3d0ee5f6832671f32d587c7f4594fe7
ironboxer/leetcode
/python/82.py
1,016
3.875
4
""" https://leetcode.com/problems/remove-duplicates-from-sorted-list-ii/ Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. Return the linked list sorted as well. Example 1: Input: 1->2->3->3->4->4->5 Output: 1->2->5 Example 2: Input: 1->...
d054e9aad8c2cd73a3c3b5ec8a550ddb90db946b
ironboxer/leetcode
/python/10.py
7,159
4.125
4
""" https://leetcode.com/problems/regular-expression-matching/ Given an input string (s) and a pattern (p), implement regular expression matching with support for '.' and '*'. '.' Matches any single character. '*' Matches zero or more of the preceding element. The matching should cover the entire input string (not pa...
c959ef443fc1a250b91888c0b44826c918817920
ironboxer/leetcode
/python/168.py
826
4
4
""" https://leetcode.com/problems/excel-sheet-column-title/ Given a positive integer, return its corresponding column title as appear in an Excel sheet. For example: 1 -> A 2 -> B 3 -> C ... 26 -> Z 27 -> AA 28 -> AB ... Example 1: Input: 1 Output: "A" Example 2: Input: 28 Output: ...
c752961be11da4e30675312ef3d7b64a711d1a2d
ironboxer/leetcode
/python/91.py
1,811
3.65625
4
""" https://leetcode.com/problems/decode-ways/ A message containing letters from A-Z is being encoded to numbers using the following mapping: 'A' -> 1 'B' -> 2 ... 'Z' -> 26 Given a non-empty string containing only digits, determine the total number of ways to decode it. Example 1: Input: "12" Output: 2 Explanation...
bc509ad8e8375270c803a118c24746d45af97088
ironboxer/leetcode
/python/49.py
1,050
4.1875
4
""" https://leetcode.com/problems/group-anagrams/ Given an array of strings strs, group the anagrams together. You can return the answer in any order. An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once. Example 1: In...
810fcfc1c47678077daa036d317df47661ef1c4b
ironboxer/leetcode
/python/863.py
2,272
3.703125
4
""" https://leetcode-cn.com/problems/all-nodes-distance-k-in-binary-tree/ 863. 二叉树中所有距离为 K 的结点 给定一个二叉树(具有根结点 root), 一个目标结点 target ,和一个整数值 K 。 返回到目标结点 target 距离为 K 的所有结点的值的列表。 答案可以以任何顺序返回。 示例 1: 输入:root = [3,5,1,6,2,0,8,null,null,7,4], target = 5, K = 2 输出:[7,4,1] 解释: 所求结点为与目标结点(值为 5)距离为 2 的结点, 值分别为 7,4,以及 1 注意...
edf2dbb1ab0825c90eb8f3335ad0da37f471a619
ironboxer/leetcode
/python/680.py
806
3.71875
4
""" https://leetcode-cn.com/problems/valid-palindrome-ii/ 680. 验证回文字符串 Ⅱ 给定一个非空字符串 s,最多删除一个字符。判断是否能成为回文字符串。 示例 1: 输入: "aba" 输出: True 示例 2: 输入: "abca" 输出: True 解释: 你可以删除c字符。 注意: 字符串只包含从 a-z 的小写字母。字符串的最大长度是50000。 """ class Solution: def validPalindrome(self, s: str) -> bool: def f(s, l, r): ...
5d5bfff8c7c2e18f750b931eaab0a4a1f8da0ab2
ironboxer/leetcode
/python/Offer56-I.py
1,697
3.609375
4
""" https://leetcode-cn.com/problems/shu-zu-zhong-shu-zi-chu-xian-de-ci-shu-lcof/ 剑指 Offer 56 - I. 数组中数字出现的次数 一个整型数组 nums 里除两个数字之外,其他数字都出现了两次。请写程序找出这两个只出现一次的数字。要求时间复杂度是O(n),空间复杂度是O(1)。 示例 1: 输入:nums = [4,1,4,6] 输出:[1,6] 或 [6,1] 示例 2: 输入:nums = [1,2,10,4,1,4,3,3] 输出:[2,10] 或 [10,2] 限制: 2 <= nums.length <= 10000...
2e2d48dc8f9d7523a82cf024a345d7b6ed002a90
ironboxer/leetcode
/python/460.py
4,709
3.625
4
""" https://leetcode-cn.com/problems/lfu-cache/ 460. LFU 缓存 请你为 最不经常使用(LFU)缓存算法设计并实现数据结构。 实现 LFUCache 类: LFUCache(int capacity) - 用数据结构的容量 capacity 初始化对象 int get(int key) - 如果键存在于缓存中,则获取键的值,否则返回 -1。 void put(int key, int value) - 如果键已存在,则变更其值;如果键不存在,请插入键值对。当缓存达到其容量时,则应该在插入新项之前,使最不经常使用的项无效。在此问题中,当存在平局(即两个或更多个键具有相同使用...
3c8f17714344dfeabc1570551b76c50acd853b33
ironboxer/leetcode
/python/516.py
3,334
3.5
4
""" https://leetcode-cn.com/problems/longest-palindromic-subsequence/ 516. 最长回文子序列 给定一个字符串 s ,找到其中最长的回文子序列,并返回该序列的长度。可以假设 s 的最大长度为 1000 。 示例 1: 输入: "bbbab" 输出: 4 一个可能的最长回文子序列为 "bbbb"。 示例 2: 输入: "cbbd" 输出: 2 一个可能的最长回文子序列为 "bb"。 提示: 1 <= s.length <= 1000 s 只包含小写英文字母 """ # slow but work from functools imp...
3254c7e78c64316a34638d428a68a46272dc01a7
ironboxer/leetcode
/python/1235.py
4,081
3.578125
4
""" https://leetcode-cn.com/problems/maximum-profit-in-job-scheduling/ 1235. 规划兼职工作 你打算利用空闲时间来做兼职工作赚些零花钱。 这里有 n 份兼职工作,每份工作预计从 startTime[i] 开始到 endTime[i] 结束,报酬为 profit[i]。 给你一份兼职工作表,包含开始时间 startTime,结束时间 endTime 和预计报酬 profit 三个数组,请你计算并返回可以获得的最大报酬。 注意,时间上出现重叠的 2 份工作不能同时进行。 如果你选择的工作在时间 X 结束,那么你可以立刻进行在时间 X 开始的下一份工作。...
ef8b88794dfc2b93e3ae3df39fc0d21e5df9cc50
ironboxer/leetcode
/python/124.py
4,524
3.953125
4
""" https://leetcode.com/problems/binary-tree-maximum-path-sum/ Given a non-empty binary tree, find the maximum path sum. For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child connections. The path must contain at least one node and does no...
9b79ae5a9eaadcef2a1be81c479ca9675c0d3553
ironboxer/leetcode
/python/231.py
652
4.125
4
""" https://leetcode.com/problems/power-of-two/ Given an integer, write a function to determine if it is a power of two. Example 1: Input: 1 Output: true Explanation: 20 = 1 Example 2: Input: 16 Output: true Explanation: 24 = 16 Example 3: Input: 218 Output: false """ class Solution: def isPowerOfTwo(self,...
a417b8085ba4b75ce5421b90016231ba75a53733
ironboxer/leetcode
/python/1109.py
1,951
3.625
4
""" https://leetcode.com/problems/corporate-flight-bookings/ 1109. Corporate Flight Bookings Medium 555 105 Add to List Share There are n flights, and they are labeled from 1 to n. We have a list of flight bookings. The i-th booking bookings[i] = [i, j, k] means that we booked k seats from flights labeled i to ...
516e25e9f680aaad96261fa816d6c96d018ce76a
ironboxer/leetcode
/python/23.py
4,272
4.09375
4
""" https://leetcode.com/problems/merge-k-sorted-lists You are given an array of k linked-lists lists, each linked-list is sorted in ascending order. Merge all the linked-lists into one sorted linked-list and return it. Example 1: Input: lists = [[1,4,5],[1,3,4],[2,6]] Output: [1,1,2,3,4,4,5,6] Explanation: The l...
5fca6c769c3da120a8557b37d2588e79fbf601fd
ironboxer/leetcode
/python/198.py
2,114
3.6875
4
""" https://leetcode.com/problems/house-robber/ You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security system connected and it will automatically contact the ...
b0ff62eb9defd12b5203adbcc512a35190b534e9
ironboxer/leetcode
/python/113.py
1,434
3.84375
4
""" https://leetcode.com/problems/path-sum-ii/ Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum. Note: A leaf is a node with no children. Example: Given the below binary tree and sum = 22, 5 / \ 4 8 / / \ 11 13 4 / \ / \ 7 2 5 ...
8ae32570722813e2c8f331600a14d6e11095e8c1
ironboxer/leetcode
/python/1115.py
2,052
3.90625
4
""" https://leetcode-cn.com/problems/print-foobar-alternately/ 1115. 交替打印FooBar 我们提供一个类: class FooBar { public void foo() { for (int i = 0; i < n; i++) { print("foo"); } } public void bar() { for (int i = 0; i < n; i++) { print("bar"); } } } 两个不同的线程将会共用一个 FooBar 实例。其中一个线程将会调用 foo...
2bd4ef9b6c8264110837172b7e33f3080ace69e6
ironboxer/leetcode
/python/337.py
6,113
4
4
""" https://leetcode.com/problems/house-robber-iii/ The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the "root." Besides the root, each house has one and only one parent house. After a tour, the smart thief realized that "all houses in this place forms a b...
6e3d8b54092422465a3fe6a3fea3306b84932865
ironboxer/leetcode
/python/Interview01.01.py
1,042
3.671875
4
""" https://leetcode-cn.com/problems/is-unique-lcci/ 面试题 01.01. 判定字符是否唯一 实现一个算法,确定一个字符串 s 的所有字符是否全都不同。 示例 1: 输入: s = "leetcode" 输出: false 示例 2: 输入: s = "abc" 输出: true 限制: 0 <= len(s) <= 100 如果你不使用额外的数据结构,会很加分。 """ class Solution: def isUnique(self, astr: str) -> bool: return len(set(astr)) == len(as...
cc05583f5d65fc9e9db7210075f536616c318a28
ironboxer/leetcode
/python/127.py
2,311
4
4
""" https://leetcode.com/problems/word-ladder/ Given two words (beginWord and endWord), and a dictionary's word list, find the length of shortest transformation sequence from beginWord to endWord, such that: Only one letter can be changed at a time. Each transformed word must exist in the word list. Note: Return 0 i...
8f74502c092e9a8abdad6939a1c10e182dd62268
ironboxer/leetcode
/python/215.py
1,797
4.0625
4
""" https://leetcode.com/problems/kth-largest-element-in-an-array/ Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element. Example 1: Input: [3,2,1,5,6,4] and k = 2 Output: 5 Example 2: Input: [3,2,3,1,2,4,5,5,6] and k = 4 Output:...
9fee37084aec1ce1f580c0bd7915c8222281d0ce
ironboxer/leetcode
/python/112.py
2,267
4
4
""" https://leetcode.com/problems/path-sum/ Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. Note: A leaf is a node with no children. Example: Given the below binary tree and sum = 22, 5 / \ 4 8 ...
9d4704fdd9c477d5268be20635a003427ece3545
ironboxer/leetcode
/python/84.py
4,625
3.515625
4
""" https://leetcode.com/problems/largest-rectangle-in-histogram/ Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram. Above is a histogram where width of each bar is 1, given height = [2,1,5,6,2,3]. The lar...
9a2d105283039ed30addd361c5f7ed58551552b2
larwal6312/Point_Tracker
/main.py
1,892
3.703125
4
from tkinter import * from tkinter import ttk import sqlite3 from datetime import datetime ###Prepare DB Connection### conn = sqlite3.connect('points.db') c = conn.cursor() c.execute("""CREATE TABLE IF NOT EXISTS points ( date text, points integer, reason text )""") conn...
5425e4019d369b1a7379d968e61ed5e05e42c1cb
MNeipp/OOP
/users_with_bankaccount.py
1,597
3.96875
4
class BankAccount: def __init__(self,int_rate = 0.02, balance = 0): self.int_rate = int_rate self.balance = balance def deposit(self, amount): self.balance += amount return self def withdrawl(self, amount): if self.balance < amount: print("insufficient f...
8e03c0716e1d06cd10ffd694a756b552eebd4889
Masibulele22/practiseQuestions
/average_score.py
407
4.03125
4
first_score = float(input(("Hey there Mochacho! Please typein your first score: "))) second_score = float(input(("Good going! Please typein your second score: "))) third_score = float(input(("Almost there... Now please typein your third score: "))) score_total = first_score + second_score + third_score score_average =...
721da092b3168fc6e2d2c5802a889d57f0a85e17
Blake-Goms/HackerRank
/Algorithms/CountingValleys/cv.py
702
4.03125
4
def countingValleys(n, s): # s is a string of Us and Ds # keep track of the height height = 0 # keep track of number of valleys valleys = 0 # loop through the string s for step in s: # depending on whether we see a U or a D # only need to keep track of one if ste...
ea8eb4f5f994bf5646b68665e7e8d8cca2c37cee
Blake-Goms/HackerRank
/Algorithms/miniMax-Sum/miniMax-Sum.py
310
4.03125
4
def miniMaxSum(arr): sum = 0 for i in range(len(arr)): # add value of index to sum sum += arr[i] # once we find the sum all we need to do is subtract # the highest and lowest values to find the max/min print(sum - max(arr), sum - min(arr)) miniMaxSum([1,2,3,4,5])
7f4fbcd4f3c3c3d433043127c6193217abe7a363
Yael-Hari/hw1_094700
/data.py
2,454
4.09375
4
import pandas as pd def load_data(path, features): """ this func turns the .csv file into dict, keeping only needed columns :param path: string: path to .csv file :param features: list: columns to keep :return: dict with features as keys """ df = pd.read_csv(path) data = df.to_dict('li...
630f27f0dd17c98ff49ec247486fd8ef2a1c4d1e
dollarkillerx/PyTorchStudy
/two.py
312
3.625
4
import torch x = torch.ones(2,2,requires_grad=True) # 生成2*2的矩阵 默认初始值为1 print(x) y = x + 2 z = y *y + 3 out = z.mean() print(y) print(z) print(out) # 计算梯度 out.backward() print(x.grad) with torch.no_grad(): # 忽略梯度 k = x + 1 print(k) k = x + 1 print(k)
19c376a429bdd8011229851248d60431fc4eedf1
imfarhanAK/Python-Projects
/Hangman_Game.py
1,137
3.984375
4
print("\n\t\t\tProgram to build the Hangman game") print("\n\t\t\t\t\t\t\t---------WELCOME TO HANGMAN----------\n") print("Guess the blank spaces to complete the given paragraph") para="On a spring day,Saba and I went to the park.Once we got to the park, the sky turned Black.It started rain." print("On a spring day,---...
213328b0f3f5aa73e5b3a1bf6248fcb5e21b2d94
SuyashMohanty/Python-Code
/Reversing_LinkedList_using_inPlace_algorithm.py
3,042
4.1875
4
""" Reversing a linked list using in-place algorithm """ class Node: def __init__(self, data): self.data = data self.nextNode = None class LinkedList: def __init__(self): self.head = None self.numOfNodes = 0 # O(N) running time complexity ...
dab99186068b963eea5dba4d0a16b58b47ac6eee
GeddingsJ/OSU_CS325_Analysis-of-Algorithms
/hw1/datatxt/merge.py
653
3.6875
4
def merge(l, r): arr = [] while len(l) != 0 and len(r) != 0: if l[0] < r[0]: arr.append(l[0]) l.remove(l[0]) else: arr.append(r[0]) r.remove(r[0]) if len(l) == 0: arr += r else: arr += l return arr def mergeSort(arr): if len(arr) == 0 or len(arr) == 1: return arr else: mid = len(arr)/2...
f71720012253e3267972a99ebed6e477c24e925e
Steven4869/Simple-Python-Projects
/excercise13.py
145
4.28125
4
#Palindrome printing a=input("Please enter your word\n") if(a==a[::-1]): print(a,"is a palindrome") else: print(a,"is not a palindrome")
9f5813b1648efb443d1f37f581f244bf9c0b719f
Steven4869/Simple-Python-Projects
/String_searching_from_input.py
1,069
3.953125
4
#SEARCH ENGINE """ TO MAKE A PROGRAM WHERE DIFFERENT SENTENCES ARE THERE, INPUT MUST BE GIVEN AND IT WILL SHOW ALL THE RELATED SEARCH FOR EXAMPLE SENTENCE: "ATTACK ON TITAN IS GOOD","EREN IS GREAT","ARMIN IS HIS BEST FRIEND","EREN LIKES FREEDOM" INPUT : PLEASE ENTER THE STRING EREN OUTPUT: 2 RESULTS ARE FOUND "EREN IS ...
2f75bae5333e1dbe92c7f3b3d620331cea334c96
Steven4869/Simple-Python-Projects
/Tuple-sorting.py
157
4.09375
4
def last(n): return n[-1] def sort(tuples): return sorted(tuples, key=last) a = input("Enter a list of tuples:") print("Sorted:") print(sort(a))
9e4fc7517fbe8fd3e2f9c68694b0692e5ad0eef4
Steven4869/Simple-Python-Projects
/excercise21.py
434
4.25
4
#Amstrong number print("Welcome to Amstrong number checker, if the number's sum is same as the sum of the cubes of respective digits then it is called Amstrong number") a=int(input("Please enter your number\n")) sum=0 temp=a while(temp >0): b=temp%10 sum+=b **3 temp//=10 if(a==sum): print(a,"is an Amstr...
0f1583766e25571d9a33988495d1ae4ef70ec015
leahfitch/handbag
/handbag/cursor.py
6,161
3.515625
4
import dson import random import math class Cursor(object): def __init__(self, dbm, name, reverse=False): self.dbm = dbm self.name = name self.reverse = reverse self._cursor = None def next(self): if not self._cursor: self._cursor = se...
5c53ea9ba24675a15b108e7c908b8d4bf936dbef
furixturi/ATBS
/mad_libs.py
1,952
4.03125
4
#! /usr/bin/env python3 # mad_libs.py - read in a file with text like ''' The ADJECTIVE panda walked to the NOUN and then VERB. A nearby NOUN was unaffected by these events. ''' # then prompt the user to replace each ADJECTIVE|NOUN|VERB with his/her # own word, print the finished text to screen as well as copy to the #...
3b78404f3bcdb050fd13bc0180384e324dbb130c
swdevbali/modularisasi-python
/models/manusia.py
428
3.640625
4
#encapsulation class Manusia: def __init__(self): self.nama = 'Unnamed' self.usia = 25 self.alamat = 'Jogja' def bicara(self): print('Hoi! Nama saya {}'.format(self.nama)) def __repr__(self): """ Dipanggil saat object di cetak oleh print :return: ...
5d0474fa25c7504d6f4f3c0f5d146ac1cf2931e6
sawantaniket461/RosalindCodes
/Q14_CalculatingOffspringProbability/CalculatingOffspringProbability.py
1,060
3.90625
4
'''Given: Six nonnegative integers, each of which does not exceed 20,000. The integers correspond to the number of couples in a population possessing each genotype pairing for a given factor. In order, the six given integers represent the number of couples having the following genotypes: probabilty of offspring having ...
8331900c3a1c5d994c1b3616e62198af66396cb4
RainbowBite/Project_Eilera
/1-10/py1.py
2,286
4.21875
4
""" Если выписать все натуральные числа меньше 10, кратные 3 или 5, то получим 3, 5, 6 и 9. Сумма этих чисел равна 23. Найдите сумму всех чисел меньше 1000, кратных 3 или 5. """ # создаем переменную = список zed = [] # заполняем список числами от одного до 1000 for i in range(1,1001): zed.append(i) # append запи...
53db807ecffe5342f464ef40fb41e7af5f90001e
MagicWinnie/PythonSchool
/Lesson_5/8.py
830
3.84375
4
data = list(map(int, input().split("."))) if (data[1] < 1 or data[1] > 12): print("Неверная дата") elif (data[1] == 1 or data[1] == 3 or data[1] == 5 or data[1] == 7 or data[1] == 8 \ or data[1] == 10 or data[1] == 12) and (data[0] < 1 or data[0] > 31): print("Неверная дата") elif (data[1] == 4 or data[1] ...
ac448963797d0cb9507f92c2a6b71c1ff524a55c
MagicWinnie/PythonSchool
/Lesson_5/4.py
253
3.921875
4
# -*- coding: utf-8 -*- s = input() if "жы" in s: print(s.replace("жы", "жи")) elif "Жы" in s: print(s.replace("Жы", "Жи")) elif "шы" in s: print(s.replace("шы", "ши")) elif "Шы" in s: print(s.replace("Шы", "Ши"))
6539f2acf6e6f1ce80f9365ac07e9648949bdcf5
MagicWinnie/PythonSchool
/Lesson_5/5.py
80
3.6875
4
s = input() n = 0 for i in s: if i.isnumeric(): n += int(i) print(n)
ea92a69f274fcbe08698fd0d60d03d6246b05dfb
MikkoJo/SchoolWorks
/Python/carTest.py
682
4.03125
4
class Car(): def __init__(self, name = "BMW", kind = "830i", color = "Blue", value = 4000000): self.name = name self.kind = kind self.color = color self.value = value def printModel(self): print(f"Model: {self.name} {self.kind}\nColor: {self.color}\nPrice: {s...
610d81066756ba96e29d6570fd42752916950c44
MikkoJo/SchoolWorks
/Python/javelinScore.py
969
3.765625
4
import statistics NUMBER_OF_THROWS = 6 def calculateAverage(distances): # return sum(distances)/len(distances) return statistics.mean(distances) def printScores(distances): succesfull = len(distances) failed = NUMBER_OF_THROWS - succesfull average = calculateAverage(distances) print...
61d82697168c56930aa548330ba21a8990593d5d
leon1peng/Python004
/Week09+10/homework02.py
243
3.9375
4
def my_map(fun, *iterators): for nums in iterators: yield [fun(num) for num in nums] def my_func(x): return x - 1 if __name__ == '__main__': result = my_map(my_func, [1, 2, 3]) print(result) print(next(result))
59df467be9e4bbf441e505cde8e7b95c0ba142cc
ayan468826/LinkedList-Python-
/LinkedList.py
1,437
3.9375
4
class Node: def __init__(self, data, nextNode=None): self.data = data self.nextNode = None choice = 1 dt = int(input("Enter the value for the root node : ")) Head = Node(dt) Head.nextNode = None while(choice!=0): choice = int(input("\n\n####Enter operation : 0.Exit ; 1.Append Node; 2.Add Node at Pos ; 3....
b15b77753c5241a39900ca8f697e160215d794e3
emersonleite/python
/Introdução a Programação com Python - exercícios baixados do site oficial/Exercícios/exercicio-04-04.py
791
4.34375
4
############################################################################## # Parte do livro Introdução à Programação com Python # Autor: Nilo Ney Coutinho Menezes # Editora Novatec (c) 2010-2014 # Primeira edição - Novembro/2010 - ISBN 978-85-7522-250-8 # Primeira reimpressão - Outubro/2011 # Segunda reimpressão - ...
7988fec9082331a5ca49538884019261be7bc21c
emersonleite/python
/Introdução a Programação com Python - exercícios baixados do site oficial/Exercícios/exercicio-06-07.py
1,014
4.15625
4
############################################################################## # Parte do livro Introdução à Programação com Python # Autor: Nilo Ney Coutinho Menezes # Editora Novatec (c) 2010-2014 # Primeira edição - Novembro/2010 - ISBN 978-85-7522-250-8 # Primeira reimpressão - Outubro/2011 # Segunda reimpressão - ...
c76cdc4f976dad6112dc7bfa06e288e61e890393
feleHaile/20180813JPL
/carddeck.py
1,503
3.59375
4
#!/usr/bin/env python import random class CardDeck(): SUITS = 'C D H S'.split() RANKS = '2 3 4 5 6 7 8 9 10 J Q K A'.split() def __init__(self, dealer): self._dealer = None self._cards = None self.dealer = dealer self._create_deck() @property def id(self): ...
e3749bf78812a259d5b768c4d3ffa045ba67658a
feleHaile/20180813JPL
/EXAMPLES/sieve_generator.py
671
3.734375
4
#!/usr/bin/env python def next_prime(limit): flags = set() # <1> for i in range(2,limit): if i in flags: continue for j in range(2*i,limit+1,i): flags.add(j) # <2> yield i # <3> np = next_prime(200) # <4> for prime in np: # <5> print(prime, end=' ') pr...
cc79a3c818177122420407f775719aa341f9c2a8
mkgame2015/py
/before/hello.py
350
3.546875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # print('hello, world','wo shi dier') # name = input('please input your name :') # print('hello,',name) # n = 123 # f = 456.789 # s1 = 'Hello, world' # s2 = r'Hwllo,\'Adam\'' # s3 = r'Hwllo,"Bart"' # s4 = r'''Hello, # lisa!''' # print(n) # print(f) # print(s1) # print...
7252b1ba7d508d3288158fcafaa41e320a57b9a9
ashahrior/DS_Algo
/binary_search.py
690
4.03125
4
def binary_search_recursive(l, x, left, right): if left>right: print("Not found") mid = left + (right-left)//2 if l[mid]==x: print(str(x) + " found at " + str(mid)) elif l[mid] > x: binary_search_recursive(l, x, left, mid-1) else: binary_search_recursive(l, x, mid+1, right) def binary_search_iterative(l, x,...
4a97d512ff0822c2e6a7826adc7c84cace571db8
ashahrior/DS_Algo
/stack_LL_impl.py
1,444
4
4
class Stack: class __Node: def __init__(self, data): self.__data = data self.__next = None def __init__(self): self.__head = None self.__size = 0 def push(self, data): __node = self.__Node(data) if self.__head is None: sel...
2d9a91ec79806c6e98bea75406d5ceb26e73e669
abdullahgamal17/Comparing-Genes-Proteins-and-Genomes
/Editing Distance.py
1,584
4.0625
4
# Levenshtein introduced edit distance but did not describe an algorithm for computing it, which we leave to you. # Edit Distance Problem: Find the edit distance between two strings. # Input: Two strings. # Output: The edit distance between these strings. # Code Challenge: Solve the Edit Distance Problem. # ...
2b791b5ce1621ce32604a7938b3b1b66d678b2ad
bergm4517/cti110
/P2T1_SalesPrediction_Michael Berg.py
302
3.796875
4
#This is a program that predicts the total profit from sales. #11/4/2018 #CTI-110 P2T1 - Sales Prediction #Michael Berg # total_sales = float(input('Enter the projected sales: ')) profit = total_sales * 0.23 print('The profit is $', format(profit, ',.2f')) input('Press enter to continue.')
bfa217c4cfd8b785ba0a5ff159440b0a79cdf646
vasana12/python_python_git
/python_Source/Test.Py/function06.py
396
4.03125
4
def circle_area(radius, *pi, **info): for item in pi: area = item*(radius**2) print("반지름:",radius,"PI:",item,"면적:",round(area,2)) for key in info: print(key,":",info[key]) if __name__=="__main__": circle_area(3, 3.14, 3.1415, line_color="파랑",area_color="노렁") print() circl...
a9b835e7a00d477db6296ec5c4ed8739935525f6
vasana12/python_python_git
/python_Source/Test.Py/gugudan.py
432
3.828125
4
num1=int(input("첫번째 숫자를 입력하세요=>")) num2=int(input("두번째 숫자를 입력하세요=>")) if num1>num2: max_num=num1 min_num=num2 else: max_num=num2 min_num=num1 print() for dan in range(min_num, max_num+1): print(" ** %d단 ** " % dan, end="") print() for i in range(1,10): for dan in range(min_num,max_num+1): ...
57b92de59c5b856001990e90da8ec8ae226ac808
vasana12/python_python_git
/python_Source/Test.Py/if03.py
920
3.8125
4
#-*-coding:utf8 -*- dict={} dict['hakbun']=input("학번 입력 =>") dict['irum']=input("이름 입력=>") dict['kor']=int(input("국어점수 입력=>")) dict['eng']=int(input("영어점수 입력=>")) dict['math']=int(input("수학점수 입력=>")) dict['total']=dict.get('kor')+dict.get('eng')+dict.get('math') dict['avg']=dict.get('total')/3 if dict.get('avg') >=90...
f547db679d1d1a375d7dbea8c87fc9cc35f0525b
vasana12/python_python_git
/python_Source/Test.Py/class04.py
338
3.734375
4
class Person: def __init__(self, name, age): Person.name =name Person.age = age def aboutPerson(self): print("name :"+self.name+",age: " + str(Person.age)) def __del__(self): print("call del") if __name__ == "__main__": objectPerson = Person("Dominica", 20) objectPer...
f947518288645c559321a707552a219b323f704c
vasana12/python_python_git
/python_Source/untitled2/chapter12/sqlite02.py
633
3.671875
4
#-*-coding:utf-8-*- import sqlite3 import time dbconn = sqlite3.connect('tel.db') dbcursor = dbconn.cursor() name = input("이름:") tel = input("전화번호:") addr = input("주소:") memo = input("메모:") input_time = str(time.asctime(time.localtime(time.time()))) dbcursor.execute("insert into tel(name,tel,addr,input_time,memo)\ v...
d236a0fb9151b6bcfcf58416a0725f38f53e1aa6
vasana12/python_python_git
/python_Source/untitled2/chapter11/thread_j03.py
763
3.890625
4
#-*-coding: utf-8 -*- #Thread객체 생성 자의 매개인자로 스레드 대상, 스레드 이름, 타겟을 호출할 때의 인수 등을 전달함과 #동시에 여러개의 스레드를 실행시키는 코드이다. import threading import time lock = threading.Lock() def Mythread(nsleep): lock.acquire() for i in range(5): print("[%s]%d" % (threading.currentThread().getName(),i)) print(nsleep) ...
ca8b5e080978598b5982ca3ccb04e219afc9aa4e
mohi/PyRssReader
/PyRssReader/outputter/outputwriterinterface.py
425
3.609375
4
import abc class OutputWriterInterface(metaclass=abc.ABCMeta): """ Defines interface for specification to write outputs """ @classmethod def __subclasshook__(cls, subclass): return ((hasattr(subclass, 'write') and callable(subclass.write)) or NotImplemented) @abc.abstr...
67ffe0a6ea4475d7bb0b0ed2a5a0d40ba4e453e0
AoeRunner/HGWZLG6
/python_demo/animal/kitten_class.py
972
3.515625
4
# !/usr/bin/env python # -*- coding = utf-8 -*- # ================================================ # @Time :2021/1/23 0:14 # @Author:汤易怀 # @File :kitten_class.py # @IDE :PyCharm # @Phone :13926528314,微信同号 # ================================================ from python_demo.animal.animal_class import AnimalClass cl...
a92a5371ecbf8a8b7e80695f1935ea44606983fb
davidholmes1999/first-project1
/Holmes_numbergenerator.py
892
4.15625
4
#David Holmes #3/9/17 #Number Simulator #Print Statements print("\nWeclome to the number simulator game! You will be seeing how many guesses it takes for you to guess my number!\n") print("\nFirst let me think of a number between 1 and 100\n") print("\nHmmmmmm...\n") import random #Defining Variables ...
3f58481b021dfec52ee2b15dad5699c7f9bd6aac
Aanchalmittal-123/hangman_game
/hang.py
2,816
3.921875
4
import random def k(): word=random.choice(["pugger","aanchal","himanshu","sulabh","mittal","walia","kaur","simran","amanat","bir"]) v_list="abcdefghijklmnopqrstuvwxyz" turn=10 guess_made='' while len(word)>0: main="" miss=0 for l in word: if l in guess_m...
21d764b5c154ea14771a48b5e0c0d9b0bcac4509
bhagyamudgal/learning-python
/data-types/data-types.py
2,563
4.125
4
# Variables num1 = 10 num2 = 5 num3 = 2 num4 = 3 print("Sum of 10 and 5 is", num1 + num2) print("Differnce of 10 and 5 is", num1 - num2) print("Product of 10 and 5 is", num1 * num2) print("Dividend of 10 and 5 is", num1 / num2) print("Remainder of 10 and 5 is", num1 % num2) print("2 to the power of 3 is", num3**num4) p...
97e60f5987772be03312bb56afd8cf4ef0d069a9
ivanstewart2001/projects
/Variables_Strings/Exercise2.py
253
3.953125
4
while True: user_input = input("Please type something and press enter: ") print("You entered:") print(user_input) finish = input("Continue? Yes/No: ").capitalize().strip() if finish == 'Yes': continue else: break
5c227b785566fa7a29d6944795fc070f4ca262d7
Vicat420/Proj531
/Main.py
2,273
3.625
4
import pygame from Board import Board from Cases import Case from Pieces import Piece,Pion,Cavalier,Fou,Tour,Roi,Reine # We have a main that launches the program def main() : # We create a board which is a matrix of zeros board = Board() # We launch the program pygame.init() # In...
37447abeaaa4a23be479740dbba68113055885be
Deego88/Multi-Paradigm-Programming
/Python/shop_v04.py
16,735
4.09375
4
# Shop simulator in Python procedural v03 # Author: Andrzej Kocielski # Multi-Paradigm Programming, GMIT 2020 # Lecturer: dr Dominic Carr ''' # ===== ===== ===== ===== ===== ===== # Importing external libraries # ===== ===== ===== ===== ===== ===== ''' import os from dataclasses import dataclass, field f...
f4259958dc63fdc988131e510e23512a9040bad9
Carlos-s1/Shitposting-Harder-Than-Obama
/PLTW py/Carlos_Serrano_PLTW_1.3.7 (3).py
493
3.640625
4
import matplotlib.pyplot as plt # standard short name import random plt.ion() # sets "interactive on": figures redrawn when updated def picks(): a = [] # make an empty list # Why all the brackets below? # a += [ brackets here to add an iterable onto a list ] # random.choice( [brackets here...
5176b6f8aa487e63b7b00325c0a8aceee555afcd
Carlos-s1/Shitposting-Harder-Than-Obama
/PLTW py/Carlos_Serrano_PLTW_1.3.4.py
1,366
3.78125
4
def food_id(food): fruits=['apple','banana','orange'] citrus =['orange'] starchy =['banana','potato'] if food in fruits: if food in citrus: return 'Citrus, Fruit' else: return 'Not Citrus, Fruit' else: if food in starchy: return 'Starchy, N...
09299d6accf321e84efee1f6e6a9b9b0ff0790be
DotaArtist/image_classification
/test.py
268
3.578125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = 'yp' def yield_test(list_a): for i in range(len(list_a)): print(i) yield list_a[i] if __name__ == '__main__': a = yield_test(["a", "b", "c", "d"]) for i in a: print(i)
fd74144669b2dfb6dd3ad08b4ad8f029d817b0d3
Dexmo/pypy
/playground.py
1,126
4.21875
4
values = (1,2,3,4,5) #tuple - immutable, orderly data structure squares = [value**2 for value in range(1,11)] #list comprehension ''' 3 short subprogram for quick work ''' print(max(values)) print(min(values)) print(sum(values)) print(squares) '''---------------------------------------''' for number in range(1, 21): ...
da297e3f92c7061eb9c7dbc50b66cc4bafe59329
tkaleas/python-sandbox
/algorithms/binarysearch.py
590
3.875
4
def binary_search(input_array, value): index_start = 0 index_end = len(input_array)-1 # Repeat Until Found or Not In Array (-1) while (index_start <= index_end): index = (index_end+index_start)/2 listVal = input_array[index] if(listVal == value): return index ...
1e9dff6908b706c07bdf2e3371826f9bed0d9429
tkaleas/python-sandbox
/problems/remove_chars.py
1,267
3.984375
4
## PROBLEM # Write an efficient funciton that deletes chars from a mutable string. # INPUT str and remove # Example "Battle of the Vowels: Hawaii vs. Grozny" `aeiou` # Output: "Bttle f the Vwls: HW vs. Grzny" #SOLUTION # construct a hashmap of the removeable characters -> bool map, remove or do not remove. # two poi...
021398f785e043708e29d4efbbc1e52620dafabe
tc-yue/taiyi
/model/candidate_answer.py
935
3.953125
4
""" 候选答案 每一个候选答案都包含答案名称以及分值 """ class CandidateAnswer: def __init__(self): self.__answer = '' self.__score = 1.0 def get_answer(self): return self.__answer def set_answer(self, answer): self.__answer = answer def get_score(self): return self.__score def ...
d2323e74aeda8b1c0748822fe9c7b5c9424301e5
ivanlykhosherst/Pythonrapidtest
/Task17.py
477
3.75
4
# В принимаемом тексте выводит два слова: наиболее часто встречающееся # и самое длинное. from MostFreqWord import most_frequent from ReadJson import read_json data = read_json('task17.json') # Finding longest word longest = max(data.split(), key=len) frequent = most_frequent(data) # Displaying longest word & most...
81f9128777e6d0ad060eb661c77cf72c7ef1fcc4
sloniewski/programing-challenges
/22.BMI_calculator/python/2.7_BMI_calculator.py
1,424
3.75
4
from __future__ import division import re print('Please eneter your:') def validateInput(text): match = re.match('[a-zA-Z]*$', text) if match is None: return True elif match: return False def inputWeight(): weight = raw_input('weight in kilograms: ') if validateInp...
2236b6d466851e75d2e28ff9c23f42bd68e012c4
brandonio/LaTeX-HW-Template
/hwTemplate.py
2,230
3.671875
4
import string lst = string.ascii_lowercase print("\n\n\nWelcome!\n") name = input("What is your name?\n") hw = input("What HW number is this?\n") output = open("CS70__HW" + str(hw) + ".tex", "w") hw = "HW" + hw date = input("When is it due?\n") partners = [] num = int(input("How many people did you work with?\n...