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
2459d4c491e62e50a3231dc18bf275997a842911
yogeshpython/task
/accion/partionable.py
298
3.90625
4
def PartionCheck(user_list): if len(user_list)%2 == 0: print("Entered list"+ str(user_list)+ "is partitionable") else: print("Entered list"+ str(user_list)+ " is not partitionable") user_list = list(input("Please enter the valuse"+" ")) PartionCheck(user_list)
e0dbdd21ec928bb03ab08411fab7a9e3490e62ec
cocoa-maemae/atcoder
/abc/abc162/fizzbuzz_sum.py
362
3.890625
4
def sum(n): return (n * (n + 1)) // 2 N = int(input()) fizz_cnt = N // 3 buzz_cnt = N // 5 fizzbuzz_cnt = N // 15 print(sum(N) - 3 * sum(fizz_cnt) - 5 * sum(buzz_cnt) + 15 * sum(fizzbuzz_cnt)) """ sum of all - sum of 3 multiple - sum of 5 multiple + sum of 15 multiple ---------- ------ -----| 5m | | 15m |...
94c43f54b566c98f9cb53e3fbca960db186fb98f
cocoa-maemae/atcoder
/abc/abc159/maximum_volume.py
135
3.875
4
L = int(input()) print(pow(L / 3, 3)) """ If 3 sides are equal, bulk will be maximum https://img.atcoder.jp/abc159/editorial.pdf """
1a377f69e400f6e0b165b68161c3f15fb97bc759
cocoa-maemae/atcoder
/abc/abc144/water_bottle.py
213
3.5625
4
a, b, x = map(int, input().split()) import math if a * a * b >= x * 2: c = x * 2 / (b * a) print(math.degrees(math.atan(b / c))) else: d = 2 * (b - x / a / a) print(math.degrees(math.atan(d / a)))
0f94d378142472a38e36af21db9663b0b6ba8494
cocoa-maemae/atcoder
/abc/abc105/base_2numbers.py
199
3.625
4
N = int(input()) a = [] if N == 0: a = ["0"] while N != 0: a.append(str(N % 2)) # N mod 2 is same as N mod -2 because remainder is 1 or 0 N = -(N // 2) print("".join(list(reversed(a))))
bf11fb62bb6185041c7fd78d4fc0073706ad2b62
ArKonon/Homework
/lesson_2_task_5.py
561
3.609375
4
my_list = [7, 5, 3, 3, 2] print(f'{my_list} - текущий рейтинг.') rating_num = int(input('Введите ваш балл, (404 - выход): ')) while rating_num != 404: index = None for i, num in enumerate(my_list): if rating_num > num: index = i break if index is None: my_li...
4bda869f09f285c79418e879786f1c44211f3944
Jaimej5/Python
/Diccionario.py
338
3.890625
4
#Variables que son ojetos clave valor product={ "name": "book", "quantity": 3, "price": 2.9 } #diccionario de diccionarios products = [ {"name": 'book', "price": 10.99}, {"name": 'laptop', "price": 1099} ] print(products) print(product.keys()) #imprime sus valores print(product.items()) #imprime...
5d94c39b3d297c62a13af7787212156a1dd04a4c
wonggw/Machine_learning_pipeline_on_AWS
/Lab2/PE-datapreprocesing.py
17,514
3.890625
4
#!/usr/bin/env python # coding: utf-8 # # Practice Exercise – Preprocessing # # The first rule in preprocessing is: **know your data!** # # Therefore, you are going to explore your data over several dimensions and views to bring your raw data to a state of processed data, ready to be used for your model. # # The **...
bce11af97ab61ecc0ea7507f10548e083cf49ddd
nveenverma1/Dataquest
/Practice/12_SQL_n_Databases_Advanced/Using PostgreSQL-114.py
1,366
3.84375
4
## 3. Psycopg2 ## import psycopg2 conn = psycopg2.connect("dbname=dq user=dq") cur = conn.cursor() print(cur) conn.close() ## 4. Creating a table ## import psycopg2 conn = psycopg2.connect("dbname= dq user=dq") cur = conn.cursor() template = ''' CREATE TABLE notes ( id integer PRIMARY KEY, body text, tit...
1c36f5bf5a686c7fe074bf882ef11d16051a18ba
nveenverma1/Dataquest
/Practice/20_Linear_Regression_for_ML/The Linear Regression Model-235.py
2,059
3.65625
4
## 2. Introduction To The Data ## import pandas as pd data = pd.read_csv('AmesHousing.txt', '\t') train = data[:1460] test = data[1460:] print(train.info()) print(test.info()) target = 'SalePrice' ## 3. Simple Linear Regression ## import matplotlib.pyplot as plt # For prettier plots. import seaborn as sns fig =...
61f47ac3aad2b22340c925731ccb828bfe7e871b
degavathmamatha/javascript
/mamatha/even list with function.py
213
3.859375
4
def check_number(n,m): i=0 while i<len(n): if n[i]%2==0 and m[i]%2==0: print("even") else: print("not even") i=i+1 n=[2,6,18,10,3,75] m=[6,19,24,12,3,87] check_number(n,m)
b720a53ecd1a2e90b73c3a1dcd473c7de3c80508
itsdddaniel/AED
/I Parcial/python/nodos2.py
254
3.65625
4
class Cola: def __init__(self): self.cola=[] def pop(self): return self.cola[0] def push(self, elemento): self.cola.append(elemento) def getCola(self): return self.cola C=Cola() C.push("1") C.push("2") print C.pop() print C.getCola()
6d8be0263e3139f62f1003c98f0ea642c6803630
itsdddaniel/AED
/I Parcial/python/ordenamiento2.py
706
3.609375
4
def Ordenamiento(self): for i in range (len(A)-1,0,-1): for j in range (i): if A[j] < A[j+1]: T = A[j] A[j] = A[j+1] A[j+1] = T A=[7,4,3,5,10,11] Ordenamiento(A) print A def OrdenamientoPorSeleccion(self): for i in range(len(A)-1,0,-1): Mayor=0 for j in range(0,i+1): if A[j]<A[Mayor]: ...
091c814fe8089cd450c4e116f7e7717d3e11391e
itsdddaniel/AED
/I Parcial/python/diccionario.py
398
3.84375
4
diccionario = {"azul":"blue","rojo":"red","verde":"green"} print diccionario["azul"] diccionario["amarrillo"]="yellow" print diccionario del(diccionario["verde"]) print diccionario diccionario = {"Daniel":[19,1.75]} print diccionario equipo = {10:"Paulo",11:"Douglas Costa",7:"Cristiano Ronaldo"} print equipo.get(1,...
655b7a34fc39ea3d014e2315ef7f9eff9ae3bb25
lfuhr/geoQAS
/predicates.py
586
3.9375
4
""" Converts a number of words to a predicate. Used by precise module. """ import re _rexes = [ ("range", 'range'), ("located in", 'in|are there|does have'), ("closest to", 'closest|nearest'), #("distance", 'from|between'), ("near", 'near'), ] _compiled_rexes = [(a,re.compile( '.*(' + b + ')' )) f...
eb7b6302495e29878e2db6ffd4240b8c941a61d0
nasreen94/luminar-python
/flow contols/decisin making/ifelif.py
1,098
4.125
4
# no1=int(input("enter d first no")) # no2=int(input("enter d secnd no")) # no3=int(input("enter d third no")) # if no1>no2: # if no1>no3: # print("largest no is",no1) # else: # print("largest no is",no3) # else: # if no2>no3: # # print("largest no is ",no2) # else: # pri...
14e4f2b79bd7e987b100cf3d3d40184159fd0ca3
sunnyyang1576/Impact-of-Government
/analysis/Sentiment Analysis/src/utils/SenAna_Dictionary.py
2,051
3.859375
4
import pandas as pd import numpy as np def confusion_matrix(test_word,text,label): ''' This function calculates the confusion matrix of the keyword. It returns N11,N10,N01,N00. N11: word in text and text is in label N10: word in text but text is not in label N01: word is not in text but...
2230d96c90277abfb129c817c29e8aef43cfe15b
JIghtuse/exercism-solutions
/python/robot-simulator/robot_simulator.py
1,299
3.765625
4
from enum import Enum class Direction(Enum): NORTH = 0 EAST = 1 SOUTH = 2 WEST = 3 NORTH = Direction.NORTH EAST = Direction.EAST WEST = Direction.WEST SOUTH = Direction.SOUTH DIRECTION_LIST = list(Direction) class Robot: def __init__(self, bearing=Direction.NORTH, x=0, y=0): self.x = x ...
32b18dce35a3a910dcd90249c6662ec279342a7f
JIghtuse/exercism-solutions
/python/pangram/pangram.py
188
3.65625
4
def is_pangram(sentence): alphabet = set(chr(i) for i in range(ord('a'), ord('z') + 1)) letters = set(sorted(sentence.lower())) return len(alphabet) == len(alphabet & letters)
d30e87902b060e3ee5ffe9249453e0c1c1b3b2ec
lchebib/room-to-grow-plant-daycare
/users.py
1,476
4.09375
4
import sqlite3 # information we need: user name, user location, user instances of plants # users # name # location # plants # breed # name #need to to create two tables one for our users and one for out plants #each plant instance will have a property tied to the user so when we want to recall a certain...
c6377152617f214a31292c95b7759d77a689cf59
JuanDAC/holbertonschool-higher_level_programming
/0x04-python-more_data_structures/6-main.py
450
3.640625
4
#!/usr/bin/python3 print_sorted_dictionary = __import__('6-print_sorted_dictionary').print_sorted_dictionary a_dictionary = { 'language': "C", 'Number': 89, 'track': "Low level", 'ids': [1, 2, 3] } print_sorted_dictionary(a_dictionary) print("-" * 50) a_dictionary = { 'az': "3", 'ab': 2, 'aaz': "1", 'ids': [1, 2, 3] }...
df5956e1b73181b9b7cbb00c53061625bdd7085d
JuanDAC/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/0-add_integer.py
289
4
4
#!/usr/bin/python3 """ add integer """ def add_integer(a, b=98): """ add integer """ if type(a) not in [float, int]: raise TypeError("a must be an integer") if type(b) not in [float, int]: raise TypeError("b must be an integer") return int(a) + int(b)
2a70d6a3091d1822857dcf353f1313319717ff5a
JuanDAC/holbertonschool-higher_level_programming
/0x06-python-classes/2-square.py
1,062
4.09375
4
#!/usr/bin/python3 """Class docstrings go here.""" class Square: """Class docstrings go here.""" def __init__(self, size=0): """__init__ constructor method.""" if type(size) is not int: raise TypeError("size must be an integer") if size < 0: raise ValueError("...
6644a5e945b8a98ea50d472b0f2caa352ec5f52c
JuanDAC/holbertonschool-higher_level_programming
/0x02-python-import_modules/1-calculation.py
404
3.640625
4
#!/usr/bin/python3 if __name__ == '__main__': from calculator_1 import add, sub, mul, div a = 10 b = 5 print("{:d} {:s} {:d} {:s} {:d}".format(a, "+", b, "=", add(a, b))) print("{:d} {:s} {:d} {:s} {:d}".format(a, "-", b, "=", sub(a, b))) print("{:d} {:s} {:d} {:s} {:d}".format(a, "*", b, "=", ...
1d3aa3f48f21862ef84f2504529015f498988f8e
JuanDAC/holbertonschool-higher_level_programming
/0x05-python-exceptions/101-main.py
507
3.890625
4
#!/usr/bin/python3 safe_function = __import__('101-safe_function').safe_function def my_div(a, b): return a / b result = safe_function(my_div, 10, 2) print("result of my_div: {}".format(result)) result = safe_function(my_div, 10, 0) print("result of my_div: {}".format(result)) def print_list(my_list, len): ...
b1c3fa918bcbc2fa1ac9f877291389d52eaf0278
JuanDAC/holbertonschool-higher_level_programming
/0x06-python-classes/101-square.py
1,910
4.5625
5
#!/usr/bin/python3 """File with class Square""" class Square: """Class use to represent a Square""" def __init__(self, size=0, position=(0, 0)): """__init__ constructor method""" self.size = size self.position = position @property def size(self): return self.__size ...
d666d415da0c2aaf74a4e2c34c4b24c1c6fa24ef
nsyzrantsev/algorithms_3
/QuickSort/QuickSortTailOptimization_tests.py
574
3.515625
4
from QuickSortTailOptimization import QuickSortTailOptimization from unittest import TestCase import random class QuickSortTailOptimizationTest(TestCase): def test_quick(self): arr = [1,3,4,6,11,5,9,8,2,7] check = sorted(arr[:]) QuickSortTailOptimization(arr, 0, len(arr)-1) self.a...
7a924a7edacaa0b4fe5a19ed46f93cc4a0775444
nsyzrantsev/algorithms_3
/KSort/KSort.py
682
3.765625
4
# https://skillsmart.ru/algo/15-121-cm/i58fbc20d6.html class ksort: def __init__(self): self.items = [None] * 1000 def check(self, s): if len(s) == 3 and s[0] in 'abcdefgh' and \ s[1].isnumeric() and s[2].isnumeric(): return True return False def i...
fd432d8ee94a20a7b1bda6465f12cea74751d793
almazkun/adventofcode2020
/02.py
5,617
3.96875
4
""" --- Day 2: Password Philosophy --- Your flight departs in a few days from the coastal airport; the easiest way down to the coast from here is via toboggan. The shopkeeper at the North Pole Toboggan Rental Shop is having a bad day. "Something's wrong with our computers; we can't log in!" You ask if you can take a ...
683e706efdca1aa56a623716c6392daf37cb6d5a
cpe202fall2018/lab0-rkthomps
/test.py
286
3.59375
4
def bubbles(l): for i in range(0, len(l) - 1): for j in range(0, len(l) - i - 1): if l[j + 1] < l[j]: temp = l[j] l[j] = l[j + 1] l[j + 1] = temp return l l = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1] print (bubbles(l))
2aac08cdac3ed1a5dc6c875d5ebb9f91e900bb81
daveshanahan/python_challenges
/database_admin_program.py
1,848
4.15625
4
log_on_info = { "davids1":"MahonAbtr!n1", "lydiam2":"Password1234", "carlynnH":"scheduling54321", "maryMcN":"Forecaster123", "colinM":"paymentsG145", "admin00":"administrator5", } print("Welcome to the database admin program") username = input("\nPlease enter your username: ").strip...
78fd793c2ca6e3021894ee562e7d7cc5ad32b990
daveshanahan/python_challenges
/Quadratic_Equation_Solver_App.py
1,261
4.375
4
import cmath # print introduction print("Welcome to the Quadratic Equation Solver App") print("\nA Quadratic equation is of the form ax^2 + bx + c = 0.") print("Your solutions can be real or complex numbers.") print("A complex number has two parts: a + bj") print("Where a is the real portion and bj is the imag...
c6ab0fa71832cc589f844da6120d509fedd04a15
daveshanahan/python_challenges
/guess_my_number_game.py
893
4.21875
4
import random print("Welcome to the Guess My Number App") # gather user input name = input("\nHello! What is your name: ").title().strip() # generate random number print("Well " + name + ", I am thinking of a number between 1 and 20.") random_num = random.randint(1,20) # initialise guess counter and get ...
0deda362dc460620ab43364b17599182f1f12e87
daveshanahan/python_challenges
/grade_point_average_calculator.py
2,658
4.4375
4
print("Welcome to the average calculator app") # gather user input name = input("\nWhat is your name? ").title().strip() num_grades = int(input("How many grades would you like to enter? ")) print("\n") # initialise list and append number of grades depending on user input grades = [] for i in range(num_grades...
2a636e258b43c442da48505de0c0994a3b27584b
simamzadeh/Differentiation_with_sympy
/differentiation.py
6,258
4.125
4
# FY1006 module - maths/computing # import libraries import matplotlib.pyplot as plt import numpy as np import sympy as sp x = sp.Symbol('x') # FY1006: Using sympy in python for differentiation # Make sure you look at the video for a walkthrough of how to do the following questions # Then come back here a...
a85f63d5cfc5b211612bb92d388bbfb9526de482
davidac2007/python_tutorials
/numbers.py
2,448
4.5
4
# Python numbers # There are three numeric types in Pythom: # int x = 1 # float y =2.8 # complex z = 1j print(type(x)) print(type(y)) print(type(z)) # Int # Int or integer, is a whole number, positive or negative, without decimals, # of unlimited length. x = 1 y = 366376429 z = -3255522 print(type(x)) print(t...
7b7d2f9aaaf43109d606e4e4a406d83530ca1850
SickanEkman/Labbar
/Labb_1/test.py
2,129
3.9375
4
from itertools import islice from collections import Counter l1_list = [] l1_dict = {} l2_list = [] mapping_list = [] def readfile(): """opens file and reads words to dict""" with open("../../smt/mini.txt", "r") as p_file: print(p_file) try: while True: # tells program to continue...
290a07e0b684a95e04e75412cc9e033f4d21e3a3
fibbo/CircleHTCPP
/CreateData/DataGenerator/Basic.py
7,973
3.5625
4
# Basic classes and functionality of DataGenerator from scipy import stats import math,random,copy class Plane(object): """ Class representing the rectangle within which data points are stored """ def __init__(self,xmin=-1.0,xmax=1.0,ymin=-1.0,ymax=1.0): """ Defining the rectangle Val...
ce76d3ccb5bcb885404d89fc06b5f3546cac09b8
Jehyeok/ProgrammingPractice
/d.py
118
3.875
4
def abs(num) : if num > 0 : return num else : return -num x = raw_input("input message : ") print abs(int(x))
44d864a6f5f5e053f4dbbde3630a66e707cad242
tntll/algorithm-Atom
/Ag-py-Git/Ag-test/test.py
839
3.71875
4
a = [[1]]+[[2]] print(a) a = 13 print(a>>2) a = '123123' for i in a : print(i) a = [1,3,2,4] rowa = [i for i in a] b = a.sort() print(a) print(rowa) a = 2 b = 33 c = a^b print(c) c = c^b class Solution: def FindContinuousSequence(self, tsum): # write code here if tsum < 3: return [] ...
93e5b141e755e4bce5a6b8bec02c097985e8ed2c
tntll/algorithm-Atom
/Ag-py-Git/leetcode-my/001-two-sum.py
1,110
3.640625
4
# Given an array of integers, return indices of the two numbers such that they # add up to a specific target. # You may assume that each input would have exactly one solution, and you may # not use the same element twice. # Example: # Given nums = [2, 7, 11, 15], target = 9, # Because nums[0] + nums[1] = 2 + 7 = 9, # ...
5ea204e1c078ed16c4974c892e58e13527e446fe
ashwinm2/Challenges
/Swap_2Nodes.py
871
3.75
4
# Swap 2 Nodes # Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def swapPairs(self, head): """ :type head: ListNode :rtype: ListNode """ temp = head ...
576827cd1dc5c4ce1b43cc34f06f766990062147
ashwinm2/Challenges
/Reversing_number.py
418
3.71875
4
# Reversing a number class Solution(object): def reverse(self, x): if x < 0: flag = -1 x = x * -1 else: flag = 1 rev = 0 while x: temp = x % 10 rev = temp + rev * 10 x = x / 10 ...
1c5c58c2d611f5c3482f5b6d1ba13de25757a585
ashwinm2/Challenges
/Find_2D_matrix.py
988
3.9375
4
# Find element in 2D matrix class Solution(object): def check(self, temp, length, target): start = 0 end = length - 1 while start <= end: mid = (start + end)/ 2 if target > temp[mid]: start = mid + 1 elif target < temp[mid]: ...
97da221bb8856bb18e29a064d725b850e08774ec
ashwinm2/Challenges
/Convert_number_toanother_Bit.py
488
3.96875
4
# Converting a number to A to B using Bit manipulation p, n = map(int, raw_input().split()) print p, n print "{0:b}".format(p), "{0:b}".format(n) temp = p ^ n a = 1 i = 0 count = 0 # To find the length of a binary number or the most significant bit samp = temp j = 1 # print "{0:b}".format(temp) while 1 < samp: samp...
90044bfe2be66d9a0b4b87ccbf4aef9c2124c08a
AllenMkandla/level_1_programming_katas
/square_code.py
210
4.03125
4
def square(number_to_square): hash_row = "#" * number_to_square for i in range(number_to_square): print(hash_row) num_square = int(input("Enter your integer for squares: ")) square(num_square)
09d3c1a3b13370884b68dcf5f5d08d86c24c8593
csymeme/python
/algorithm/TreePrinter.py
772
3.828125
4
# -*- coding:utf-8 -*- # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class TreePrinter: def printTree(self, root): # write code here if root == None: return [] stack = [root, '#'] res = [] ...
50613d2b704e39b37a51d5bf25ea8cab1eb63474
FLyingLSJ/algo
/python/12_sorts/merge_sort.py
1,476
4.09375
4
""" Author: Wenru """ from typing import List def merge_sort(a: List[int]): _merge_sort_between(a, 0, len(a) - 1) def _merge_sort_between(a: List[int], low: int, high: int): # The indices are inclusive for both low and high. if low < high: mid = low + (high - low) // 2 _merge_sort_b...
87b1a6c86803a5db7df13dbf8de4c0209f725b32
FLyingLSJ/algo
/python/41_dynamic_programming/min_dist.py
1,385
3.953125
4
""" Author: Wenru Dong """ from typing import List from itertools import accumulate def min_dist(weights: List[List[int]]) -> int: """Find the minimum weight path from the weights matrix.""" m, n = len(weights), len(weights[0]) table = [[0] * n for _ in range(m)] # table[i][j] is the minimum dista...
93e2e4f5fef8ce368fe273933aba9dbd8f218233
FLyingLSJ/algo
/python/17_skiplist/skip_list.py
2,896
3.78125
4
""" An implementation of skip list. The list stores positive integers without duplicates. 跳表的一种实现方法。 跳表中储存的是正整数,并且储存的是不重复的。 Author: Wenru """ from typing import Optional import random class ListNode: def __init__(self, data: Optional[int] = None): self._data = data self._for...
43912ca58a6e930359012a0a469de1750108eb5b
FLyingLSJ/algo
/python/38_divide_and_conquer/merge_sort_counting.py
1,230
4.09375
4
#!/usr/bin/python # -*- coding: UTF-8 -*- inversion_num = 0 def merge_sort_counting(nums, start, end): if start >= end: return mid = (start + end)//2 merge_sort_counting(nums, start, mid) merge_sort_counting(nums, mid+1, end) merge(nums, start, mid, end) def merge(nums, start, mid, end...
d1a92512933ca5214a124aadcaa4207ac615a783
Dmitry057/tutorial
/pythonTest.py
89
3.578125
4
import time print("Hello world!") print("time = " + time.strftime("%Y_%B_%d, %H:%M:%S "))
6e5e86c2aae64025bb13a653af91f554366e3a58
rafael146/workufal
/equacao_resolver/utils.py
1,708
3.6875
4
# -*- coding: utf-8 -*- # Autor: Alisson Oliveira from excessoes import * from math import sqrt # dicionario contendo os expoentes usando utf-8 expoentes = {"-":'⁻', "0":'⁰', "1":'¹', "2":'²', "3":'³', "4":'⁴', "5":'⁵', "6":'⁶', "7":'⁷', "8":'⁸', "9":'⁹', "(": '⁽', ")":'⁾'} def expoenteFromChar(cha...
2d6ab69554a9cd3da6fb92d6438a372ef960c9df
leoouyang/csc411
/36/proj2/subplot.py
1,424
4
4
"""Examples illustrating the use of plt.subplots(). This function creates a figure and a grid of subplots with a single call, while providing reasonable control over how the individual plots are created. For very refined tuning of subplot creation, you can still use add_subplot() directly on a new figure. """ import...
776dcaa37cd63882aa21a1aff3ebb9fe0d9d6964
LenHu0725/03_LeetCode-Notebook
/005_MaxBackNum.py
1,024
3.578125
4
def longestPalindrome(self, s): """ :type s: str :rtype: str """ l = len(s) max_length = 0 palindromic = '' for i in range(l): x = 1 while (i - x) >= 0 and (i + x) < l: if s[i + x] == s[i - x]: ...
5408f7cff1b855eb294b0cf06c5d282ed449c496
walterlam/codingbat_python
/list-1.py
4,100
4.15625
4
def first_last6(nums): ''' Given an array of ints, return True if 6 appears as either the first or last element in the array. The array will be length 1 or more. first_last6([1, 2, 6]) → True first_last6([6, 1, 2, 3]) → True first_last6([13, 6, 1, 2, 3]) → False ''' return...
bf4226228202eefcf22e65c84664a3fd6068d457
tik26/gpaAnalyzer
/src/analyzeGPA_us.py
1,446
3.625
4
class AnalyzeGPA_US: def __init__(self, cource_list): self.cource_list = cource_list def get_gpa(self): sum_gp_by_credits = 0.0 sum_credits = 0.0 for cource_dict in self.cource_list: gp_us = self.grade_points_to_gp(cource_dict["grade_points"]) print("{}:...
7134b44ceed0365ae2a2fbefa78cbb2bcef9f7e6
dvd42/Tweet_Classification_Model
/classifier.py
1,952
3.5625
4
import math as m import numpy as np from nltk.stem.lancaster import LancasterStemmer def classify(tweets,table,positives,negatives,p_tweets,n_tweets): """Classify user or hashtag as positive or negative Args: tweets: (:obj: 'str numpy array'): Tweets table: (:obj: 'dict'): Words and its ...
9dda68c3e93388399b7d1026d82efa2d41ea26a5
GuhanSGCIT/Trees-and-Graphs-problem
/The lost one.py
2,750
4.375
4
""" Shankar the Artist had two lists that were permutations of one another. He was very proud. Unfortunately, while transporting them from one exhibition to another, some numbers were lost out of the first list. Can you find the missing numbers? As an example, the array with some numbers missing, arr=[7,2,5,3,5,3]...
e657a54a4c2ca764be48fd4557ca528d33496f90
GuhanSGCIT/Trees-and-Graphs-problem
/Beach volleyball.py
2,225
3.890625
4
""" Question:- In Beach Volleyball tournament , there are usually three people in a team. For each person in the team, you know their scores in three skills - Passing,Setter,Serving. You want to check whether it is possible to order these people (assign them numbers from 1 to 3) in such a way that for each 1 ≤...
beab4e2fe24e2b4855c0506ced45d9392ac623ac
GuhanSGCIT/Trees-and-Graphs-problem
/trains intersect.py
1,779
3.65625
4
""" There are N trains running on M tracks. The i-th train currently has its ends at distances li and ri from the starting of occupied track. Find the minimum value of M such that no two trains intersect or touch each other. Input: First line will contain T, number of testcases. Then the testcases follow. First ...
60652845c16c2840261f73b47b9225abd39ca9b0
GuhanSGCIT/Trees-and-Graphs-problem
/Spell Bob.py
2,515
4.3125
4
""" Varun likes to play with cards a lot. Today, he's playing a game with three cards. Each card has a letter written on the top face and another (possibly identical) letter written on the bottom face. Varun can arbitrarily reorder the cards and/or flip any of the cards in any way he wishes (in particular, he can le...
f115abda2b3c77ac0227864f10ab370a0ec075e4
GuhanSGCIT/Trees-and-Graphs-problem
/Maximum Anagram.py
1,100
3.984375
4
""" Beware! You might lose time on this. Try others and jump back here. So the deal is, you need to find the lexicographically maximum anagram of the given string. Can you do this? timing:1sec level:3 Input First line contains T, the number of test cases. Next T lines contain a string S. Output Print the...
93ef3a8a508942cfcbace7b43db265deeab8a756
GuhanSGCIT/Trees-and-Graphs-problem
/Some_thing.py
3,085
3.5
4
""" Consider the infinite x axis. There are N impacts on this X-axis at integral points (X1,X2,....XN) (all distinct) . An impact at a point Xi propagates such that at a point X0, the effect of the impact is K|Xi−X0|. Given the point X0, N and K. Assume the total impact on X0 is M , find if it is possible to do so. ...
6d71128e02a53f8a047e66f3355298f734cd0e69
GuhanSGCIT/Trees-and-Graphs-problem
/Count the ways.py
1,835
3.734375
4
""" Question:- kosaksi pasapugazh is learning Combinatorics in his college. He find it very interesting to calculate number of ways of going to point (c,d) from point (a,b) in co-ordinate plane. We can take horizontal and vertical steps only and can not visit at a point twice.In a step, you can move one unit on...
72e322dfa3ae40b95b33d9b798822c14d093ae18
GuhanSGCIT/Trees-and-Graphs-problem
/energy savings.py
1,412
3.703125
4
""" There are N towns in a line, numbered from 0 to N - 1. Starting from town 0, we want to reach town N - 1. From town i, we can jump to any town j > i with an energy cost of (j-i)*A[i] + (j2 - i2)*A[i]2, where A[i] for all i are given in input. Find the minimum total energy cost to reach town N - 1 from town 0...
a008d007a7b7d082985040bd9b57fd71397c210b
GuhanSGCIT/Trees-and-Graphs-problem
/Overlapping rectangles-Goldman Sachs.py
2,919
3.75
4
""" Given two rectangles, find if the given two rectangles overlap or not. A rectangle is denoted by providing the x and y co-ordinates of two points: the left top corner and the right bottom corner of the rectangle. Two rectangles sharing a side are considered overlapping. Note : It may be assumed that the recta...
4472990ca9ef518a8e02dfcd668a19b7fcefd1ab
GuhanSGCIT/Trees-and-Graphs-problem
/snake pattern.py
1,244
4.28125
4
""" Given an M x N matrix .In the given matrix, you have to print the elements of the matrix in the snake pattern. i des First line contains two space separated integers M,N,which denotes the dimensions of matrix. Next for each M lines contains N space separated integers,denotes the values. Odes print the sn...
cd808948eeee4839fe8047f9e06856ca6da6e35b
GuhanSGCIT/Trees-and-Graphs-problem
/Find couple.py
775
4.03125
4
""" In a party everyone is in couple except one. People who are in couple have same numbers. Find out the person who is not in couple. In des The first line contains an integer 'N' denoting the size of array. The second line contains N space-separated integers A1, A2, ..., AN denoting the elements of the array. (...
f08875505678f50aee58eeaa2a4e9c265e99bdfd
GuhanSGCIT/Trees-and-Graphs-problem
/Detect Loop in linked list.py
1,354
3.796875
4
""" Given a linked list of N nodes. The task is to check if the the linked list has a loop. Linked list can contain self loop. input: The first line contains a single integer N. The second line contains N space-separated integers A1,A2,…,AN. The third line Contains a single integer X. output: Print the outpu...
6012371aef940cf255e34f4d6960533564924be4
GuhanSGCIT/Trees-and-Graphs-problem
/Guna and grid.py
1,212
4.125
4
""" Recently, Guna got a grid with n rows and m columns. Rows are indexed from 1 to n and columns are indexed from 1 to m. The cell (i,j) is the cell of intersection of row i and column j. Each cell has a number written on it. The number written on cell (i,j) is equal to (i+j). Now, Guna wants to select some cells f...
13b5c6797ec6c04f9b2d8f5df65d891cf2443cc4
GuhanSGCIT/Trees-and-Graphs-problem
/Different string.py
2,454
3.828125
4
""" You are given two strings A, B made up of upper case and lower case letters.You have to check if they are same. Two strings are same if they satisfy both of the following conditions: |A|=|B| Ai=UpperCase(Bi) or Ai=LowerCase(Bi) for every 1≤i≤|A| If any one of the above conditions is not satisfied then the st...
854aaa60ae64bfad0437e34dc81dd41eec255c46
GuhanSGCIT/Trees-and-Graphs-problem
/occurrence.py
842
3.828125
4
""" Question A string consists of char or num denotes the bus,your task is to find the last trip of a given bus k.The last trip is the last occurrence of k in string.If not have trip print 0. Input description First line has string Second line has a char k Output description print the value integer Expla...
d0ae84a9f2cb762c24b70b92ea1cab0e3acbe92d
GuhanSGCIT/Trees-and-Graphs-problem
/Egg Dropping Puzzle-Samsung.py
2,110
4.40625
4
""" Suppose you have N eggs and you want to determine from which floor in a K-floor building you can drop an egg such that it doesn't break. You have to determine the minimum number of attempts you need in order find the critical floor in the worst case while using the best strategy.There are few rules given below. ...
4a32c9ab8bc0933524cda656632c99c93defc807
GuhanSGCIT/Trees-and-Graphs-problem
/Varun matrix.py
2,784
3.609375
4
""" Varun has two matrices A and B, each with N rows (numbered 1 through N) and N columns (numbered 1 through N). Varun may perform the following operation any number of times (including zero): choose an integer i(1≤i≤N), then swap row i and column i in matrix A. (Formally, for each valid j, she swaps Ai,j with Aj...
5d28f9f7ead2d429a716fb140943cbffc94aea3c
nguyen8k/Python-variables
/main.py
415
4.03125
4
# num_char = len (input("what is your name ?")) # new_num_char = str(num_char) # print (" Your name is :" + num_char + " character ") # print ( " Your name is " + new_num_char + " Characters") # a = 123 # b = " i like it" # print (type(a)) # print(type(b)) # a = float("2") # print(1+ a) # print (str(1)+str(a)) get_nu...
8bb4035b6a28148a5c176999b2ddab2c5306e0d8
Umebosh1/challenge8
/cubed.py
133
3.6875
4
import math def cube(): a=input("3乗する数を入れてください") a=int(a) a=math.pow(a,3) print(a)
107af45f5d69abc93010478c5808c3cb08ab432f
NNH2512/testpython3
/test2.py
970
4.03125
4
import re def isPhoneNumber(text): if len(text) !=12: return False for i in range(0,3): if not text[i].isdecimal(): return False if text[3] !='-': return False for i in range(4,7): if not text[i].isdecimal(): return False if text[7] !='-': ...
7c2e92172c019c38075f9f8d644511181239f0d0
anjaligeda/Pythonstring-branch
/lnbsplitlist.py
481
3.71875
4
#adding elements in list q=[] for i in range(20): a=int(input('enter number = ')) q.append(a) print(q) #slicing the list l2=q[0:5] l3=q[15:20] l4=l2+l3 print(l4) #squaring the elements of list square=[i**2 for i in l4 ] print(square) #splitting the list length = len(l4) middle_index = length ...
cbc7d523b97ec18e747d0955b769c475c6935aff
alfonso-torres/eng84_OOP_exercises
/Fizzbuzz.py
1,403
4.4375
4
# Exercise 1 - Fizzbuzz # Write a program that outputs sequentially the integers from 1 to 100, but on some conditions prints a string instead: # when the integer is a multiple of 3 print “Fizz” instead of the number, # when it is a multiple of 5 print “Buzz” instead of the number, # when it is a multiple of both 3 an...
873d3b56441924fcfda25f9cc6fbc34b1b4bdbc8
datacenter/nexus9000
/nexusdash/utils/qaes.py
1,516
3.578125
4
''' http://www.tylerlesmann.com/2008/dec/19/encrypting-database-data-django/ ''' #!/usr/bin/env python import string from random import choice from Crypto.Cipher import AES EOD = '`%EofD%`' # This should be something that will not occur in strings def genstring(length=16, chars=string.printable): return ''.join(...
a14f8ffdfe632cfa0c73976d8baa2b946513e117
3652365/Euler-Problems
/problem10.py
423
3.84375
4
#!/usr/bin/python ''' Problem10 The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of all the primes below two million. ''' def is_primes(num): for i in range(2, num / 2 + 1): if (num % i == 0): return False return True result = 0 for k in range(2 * 1000000): if (is_p...
dcf9336eb7fb2441093422191d6d211ebdeba3a6
3652365/Euler-Problems
/problem14.py
1,253
4.03125
4
#!/usr/bin/python ''' Problem 14 Longest Collatz sequence The following iterative sequence is defined for the set of positive integers: n --> n/2 (n is even) n --> 3n + 1 (n is odd) Using the rule above and starting with 13, we generate the following sequence: 13 --> 40 --> 20 --> 10 --> 5 --> 16 --> 8 --> 4 -->...
1311325a64120f621099e2d1754cddbbc3b0b0e9
rituzy/bet_bot
/service/hockey_game_stats.py
1,016
3.546875
4
"""HockeyGame decorator for gathering statistics""" class HockeyGameStats: """HockeyGame decorator for gathering statistics""" def __init__(self, game): self.game = game self.match_total = None def calculate(self): """Logic to figure out the game statistics""" try: ...
6b4d882519ba7e7afd6537aceeea6cc5cc14d1e6
Dagurf21/Forritun.1hluti
/Verkefni3.py
4,115
3.890625
4
#Liður 1 num1 = int(input("Sláðu inn heiltölu: ")) print ("Þú hefur vailð töluna:",num1,) num2 = input("Villtu slá inn aðra tölu?: ") #Forrit fær heiltölu frá notanda og birtir hana á skjáinn, einnig er spurt hvort notandi vilji endurtaka forritið while num2 == "já": num3 = int(input("Sláðu inn ...
d893a6cafae4f9dc5e0a4a151a5da84ec0acbcb5
SandySY/Python-notes
/day/demo2.py
814
3.6875
4
#捕获异常 try: print('----test--1--') f = open('123.txt', 'r') print('-----test----2--') except IOError: pass try: print(num) # except IOError: # print("产生错误了") # except NameError: # print("未定义") # except (IOError, NameError): # print("有多种可能异常发生") # except NameError as result: # pri...
e4744f1b11d4af7d4bc0480e7b384014ee3d502f
lilianarondon/pdsnd_github
/bikeshare.py
7,515
4.34375
4
import time import pandas as pd import numpy as np CITY_DATA = { 'chicago': 'chicago.csv', 'new york city': 'new_york_city.csv', 'washington': 'washington.csv' } MONTHS = ['all', 'january', 'february', 'march', 'april', 'may', 'june'] DAY = ['all', 'monday', 'tuesday', 'wednesday', 'thursda...
9944660718d8207942508f7e98a2c66b582aa4d7
saikatkar/ds-algos
/python/sorting/SelectionSort.py
275
3.5625
4
A = [64, 25, 12, 22, 11,8,23] for i in range(len(A)): min = A[i] minIdx = i for j in range(i+1,len(A)): if A[j] < A[minIdx]: minIdx=j A[i],A[minIdx] = A[minIdx],A[i] print("Sorted array") print(A) for i in A: print ( i ,end=' ')
6ed4d522eed64bb845676e0b9bcbd24e21ffa1ff
taroserigano/coderbyte
/Arrays/Consecutive.py
737
4.1875
4
''' Consecutive Have the function Consecutive(arr) take the array of integers stored in arr and return the minimum number of integers needed to make the contents of arr consecutive from the lowest number to the highest number. For example: If arr contains [4, 8, 6] then the output should be 2 because two numbers ne...
4d03565e948a1b5f093d0ff0cb589ead794f8d21
taroserigano/coderbyte
/Trees & Graphs/SymmetricTree.py
1,203
4.5
4
''' Symmetric Tree HIDE QUESTION Have the function SymmetricTree(strArr) take the array of strings stored in strArr, which will represent a binary tree, and determine if the tree is symmetric (a mirror image of itself). The array will be implemented similar to how a binary heap is implemented, except the tree ...
846bbc9c8b053e25f3e1699a24ee7f513ce10ee6
DonovanTarsis/Aprendizagem-Python
/PythonExercicios/ex061.py
157
3.796875
4
pt = int(input('Digite o primeiro termo da P.A.:')) r = int(input('Digite a razão da P.A.:')) c = 0 while not c == 10: print(pt) pt += r c += 1
0663b3ab1c17722264343722bb56c96725213329
DonovanTarsis/Aprendizagem-Python
/PythonExercicios/ex026.py
264
3.796875
4
f = str(input('Digite uma frase:\n')).strip().upper() a = f.count('A') pa = f.find('A') + 1 ua = f.rfind('A') + 1 print(f"""A letra "A" aparece {a} vezes na frase. A primeira letra "A" apareceu na posição {pa}. A última letra "A" apareceu na posição {ua}""")
8406db5c0f8dfc48b6f22cdb95d3b6e092cb6f86
DonovanTarsis/Aprendizagem-Python
/PythonExercicios/ex068.py
877
3.734375
4
from random import randint print('-=-' * 9, '\nVamos jogar par ou ímpar.') print('-=-' * 9) c = 0 while True: jogador = int(input('Digite um número:')) pi = str(input('Par ou Ímpar?[P/I] ')).strip().upper()[0] while pi not in 'PI': print('Opção inválida. Tente novamente') pi = str(input('Par...
a2df85e6fdf79235ab13c453439cdf7eeaafc477
DonovanTarsis/Aprendizagem-Python
/PythonExercicios/ex054.py
314
3.609375
4
from datetime import date y = (date.today().year) ma = 0 me = 0 for c in range(0, 7): a = int(input('Digite seu ano de nascimento:')) i = y - a if i >= 21: ma += 1 else: me += 1 print(f'{me} pessoas ainda não atingiram a maior idade. \n{ma} pessoas já atingiram a maior idade.')
89caf2e2ea17dbab409725ab6187da488b7d5eb9
DonovanTarsis/Aprendizagem-Python
/PythonExercicios/ex029.py
336
3.734375
4
v = int(input('Digite sua velocidade em km\h:\n')) m = (v - 80) * 7 if v > 80: print(f"""Você foi multado por excesso de velocidade. A multa por excesso de velocidade é de R$7,00 para cada km excedido do limite de 80km/h. Sendo assim, sua multa totaliza o valor de R${m:.2f}""") print('Tenha um bom dia! Dirija com ...
4cec0e5d23557c23d6c7a970d9513a3a7d37fca6
DonovanTarsis/Aprendizagem-Python
/PythonExercicios/ex031.py
184
3.578125
4
d = int(input('Qual a distância que irá viajar?\nDigite a distância em km:')) if d <= 200: v = d * 0.50 else: v = d * 0.45 print(f'O valor da sua passagem é de R${v:.2f}')
4a8a50e3bbd7ae40ce4464c389a7cc0ba01574bf
DonovanTarsis/Aprendizagem-Python
/PythonExercicios/ex009.py
353
3.984375
4
n = int(input('Digite um número inteiro:')) a = n*1 b = n*2 c = n*3 d = n*4 e = n*5 f = n*6 g = n*7 h = n*8 i = n*9 j = n*10 print('_'*13) print(' {0}x1 = {1}\n {0}x2 = {2}\n {0}x3 = {3}\n {0}x4 = {4}\n {0}x5 = {5}\n {0}x6 = {6}\n {0}x7 = {7}\n {0}x8 = {8}\n {0}x9 = {9}\n {0}x10 = {10}'.format(n, a, b, c, d, e...
75bb3cbcba0b24a5487276691650603e261e416d
mgomez9638/CIS-106-Mario-Gomez
/Assignment 8/Activity 1.py
668
4.40625
4
# Activity 1 # This program gives the user access to create a multiplication table. # You simply begin with entering a value, entering a starting point, and the size of the table. def getExpressions(): print("Enter the number of expressions") expressions = int(input()) return expressions def getValue...
bf3a761daa923e3fc486c37ed4a522d4cbb57d45
mgomez9638/CIS-106-Mario-Gomez
/Assignment 5/Activity 6.py
2,061
4.34375
4
# Activity 6 # This program is intended to determine how much paint is required to paint a room. # It, also, expresses how much the gallons of paint cost. def get_length(): length = float(input("Enter the length of the room(in feet): ")) return length def get_width(): width = float(input("Enter the...
3031e95c3286a9b596e179e6e08b8903b99625ba
mgomez9638/CIS-106-Mario-Gomez
/Assignment 4/Activity 3.py
439
4.15625
4
# Assignment Three # This program gives the user access to calculate the distance in U.S. standard lengths. # It converts miles into yards, feet, and inches. print("Enter distance in miles: ") miles = float(input()) yards = 1760 * miles feet = 5280 * miles inches = 63360 * miles print("The distance in yards is " +...