blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
7ea0f423e0b1c2e4f915f77013121ba8d4df870c
Michaelndula/Python-Projects
/pset6/Hello/hello.py
135
3.78125
4
from cs50 import get_string # get input from the user s = get_string("what's your name?\n: ") # print out the result print("Hello,", s)
6b400ab5c6907812a970714e895afbe9fc60d655
ParulProgrammingHub/assignment-1-Purvang12
/pur_ass1_12.py
128
3.75
4
n=input('enter the number to calculate n+nn+nnn of number') nn=n*(10**1)+n nnn=n*(10**2)+nn print'answer is',n+nn+nnn
618a0e2df663b0f82abb03db80f54d4407d37f3f
JenBanks8585/cs-module-project-algorithms
/scratch.py
4,692
4.03125
4
import random import time from itertools import combinations """ class Items: def __init__(self, name, weight, value): self.name = name self.weight = weight self.value = value self.efficiency = 0 def __str__(self): return f'{self.name}, {self.weight} lbs, ${self.value}' ...
d541951232c207a623de7e946bfaa931b5297f24
priyankapatki/D04
/HW04_ch08_ex05.py
1,419
4.125
4
#!/usr/bin/env python # HW04_ch08_ex05 # Structure this script entirely on your own. # See Chapter 8: Strings Exercise 5 for the task. # Please do provide function calls that test/demonstrate your # function. ############################################################################### # Find the ord('a') and or...
060187170d4fdfec718c5ede37f0ef3aa9410a59
ghtt/pdf_processing
/pdf.py
875
3.53125
4
import PyPDF2 import argparse WATERMARK_PDF_FILE = "wtr.pdf" OUTPUT_FILE = "test.pdf" def add_watermark(file, watermark): """Add watermark pdf""" pdf = PyPDF2.PdfFileReader(file) # for each page add watermark for page in pdf.pages: page.mergePage(watermark) # add all pages from reader to w...
ffd1ee6dc2b58f72d54f5b5ff9b4e1c5d08527ca
jgarg1991/Python
/Project/GuessingGame.py
425
4.03125
4
import random var = random.randint(0,20) x = 5 print "Guess the number, you have 5 chances:" while True: guess = input("Enter your guess between 0 - 20: ") if(x>1): if guess<var: print "Its bigger than %s"%(guess) x -= 1 elif guess>var: print "Its smaller than %s"%(guess) x -= 1 else: print "Y...
c98bec534009a0d1c46c8dc3c275550818984bf7
JoeSvr95/CompiladorPythonWhile
/Compilador/Niveles.py
1,209
3.703125
4
import libreriaCompilador as compiler import libreriaFunciones as libreria import re opciones="0" while opciones!="3": libreria.logo() libreria.menu_Juego() opciones=input("☺→") if opciones=="1": niveles=9 print("PD: Escriba Salir como escape") while niveles<11: prin...
7321ee9218db3b9ab2b7793e93d5bc08b14eba77
vanis-19/Python_variables
/10.py
626
4.34375
4
#Python program to check if lowercase letters exist in a string '''s='Vani' for i in s: k=i.islower if k==True: print('True') break if k!=1: print('False')''' str = "Live life to the Fullest" # Traversing Each character of # the string to check whether # it is in lowercase for...
3561aaa6f8598378184d7ddd2a69a2c647fe7329
sopanshewale/python-trainings
/batch-one/day-6/grouped_one.py
387
3.90625
4
#!/usr/bin/python3 import numpy as np import pandas as pd df = pd.DataFrame( {'key1' : ['a', 'a', 'b', 'b', 'a'], 'key2' : ['one', 'two', 'one', 'two', 'one'], 'data1' : np.random.randn(5), 'data2' : np.random.randn(5), } ) print(df) grouped = df['data1'].groupby(df['key1...
4b9121af8c63191e0dd941545500c11c6d3a4f36
RohanMiraje/DSAwithPython
/DSA/linked_list/single_linked_list/remove_all_repeating_nodes.py
2,568
3.5
4
from practise.linked_list.single_linked_list.template import * class DeleteRepeating(HeadTailLinkedList): def __init__(self): super(DeleteRepeating, self).__init__() def delete_repeat(self, curr, deleted=None): while curr and curr.next: if deleted == curr.data: sel...
6ec03ace7d88934973a8cf7bae47f6600ad3b21c
Revanthkarya/program-to-find-ve-numbers-using-python
/positive numbers.py
321
3.703125
4
nums = [12,-7,5,64,-14] print("original numbers in the list:",nums) new_nums=list(filter(lambda x: x>0,nums)) print("positive numbers in the list:",new_nums) nums = [12,14,-95,3] print("original numbers in the list:",nums) new_nums=list(filter(lambda x: x>0,nums)) print("positive numbers in the list:",new_nums) ...
e6a2dc74626566461e10c7c64fdaef660355b3d8
yun1989yue/linked-list
/sort list.py
1,247
3.828125
4
''' Sort a linked list in O(n log n) time using constant space complexity. ''' ''' Method: divide and conquer O(nlogn) time O(n) space ''' class Solution(object): def sortList(self, head): """ :type head: ListNode :rtype: ListNode """ if not head or not head.next: ...
a32e34b1f0cb35cc5f76f98f8ec4ddba1d997a3d
SandeshDhawan/PythonPrograms
/AdditionalPrograms/ReverseString_1.py
292
3.921875
4
""" input = Sandesh Sunil Dhawan output = Dhawan Sunil Sandesh """ class ReverseString: def reverse(self,str): splitted_str = str.split(" ") for i in range(len(splitted_str)-1,-1,-1): print(splitted_str[i],end=" ") str = input("Enter Any String") ob = ReverseString() ob.reverse(str)
1bdaab0e8be2dafeb986554ffa5daf2affc16c1e
hisoul22/cs61A
/practice_code/Str_And_Repr.py
622
3.953125
4
""" The behavior of repr is slightly more complicated than invoking __repr__ on its argument: An instance attribute called __repr__ is ignored! Only class attributes are found. The behavior of str is also complicated: • An instance attribute called __str__ is ignored • If no __str__ attribute is found, uses repr strin...
2e4e51a70b4526d022591a829bd2ff2e775b44b1
esmaclo/empresa-0.2
/empleado.py
756
3.578125
4
__author__ = 'Esmir Acosta' class Empleado(): def __init__(self, nombre, apellidos, dni, direccion, edad, email, salario): self.nombre = nombre self.apellidos = apellidos self.dni = dni self.direccion = direccion self.edad = edad self.email = email self.sala...
6981073b35de4efaadd0495e819aac9d78c2c89d
mimitchi/sinoalice-weapon-chooser
/main.py
1,740
3.625
4
from typing import NamedTuple class Weapon(NamedTuple): name: str cost: int stats: int def dp_knapsack(max_cost, weapon_list): max_weapons = 20 weapons = [] for weapon in weapon_list: weapons.append(Weapon(weapon[0], weapon[1], weapon[2])) length = len(weapons) knapsack = [[[0 ...
eaeb52cc0eace7679d4b07c8cd20408cb6542f33
adoredavid/adore
/print.py
315
3.65625
4
print("你好,請不要打中文!")#字符串 print(1111) #整数 print(1.111)#小数 print(True)#布尔值 print(())#元组 print([])#数组 print({})#字典 """ 注释 注释 注释 """ print("呵呵",2333,23.33) print("呵呵"+"嘿嘿")#字符串拼接 print("呵呵"*111) print(((1+2)*100-8.5)/2) print(3>2)
d410896d5f95c8eed193188241b610fa54f3d4a5
garyblocks/leetcode
/round1/95_UniqueBinarySearchTreesII.py
1,440
3.765625
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def gen(self,ls,res,se): tree = TreeNode(ls[0]) cur = tree for i in ls[1:]: ...
e3d55bacad4b1a28ad8449a33ec6dd6bd18612cc
raphaellaxz/PolyUCourseworks
/COMP1001/Assignment/6/6/3.py
251
3.921875
4
def func(min, max, opr): if opr == "+": try: result = max + min return max + min elif opr == "-": return max - min elif opr == "*": return max * min elif opr == "/": return max / min
0ba540406ebc8d59010ac591b7ab589b01c08847
rikeadelia/SG_Basic_Prerequisite_Batch2
/soal3.py
1,390
3.625
4
# KELAS GRAPH # Buatlah kelas objek Graph class Graph(object): def __init__(self, graph_dict=None): if graph_dict == None: graph_dict = {} self.__graph_dict = graph_dict def getVertices(self): #mengembalikan semua vertex pada graf return list(self.__graph_dict.keys()) def getEdges(sel...
dcfdcb2471ad798115c10571a9fcf0df4371a4ff
MthwBrwn/data_structures_and_algorithms
/challenges/quicksort/quick_sort.py
1,291
4.03125
4
def quickSort(_list): if not isinstance(_list, list): raise TypeError quickSortRunner(_list, 0, len(_list)-1) return _list # Quicksort sets up the initial state of the sort # quicksort runner will recursively come up with the split point # after the initial reun through def quickSortRunner(_list...
1a6a9f3a22936df3519f07ca79a8ec0b2fc2bbde
pranjay01/leetcode_python
/Convert SortedArraytoBinarySearchTree.py
587
3.609375
4
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution: def sortedArrayToBST(self, nums) -> TreeNode: l=len(nums) if l ==0: return None mid=int(l/2) node=Tr...
8099dcc061247efdae49fa8830cc98b105f191f9
csmarin/python_projects
/connector/learning_python/exercises.py
1,125
3.75
4
# -*- coding: utf-8 -*- print("I am $€") """ Exercise 17 """ # from sys import argv # from os.path import exists # script, from_file, to_file = argv # print("Copying from {} to {}".format(from_file, to_file)) # in_data = open(from_file).read() # print("The input file is {} bytes long.".format(len(in_data))) # pri...
10074a947a0564210f2dc537e204e45f62012049
robyjj/Python-Django-Workspace
/HellloWorld/utils.py
143
3.84375
4
def find_max(numbers): max_num = numbers[0] for num in numbers: if num > max_num: max_num = num return max_num
7b09b097e1b69a00df496464bc655d75dd72f0d0
Gambrinus/Rosalind
/Python/SSET.py
1,801
4.3125
4
#!/usr/bin/env python """ Rosalind project - Problem: Enumerating Subsets Problem A set is the mathematical term for a loose collection of objects, called elements. Examples of sets include {the moon, the sun, Wilford Brimley} and R, the set containing all real numbers. We even have the empty set, repr...
24dfff0e2db2ab3c9035a160eaa0325a9d00e197
yuynwa/coding-exercises
/g_longest_word_in_str_mine.py
908
4.25
4
#!/use/bin/env python # -*- coding: utf-8 -*- """ This problem is from https://techdevguide.withgoogle.com /paths/foundational/find-longest-word-in-dictionary- that-subsequence-of-given-string#code-challenge For example, given the input of S = "abppplee" and D = {"able", "ale", "apple", "ba...
6f16f3327e36ccd022a335c8b2e491dac923dfbd
ksambaiah/python
/leet/leet217.py
357
3.78125
4
#!/usr/bin/env python3 def containsDuplicate(nums) -> bool: for i in range(len(nums)-1): for j in range(i+1,len(nums)): print(nums[i], nums[j]) if nums[i] == nums[j]: return True return False if __name__ == '__main__': a = [1,2,3,4] pri...
8df4877cf95218f2df10548e36a906646b7afaee
AbdElrhman-m/mini-project-fractels
/fractels.py
2,967
4.0625
4
import turtle def lets_make_it_Awesome(): """drawing fractels of square""" #opening screen window = turtle.Screen() # changing the background color window.bgcolor('green') # idenfing the brad turtle brad = turtle.Turtle() # reset some prop.s brad.shape('turtle') brad.color('black',"g...
6fbbffd67157e18e043b413e6d6a93e27f42f196
olu144/Trig-Grapher
/Trigonometric-Visualizer.py
1,408
3.828125
4
import math import turtle def main(): fred=turtle.Turtle() wn=turtle.Screen() setUpWindow(wn) setUpTurtle(fred) drawSine(fred) drawCosineCurve(fred) drawTangentCurve(fred) drawNaturalLog(fred) wn.exitonclick() def setUpWindow(screen_object): screen_object=turtle.Screen() ...
1cb5dbd7fad2731dbbb60bf49ec4c3aac999ff0e
Allen-ITD-2313/hello-world
/dropBall.py
504
4.21875
4
def main(): height=float(input("Enter the height from which the ball is dropped in feet: \n")) BOUNCINESS=.6 bounces=int(input("Enter the number of times the ball is allowed to continue bouncing: \n")) distance=0 while bounces > 0: distance = distance + heigh...
bf30f8f41422224b42ce3906bf485c5cbc1d4d21
federicodiazgerstner/sd_excercises_uade
/Ejercicio 6.09.py
657
3.71875
4
#imprime una lista def imprimelista(v): for i in range(len(v)): print(v[i], end=" ") #crea lista booleana def crealistabooleana(v, w): for i in range(len(v)-1): if v[i] <= v[i+1]: w.append(True) else: w.append(False) #programa principal lista = [] booleana = []...
f4db06d1e25abc25129604ccc0bcb96892aa3b52
NotQuiteHeroes/HackerRank
/Python/Basic_Data_Types/Tuples.py
630
4.1875
4
''' Task Given an integer, n, and n space-separated integers as input, create a tuple, t, of those n integers. Then compute and print the result of hash(t). Input Format The first line contains an integer, n, denoting the number of elements in the tuple. The second line contains n space-separated integers describing ...
3ce0ca40d34d0f0900a696d10b5d13bfc623bda4
mateusoliver/cursoemvideo
/mundo01/Desafios/desafio026.py
357
3.984375
4
nome = str(input('Entre com seu nome por favor: ')).strip() #print(nome.upper()) print('A letra A aparece no seu nome: {}'.format(nome.upper().count('A')) + ' vez(es)') print('A posição da primeira letra é: {}'.format(nome.upper().find('A')+1) + ' posição') print('A ultima posição da letra A esta na posição {}'.format(...
b5b9281e3eb8a85b709b24d436f7012141efc2ad
carissa406/python-practice-scripts
/AreaCalculator.py
769
4.0625
4
# -*- coding: utf-8 -*- """ Created on Mon Aug 3 13:53:43 2020 @author: hicks """ shape = input("Are you calculating the area for a rectangle, square, or triangle? :") if shape == "rectangle": l = float(input("What is the length of the rectangle?: ")) b = float(input("what is the width of the rectangle?: ")...
3f8c40a9c87373a1788612c9dfd3a9d882072e39
mmarkie2/Studies
/Python/bsi/class5-ex4/main.py
1,185
3.71875
4
import os import random def generate_text(length): chars = ['a', 'b', 'c', 'd', 'e', 'f', 'g', ' ', 'l', 'm', 'k', 'o', 't'] string = '' for i in range(0, length): string += random.choice(chars) return string def do_hash(text, algorithm): cmd = f'echo "{text}" > temp-source.txt' os.s...
b090c238db14d6bcc5b30c7e612c9a1d859b542a
breadpitt/SystemsProgramming
/python_stuff_2/json_grade_avg.py
767
3.765625
4
#!/usr/local/bin/python3 import json json_string = "" #input_data = "" # grade_obj["students"][0]["grades"][0]["assn1"] gets the value for assn1 for first student in grades num, total, avg, count = 0,0,0,0 with open('grades.json') as json_fh: input_data = json.load(json_fh) print(json.dumps(input_data)) for...
44a62b08219d66d0e79b60fe6b46cadc1e516017
Josh-stafford/NN-From-Scratch
/matmult.py
1,200
3.515625
4
mat1 = [[1, 2, 3], [3, 4, 5]] mat2 = [[5, 6], [7, 8], [9, 10]] def mult(mat1, mat2): nums = [] finalMat = [] height = len(mat1) width = len(mat2[0]) # print('Height:', height, '\nWidth:', width) lastNums = [] for row in range(height): for c...
f17478547ff161c2fad76d7ff1adf19a3234962c
alexagrchkva/for_reference
/theory/14th_sprint/J.Bubble_sort.py
626
3.875
4
""" some specific bubble sort """ def bubble_sort(arr): times = 0 for i_index in range(len(arr)-1): j = 0 changed = False while j < len(arr)-1: if arr[j] > arr[j + 1]: arr[j], arr[j+1] = arr[j+1], arr[j] changed, times = True, times+1 ...
6b6421e5f5342370b200bbd34f873ccb85e19c74
Zhenye-Na/leetcode
/python/296.best-meeting-point.py
3,064
4.34375
4
# [296] Best Meeting Point # A group of two or more people wants to meet and minimize the total travel distance. # You are given a 2D grid of values 0 or 1, where each 1 marks the home of someone in the group. # The distance is calculated using Manhattan Distance, where distance(p1, p2) = |p2.x - p1.x| + |p2.y - p1....
846ecc325813b4a59af5115cce9087b6bb2b5c06
jmabf/uri-python
/1095.py
162
3.59375
4
i = 0 j = 0 while j==0: j+=60 i+=1 print('I={} J={}'.format(i, j)) while j>0: i+=3 j-=5 print('I={} J={}'.format(i, j))
bbdf85e683b1d79973bd0a7fe21e21cac92d4865
Phdmr/grafo
/ciclo.py
1,866
3.609375
4
grafo = {0: [2, 3], 1: [4, 8], 2: [5], 3: [7, 8], 4: [8], 5: [6], 6: [2], 7: [9], 8: [0], 9: [7]} def edge_list(G): links = [] for u in G: for v in G[u]: links.append((u, v)) return links def achar_aresta...
982c67c07839dab7ff384ea201fb6190a1909151
sreelakshmig009/Python-Projects
/csv_to_json.py
2,520
4.0625
4
# Importing csv and json modules from typing import Any import csv import json # Function to convert a CSV file to JSON file # Takes the path of the files to be converted as arguments def convert_csv_to_json(csvPath:Any, jsonPath:Any)-> Any: """ I used a csv file called ratings fro...
e0feab8322d11af924a85622abad5f2c58bc4b3d
Asperas13/leetcode
/problems/23.py
947
3.703125
4
class Solution: def mergeKLists(self, lists): if not lists: return None def _merge(l1, l2): dummy = ListNode(-1) l3 = dummy while l1 or l2: if l1 and l2: if l1.val < l2.val: l3.next = ListNod...
202174c1456efe0cadbcc140acc2a25384d8fbfb
Rossel/Solve_250_Coding_Challenges
/chal125.py
188
3.75
4
x = {1: "Python", 2: "Java", 3: "Javascript", 4: "Ruby", 5: "Perl", 6: "C#", 7: "C++"} if sum(x) < len(x[1] + x[2] + x[3] + x[4] + x[5]): print("True!") else: print("False!")
7c627aebb0b967337d6d5df9f931e484c99c286b
manusoler/code-challenges
/hackerrank/tutorials/30_days_of_code/day25_running_time_and_complexity.py
380
4.09375
4
from math import sqrt def is_prime(n): if n == 2: return True if n < 2 or n % 2 == 0: return False for i in range(3,int(sqrt(n))+1,2): if n % i == 0: return False return True if __name__ == '__main__': num_tests = [int(input()) for i in range(int(input()))] for n in num_t...
dfbb1d0a6d09d617ce6a3d30579a40a6793b3f71
AndyDaly90/FYP_PythonScraping
/FYPSprint3/car_crawler.py
2,922
3.515625
4
# -*- coding: utf-8 -*- from __future__ import print_function import mechanize from bs4 import BeautifulSoup import re import urllib2 def clean_url(data): """ In order to make requests across the network I need a clean URL (example : http://www.desiquintans.com/articles/). This is done by using a regular...
3cd14a7bd2a12000a2e903c2120706b7a6a68aa4
ojaln/Bigdataprog
/Numpy.py
1,614
3.765625
4
# -*- coding: utf-8 -*- """ Created on Fri Jun 28 09:05:33 2019 @author: ADMIN """ # Exercise 1: Replace all odd numbers in arr with -1 import numpy as np arr = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) arr[arr % 2 == 1] = -1 arr # Exercise 2: Convert a 1D array to a 2D array with 2 rows arr = np.arange...
a2aac88d11173b8c0caa156501850dce135eb931
rajalur/Python
/roshun-python-exercises/class_example.py
1,348
3.890625
4
class RoshunClass: dogs = [] cats = [] def __init__(self, d, c): self.dogs.append(d) self.cats.append(c) def __repr__(self): str = 'Dogs: ' for dog in self.dogs: str += dog + ' ' str += ', Cats: ' for cat in self.cats: str += cat ...
ca54e9ad86c30a7f166a40c4f834395c835ad924
Alexvizcainolabrador/Ofimatica
/practica8.py
304
3.8125
4
def obtener_vocales(frase): vocales = ["a", "e", "i", "o", "u", "A", "E", "I", "O", "U"] num_vocales = 0 for letra in frase: if letra in vocales: num_vocales = num_vocales + 1 print(num_vocales) frase = input("Escribe una frase aleatoria") obtener_vocales(frase)
c31248bbd3233ab64b82790a75717c37d794efac
padmacho/pythontutorial
/Documentation/Docstrings/calc.py
272
3.84375
4
"""Contains basic mathematical functions Usage: import calc calc.add(1,2) """ def add(x, y): """ addes two numbers. Args: x: argument 1 y: argument 2 Returns: returns of sum of x and y """ return x + y
7400368b0f577a04c6fc6747aa6a7b5ff8782bed
DavidAnaiye/looped-list-comprehension
/Documents/I.T/classworks/python/Class works/list/list.py
565
4.1875
4
#a = [hhiloue,juioedd,uhijole,] # how to creat a list # how to call its index + or -// numbers[x], or numbers[x][y] # range method of list, making a list from a range list(range(1,10)) # numbers= list(range(1,10)) # how to append to a list numbers.append() numbers = list(range(10)) #print (numbers) numbers.append([...
336aadebbcdc4f9f1becc797187d3d9b3d268e89
lucasbflopes/codewars-solutions
/7-kyu/without-the-letter-'e'/python/solution.py
138
3.71875
4
def find_E(s): if not s: return s n = list(s.lower()).count("e") return "{}".format(n) if n > 0 else "There is no \"e\"."
09f75014ff06a6861ef365aeabae7327eb453876
shamim-ahmed/udemy-python-masterclass
/section-12/examples/repeat_tuple2.py
123
3.828125
4
#!/usr/bin/env python from itertools import repeat my_tuple = (1, 3) result = tuple(repeat(my_tuple, 4)) print(result)
a3b8da96f78d48972e23bbc14d65e73fb77b1bb5
rjunior8/tasks
/exercicios/aula02/exc06.py
668
3.875
4
x = 2 y = 5.3 while True: e = int(input("Menu:\n1-adição\n2-subtração\n3-divisão\n4-multiplicação\n5-sair\nOpção: ")) if e == 1: print("A soma de {} + {} = {}\n".format(x, y, x + y)) continue elif e == 2: print("A subtração de {} + {} = {}\n".format(x, y, x - y)) continue ...
0b2fc9cd78c6de6fdba1117991de6ce97214de2d
MrBetros/CURSOPYTHON
/Ejercicios/Ejercicio3.py
166
3.703125
4
AñoN = input("Ingresa tu Año de Nacimiento "); AñoA = input("Ingresa el Año Actual: "); Edad = float(AñoA) - float(AñoN); print("Tu edad es: " + str(Edad));
3a1240f97d8fb50e135c7fd9bca59e4ab6879b7a
SocialSeismometer/Twittermoto
/twittermoto/database.py
4,388
3.734375
4
''' This module contains the database classes. ''' import sqlite3 from datetime import datetime class database(object): "A base class for a tweet database" def __init__(self, *args): pass def __len__(self): pass # def connect(self): # pass def close(self): pass...
4319876a4cc8588e3989dd590cd2b137201a16ca
irfa89/HackerRank-InterviewPreparation
/repeatedString.py
332
3.859375
4
import sys """ # Overflow error def repeatedString(s): return s.count('a') def repeatToLength(s,l): if l > 0 : a = (s*(l//len(s)+1))[:l] return a else: return s """ if __name__ == '__main__': s = input() n = int(input()) print(s.count('a')*(n//len(s)+s[:n% len(s)].c...
9f66630a48f2eb2e466ef616048cf7574955f67f
dougp85/lottery_num_gen
/lottery_num_gen.py
311
3.734375
4
import random randomList = [] # Set a length of the list to 5 for i in range(0, 5): # any random numbers from 0 to 1000 randomList.append(random.randint(0, 69)) print("Here are your 5 Lottery numbers:") print(randomList) print('Here is your Powerball Number:') print(random.randint(1,26))
53802dbb7c3ef2e3febadba073834b581450d859
abosloh/timer
/timer.py
674
3.734375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- from time import sleep from sys import stdout # replace seconds to clock h:m:s (00:00:00) def getClock(s): clock = "" clock+= "%02d:" % (s/3600,) # find hours s = s%3600 # decrement seconds clock+= "%02d:" % (s/60,) # find minutes s = s%60 # decremen...
f0fcde39dd93951d6cc59d82ce83e1c4c193f36f
voltz92/ATBS-Files
/Strings/strings_1.py
540
3.890625
4
# to include some special characters in strings we need to use the escape character '\' e = 'This is a string that\'s like new \t the best of both \n' print(e) # raw strings spam = r'this is an example of a raw string here \n we dont need to escape "special characters"' print(spam) # or we can use """ quotes if th...
b534d09482005784cbb40c846d085fa47dc6767c
rabestro/sololearn-challenges
/easy/popsicles/Popsicles.py
140
3.5
4
siblings = int(input()) popsicles = int(input()) if popsicles % siblings == 0: print("give away") else: print("eat them yourself")
10a6fbf4cccc12421e5bcdb088e02ea359c3872b
calvar122/EXUAGO2021-VPE-L1
/0922/alejandro.orozcoa/num_mayor.py
346
4.125
4
#!/usr/bin/env python3 #Se pide al usuario ingresar 2 numeros num1 = eval(input("Ingresa numero 1: ")) num2 = eval(input("Ingresa numero 2: ")) # se hace la comparativa de los numeros if num1 > num2: print("Num 1 es mayor que Num 2") elif num1 < num2: print("Num 2 es mayor que Num 1") else: print("Los ...
a756dd7a57dc1ef68a9b88bfff5e8bdd1a92b11f
Abeelha/Udemy
/Curso Udemy/visual_dados.py
1,771
3.65625
4
# Visualizacao de dados em Python import matplotlib.pyplot as plt import random x1 = [1, 3, 5, 7, 9] y1 = [2, 3, 7, 1, 0] x2 = [2, 4, 6, 8, 10] y2 = [4, 2, 1, 7, 5] z = [200, 400, 400, 1000, 250] #tamanho titulo = "Scatterplot: gráfico de dispersão" eixox = "Eixo X" eixoy = "Eixo Y" # Legendas plt...
6a91e093619795ccde23a4cfe8dc487a2e23b3fa
Haut-Stone/study_Python
/base_test/my_json.py
798
3.796875
4
# -*- coding: utf-8 -*- # @Author: Haut-Stone # @Date: 2017-07-05 18:21:08 # @Last Modified by: Haut-Stone # @Last Modified time: 2017-07-05 20:59:34 import json # 读写json文件 numbers = [2,3,5,7,11,13] filename = 'numbers.json' with open(filename, 'w') as f_obj: json.dump(numbers, f_obj) tests = [] filename = 'nu...
9dce462595ea261ce2652fdd54b00bf5300deae6
vijayshahwal/project-euler
/problem72.py
1,300
3.53125
4
l=[] def SieveOfEratosthenes(n): prime = [True for i in range(n+1)] p = 2 while (p * p <= n): # If prime[p] is not changed, then it is a prime if (prime[p] == True): # Update all multiples of p for i in range(p * p, n+1, p): ...
37da5123c4149fd73fda2a761af78465e17f3065
JaKoZpl/python_lab
/laba6/1.py
4,066
4.125
4
import random def make_arr()->list: array = [] while len(array) < 10: array.append(random.randint(-49, 50)) return array array1 = make_arr() array2 = make_arr() print("Перший масив:") print(array1) print("Другий масив:") print(array2) # Бульбашкове сортування def bubble(array)->list: for i in...
1a554307c1a8eec3a3f7d34904c9e3c0784ae8e3
RenhanZhang/EECS-545-Machine-Learning
/545-HW5A/kmeans.py
2,048
3.515625
4
import numpy as np import random #improvement: distance can be euclidean, cosine, or user defined def distance(a,b): return np.dot(a-b, a-b) def find_nearest(v, u): ''' find the elements in u that is closest to v ''' nearest = 0 # index of the element in v that's nearest to v min_dist = 0 ...
0e943462ed7e3888fb8046f7787aa5c2c1656288
belodpav/algoproblems
/algorithms/sorting/buble_sort/buble_sort.py
288
3.59375
4
def swap(a, x, y): buf = a[x] a[x] = a[y] a[y] = buf def bubleSort(a): aLen = len(a) for i in range(aLen): for j in range(aLen - i - 1): if a[j] > a[j+1]: swap(a, j, j+1) return a print(bubleSort([-989, 3, 4666, -34, -43]))
bd691c4b1a3e1301145239919c2fb7f0942937f4
hinsonan/ThinkPython
/ThinkPython/Chap9/9.4.py
437
4.0625
4
# -*- coding: utf-8 -*- """ Created on Mon Jun 25 13:44:53 2018 @author: hinson Write a function named uses_only that takes a word and a string of letters, and that returns True if the word contains only letters in the list. """ def uses_only(word: str, string: str) -> bool: for letter in word: ...
d6fceae0dc9226c5645e3c2863033d4db0bfa97f
cwong168/py4e
/chapter_3/ch_3_ex_2_hours_pay.py
443
4.15625
4
hours = input('Enter Hours:') rate = input('Enter Rate:') try: float_hours = float(hours) float_rates = float(rate) except: print("Error, please enter numeric input") quit() if float_hours > 40 : print("Overtime") pay = float(hours) * float(rate) overtime = (float_hours - 40.0) * (floa...
33ec883b657fc84b23a40831a6e31adaf2fee490
lilberick/Competitive-programming
/online-judge-solutions/Codeforces/411A.py
261
3.640625
4
#https://codeforces.com/problemset/problem/411/A #Lang : Python 3.8 #Time : 46 ms #Memory : 0 KB s=input() print("Correct" if (len(s)>=5 and any(c.isupper() for c in s) and any(c.islower() for c in s) and any(c.isdigit() for c in s)) else "Too weak")
e2a059564e74cfe0f1dfb02144d60c460c8633eb
gxgarciat/Playground-PythonPractice
/D2_c3.py
823
4.5
4
# Type a program that will work as a tip calculator # First, the user will need to type the bill. Second, the program will ask the percentage of tip # Finally, the program will ask how many people to split the bill and it will provide how much each person should pay # For example, the bill is $124.56, then you want to ...
727a9eb897c876e782e44400baf629aeca4459fc
Kunal12072000/python
/DSA lab/118EI0374_assignment_6.py
2,234
3.6875
4
a = {'+':1,'-':1,'*':2,'/':2,'^':3} b = a.keys() A = [] def enterval(A): while(True): v = input() if len(v) <= 0: break A.append(v) return A def check(A): if len(A) <= 2: return (0) for i in range(0,len(A)-1): if ((A[i] in b) and (A[i+1] in b)) or ( A...
379bf9429570dd08feffe4daac7cfe1ab3f2ba4c
showyou/crochet
/toDate.py
546
3.671875
4
#! /usr/bin/env python # -*- coding:utf-8 -*- import datetime """ 地域に応じた時差を返す 日本だと+9時間(JST) GSTなら0かしら? ニューヨークなら9-14 = -5? サンフランシスコ 9-17 = -8? """ def getLocalTime(timezoneName): if timezoneName == "JP": return 9 else: return 0 def toDate(date,str): from time import strptime for i in range(len(date)): print ...
4adcc4c746ed634d74fcf9708626908cb479f637
luchen29/Algorithm-Practice
/Lintcode_610_TwoSum_Difference_equals_to_target_hash.py
686
3.515625
4
class Solution: """ @param nums: an array of Integer @param target: an integer @return: [index1 + 1, index2 + 1] (index1 < index2) """ def twoSum7(self, nums, target): if len(nums)<=1: return None #key: nums[index] #value: index hash = {} for ...
058ccf2ed9dfd2fe39417dbdabdfe09a72121beb
instructor-raym/Python-Ray
/PythonFundamentals/tuples/tuples.py
214
3.828125
4
dog = ("Canis Familiaris", "dog", "carnivore", 12) print (dog[2]) for data in dog: print (data) dog = dog + ("domestic",) # comma makes it a string print (dog) dog = dog[:3] + ("man's best friend",) + dog[4:] print (dog)
d71980e814dacd34b5f3292069de6ef5a60643d5
Spinu2b/blender_addon_import_armature_animations
/utils/model_spaces_integration/quaternion.py
1,525
3.625
4
from math import sqrt class Quaternion: def __init__(self, w: float = 0.0, x: float = 0.0, y: float = 0.0, z: float = 0.0): self.w = w # type: float self.x = x # type: float self.y = y # type: float self.z = z # type: float def conjugate(self): return Qu...
b6f6d522eeb80de8eade3ed227edf97d7771dac7
varunsai2494/qnaknowledgegraphfullstack
/knowledge-graphs/knowledgegraphs/generic_functions.py
673
3.515625
4
def doubleMatch(string, substringarray): string =string.replace(","," , ").replace("."," . ") match=[item for item in substringarray if str(" "+str(item).lower().strip()+" ") in str(" "+str(string).lower().strip()+" ")] return match def doubleMatchWithNoDuplicates(string, substringarray): string =st...
82d47b635959ef35a503cf8883af9063b61cb987
AkinyiOwuor/Password-Locker
/user.py
1,578
3.78125
4
import pyperclip class User: ''' Class that generates new instances of users. ''' user_list=[]# Empty user list def __init__(self,user_name,email,account_name,password): self.user_name=user_name self.email=email self.account_name=account_name self.password=password ...
fdfcc4c45021f576e47ff7d85d99f35b57353014
xkender/Cloud-programming
/Python 3 the Hard Way/x22a.py
126
3.53125
4
def factorial(x): for i in range(x): if i != 0: xfac = i * (i+1) print(xfac) factorial(1005)
ff28adc64f70eb79a14b19ce29ae6a41491f2fbb
ajfm88/PythonCrashCourse
/Ch8/city_names.py
619
4.625
5
#Write a function called city_country() that takes in the name of a city and its country. #The function should return a string formatted like this "Santiago, Chile" #Call your function with at least three city-country pairs, and print the values that are returned. def city_country(city, country): """Returns the na...
8792d7ead0dc4c7c5bf0535fae4ba77734a7be50
lowrybg/SoftuniPythonFund
/final_exam_prep/exam_problem_two.py
724
3.578125
4
import re import math num = int(input()) pattern = r"^(\$|%)(?P<word>[A-Z][a-z]{2,})\1:\s(?P<ords>\[\d+\]\|\[\d+\]\|\[\d+\]\|)$" for n in range(num): line = input() match = re.finditer(pattern, line) match = [el.groupdict() for el in match] # print(match) # print(match[0]['word']) # print(matc...
46e3e3f99af8b77cc0a152f6ce2558feab1c3637
nikolaj74-hub/lessons
/lesson2.5.py
816
3.6875
4
lis = [1, 9, 7, 4, 2, 2] print(lis) a = int(input('Введите новый элемент рейтинга:')) s = lis.count(a) # пер s присв.зн.=колич.элементов равных пер а lis.append(a) # в конец списка добавляем знач.пер. а t = lis.index(a) # пер t присв номер индекса первого элемента равному а # sum = lis.index(a) + lis.count(a)# пер....
51ee524cb8e314dad2d7b960e1084d0a8a0623d9
xuqil/DataStructures
/page1/demo2.py
429
3.75
4
# 图色法(贪心法) def coloring(G): # 做图G的着色 color = 0 groups = set() verts = G while verts: new_group = set() for v in list(verts): if not v: new_group.add(v) verts.remove(v) groups.add((color, new_group)) color += 1 return groups...
68bca3be78f2713d556b7c6dc988de2c347bd7eb
Homnis/hyx
/re/days09_正则表达式/demo05_python中的正则.py
1,472
3.5625
4
''' author: 大牧 牟文斌 version: V1.0.0 time: 2018/10/18 14:59 desc: python中正则操作函数 ''' import re ''' ['I', 'S', 'compile', 'findall', 'finditer', 'match', 'search', 'split', 'sub', 'subn'] ''' target = "hello regular expression" # 创建正则表达式:2种创建方式 # 1. 快捷操作方式 # reg = r'l' # <class 'str'> # print(type(reg)) # # res = re....
a3c252a60e95467555fce923b1324b339726400b
wangpengda1210/Rock-Paper-Scissors
/Problems/Decimal places/main.py
84
3.5625
4
number = float(input()) num_digits = int(input()) print(f"{number:.{num_digits}f}")
f708d1cece14cc2da6526d8b131c1d829f741195
rafaelperazzo/programacao-web
/moodledata/vpl_data/380/usersdata/308/84680/submittedfiles/testes.py
150
3.671875
4
# -*- coding: utf-8 -*- #COMECE AQUI ABAIXO def soma(): print(a+b) print('Resultado') a = float(input('A: ')) b = float(input('B: ')) soma()
60bed0869fd993ce7d260fc605eb2dd54b659413
Sidharth4032/CSCI-1100
/Lecture Exercises/Lecture_15/problem_2.py
611
3.734375
4
imdb_file = input("Data file name: ").strip() print(imdb_file) prefix = str(input("Prefix: ")) print(prefix) name_list = [] match_prefix = [] for line in open(imdb_file, encoding = "ISO-8859-1"): words = line.strip().split('|') name = words[0].strip() last_name = name.split(',')[0] name_list.append(last...
8cab0fb9cc8e96850900733ded898f0fa08d7920
dankolbman/NumericalAnalysis
/Homeworks/HW1/Problem2.py
324
4.3125
4
# Using numpy matrix module import numpy as np import numpy.matlib # 5x5 random matrix M = numpy.matlib.rand(3,3) # The inverse N = M.I print("A matrix:") print(M) print("The inverse of that matrix:") print(N) # Gives the identity matrix print("The two multiplied together (should be the identity matrix):") print(M.dot(...
a974f16291fb85675d72266d2d58f08cbbb62db9
wijdanb/Python-scripts
/CSV&TSV.py
9,542
4.71875
5
#Working with CSV files """ CSV files are simple, lacking many of the features of an Excel spreadsheet. For example, CSV files: Don’t have types for their values—everything is a string Don’t have settings for font size or color Don’t have multiple worksheets Can’t specify cell widths and heights Can’t have merged cel...
c01a093328deac835976772c296010b8ea4b166c
javaspace71/skp
/IntrotoPython/s3messages_decryption.py
1,020
3.953125
4
alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890! #@&*^+' key = '' scrambled_message = '' secretalphabet = '' newMessage = '' def prompt_decrypt(): print("\n ******** SUPER SECRET SPY SYSTEM *********\n") print("super secret spy system is watching you now ...") print("you can decrypt y...
5e0f9ad2915ab4aaecc0cdafe604ed0d64d73c3f
shen-huang/selfteaching-python-camp
/19100101/zhwycsz/d5_exercise_array.py
787
3.5625
4
''' 1.将数组[0,1,2,3,4,5,6,7,8,9]翻转 2.翻转后的数字拼接成字符串 3.用字符串切片的方式取出第三到第八个字符(包含第三和第八个字符) 4.将获得的字符串进行翻转 5.将结果转为int类型 6.分别转换成二进制、八进制、十六进制 7.输出三种进制的结果 ''' array=[0,1,2,3,4,5,6,7,8,9] array.reverse() #将数组翻转 print(array) s = '' #翻转后的数组拼接成字符串方法一 for i in range(0,10): array[i]=str(array[i]) zifucuan=s.join(array) print...
0ba7b11bbff2a1a8b9eff6470d242196d282722d
lakshyatyagi24/daily-coding-problems
/python/129.py
1,143
4.25
4
# --------------------------- # Author: Tuan Nguyen # Date created: 20190924 #!solutions/129.py # --------------------------- """ Given a real number n, find the square root of n. For example, given n = 9, return 3. """ def squareRoot(n): # input: a real number n # output: square root of n round to 3 decimals # method...
2f585588a04b715718a84fbbed86ddb9a7af3713
Amiao-miao/all-codes
/month01/day06/homework1.py
246
4.1875
4
""" 将列表中的数字累减 list02 = [5, 1, 4, 6, 7, 4, 6, 8, 5] 提示:初始为第一个元素 """ list02 = [5, 1, 4, 6, 7, 4, 6, 8, 5] result=list02[0] for item in range(1,len(list02)): result-=list02[item] print(result)
2dca97a5009b231184722409e4f4a0b3cf4da8d0
Nordevor/hi
/UCSP/Python/Alexis/holacomo.py
423
3.765625
4
#1 def quicksort(lista,a,b): c=lista[(a+b)/2] while a<=b: while lista[a]<c and b<=a: a=a+1 while c<lista[b] and b>=b: b=b-1 if a<=b: aux=lista[a] lista[a]=lista[b] lista[b]=aux a=a+1 a=a-1 if a<b: quicksort(lista,a,b) if a<b: quicksort(lista,a,b) def imprime(lista,tam): for d i...
20cf439558137fb6b97e16e8450790f799a4c50a
Morek999/OMSCS_Taiwan_Leetcode
/Jason/Jason_0121_20200107.py
1,253
3.65625
4
''' Idea: Originally I just used two for loop to iterate every possibility and keep updating the max profit, which is O(n^2) and brutal force passed for C++. Then I came up using one for loop to keep updating local minimum price(min_price = min(min_price, price[i]) and maximum profit should be equal to either previo...
d83317ca98fb3a8046100ee9f59221dd1e870c3e
DumAdudus/own
/advent_of_code_2018/p2/a1.py
580
3.53125
4
#!/usr/bin/env python import string import copy with open('q') as f: slist = f.readlines() two = 0 three = 0 sublist = {} for char in list(string.ascii_lowercase): sublist[char] = 0 for s in slist: countlist = copy.deepcopy(sublist) f=0 for c in list(s.rstrip('\n')): countlist[c] += 1 ...
1b026b867a25822b6eb7f9a18b678c32b7feba8d
wogus3602/PracticeCode
/Python,Cpp/백준/10820.py
371
3.71875
4
import sys for line in sys.stdin: lower = 0 upper = 0 number = 0 space = 0 li = line for x in li: if x>='a' and x<='z': lower += 1 elif x>='A' and x<='Z': upper += 1 elif x>='0' and x<='9': number += 1 elif x == ' ': ...
1dbdeb0ab1e9ac41973b8448a6e993c7b914ae5e
yangzhao5566/go_study
/DesignPatterns/bag.py
880
3.671875
4
""" Bag """ class Bag(object): """ bag """ def __init__(self): self._items = list() def __len__(self): return len(self._items) def __contains__(self, item): return item in self._items def add(self, item): self._items.append(item) def remove(self, ite...
1f772152a515bf0f8ecc45e8a4f1a79b1c21d0d4
loryuen/python-challenge
/PyPoll/main.py
2,089
3.578125
4
import os import csv poll_csv = os.path.join('PyPoll_election_data.csv') # create empty lists number_votes = [] candidates = [] all_candidates = [] counter = [] averagelist = [] # open and read csv with open(poll_csv, 'r') as csvfile: csvreader = csv.reader(csvfile, delimiter=',') header = next(csvreader) ...