blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
3c9d353b622b33ced30f2d68c00928ef1f6c1394
thenol/Leetcode
/Search/79. Word Search.py
1,602
3.90625
4
''' Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or vertically neighboring. The same letter cell may not be used more than once. Example: board = [ ['A','B','C','E'], ['S','F...
fd4e26a6f688c13b6c401f639867310aa1ac8c3e
privateOmega/coding101
/hackerearth/CodeMonk/Basic Programming/Basics of IO/seating-arrangement.py
2,177
4.03125
4
def calculate_seat(addOperation, seatNumber, operand, seatType): if addOperation: return '{} {}'.format(seatNumber + operand, seatType) else: return '{} {}'.format(seatNumber - operand, seatType) def get_seating_arrangement(seatNumber): workableValue = seatNumber % 12 switcher = { ...
4874a015b6257229d709e97e80e71651edc190eb
haifeng-jin/codejam
/2016/r1b/a.py
710
3.609375
4
for case_num in range(int(input())): print('Case #%d: ' % (case_num + 1), end='') st = input() letter_count = {chr(char): st.count(chr(char)) for char in range(ord('A'), ord('Z') + 1)} words = ['ZERO', 'SIX', 'SEVEN', 'FIVE', 'EIGHT', 'THREE', 'TWO', 'FOUR', 'NINE', 'ONE'] letters = ['Z', 'X', 'S',...
f02eb979185ccfc5e078b165d485444383e30b34
The-Radiant-Sun/Cypher_Playground
/Codes/Vigenere.py
1,924
3.78125
4
# Vigenere cypher class VigenereCypher: def __init__(self, message, key): """Save char_set, message and key as self variables""" self.char_set = [char for char in (chr(i) for i in range(32, 127))] self.message = message self.key = self.check_error(key) @staticmethod def hist...
3ee95c61df1d7d8561cf9c444ae169862c266a07
BboyZander/CodeWars
/[6kyu]/[6kyu] create_phone_number.py
566
4.125
4
# Функция, которая записывает номер телефона в определенном формате def create_phone_number(n): m = [str(i) for i in n] elements = [m[:3],m[3:6],m[6:]] first = '(' + ''.join(elements[0]) + ') ' second = ''.join(elements[1])+'-' third = ''.join(elements[2]) return first + second + third def cre...
54ebc9083b70a98db8a70fc1a6541885e6f5eaf4
MarieDon/Cloud
/samples.py
468
3.875
4
def miles_to_feet(miles): print (5280*miles) miles_to_feet(13) def total_seconds(hours,minutes,seconds): print (hours *3600 + minutes *60 +seconds) total_seconds(7, 21, 37) def is_even(number): if number % 2 == 0: print("True") else: print("False") is_even(5) def name_and_age(n...
28754e483584b8086d4ab6661f9a40b885af61b7
kowshik448/python-practice
/python codes/pairsum.py
1,292
3.8125
4
class Node: def __init__(self,data): self.data=data self.left=None self.right=None class BST: def __init__(self,data): self.root=Node(data) def insert(self,root,data): if root is None: return Node(data) elif root.data==data: ...
c3c436157ce035b2fb860db0d719cbbe46e40e80
jkoser/euler
/solved/p44.py
851
3.90625
4
#!/usr/bin/env python3 # Pentagonal numbers are generated by the formula Pn = (3n - 1) / 2. The # first ten pentagonal numbers are: # # 1, 5, 12, 22, 35, 51, 70, 92, 117, 145, ... # # It can be seen that P4 + P7 = 22 + 70 = 92 = P8. However, their # difference, 70 - 22 = 48, is not pentagonal. # # Find the pair of p...
a398b13e6f88a70bec40b007228369cfe0556a88
superpigBB/Happy-Coding
/Algorithm/Sum of Two Integers.py
963
4.15625
4
# Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -. # # Example: # Given a = 1 and b = 2, return 3. # # Credits: # Special thanks to @fujiaozhu for adding this problem and creating all test cases. ### Original Method: ### This should be basic knowledge of how to transform ...
2d8cf44446c0690136fef92d532032fc1247a4ad
dubonzi/estudos
/python/Lista2CT/exe4.py
326
4.09375
4
valor = input("Digite o 1º número:") num1 = float(valor) valor = input("Digite o 2º número:") num2 = float(valor) soma = num1 + num2 multiplicacao = num1 * num2 divisao = num1 / num2 resto = num1 % num2 print(f"Soma:{soma}") print(f"Multiplicação:{multiplicacao}") print(f"Divisão:{divisao}") print(f"Resto:{resto}")
60a978f6a833207d35bbc0ad92f130e239f1c302
iisojunn/advent-of-code-2020
/day4-passport-protection/main.py
1,960
3.625
4
"""Day 4 advent of code 2020""" import re REQUIRED_FIELDS = {"byr", "iyr", "eyr", "hgt", "hcl", "ecl", "pid"} def passport_dict(chunk): fields = chunk.replace("\n", " ").rstrip().split(" ") return {k: v for k, v in [field.split(":") for field in fields]} def read_input(): with open("input", "r") as inp...
4badacf85290ab2a74cd0897cefd3f4b647cf84d
nicolasmancera/Insertion_sort
/insertion_sort.py
195
3.84375
4
def insertion_sort(lista): for p in range (1,len(lista)): valor=lista[p] i=p-1 while i>=0: if valor < lista[i]: lista[i+1] = lista[i] lista[i]=valor i=i-1 else: break
03cbc768200366cfc81b0a489a3d98c1dfff9b02
jazhten/python
/similar_list.py
447
3.9375
4
import random #this could also be used to show/test Pigeon hole principle len1 = int(input('Enter length of the first list: ')) len2 = int(input('Enter length of the second list: ')) list1 = random.sample(range(100),len1) list2 = random.sample(range(100),len2) print('list one :' + str(list1)) print('list two :' + s...
f3d14dc0ed2d6ad7a5fffcf7b3ee3aee3bd13c98
HuipengXu/leetcode
/reverse.py
267
3.8125
4
def reverse(x): """ :type x: int :rtype: int """ if x >= 0: reverse_x = int(str(x)[::-1]) else: reverse_x = - int(str(abs(x))[::-1]) if reverse_x > 2 ** 31 - 1 or reverse_x < -2 ** 31: return 0 return reverse_x
177a5afbe29feff781f99a892f9d71b7b51d9970
RafaelBispoCunha/Curso_em_Video
/Curso_Python3_Mundo1/exercicio_016.py
278
3.90625
4
''' Crie um programa que leia um número Real qualquer pelo teclado e mostre na tela sua porção inteira. 13/01/2020 ''' from math import trunc numero = float(input('Digite um valor qualquer: ')) print('A porção inteira do numero {} é de {}'.format(numero, trunc(numero)))
fb43f3fdaf39cf2f85e1b9397c6641d8f53b8b14
geniousisme/CodingInterview
/Company Interview/SC/meetingRoomII.py
1,169
3.578125
4
# Definition for an interval. # class Interval(object): # def __init__(self, s=0, e=0): # self.start = s # self.end = e class Solution1(object): def minMeetingRooms(self, intervals): """ :type intervals: List[Interval] :rtype: int TC: O(nlogn) SC: O(n) ...
b62c78a58ec2d1ca63b5147d9ab03bbba5a2a847
MayraMRossi/Codo_A_Codo_4.0--Python
/Clases/PYTHON - Ejemplos/ejemplos-python-3/diccionarios.py
593
4.3125
4
# DICCIONARIOS # Ejemplos de diccionarios {} # diccionario vacío {'Juan': 56} # diccionario de un elemento {'Juan': 56, 'Ana': 15} # diccionario de dos elementos # Creación: Por extensión diccionario = {'Juan': 56, 'Ana': 15} print(diccionario) # Creación: Por compresión diccionario = {...
cbe12849f009cf790e12a6a94800b90bab6ae8a5
50417/phd
/learn/ctci/0104-escape-string.py
2,060
4.4375
4
from absl import app # Exercise 1.4: # # Write a method to replace all spaces in a string with '%20'. You # may assume that the string has sufficient space at the end of # the string to hold the additional characters, and that you given # the "true" length of the string. # # First off, let's get the o...
1f38806edac48cfa9422c668dccb56034029dc7f
David-Carrasco-Vidaurre/trabajo04.CarrascoVidaurreDavid
/Calculadora03.py
306
3.609375
4
#calculadora nro3 #esta calculadora realiza el calculade de la potencia #declaracion de variables trabajo,tiempo,potencia=0.0,0.0,0.0 #calculadora trabajo=18 tiempo=9 potencia=(trabajo//tiempo) #motrar datos print("trabajo =",trabajo) print("tiempo =",tiempo) print("potencia=",potencia)
c07f2d2aee46063041bbdfd704730496c98484bc
gaurav638012/SURP_IPL
/Week2/stats.py
2,672
3.578125
4
import pandas as pd #This function will take player name as input and output is dict in the form - #{match_id: [innings, batting position, runs scored, balls faced, strikerate, out/notout, 50, 100, runs in powerplay, runs in middle overs, runs in death overs, result of match, str in first 20, str in next 10, str after...
ba4bdecaba6569f57bcf30754491acfdc30ca103
rajat-jain9/python
/excel.py
2,075
3.53125
4
import pandas as pd df = pd.read_excel(r"./test data_Malkajgiri.xlsx") #print(df) df2 = df.set_index("#") print(df2) ### 1) INDEXING###### print(df2.loc[1:5,"From":"To"]) print(df2.loc[: ,"To"]) print(df2.head(2)) OR print(df2.loc[1:2,"ID":"Booking History"]) (For first two rows) print(df2.tail(2)) (Fo...
1743307e92942f4324451c3ebdf31315cf8ccdf6
sumitsethtest/Python-67
/Alien_invasion/ship.py
2,923
3.53125
4
# coding=utf-8 import pygame from pygame.sprite import Sprite class Ship(Sprite): def __init__(self, ai_settings, screen): """初始化飞船并设置其初始位置""" super(Ship, self).__init__() self.screen = screen self.ai_settings = ai_settings # 加载飞船图像并获取其外接矩形 self.image = pygame.imag...
fabb46f73fd5920a7db1a5a4c330c1f7d47d6bb2
brackengracie/CS-1400
/Class_average.py
779
4.03125
4
# Class Average by Gracie Bracken def main() : # print instructions print("This program inputs test scores") print("and calculates the average.") print("") # get the # of students number_students=input("please enter the number of students -> ") number_students=int(number_students) ...
8a95aa4ba4b867852e03aab0bcb879b837790b06
supernifty/dovex
/util.py
248
3.546875
4
def choose_delimiter(fh): start = (fh.readline(), fh.readline()) if start[0].count('\t') >= 1 and start[0].count('\t') == start[1].count('\t'): delimiter = '\t' else: delimiter = ',' fh.seek(0) return delimiter
ca3a018ba6b17a539aee8ed4539e32db117af83f
MychalCampos/Udacity_CS101_Lesson3
/measure_udacity.py
608
3.859375
4
# -*- coding: utf-8 -*- """ Created on Fri Jun 26 13:35:29 2015 # Define a procedure, measure_udacity, # that takes as its input a list of strings, # and returns a number that is a count # of the number of elements in the input # list that start with the uppercase # letter 'U'. @author: Mychal """ def measure_udaci...
d707ba68840748f3e9736999ceb64c589c635bfe
thiagosousadasilva/Curso-em-Video
/CURSO DE PYTHON 3/Mundo 3 - Estruturas Compostas/1 - Tuplas em Python/Exerc077.py
519
4.15625
4
''' Exercício Python #077 - Contando vogais em Tupla: Crie um programa que tenha uma tupla com várias palavras (não usar acentos). Depois disso, você deve mostrar, para cada palavra, quais são as suas vogais. ''' print("== Exercício Python #077 - Contando vogais em Tupla ==") palavras = ('thiago', 'sousa', 'sofia', '...
f1b8b884adb7c7601a16d8360aa5012c65decc31
Baalajisk/pythonPrograms
/week2_2p.py
497
3.78125
4
def depth(string): total=0 inc=0 dec=0 count=0 for i in string: if i=='(': inc=inc+1 count=count+1 elif i==')': dec=dec+1 if inc==dec: if count>total: total=count ...
be22bce00e4a152a337f08e3b727180422836ed7
ygorfds/1_Exercicios_Python3
/7_LISTA1.py
424
4.1875
4
""" 7. Faça um Programa que calcule a área de um quadrado, em seguida mostre o dobro desta área para o usuário. """ # LISTA 1 - EXERCÍCIO 7 print('Cálculos geométricos: quadrado') b = float(input('Entre com o valor da base em milímetros:')) h = float(input('Entre com o valor da altura em milímetros:')) area = b*h prin...
790eea7941c1ec85dea3a33d220e82d8089036c1
nmoore32/coursera-fundamentals-of-computing-work
/1 An Introduction to Interactive Programming in Python/Week 7 and 8/Mini project for week 7 and 8/asteroids_clone.py
14,243
3.78125
4
# program template for Spaceship # Provided via An Introduction to Interactive Programming in Python (Part 2) (Coursera, Rice University) import SimpleGUICS2Pygame.simpleguics2pygame as simplegui from math import cos, pi, sin, sqrt from random import random, randrange # Hide the simplegui control panel area simplegui....
3094f53640d45deb4eb3a0bcda0496f36326f5bf
omar1slam/Code-Wars
/Multiples of 3 & 5.py
435
3.875
4
# Find multiples of 3 and 5 below the number given # https://www.codewars.com/kata/514b92a657cdc65150000006/train/python # 6 kyu def solution(number): found = [] for i in range(number-1,0,-1): if (i % 3) == 0 or (i % 5) == 0: if i not in found: found.append(i) ...
2d36f3a77acbddea594a50263af67e41971b583d
bitterengsci/algorithm
/九章算法/强化班LintCode/Word Search II.py
4,092
3.875
4
DIRECTIONS = [(0, -1), (0, 1), (-1, 0), (1, 0)] class TrieNode: # define node in a trie def __init__(self): self.children = {} self.is_word = False self.word = None class Trie: def __init__(self): self.root = TrieNode() def add(self, word): # insert the wor...
f5cc79eca4426aefcc3220491a3d953d0e6f8b65
DevGusta/AplicacaoPython
/ListaTarefas/main.py
863
3.796875
4
from opcaoTarefas import addTarefas, listarTarefas, desfazer, refazer tarefas = [] excluidos = [] while True: print("#" * 50) print("1. Adicione uma tarefa.") print("2. Liste suas tarefas.") print("3. Desfaça sua última alteração.") print("4. Refaça sua última alteração") opca...
bfd227edc6b79aed92e3a4357e1091aa0690ee25
phibzy/InterviewQPractice
/Solutions/CourseSchedule/courseSchedule.py
4,004
4.125
4
#!/usr/bin/python3 """ Takes in numCourses(int) and prerequisites (list of list of int) aka graph edges Returns if possible to finish all courses Questions to Interviewer: - Will there be redundant prereqs? E.g. [[1,0], [2,1], [2,0]] - Multiple prereqs? - Max numCourses? - Range of prereqs size? Alg...
f9a38cd6067ee20c8e7604db2e2c2c23b9b6f507
mccornet/leetcode_challenges
/Python/0167.py
1,659
3.84375
4
class Solution: def twoSum(self, nums: list[int], target: int) -> list[int]: """ ## Challenge: Given an array of integers numbers that is already sorted in non-decreasing order, find two numbers such that they add up to a specific target number. Return the indi...
24d3541ed5122c20cd1d7c10955025689b3f3541
michnik3/Python
/Lesson6/ask4.py
199
3.71875
4
primes_list = [] for N in range(2,100+1): for i in range(2,N): if N % i == 0: break else: print("It's prime") primes = tuple(primes_list) print(primes)
7ede1bbe6fac1040529944e8637f819db14ffc43
justinbourb/coding_challenges
/code_challenges_python/google_round_f_2021_festival_2.py
2,668
3.59375
4
""" Problem Festival You have just heard about a wonderful festival that will last for D days, numbered from 1 to D. There will be N attractions at the festival. The i-th attraction has a happiness rating of hi and will be available from day si until day ei , inclusive. You plan to choose one of the days to attend t...
47e09c4881150ee24fd0992596e6a1257c702161
GregFriedlander/Python-Stack
/OOP/hospitalsolution.py
2,201
3.59375
4
class Patient(object): PATIENT_COUNT = 0 def __init__(self, name, allergies): self.name = name self.allergies = allergies self.id = Patient.PATIENT_COUNT self.bed_num = None Patient.PATIENT_COUNT += 1 class Hospital(object): def __init__(self, name, cap): sel...
ba61a1f46c8cd9fcff0e6ff65ab0ff3940f506eb
korysas/MIT-6.00.1x
/problem-set-1/vowels.py
664
4.0625
4
"""program that counts the number of vowels in a string""" def main(): res1 = vowels_in_string('azcbobobegghakl') print_result(res1) res2 = vowels_in_string('hello') print_result(res2) res3 = vowels_in_string('HELLO') print_result(res3) def vowels_in_string(string): """accepts a string a...
d57d9aa8e99b69d71646cabaf17534300a000758
Julianhm9612/seti-python-course
/stage-1/conditionals.py
728
4
4
x = 10 y = 1 color = 'blue' first_name = 'Julian' last_name = 'Henao' # < > <= <= == if x < 30: print('X is less than 30') else: print('X is greater than 30') if color == 'red': print('The color is red') else: print('Any color') if color == 'yellow': print('The color is yellow') elif color == 'b...
4fdf333f8af81e44903a957485d954bc6784e43f
joetechem/python_tricks
/pascal/pascals_calc.py
490
3.953125
4
def pascal(previous_row): next_row = [1] # working formatting def numberFormat(number): if number > 10: return " " + str(number) + " " else: return " " + str(number) + " " for i in range(len(previous_row)-1): next_row.append(previous_row[i] + previous_row[i+1]) next_row.append(1) return next_ro...
2b1b59c65341bd3d1ac896952c5a80d5d18c1a43
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_118/1139.py
757
3.8125
4
#! /usr/bin/python from sys import argv,exit from math import sqrt def palindrome(n): s = str(n) return s == s[-1::-1] def not_is_square(n): return sqrt(n) != int(sqrt(n)) def square_palindrome(n): if not_is_square(n): return False sq = int(sqrt(n)) return palindrome(sq) def analizar_linea(s): a = int(s.s...
1bdb6aa475f96e2cf27ff4aa3d4bc5237476c26e
MrHamdulay/csc3-capstone
/examples/data/Assignment_8/mthsfi005/question1.py
292
4.0625
4
def backward(s): if s=='': return '' else: return backward(s[1:]) + s[0] def main(): c = input('Enter a string:\n') if c == backward(c): print('Palindrome!') else: print('Not a palindrome!') main()
c2ee4fe42af7a23a233367a4d8db77d339437c1f
zeeking786/BSCIT_PYTHON_PRACTICAL
/PRACTICAL-7/Pract_3.py
1,569
4.15625
4
""" Create a class called Numbers, which has a single class attribute called MULTIPLIER, and a constructor which takes the parameters x and y (these should all be numbers). i. Write a method called add which returns the sum of the attributes x and y. ii. Write a class method called multiply, which takes a single number...
48b15e5372d144965e1ace9a3bf5e1c1003e4daf
Palash51/Python-Programs
/program/dictionary_sort.py
424
4.125
4
def sortByValue(dictionary): tmp = [] for key,value in dictionary.items(): tmp.append((value,key)) tmp.sort() return tmp def sortByKey(dictionary): tmp = [] for key,value in dictionary.items(): tmp.append((key,value)) tmp.sort() return tmp #test the sorts. ...
037782e55e9b1f3a522c3afe0f98d35f281d4c54
phylp/NerdTalk
/algorithmic_toolbox/sort/swap_sort.py
332
4.03125
4
#Uses python3 #runtime is quadratic #swap based on index values def swap(a, x, y): temp = a[x] a[x] = a[y] a[y] = temp def swap_sort(a): for i in range(0, len(a)): min_index = i for j in range(i+1, len(a)): if a[j] < a[min_index]: min_index = j swap(a, min_index, i) return a print(swap_sort([5,3...
643f6968a3431ea006d80b4b8f5227b9129ab37d
Jasmine-syed2197/PYTHON_LAB
/count/11.py
111
3.71875
4
s=input("Enter the sentence :") li=s.split() s=set(li) d={} for i in s: d[i]=li.count(i) print(d)
3aec1078c0288f9c079c475952b2aa0e31626e86
Coders222/Shared
/CCC/CCC 12 J3 Icon Scaling.py
416
3.5625
4
top = list("*x*") middle = [" ", "x", "x"] bottom = ["*", " ", "*"] bruh = [top, middle, bottom] num = int(input()) matrix = [] for i in bruh: new = [] for e in i: new.append(e * num) matrix.append(new) final = [] counter = 0 for i in matrix: for m in range(num): ...
839632c5a9269a562162450739812509fb5cd460
Aasthaengg/IBMdataset
/Python_codes/p02405/s318015421.py
232
3.53125
4
while True: h,w = map(int,input().split()) if h==0 and w==0: break for i in range(h): s = '' for j in range(w): if (i+j)%2==0: s += '#' else: s+='.' print(s) print()
d21efe105cecb5f88a49dd7998cb8533786ec301
dillonp23/CSPT19_Sprint_1
/1.2/lecture_notes.py
6,191
4.125
4
""" # Sprint 1 Module 2 - Problem Solving The U.P.E.R. Framework: (U)nderstand - know what youre being asked to do - create 3-5 test-cases, you can actually discover the optimal algorithm in doing so - tests should not be too easy or too hard (P)lan - takes the most time for this step - you ...
ddaf97d5d4f6f84ac8635b4a911911428033cf75
pavaniailuri/euler
/the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.py
155
3.53125
4
odd,even=0,1 pavani=0 while True: odd,even=even,odd+even if even>=4000000: break if even%2==0: pavani+=even print(pavani)
2dc8d8c29929deead505b0220a1401099f3478ba
nikita-chudnovskiy/ProjectPyton
/00 Базовый курс/043 Рекурсивный обход файлов в Python/01 Обход папок Windows.py
747
3.640625
4
import os #os.isdir #os.isfile #path =input('Ведите путь где искать ') path = 'C:\\Movies' # Путь где искать print(os.listdir(path)) # os.listdir показывает содержимое по указанному пути в виде списка name = '123' for i in os.listdir(path): # функция возвр все в виде списка print(path+'\\'+i,os.path.isdir(pat...
b57f3962db2ae6c67fbb02145296a713115487f1
sergiogbrox/guppe
/Seção 4/exercicio08.py
602
4.21875
4
""" 8- Leia uma temperatura em graus Kelvin e apresente-a convertida em graus Celsius. A fórmula de conversão é: K = C + 273.15, sendo C a temperatura em Ceusius e K a temperatura em Kelvin. """ print("\nDigite uma tenmperatura em graus Kelvin para ser convertida para graus Celsius:\n") kelvin = input() try: kelv...
7a2ceec21a313d567a9cda250dcb6798e0d11551
larissacsf/Exercises-1
/PYTHON/Questao22.py
1,257
4.1875
4
'''Uma empresa concederá um aumento de salário aos seus funcionários, variável de acordo com o cargo, conforme a tabela abaixo. Faça um algoritmo que leia o salário e o cargo de um funcionário e calcule o novo salário. Se o cargo do funcionário não estiver na tabela, ele deverá, então, receber 40% de aumento. Mostre o ...
7362631ac591a1882c451473f906d99dcdfe1da5
nataway/Python-PTIT
/sapdatlaixaukytu.py
384
3.75
4
""" Author: Tris1702 Github: https://github.com/Tris1702 Gmail: phuonghoand2001@gmail.com Thank you so much! """ T = int(input()) for t in range(1, T+1): s1 = input() s2 = input() print('Test '+str(t)+': ', end = '') if (len(s1) != len(s2)): print('NO') continue s1 = sorted(s1) s...
ae4377b2ca41344f4d2197f6120a79812bfb882a
dmdang/ECE-40862-Python-for-Embedded-Systems
/dangd_lab0/program2.py
276
3.96875
4
def main(): a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] newList = [] print("a =", a) number = int(input("Enter number: ")) for i in a: if i >= number: break newList.append(i) print("The new list is", newList) main()
73dd81ce1b8a2e4832a8c52095fa2d31622d6b6d
caesarhoo/Algorithm
/Move Zeros.py
227
3.6875
4
# nums = [0,1,2,0,3] # a=[] # for i in nums: # if i!=0: # a.append(i) # while len(a)<len(nums): # a.append(0) # nums=a # print nums nums = [0,1,3,4,0,7,0,9,0] nums.sort(cmp=lambda a,b:0 if b else -1) print nums
7f07c69e51245ba9c9463fb696ab22e95bc0869a
krombout/heuristics_2017
/src/Example.py
2,154
3.5625
4
from src.Groundplan import Groundplan from src.GroundplanFrame import GroundplanFrame from districtobjects.Mansion import Mansion from districtobjects.Bungalow import Bungalow from districtobjects.FamilyHome import FamilyHome from districtobjects.Playground import Playground from districtobjects.Waterbody import ...
38911d7a848623a0a756e3e0f24ad7a0ef9ed7f5
cerulean2014/COMP2041
/Test13/palindrome.py
327
3.59375
4
#!/usr/bin/python3 import sys, re l = list(sys.argv[1]) result = [] for char in l: match = re.match(r'\w', char) if match: result.append(char.lower()) maxlen = (len(result)+1) // 2 i = 0 p = 1 while i < maxlen: if result[i] != result[len(result)-1-i]: p = 0 break i += 1 if p == 0: print("False") else: print("T...
9cd3b6d106e85ba7eb2f81daa57bc125393dcfa7
Amal-Alharbi/systematicreviews
/log-likelihood.py
2,280
3.59375
4
def find_log_likelihood(topics,frq_word_rel_doc,frq_word_non_rel_doc,threshold): """ This method finds the log likelihood (LL) for terms in the training dataset For each topic in the training dataset, it uses the text of relevant and non-relevant documents. then calculate the average ll...
75e8589621e725384a2afc92b79f87ab7b859c3a
praveenbommali/DS_Python
/Stack/linkedllImpl/LinkedListImpl.py
890
4.03125
4
# Stack implementation using Linked list class Node: def __init__(self, data): self.data = data self.next = None class StackImpl(object): def __init__(self): self.root = None self.size = 0 def push(self, data): newNode = Node(data) if self.root is None: ...
3b3f6bd18eb590309927109ea56e614688486bb3
Mietunteol/playground
/codewars.com/python/kyu_8/stringy_strings.py
132
3.59375
4
# https://www.codewars.com/kata/stringy-strings def stringy(size): return ''.join(str(int(not (x % 2))) for x in range(size))
e00edfb653fd75c198d5c46d1d007e7c536517ed
handeyildirim/Access-And-Change-A-Python-Nested-Dictionary-Variables
/access_key_value_pairs.py
1,740
4.65625
5
def key_value_accessing(): # car is a dict and we need to access to each key and the value of this dictionary car = { "brand": "Ford", "model": "Mustang", "year": 1964, "color": { "blue": "Dark", "green": ['Dark','Leight'], "pink": ['Dark','Leight', 'Bright'] } } # First...
76d75b98919b4557d123bf93046463a70f8d1e71
Edigiraldo/holbertonschool-higher_level_programming
/0x0B-python-input_output/6-from_json_string.py
237
3.78125
4
#!/usr/bin/python3 """"Module for from_json_string function.""" import json def from_json_string(my_str): """function that returns an object (Python data structure) represented by a JSON string""" return json.loads(my_str)
3788dfe4369c6f11deefbd95ab05fb018da996d5
camilaffonseca/Learning_Python
/Prática/ex002.py
209
4.375
4
# coding: utf-8 # Programa que lê um número é mostra o antecessor e o sucessor numero = int(input('Digite um número: ')) print(f'O antecessor de {numero} é {numero - 1} e o sucessor é {numero + 1}')
cd0ff4fd0dca84da49def6f172d0504885d33e67
mbirostris/technologiainformacyjna
/zajecia02.py
1,902
3.703125
4
# -*- coding: utf-8 -*- import os import numpy ''' #rzutowanie na typy zmiennych: strin(), int(), float(), long() a=3; b=4; print(a+b) #a, b to liczby typu integer c='3'; d ="4"; print(c+d) #a,b to ciagi znakow print(str(a)+str(b)) print(int(c)+int(d)) ''' ##########################################################...
98a3277365ae62dbdf9c012b37d32dbbc0b1a6fa
Suryamadhan/9thGradeProgramming
/CPLAB_08/CPLab_08/Dinner.py
1,657
4.375
4
""" Ex_01 In this exercise, you will be putting together a dinner plate. You will create inputs for the meat, vegetable, starch, appetizer, and drink, and print out your dinner at the end. """ class Dinner: def __init__(self, m, v, s, a, d): self.meat = m self.vegetable = v self.starch = s...
2e045daf4cef41aaf733c3d489bacbd9cf8f8817
vinnav/Python-Crash-Course
/10Files/10-8.CatsAndDogs.py
320
3.625
4
try: with open("cats.txt") as f: contents = f.read() except FileNotFoundError: print("cats.txt not found!") else: print(contents) try: with open("dogs.txt") as f: contents = f.read() except FileNotFoundError: print("dogs.txt not found!") else: print(contents)
377908bbf9d8fd4685895dc5ad110e04423f707c
jacobaek/whoisjacobaek
/hw1_1.py
245
3.828125
4
def if_function(a,b,c): if(a==True): return b else: return c print(if_function(True, 2, 3)) print(if_function(False, 2, 3)) print(if_function(3==2, 3+2, 3-2)) print(if_function(3>2, 3+2, 3-2) )
3692c0a3b4b38ce62aa89eeb2053fd987c0376ad
jmsalmeida/tdd
/exercicios-python/primeira-lista/4-holerite.py
1,008
3.984375
4
valor_plano_saude = 347.00 salario = float(input("Entre com o salário do colaorador: ")) total_descontado = 0 desconto_INSS = salario * 0.09 total_descontado += desconto_INSS desconto_vale_transporte = salario * 0.03 total_descontado += desconto_vale_transporte desconto_plano_saude = valor_plano_saude * 0.15 total_...
ee5bbff91138916c2fdff2a409ad3cc7f0d0d622
Parkavi-C/DataScience
/Python Exercise 2.py
3,600
4.21875
4
#!/usr/bin/env python # coding: utf-8 # In[ ]: ###1. Write a Python program to find those numbers which are divisible by 7 and multiple of 5, between 1500 and 2700(both included) # In[20]: List = [] for x in range(1500,2700,1): if(x%5 == 0 and x%7==0): List.append(x) print(*List, sep=", ") # In[ ]...
ded2a86d33f73256e03d4ff48297e2d6481fed75
YoshiBrightside/Ode-to-my-Failures
/Codeforces/19_07_05/Accepted/A.py
226
3.65625
4
# 1189A # Keanu Reeves stringlen = int(input()) string = str(input()) if len(string)%2==1 or len(string.split('0'))!= len(string.split('1')): print('1') print(string) else: print('2') print(string[0]+' '+string[1:])
91dbe3ad2beac8759bea9305df8ccb2837c3fb04
osfp-Pakistan/python
/GIS_Python/Calculations/bmi.py
800
4.25
4
# Jon Nordling # GEOG656 Python Programing # December 9, 2012 # bmi.py # This is the main function that will call function and # print the bim of the user imputs def main(): bmi = calc_bmi() result = bmi_means(bmi) print 'You are: ',result # This function will determine the users Weight and hight # and calculate...
b36fc6a00dff862c046506e140e2c3fd1061ae65
nauman-sakharkar/Python-3.x
/Data Structure & Artificial Intelligence/Evaluate - Postfix, Infix Expression.py
1,081
3.8125
4
print("---------------------------------\nName : Nauman\nRoll No. : 648\n---------------------------------") class Stack: def __init__(self): self.l=[] def push(self,e): self.l.append(e) def Pop(self): if not(self.isEmpty()): return(self.l.pop()) def isEmpty(sel...
4eb0c3f4191f1f749605d29d371e4064cef96850
anvesh001/testgit
/New folder/file.py
114
4.03125
4
hungry=str(input('enter value:')) if hungry=='Yes': print('he is hungry') else: print("he doesn't hungry")
8a96854a97aa391385cebfac1ae63319f944f182
areaofeffect/hello-world
/week3/examples/python3/dice-game.py
1,336
4.375
4
#!/usr/bin/env python3 # a classic dice rolling app # start by configuring your dice below. # python roll-dice.py to run # import required modules import random # to generate random numbers # configure options numberOfSides = 6 # how many sides on your dice weightedDiceOption = True # True or False prediction = 0 # ...
c85b681564d48c731f24e18227b71426d28cc6e3
linusqzdeng/python-snippets
/exercises/list_remove_duplicates.py
644
4.125
4
# This program takes a list and returns a new list that contains all the elements of # the first list minus all the duplicates. a = [1, 1, 3, 5, 7, 4, 3, 6, 5, 8, 8, 13, 24, 33, 12, 13, 17, 14] def remove_duplicates(list): new_list = [] for x in a: if x not in new_list: new_list.a...
c56ade9061a43536fecd51e9509a04956920e265
NorCalVictoria/week-2-assess-quiz-answers
/def print_melon_at_price(price):.py
1,367
4.46875
4
def print_melon_at_price(price): """Given a price, print all melons available at that price, in alphabetical order. Here are a list of melon names and prices: Honeydew 2.50 Cantaloupe 2.50 Watermelon 2.95 Musk 3.25 Crenshaw 3.25 Christmas 14.25 (it was a bad year for Christ...
3ad093e73ba0a1f0e212618f3e3e7c7c819b7b7d
UrvashiBhavnani08/Python
/binary_search.py
809
3.859375
4
import array as arr a = arr.array('i',[0,1,2,3,4,5,6,7,8,9,10,11,12]) for i in range(0,10): print(a[i],end=" ") print("\n") num = int(input("Enter which number you want to search through LINEAR SEARCH : ")) def linear_search(a,l1,num): for i in range(0,length): beg = a[0] end = a[12] ...
bb1f5b16ac0316037317d072b03776a6d1ecaeeb
Leoleopardboy12/Tasks-for-Programming
/No.25.py
295
3.609375
4
Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:37:50) [MSC v.1916 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license()" for more information. >>> A= int(input()) 1 >>> if A<=2: F= (A*2)+(4*A)+5 print(F) else: F=1/((A*2)+(4*A)+5) print(F) 11 >>>
2b95f26c3be5bca0d6658a78512d398c40f9b744
iHeroGH/Assignment6
/MajorLeagueSoccerAnim/artist.py
26,085
4.0625
4
import pygame import random import math # File Imports from colors import Color class Artist: """ Handles all the draw operations and visual aspects of the project. Attributes ---------- clouds : list[list[int, int]] A list of [x, y] coordinates for all the clouds that should be drawn...
ec8c72e8733decf551e5d54354b2db2498168df3
CodeYueXiong/Python_basics
/5_elif_statements.py
955
4.15625
4
my_num = 5.0 if my_num % 2 == 0: print("Your number is even") elif my_num % 2 != 0: print("Your number is odd") else: print('Are you sure your number is an integer') dice_value = 32 if dice_value == 1: print('You rolled a {}. Great job!'.format(dice_value)) elif dice_value == 2: print('You rolled a...
835f3b4868cc97a3a2c7a93ae56281d1080f5d74
CalebChacko/Grocery-List
/recipe.py
551
3.640625
4
from ingredient import Ingredient class Recipe: name = 'None' ingredients = {} # Determines if we add/remove ingredient on update addIngredients = bool(0) def __init__(self, name): self.name = name def addIngredient(self, newIngred): self.ingredients[newIngred] = Ingredient(...
18774214ec41e300a76f414c3423f0b09b06095b
eduardogomezvidela/Summer-Intro
/6 Functions/excersises/10B.py
251
3.578125
4
import turtle screen=turtle.Screen() screen.bgcolor("black") alex=turtle.Turtle() alex.color("orange") alex.pensize(2) alex.speed(0) x=0 y=90 for i in range (103): alex.right(y) alex.forward(x+4) x=x+4 y=y-0.02 screen.exitonclick()
de4955ac1acc612285c1f2a08fba703f4426a996
heatherstafford/unit3
/favorites.py
165
3.890625
4
#Heather Stafford #2/14/18 #favorites.py word = input('Enter your favorite word: ') num = int(input('Enter your favorite number: ')) for i in range(0, num): print(word)
abb92b4c0b846d4f99126ff31a43d4cc7b594e2a
wushengbin-debug/Python_Course
/student_grades2.py
937
4.125
4
print("Practicing conditionals by using student grades with 'and' operator") grade1 = float ( input("Type in the grade of 1st test: ")) grade2 = float ( input("Type in the grade of 2nd test: ")) absences = int ( input("Type in the number of absences: ")) total_classes = int ( input("Type in the total number of classes...
ddf829203156704312f588d4a4121d762b67ed89
vanissawanick/flask_project
/exercises/weather.py
2,581
3.515625
4
# script to access weather information # complex... unfinished import datetime import json import urllib.request # our variables city_id = "London" appi_id = " " # function to convert the time stamp def time_converter(time): converted_time = datetime.datetime.fromtimestamp( int(time) ).strftime('%...
2b3b31dfc0baa77f79b18e5d7f63959f049d563d
tanzim721/Python
/13-Queue.py
2,761
4.0625
4
""" Name : Tanzimul Islam Roll : 180636 Session : 2017-18 E-mail : tanzimulislam799@gmail.com Blog : https://tanzim36.blogspot.com/ Dept.of ICE, Pabna University of Science and Technology """ #Problem-13: Write a program to implement a queue data structure along with its typical operation. class Queue: ...
d9ad0959c78d9d8bfcf83dae2281dde3ce0aa83d
wyrdvans/TDD-Katas
/fizzbuzz/fizzbuzz.py
478
3.84375
4
def fizzbuzz(values = range(1, 101)): output_list = [] for value in values: if (not value % 3) and (not value % 5): output_list.append("fizzbuzz") elif (not value % 3): output_list.append("fizz") elif (not value % 5): output_list.append("buzz") ...
cf683a20fbabf4a469b090af58394f92415d08c9
ministep/PythonSpider
/多线程/productConsumer.py
1,545
3.828125
4
# 生产者消费者 import threading import time import random gTimes = 0 gTotalTimes = 10 gMoney = 1000 gCondition = threading.Condition() class Producer(threading.Thread): def run(self): global gMoney global gTimes while True: money = random.randint(100, 1000) gCondition....
cd5442a58e4193d62791b2400e2875a5d9bea719
jinurajan/Datastructures
/LeetCode/medium/add_two_numbers.py
2,352
3.84375
4
""" You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list. You may assume the two numbers do not contain any leading zero, except the number 0 itself. Ex...
7b7bc735edede502a081da862f5dfde575af6067
ayyjohn/pb950oOzYABB2j8
/spreadsheet_encoding.py
1,576
4.03125
4
# write a function that takes in a string such as A, Q, Z, AA, AX, ZZ # corresponding to a spreadsheet column header and outputs the # integer mapping, eg for A it outputs 1, for D it outputs # 4, for ZZ it outputs 702. # at first glance this seems like it's just base 26? # A => 1 # Z => 26 # AA => 27 # so at the top ...
cc8e39e4dc8f5cd2bf9ebb16a7ee51610fc3106d
HEriks/doctool
/test.py
833
3.75
4
import sys f = open("faf.txt","w+") f.write("Hej") f.close print("Welcome, this tool will help you to quickly generate a short summary of your programs") userInput = input("Please enter the search path of your file (including file ending)") f = open(userInput, "r") line = 1 numFunc = 0 print("--- Functions ---") for x ...
4201b54888cb9e76b03492f41f957aa57868cffa
amisha1garg/Arrays_In_Python
/FindMinMax.py
744
4.09375
4
# Given # an # array # A # of # size # N # of # integers.Your # task is to # find # the # minimum and maximum # elements in the # array. # # Example # 1: # # Input: # N = 6 # A[] = {3, 2, 1, 56, 10000, 167} # Output: # min = 1, max = 10000 # User function Template for python3 def getMinMax(...
81c7074f589b3d13c2af0458647575c40f0f5421
lukbut/extreme_computing2
/task 2/reducer.txt
248
3.65625
4
#!/usr/bin/python # Code adapted from labs import sys i = 0 for line in sys.stdin: # For ever line in the input from stdin line = line.strip() # Remove trailing characters if i < 10: print(line) i += 1
1e0bbcb8ae0fd9e9a3712d4e2500ae204b8ad080
hatan4ik/python-3-keys-study
/solutions/test_person.py
342
3.5625
4
import unittest from person import Person class TestPerson(unittest.TestCase): def test_main(self): guy = Person("John", "Doe") self.assertEqual("John", guy.first) self.assertEqual("Doe", guy.last) self.assertEqual("John Doe", guy.full_name()) self.assertEqual("Mr. John Doe"...
ab276acc7fe33d6d3e2dd77d84876cec23bdfda3
yinshengLi/exercise
/arithmatic/basic_01.py
1,784
3.921875
4
#__author:iruyi #date:2018/10/11 # bubble sort 气泡排序 def bubble_sort(nums): for i in range(len(nums) -1): for j in range(len(nums) -i -1): if nums[j] < nums[j + 1]: temp = nums[j] nums[j] = nums[j+1] nums[j+1] = temp return nums ''' 数组中的数字本是无...
a66261c56139f09054c607f219ff02fd47d8e3aa
FilipVidovic763/vjezba
/kisa.py
248
3.78125
4
kisa=input('unesi vjerovatnost kiše:') kisa=float(kisa) if kisa >= 0.0 and kisa <=0.5: print('nema potrebe ponijet kišobran') elif kisa >=0.5 and kisa <=1: print('ponesi kišobran') else: print('neispravna vrijednost')
6b4cbf2bd84205ea7c06a31a59d4893fb4b4c434
shadanan/python-challenge
/pc30.py
1,717
3.734375
4
#!/usr/bin/env python3 # encoding: utf-8 # Start at: http://www.pythonchallenge.com/pc/ring/yankeedoodle.html # User: repeat, Pass: switch # Photograph of a beach with lounge chairs and umbrellas # Page title: "relax you are on 30" # Image named: "yankeedoodle.jpg" # Caption: "The picture is only meant to help you re...
da1a05a1d415603c66b705f02400c0e8894d6ca9
southpawgeek/perlweeklychallenge-club
/challenge-121/cristian-heredia/python/ch-1.py
900
3.8125
4
''' TASK #1 › Invert Bit Submitted by: Mohammad S Anwar You are given integers 0 <= $m <= 255 and 1 <= $n <= 8. Write a script to invert $n bit from the end of the binary representation of $m and print the decimal representation of the new binary number. Example Input: $m = 12, $n = 3 Outp...
84fca47c55c7ac43d34c5d4321755392356744c1
oaifaye/tensorflow_demo
/logistic_regression/test1.py
1,741
3.5
4
# -*- coding:utf-8 -*- #功能: 使用tensorflow实现一个简单的逻辑回归 import tensorflow as tf import numpy as np import matplotlib.pyplot as plt #创建占位符 X=tf.placeholder(tf.float32) Y=tf.placeholder(tf.float32) #创建变量 #tf.random_normal([1])返回一个符合正太分布的随机数 w=tf.Variable(tf.random_normal([1],name='weight...