blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
ab6da8c3fe515d075f36f9918eb93177404257dc
rupaliwaghmare/If-else
/ghata.py
102
3.59375
4
num1=100 num2=33 num3=55 if 100-33==55: print("barbar hai") else: print("brabar nahi hai")
9c3cb572ff870eca4ddcbce8c85a97153ac2bf9b
rupaliwaghmare/If-else
/meraki4.py
158
3.90625
4
water= int(input("enter a number")) if water<=1: print("bharna hai") elif water>1 and water<10: print("nahi bharna") else: print("overflow")
bc83475f945ffe94c5c8db8a8d0b423c24dc1ce0
rupaliwaghmare/If-else
/equal.py
303
4.09375
4
num=int(input("enter the number")) num1=int(input("enter the number")) num2=int(input("enter the number")) if num==num1 and num==num2 and num1==num2: print("All are equal") elif num==num1 or num==num2 or num1==num2: print("Any of two are equal") else: print("not equal")
e2d300decbdf3a1fbd9bab7f7ee379190e8f66d0
sunnysong/coding_practices
/cover_square.py
984
4.1875
4
def cover_square(n, m, a): """ Theatre Square in the capital city of Berland has a rectangular shape with the size n × m meters. On the occasion of the city's anniversary, a decision was taken to pave the Square with square granite flagstones. Each flagstone is of the size a × a. What is the le...
d55719fc88b337b0fec3f2afbaeb087d1156c0a9
nsjethani/Python
/DSandALGOs/DP/edit_distance.py
1,075
3.515625
4
def minDistance(word1, word2): """ :type word1: str :type word2: str :rtype: int """ # from one word to another if not word1: return len(word2) + 1 if not word2: return len(word1) + 1 buffer_array = [[0] * (len(word2)+1) for i in range(len(word1)+1)] for i in rang...
2e1a1d26f314092e793f25896837ca5c1c9fc8cf
KangIpann/Programing-With-Mosh
/MessageEngine.py
486
3.59375
4
class Person: def __init__(self, name1, name2): self.ivan = name1 self.tejo = name2 def person1_type(self): ivan_typing = input(f'{self.ivan}: ') return ("Ivan :" + '"' + ivan_typing + '"') def person2_type(self): tejo_typing = input(f'{self.tejo}: ') return (...
d98d6d77413f4387b795b44a99b6e912b9e4487b
Suhail727/GeneralProgramming
/Missing Elements of a Range.py
400
3.890625
4
def printMissing(arr, n, low, high): # Insert all elements of # arr[] in set s = set(arr) # Traverse through the range # and print all missing elements for x in range(low, high + 1): if x not in s: print(x, end = ' ') # Driver Code arr = [...
35ba1a5601c44610b57db92c45b1c8a0dc9d4c95
Suhail727/GeneralProgramming
/Algorithms/QuickUnion-Find (Weighted,Path-Compression, Connected components).py
1,536
3.625
4
class UnionFind: def __init__(self, n): self._id = list(range(n)) self._sz = [1] * n self.cc = n # connected components def _root(self, i): j = i # Make Every node point to it's grandparent, thereby halving time # This is Path Compression # Check if the...
e5a7ce155f392c001cd500b7d17a8c32c99e2261
Suhail727/GeneralProgramming
/Sorting (Bubble Sort).py
639
3.984375
4
import sys A = [64, 25, 12, 22, 11] # Traverse through all array elements for i in range(len(A)): # Set flag to check that if in any pass, if none of the elements are swapped, then # the array is already sorted, hence we can break the outer loop. flag=0 # len(A)-i-1 is to stop checking t...
3551de2ec5214fcfb5fb24951698e12d05ac4152
ASI-CASPER/RESULT-SHEAT
/RESULT.py
234
3.796875
4
x = int(input("enter your marks :-")) if (x >= 75) : print("'A'pass") elif(x >= 65) : print("'B' pass") elif(x >= 55) : print("'C'pass") elif(x >= 35) : print("'S'pass") else : print("fail")
3dd70266a482820f1cc287e6a4db47d6e7cd1ef6
bibek1892/python_assignment2
/qn8.py
349
4.21875
4
#Write a function, is_prime, that takes an integer and returns True if #the number is prime and False if the number is not prime. def is_prime(val): if val <= 1: return "False" for i in range(2,val): if val % i == 0: return "false" return "True" number=int(input("enter a number...
80b6320aa3739d5e06c7b8a318a2ba591337adde
bibek1892/python_assignment2
/qn5.py
759
4.5625
5
#5. Create a tuple with your first name, last name, and age. Create a list, #people, and append your tuple to it. Make more tuples with the #corresponding information from your friends and append them to the #list. Sort the list. When you learn about sort method, you can use the #key parameter to sort by any field in t...
ee6f7cfae43e209163fa5d47bcf175dfd0cca17d
LakeExhaust/Calc2020
/Function.py
293
3.625
4
import math class Function: def __init__(self, x, f): self.f = f; self.x = x; def get_f (self): print("Result of f'(x) " + " : " + str(self.f)) return self.f def set_f (self, x): self.f = x def set_x (self, x): self.x = x
c3f07ddb49b663602773540cab0f91b57f6076fc
zhang25121/python_learn
/register_login/register.py
1,781
3.71875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- import re # 1. 提示用户输入用户名 print("用户名由6-16位的字母数字下划线组成") while True: username = input("请输入你要注册的用户名:") if len(username) == 0: print("用户名不能为空,请重新输入!") continue if len(username) < 6 : print("用户名太短了") continue if len(username) > 16 : print("用户名太长了") continue if le...
f4093e747e56684c874134be2292c265a83dcfef
TristanV12/examples
/Search Algorithms/search_algorithms.py
6,957
3.8125
4
from graph_builder import * from util import * import argparse """ searchAlgorithm is a general function for depth-first and breadth first search. The graph must be a valid random graph as defined in graph_builder.py The search type must be a string, either "BFS" or "DFS" defaulting with BFS. """ def searchAlgorith...
b4917956cd3e29e0b1f253e28d2898cb9b5e48a1
ZdyrkoVlad/mnist-cnn
/network.py
6,724
3.515625
4
import tensorflow as tf import time def select_activation(activation): result = tf.nn.relu if activation == 'relu': result = tf.nn.relu elif activation == 'sigmoid': result = tf.nn.sigmoid elif activation == 'tanh': result = tf.nn.tanh return result class SimpleNet: "...
71fc1c310bf711b7a966e03a15d26b9f99f4f8fa
techedlaksh/trip-optimization
/optimization.py
2,296
3.578125
4
import time import random import math people = [('Seymour','BOS'),('Franny','DAL'),('Zooey','CAK'),('Walt','MIA'),('Buddy','ORD'),('Les','OMA')] location = {'BOS':'Boston','DAL':'Dallas','CAK':'Akron','MIA':'Miami','ORD':'Chicago','OMA':'Omaha'} # laGuardia airport in New York destination = 'LGA' flights={} for line...
0008aa18064e5614f60c8d7973dfc64f0f4803af
sergey-pashaev/practice
/py/src/practice/aoc/y2015/d4p2.py
1,249
3.734375
4
# Day 4, Part Two # Santa needs help mining some AdventCoins (very similar to bitcoins) # to use as gifts for all the economically forward-thinking little # girls and boys. # To do this, he needs to find MD5 hashes which, in hexadecimal, # start with at least five zeroes. The input to the MD5 hash is some # secret ke...
9bd56966c74295e8d2ba924e95d81bc020904786
sergey-pashaev/practice
/cpp/dcp/src/ex.5.py
883
4
4
#!/usr/bin/env python # ex.5 # cons(a, b) constructs a pair, and car(pair) and cdr(pair) returns # the first and last element of that pair. For example, car(cons(3, # 4)) returns 3, and cdr(cons(3, 4)) returns 4. # Given this implementation of cons: # def cons(a, b): # def pair(f): # return f(a, b) # ...
ba7487b53641e7c491b464aa2422a3beb4065614
mateusflns/Edutech-Atividades
/30 de junho/atv5.py
912
4.28125
4
#Exercicio 4: #Faça um programa que receba um valor, e traga informações sobre esse valor, dizendo se é alfanumérico, numérico e etc. # --------- VARIAVEIS E CONSTANTES --------- posneg = 'positivo' tipo = 0 letras = 'qwertyuiopaasdfghjklzxcvbnm' numeros = '1234567890' # --------- LENDO A ENTRADA DO US...
97e425e4a5876246e2cb49b6924dfbf8b9aa9d2d
vik407/holbertonschool-higher_level_programming
/0x04-python-more_data_structures/1-search_replace.py
231
3.96875
4
#!/usr/bin/python3 def search_replace(my_list, search, replace): _my_list = [] for m in my_list: if m == search: _my_list.append(replace) else: _my_list.append(m) return _my_list
2fb94b3a4c85e5b749f9cb3d9efd48badce3f4c9
vik407/holbertonschool-higher_level_programming
/0x0A-python-inheritance/100-my_int.py
237
3.8125
4
#!/usr/bin/python3 """12. My integer """ class MyInt(int): """Write a class MyInt that inherits from int """ def __eq__(self, n): return super().__ne__(n) def __ne__(self, n): return super().__eq__(n)
0eb6fac7e77dc90010ec1d32278bb08c943b5a09
vik407/holbertonschool-higher_level_programming
/0x03-python-data_structures/9-max_integer.py
250
3.703125
4
#!/usr/bin/python3 def max_integer(my_list=[]): if len(my_list) == 0: return None big_number = my_list[0] for each_number in my_list: if each_number > big_number: big_number = each_number return big_number
2d13a708a6a531eb6a808c393172a49735b86db0
vik407/holbertonschool-higher_level_programming
/0x02-python-import_modules/1-calculation.py
427
3.6875
4
#!/usr/bin/python3 from calculator_1 import add, sub, mul, div a = 10 b = 5 if __name__ == "__main__": # add print("{:s} + {:s} = {:s}".format(str(a), str(b), str(add(a, b)))) # sub print("{:s} - {:s} = {:s}".format(str(a), str(b), str(sub(a, b)))) # mul print("{:s} * {:s} = {:s}".format(str(a),...
e00b51a8bc1b8983dbd53a6364ee75bd13b5f115
vik407/holbertonschool-higher_level_programming
/0x0B-python-input_output/0-read_file.py
261
4.1875
4
#!/usr/bin/python3 """0. Read file """ def read_file(filename=""): """Write a function that reads a text file (UTF8) and prints it to stdout: """ with open(filename, 'r') as file: file_content = file.read() print(file_content, end="")
a2bb1e4e412336309573964aa560473385ad2cc4
vik407/holbertonschool-higher_level_programming
/0x0B-python-input_output/14-pascal_triangle.py
443
3.9375
4
#!/usr/bin/python3 """14. Pascal's Triangle """ def pascal_triangle(n): """A function def pascal_triangle(n): that returns a list of lists of integers representing the Pascal’s triangle of n """ list = [] if n <= 0: return list for i in range(n): row = [1] if i > 0: ...
1af29ab4b3a8416514a2fc5a3e73a85fcf40d0e2
naschwin/cryptography
/Python/csrt1.py
1,261
4
4
class Caesar_cipher(): def __init__(self): alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' self.alpha = alpha str_inp = input("Enter the string: \n") self.str_inp = str_inp.upper() def encrypt(self): inp_len = len(self.str_inp) lst_len = len(self.alpha) e...
09b917f8bb9ef1a465cc7d8539f888890f2130d0
naschwin/cryptography
/Python/euclidean_gcd.py
501
3.828125
4
# print("n1:", end="") # n1 = int(input()) # print("n2:", end="") # n2 = int(input()) def gcd(a,b): if(b==0): return a else: return gcd(b,a%b) def print_gcd(n1, n2): if n2 != 0: a = max(n1, n2) b = min(n1, n2) q = a // b r = a % b ...
6aefa33dc81efe1740140504afdc68c94ab831d4
edward795/python_numpy_module
/numpy datatypes.py
1,009
3.796875
4
# -*- coding: utf-8 -*- """ Created on Thu Oct 14 21:09:39 2021 @author: HOME PC """ """ Below is a list of all data types in NumPy and the characters used to represent them. i - integer b - boolean u - unsigned integer f - float c - complex float m - timedelta M - datetime O - object S - string U - unicode string V...
0a6abdf7621424dddf5ab65bc27a1156ac038e17
edward795/python_numpy_module
/Random Distributions/Random Permutation.py
324
3.9375
4
# -*- coding: utf-8 -*- """ Created on Fri Nov 5 19:06:29 2021 @author: HOME PC """ from numpy import random import numpy as np arr=np.array([5,7,8,9,3]) #shuffle makes changes to original array print(random.shuffle(arr)) #permutation returns a new instance of an array new_arr=random.permutation(arr) print(new_a...
4d1af0e224eeb19343112f3739c1d25f4f66942f
edward795/python_numpy_module
/Iterating Through Arrays.py
1,406
3.640625
4
# -*- coding: utf-8 -*- """ Created on Fri Oct 15 16:57:34 2021 @author: HOME PC """ #Iterationg over 1D Arrays import numpy as np arr=np.array([1,2,3,4,5]) for i in arr: print(i) #Iteration over 2D Arrays print('Iterationg over 2D Arrays:') arr2=np.array([[1,2,3],[4,5,6],[7,8,9]]) for i in arr2: p...
ddea3acbb5ac9f097a925acd8ca3aed184d5a0b7
kathfor/final_project
/code.py
21,772
3.65625
4
import json, requests import sqlite3 from datetime import datetime import matplotlib.pyplot as plt import numpy as np #Weather API def weather_conditions(query): '''Input: query to select location to search on weather API Function: calls to API and collects weather data for given query Returns: success sta...
c2e4a533bd00849863638e55129767f9a37ed741
CukCoding/Donald
/2439.py
108
3.59375
4
number=input() n=int(number) i=0 while i<=n: i=i+1 print(" "*(n-i)+'*'*i) if i==n: break
e33b6ce663994766db330cef5b2eb0fbd42993e5
deepakkapse/Lets-contribute-1
/python/MajorityElement.py
758
4.65625
5
# Python 3 program to find Majority # element in an array # Function to find Majority # element in an array def findMajority(arr, n): maxCount = 0; index = -1 # sentinels for i in range(n): count = 0 for j in range(n): if(arr[i] == arr[j]): count += 1 # update maxCount if count of ...
aca8a417ae7be758e6be454b00f3f9a98d10bee5
alemley/Python-Code-Samples
/Algorithms/Lab005/ClosestPair.py
1,832
3.734375
4
from random import randint import math import timeit class Points(object): def __init__(self, _x=None, _y=None): self.x = _x self.y = _y def closest_pair(_points, _num_points): points = _points number_of_points = _num_points dist = math.inf tuple1 = () tuple2 = () basic_o...
374d4ba1be7fb9bacfe9d2703d3bdf549d670bdb
alemley/Python-Code-Samples
/Algorithms/2.16/2.16.py
2,075
3.890625
4
import math def main(): n = [10, 20, 40, 80, 160, 320] p = [1, 2, 4, 8, 16, 32, 64, 128] print('Part a)') print('Speedup)') for i in range(len(p)): for j in range(len(n)): print('Elements:', n[j]) print('Processors:', p[i]) print('Speedup:', speedup(n[j]...
406a8d7663c5a6e26858692127ede89625c311d2
andrewsmedina/projecteuler
/python/3.py
287
3.546875
4
''' Problem 3 The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? ''' value = 600851475143 factor = 3 while factor < value: if value % factor == 0: value = value/factor else: factor += 2 print factor
7ac43edca4ed90f40900a374de8b404d3c70d060
PragmaticWays/learn-python
/converter.py
1,818
4.40625
4
''' Converter program Convert between different units of measurement ''' playAgain = True while playAgain: print("=========================================") print("Welcome to Measurements Converter Program") print("=========================================") print("What metric are you trying to con...
1970cf29aa92b1264925eecefa7c3dd88a4a0d4b
KamilZiemski/pyDev
/src1/__init__.py
165
3.5
4
''' Created on 18.06.2009 @author: Lars Vogel ''' def add(a,b): return a+b def addFixedValue(a): y=5 return y+a print( add(1, 2)) print( addFixedValue(3))
7aaeceed8f504fd132ba9db8b6f5e9bea5ce84f2
CSteele97/Leeds-stuff
/input_output_demo.py
652
4.09375
4
file_for_reading = open('in.txt', 'r') text_in_file = file_for_reading.read() file-for_reading.close() with open('in.txt', 'r') as file_for_reading: text_in_file = file_for_reading.read() with open('in.txt', 'r') as file_for_reading: for line in file_for_reading: print('I read a line and ...
d7aeefa27fe593f6618080168a92df60a887192d
CSteele97/Leeds-stuff
/model.py
2,045
3.5
4
# -*- coding: utf-8 -*- """ Created on Mon Sep 17 15:58:32 2018 @author: gycms """ # Set up variable y0 = 50 x0 = 50 # Import and set a random number import random random_number = random.random() # Move y randomly if random_number < 0.5: y0 += 1 else: y0 -= 1 if random_number < 0.5: y0 ...
abe22a4455c04ca44d78f2133bdc179821fb6813
sdheally/python-examples
/homework_5_program.py
2,010
4.21875
4
''' Python for Beginners 20776.059 Steve Heally 07/27/17 Homework #5 - homework_5_solution_program.py Write another program that will import the module you created above so that it can be used by this new program. ''' import time import homework_5_solution_module as hw5sm ''' Open two files reading all lines into tw...
80275e09871efb331c0e425a23ac7427ed5ffa9c
nikhilv2/Competitive_coding_practice_python
/Binary search tree/Answer.py
1,267
3.90625
4
class Node: def __init__(self,data): self.right=self.left=None self.data = data class Solution: def insert(self,root,data): if root==None: return Node(data) else: if data<=root.data: cur=self.insert(root.left,data) root.left...
37e93c84885264a813d3c8928ad38172573d6afe
Joshin95/programming
/infoitic/4/64.py
802
3.78125
4
a=1 while a<3: if a%2==0: b=1 while b<3: print "X", b=b+1 print "0", a=a+1 print "Aquest programa acaba escribint /X X 0/ en la pantalla, ho fa perque la funcio if es TRUE quan la variable /a/ es un numero parell entre el 1 i el 3(en aquest cas nomes pot ser el ...
6b263cebb134b4fcc9860cc5bc7451de458c59b6
Joshin95/programming
/tecpro/exercicis/ex2b/src/circuit.py
861
3.5625
4
""" El modul ajunta tots els components creats """ from component import component class circuit(object): """ Aquesta classe to com a objectiu controlar el conjunt de components d'un circuit """ def __init__(self): self._components=[] def afegirComponent(self,c): """ El metode afegeix com...
259bb252285013179c9eb9f7399ff6fe2e92a8e8
Joshin95/programming
/tecpro/Calculador_matricial/matriu.py
5,025
3.90625
4
def inicialitzarMatriu(f,c): """ Inicialitza a zeros una matriu de ordre fxc >>> inicialitzaMatriu(3,3) [[0, 0, 0], [0, 0, 0], [0, 0, 0]] >>> inicialitzaMatriu(2,4) [[0, 0, 0, 0], [0, 0, 0, 0]] """ mat=[] for i in range(f): fila=[] for j in range(c): z=0 ...
c322565b0539c0f1f60b4151b0a2e4abd77eeb35
Joshin95/programming
/infoitic/3/EOL12.py
162
3.859375
4
def justificar_a_la_dreta(a,b): return " "*(b-len(a)) x=raw_input("escriu la paraula: ") z=input("el numero d'espais: ") print justificar_a_la_dreta(x,z)+x
a249fe8800f87ca77f557c1578463e81c6426c70
Joshin95/programming
/infoitic/5/puntuatv2.py
1,660
3.796875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- def comprovaPIN(a,b,p): """ Et dona tres intents per esciure el code PIN correcte >>> comprovaPIN(1,1234,1234) False >>> comprovaPIN(2,1235,1234) True >>> comprovaPIN(4,1234,1234) False >>> comprovaPIN(5,1236,1234) False """ ...
94514f4a3b96707b5b043b74829557707cbea909
Joshin95/programming
/tecpro/Practica5/src/estat.py
2,592
4.21875
4
""" Aquest modul conte la classe Estat """ class Estat(object): """ Aquesta classe representa els estats que prenen els nodes d'un triport """ def __init__(self,e=-1): """ Metode constructor predefinit a -1 """ self._e=e def undef(self): """ Posa com...
a66f320becb42b6a553841c8b8258211ac4f883b
Joshin95/programming
/tecpro/Practica6/dataset.py
3,427
3.515625
4
from datetime import time class DataSet(object): def __init__(self,name=""): self._name=name self._ds=[] def __len__(self): return len(self._ds) def __str__(self): print self._name for element in self._ds: print (element[0].strftime("%H:%M:%S"),element...
7945600f8c33baeddc33e6c334a9682335ffdc99
Joshin95/programming
/tecpro/tema1/divisio.py
539
3.9375
4
class fraccio(object): def __init__(self,n,d): self.n=n self.d=d def sumaFrac(self,x): den=self.d*x.d num=(self.n*x.d)+(x.n*self.d) return fraccio(num,den) def divisio(self,x): num=self.n*x.d den=self.d*x.n return fraccio(num,den) def obten...
3e72496670d775e9578c607910ff6a43fc07d146
Joshin95/programming
/infoitic/3/39.py
478
3.546875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- def resultat(a): print "El resultat es: ", a def multn(n): resultat(n*1) resultat(n*2) resultat(n*3) multn(4) multn("A") print "Aquest programa te 10 línies (sense contar els meus canvis) i després de la execució mostra una cosa així:" print "El resulta...
e3086cd7f9620d7b4e886671a72944c627479018
Joshin95/programming
/tecpro/exercicis/ex8/eol8182.py
5,209
4.25
4
#!/usr/bin/env python # -*- coding: utf-8 -*- def alumne(d): """ Permet crear el diccionari d i afegir-li dades """ nom=raw_input("Escriu el nom del alumne: ") cognom=raw_input("Escriu els cognoms del alumne: ") if d.has_key((nom,cognom))==False: d[(nom,cognom)]="" else: pri...
d29d9a3b66bb6f78e3c4a4f766ef8ce2f7f26a12
HughesJoshB/CSC-121
/LastName_HandsOnExam_1.py
3,599
4.5
4
# Joshua Hughes # March 23, 2017 # Hands on in Class Exam ''' Hands On Exam #1 U will be presented with a menuu First thing is to make sure the program will run I have given you the basic structure so do NOT alter the basic structure Based on the menu we will choose 1 then 2 then 3 in that order 1)If an ...
79fced7665f0ed19d9fbf248eed1265374ac5740
abril427/SI-206-HW5
/206W17_HW5.py
5,471
3.765625
4
import unittest import tweepy import requests import json import twitter_info ## SI 206 - W17 - HW5 ## COMMENT WITH: ## Your section day/time: Thurs 6-7 ## Any names of people you worked with on this assignment: N/A ######## 500 points total ######## ## Write code that uses the tweepy library to search for tweets w...
e96d2b54141344a02281ed27073be936ae2bee52
busyjeter/test_file
/scatter_squares.py
529
3.53125
4
import matplotlib.pyplot as plt x_value=list(range(1,1001)) y_value=[x**2 for x in x_value] plt.scatter(x_value,y_value,c=y_value,cmap=plt.cm.Blues,edgecolor='none',s=10) # 设置图表标题并给坐标轴加上标签 plt.title("Square Numbers", fontsize=24) plt.xlabel("Value", fontsize=14) plt.ylabel("Square of Value", fontsize=14) # 设置刻度...
6d0cb093244907127815c73360f3ea42e79ff8d7
PoornaPragnaMS/Python-for-All
/ListOperations.py
445
4.0625
4
# In this program we are going to see, how to perform any suggested operation from end user on a List L = [] ip = input("Kindly Enter the operation to be performed on a string").split() cmd = ip[0] args = ip[1:] if cmd != 'print': cmd += '('+','.join(args)+')' eval ('L.'+cmd) else: print(L) # Sam...
d49f9d3cbefca0ffccbb0ca7f8f7a17231e3f0bc
RafaelMuniz94/AjudandoBruninho
/Questao4.py
786
3.96875
4
# 4-Faça um Programa que leia um vetor A com 10 números inteiros, calcule e mostre a soma dos quadrados dos elementos do vetor. import math vetorA = [] def LerNumeros(): for i in range(10): vetorA.append(int(input(f"{i+1} -Digite um numero:"))) def ObterQuadrados(vetor): vetorQuadrados = [] for nu...
cd6664774f50159df9b14da0dd929c2ce2f65061
ZiggerZZ/rldurak
/game/field.py
3,366
4.03125
4
import sys if sys.version_info[0] == 2: import deck elif sys.version_info[0] == 3: import game.deck as deck class Field: """A playing field containing the deck, players and cards that are put for everyone to see. Contains a list of cards on the field and a list that pairs an attack card with ...
bbdaa4f5e7c2fff56db476f857586d6df2a705bd
WGX-01/Lab-LFP-Tarea1
/Ejercicio12-SplitAndJoin.py
232
3.75
4
def split_and_join(line): # write your code here b = line.split() a = "-" string = a.join(b) return (string) if __name__ == '__main__': line = input() result = split_and_join(line) print (result)
cbc024fd9e0cd7d357b3a762d0f2879cebde9bc0
shaik101/python-web-scraper
/target_attributes.py
842
3.5
4
from bs4 import BeautifulSoup def read_file(): in_file = open('tags.html') data = in_file.read() in_file.close() return data soup = BeautifulSoup(read_file(), 'lxml') meta = soup.meta # target the first occurrence of the meta tag print(meta) print(meta.get('charset')) # supports get method as wel...
01c64e270e316c1b16532220a8b7c35dc65af960
HigorCalheiros/Curso_Topicos_Programcao_Python
/aula2/aula2.py
466
3.734375
4
''' Autor: Higor Calheiros Data: 18/05/2018 - RJ Este programa calcula uma soma ou multiplicação entre dois números ''' n1=float(input("Digite um valor: ")) n2=float(input("Digite mais um valor: ")) opcao=(input("Digite s para somar e m para multiplicar:" )) soma=n1+n2 mult=n1*n2 if opcao=='s' or opc...
e4a0a3b993d916dcb486d71d3d9e28eaa09d35df
meiyalian/algorithms-implementation-python
/LZSS/pre_processing.py
1,550
3.96875
4
def Zalgorithm (str): """ Compute Z value of the str. define Z[i] (for each position i > 1 in str) as the length of the longest substring starting at position i of str that matches its prefix Parameters: str (String): the target string Returns: int[] :...
f4cdb5f6cb05baf64677922e09f32eab987e8999
meiyalian/algorithms-implementation-python
/PatternMatching/modified_kmp.py
3,523
3.71875
4
import sys def spTable (pat): """ Compute sp table for pat Parameters: pat (String): the target string Returns: int[] : a 2d array, table[i][j] denotes the right most position of chr(i) from pat[j] Complexity: O(M), M is the length of the str """ ...
6037d04f135d4b326f0b9931f50fd467d83eec83
russodanielp/mlbsim
/teams.py
894
3.625
4
class Team: def __init__(self, team_name:str, winning_prob:float): self.team_name = team_name self.winning_prob = winning_prob self.wins = 0 self.losses = 0 def get_record(self): return [self.wins, self.losses] def won_game(self): self.wins += 1 def los...
02014465f50394a094c15157415dce4d15dc3b03
varunkumarkadambala/quantiphi-training-python
/Assignments/Assignment1/q2.py
474
3.78125
4
#Reading the input document document_text = open('input.txt', 'r').read() #List of all the words in the document words = document_text.split() count = {} #counting the unique words from the word list for word in words: if word in count: count[word.lower()] += 1 else: count[word.lower()] = 1 #Creating a output fil...
cf39d36d4dfb308724e86b981caa64bdd475442c
kyang888/leetcode
/剑指offer/构建二叉树.py
938
3.640625
4
# -*- coding:utf-8 -*- # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: # 返回构造的TreeNode根节点 def reConstructBinaryTree(self, pre, tin): # write code here if len(pre) == 0: return None re...
574ffd591e5692d8e62c5a2a23353d0d8367d139
jtlai0921/MP11704_example
/11/isPrime2.py
363
3.75
4
import time def isPrime(n): if n<2: return False if n==2: return True if not n&1: return False for i in range(3, int(n**0.5)+2, 2): if n%i == 0: return False return True num = 0 start = time.time() for n in range(100000000): if isPrime(n): nu...
1e7eb942e444d37fac5a026dc6de3abe1dfdd67f
jtlai0921/MP11704_example
/03/03_03_02.py
178
3.734375
4
def demo(newitem, old_list=[]): old_list.append(newitem) return old_list print(demo('5', [1, 2, 3, 4])) print(demo('aaa', ['a', 'b'])) print(demo('a')) print(demo('b'))
297c9e9ff1f7e957b4028d8f2cd8c2b48b0a1565
jtlai0921/MP11704_example
/14/14-02.py
984
3.890625
4
from string import ascii_uppercase as uppercase from itertools import cycle #建立密碼表 table = dict() for ch in uppercase: index = uppercase.index(ch) table[ch] = uppercase[index:]+uppercase[:index] #建立解密密碼表 deTable = {'A':'A'} start = 'Z' for ch in uppercase[1:]: index = uppercase.index(ch) deTable[ch] =...
4cf6d8715d3adef9bcd88ddb165f5af43046e5be
jtlai0921/MP11704_example
/03/03-12.py
237
3.59375
4
digits = (1, 2, 3, 4) for i in digits: ii = i*100 for j in digits: if j==i: continue jj = j*10 for k in digits: if k==i or k==j: continue print(ii+jj+k)
14eabfd4aa0e076905f32fd2f7483c0d4d709350
jtlai0921/MP11704_example
/15/15-07.pyw
1,769
3.5
4
import tkinter import tkinter.messagebox #自訂視窗類別 class myWindow: #構造函數 def __init__(self, root, myTitle, flag): #建立視窗 self.top = tkinter.Toplevel(root, width=300, height=200) #設定視窗標題 self.top.title(myTitle) #設定頂端顯示 self.top.attributes('-topmost', 1) #根據不同...
358174be382d1de2439742b40eb5aef3552583e4
jtlai0921/MP11704_example
/13/13_05_06.py
664
3.5625
4
import numpy as np import matplotlib.pyplot as plt x= np.linspace(0, 2*np.pi, 500) #建立引數陣列 y1 = np.sin(x) #建立函數值陣列 y2 = np.cos(x) y3 = np.sin(x*x) plt.figure(1) #建立圖形 #create three axes ax1 = plt.subplot(2,2,1) #第一列第一行圖形 ax2 = plt.subplot(2,2,2) #第一列第二行圖形 ax3 = plt.subplot(2,1,2) #第二列 plt.sca(ax1) #選...
e80120da93584207a2f41f144c12cff8303b8786
jtlai0921/MP11704_example
/05/05_01_02_3.py
732
3.515625
4
import timeit #使用列表推導式產生10000個字串 strlist = ['This is a long string that will not keep in memory.' for n in range(10000)] #使用字串物件的join()方法連接多個字串 def use_join(): return ''.join(strlist) #使用運算子+連接多個字串 def use_plus(): result = '' for strtemp in strlist: result = result+strtemp return result if _...
96e8e85b490f3a1fe5f0df2393ab3893fb024bb8
jtlai0921/MP11704_example
/06/06-27.py
1,092
3.5625
4
#docx檔案題庫包含很多段,每段一個題目,格式為:問題。(答案) #資料庫datase.db中,tiku資料表包含kechengmingcheng,zhangjie,timu,daan四個欄位 #資料庫有關知識,請查看本書第8章 import sqlite3 from docx import Document doc = Document('《Python程式設計》題庫.docx') #連接資料庫 conn = sqlite3.connect('database.db') cur = conn.cursor() #先清空原來的題庫,可省略 cur.execute('delete from tiku') conn.commit...
2478799c90ad98ad629f94ec299572a22938a5cd
DartmouthHackerClub/coursetown
/public/scripts/scrapers/medians/medians.py
3,771
3.59375
4
#!/usr/bin/env python # # Takes html containing medians table in, spits out JSON. Uses the popular # HTML parsing library BeautifulSoup. # # Now works for the formats used from 08F - 11W. # import sys import re import urllib import json from BeautifulSoup import BeautifulSoup import traceback # Parse the department,...
8705d6a57d2d6c8a888b9eaba8ab25deda29cbbf
TSG405/Python_HackerranK
/Pangrams.py
686
3.859375
4
''' Problem Statement: https://www.hackerrank.com/challenges/pangrams/problem @Coded by TSG, 2021 ''' import math import os import random import re import sys d = {'a':0,'b':0,'c':0,'d':0,'e':0,'f':0,'g':0,'h':0,'i':0,'j':0,'k':0,'l':0,'m':0,'n':0,'o':0,'p':0,'q':0,'r':0,'s':0,'t':0,'u':0,'v':0,'w':0,'x':0,'y':0,'z'...
efae3a482d304157b318a62c5dea3ded7a973514
Lgdev07/Criptografar-frase
/Crypt.py
2,278
3.796875
4
import string import random class Encryption(): """ SEED: Senha para descriptografar ENCRYPTION: Input a frase / palavra que queira criptografar, retorna a frase / palavra criptografada DESCRYPTION: Input a frase / palavra que queira descriptografar, INPUT o seed para libera...
e2bec2020e0735156118a4733fbc070d89ef0f58
diego-garcia-martin/PythonIntroCourse
/TicTacToe2.py
3,726
3.65625
4
from tkinter import * from tkinter import messagebox turn = 'X' board = [['-', '-', '-'], ['-', '-', '-'], ['-', '-', '-']] def reset(): global board, turn turn = 'X' board = [['-', '-', '-'], ['-', '-', '-'], ['-', '-', '-']] for button in butto...
9fa4ec33a84db53ce869f2d6cbcf3a50c171c48d
diego-garcia-martin/PythonIntroCourse
/HelloWorld.py
144
3.828125
4
print("Hello World") print("Hola Mundo") print("Gutten Tag") name = input("Please tell me your name: ") print("Hello", name, "and welcome to Python!")
b4a0a4a4577a9bbc121a0fe43862e59c914ce905
coolzoa/ALG_prime
/primo.py
1,519
3.734375
4
import tkinter from tkinter import* import ast from ast import* def primo(numero): if numero <= 1: return False elif numero == 2 or numero == 3: return True elif numero % 2 == 0: return False i = 3 while i * i <= numero: if (numero % i == 0): return False...
059fe6b648feac978a29b25b00f53b3657997977
shukubota/sakuzu
/sakuzu09/test02.py
306
3.625
4
#coding:utf-8 import numpy as np def test(i,j): return i+1,j+1 u=np.zeros((2,3)) v=2. U= test(u,v)[0] V=test(u,v)[1] #print U #print V dataex=np.zeros(()) for i in range(0,2): for j in range(0,3): dataex[i][j]=10*i+j print dataex test2=np.zeros((2,3)) #test2+=testf(1) #print test2
168e590eac31438e7e48f8609b227672f72bc5ca
fblw/course-assignments
/assignments/mit/6.0001/ps4/ps4a.py
2,173
4.40625
4
# Problem Set 4A def get_permutations(sequence): ''' Enumerate all permutations of a given string sequence (string): an arbitrary string to permute. Assume that it is a non-empty string. You MUST use recursion for this part. Non-recursive solutions will not be accepted. Ret...
c9179108f44f13ce81932d0d7823d1993c04c49d
akashjaiswal9994/ai-assignment-1
/AI assingment.py
255
3.71875
4
q1=[1,1,1,1,0,0,0,0] q2=[1,0,1,0,1,0,1,0] q3=[1,1,0,0,1,1,0,0] print(" Is every human good grader ? ") for i in q1: for j in q2: for k in q3: z=i and j or k if z==0: print("False") else: pass
74a586685d0d7e141155b28668fa0afc85b7c432
WildStriker/adventofcode_2018
/7/1/answer.py
3,461
3.609375
4
import typing class Instruction: def __init__(self, letter): self._letter = letter self._can_begin = {} self._conditions = {} self._is_completed = False @property def letter(self): return self._letter @property def conditions(self) -> typing.Dict[str, 'Ins...
90e9790546ffac81bb8bc877fc4a874310f149ad
anselmo-2010/control-questions-1
/2.py
567
3.71875
4
from random import randint random_number = randint(1, 20) i = 0 while i < 5: count = int(input("Введите число от 1 до 20 - ")) if random_number == count: print("Класс! Вы угадали") print("Случайное число :", random_number) break elif random_number > count: print("Слишком ма...
a29aab90b0c038c96763e32022f0d5bf627f5202
NisaSource/CS50-s-Introduction-to-Computer-Science
/pset6/caesar/caesar.py
664
4.125
4
from cs50 import get_string import sys def main(): # checking the proper usage if len(sys.argv) != 2: # error alert print("Usage: ./caesar k") sys.exit(1) k = int(sys.argv[1]) # get the input from the user plaintext = get_string("plaintext: ") # the output print("...
539b32c7c08bee673a43c03c8817f7a4cfe36b6e
a289459798/leetcode
/lc2/lc2.py
1,054
3.796875
4
class ListNode(object): def __init__(self, x): self.val = x self.next = None class Solution(object): def addTwoNumbers(self, l1, l2): """ :type l1: ListNode :type l2: ListNode :rtype: ListNode """ r = ListNode(0) flag = 0 curr = r ...
d3c03f2e5180950e1a79a2f2b2348fcf3db0c1c0
Viktor-Sok/Data-Science-Portfolio
/Dashboard/games_market_dash_Viktor_Sokolov.py
8,346
3.578125
4
import dash import dash_bootstrap_components as dbc import dash_core_components as dcc import dash_html_components as html import pandas as pd from numpy import random import plotly.express as px from dash.dependencies import Input, Output # Preparing the data df = pd.read_csv("games.csv") """ The code snippet belo...
95db0775c2c4cc8e5f804ca5dd94730ee7a78898
arifcahya/introduction
/Harshrathore_21BCON019_3rd.py
267
4.1875
4
n = int(input("Up to which natural number :")) ctr=1 sum_even = sum_odd = 0 while ctr<=n: if ctr%2==0: sum_even += ctr else: sum_odd += ctr ctr += 1 print("The sum of even integers is",sum_even) print("The sum of odd integers is",sum_odd)
97d34b07216a608177f684be1466fdb318e36e30
arifcahya/introduction
/Harshrathore_21BCON019_1st.py
299
4.25
4
ch=input("Enter a single charcter :") if ch>='A' and ch<='Z': print("You entered an Upper Case character.") elif ch>='a' and ch<='z': print("You entered a Lower Case character.") elif ch>='0' and ch<='9': print("You entered a digit") else: print("You entered a special character. ")
c6a251cd0ee777b13ac29538b2a91a331a7f7e89
arifcahya/introduction
/lokeshsethia21BCON195_5.py
500
4.21875
4
import random Number=random.randrange(0,101) Guess=int(input("Guess a Number Between 0 and 100 --> ")) while Guess!=Number: if Guess<=Number: print("Plz Enter A Greater Number!! ☻☻") Guess=int(input("Guess a Number Between 0 and 100 --> ")) else: print("You Need to Guess A Lower Number, ...
09ae97aa31928884eae6e2c6c1dea0db2e0037ae
arifcahya/introduction
/ayush_21bcon295_6.py
7,222
3.625
4
import random import re domino_set = [] y = -1 while y in range(-1, 7): y += 1 for x in range(y, 7): domino_set.append([y, x]) def interface(): print('=' * 70) print(f"Stock size: {len(stock_pieces)}\nComputer pieces: {len(computer_pieces)}") print() if len(domino_snake) > 6: p...
e97c602889d14e4c327bda8e55007e902bda35aa
arifcahya/introduction
/Harshrathore_21BCON019_13th.py
246
4.25
4
n=int(input("Up to which NATURAL NUMBER : ")) a=1 sum_even=sum_odd=0 while a<=n: if a%2==0: sum_even+=a else: sum_odd+=a a+=1 print("The sum of even integers is ",sum_even) print("The sum of odd integers is ",sum_odd)
c2fc875930b809a795e3baf467250b86adda3994
arifcahya/introduction
/parikshitdave21bcon157_1.py
219
4.34375
4
#This programme tells us that the given number is odd or even. Number=int(input("Enter Number:- ")) Num=Number%2 if Num==0: print("Given Number is an Even Number.") else: print("Given Number is an Odd Number.")
33a8f11220436f80719effc9a35b62cd9ffa7a7f
arifcahya/introduction
/ayush_21bcon295_3.py
1,461
4.375
4
print('Hello! My name is Jarvis.') print('I was created in 2021.') print('Please, remind me your name.') name = input('Your Name : ') print('What a great name you have, ' + name + '!') print('Let me guess your age.') print('Enter remainders of dividing your age by 3, 5 and 7.') rem3 = int(input('Remainder by 3 : ')) r...
774f1dc66dcd5531fbb4e454d985625e538f04d3
arifcahya/introduction
/Navratanprajapat21BCON440_5.py
1,123
4.0625
4
import random print("**** WELCOME TO THE GAME ****") print("Press 1 for Rock") print("Press 2 for Paper") print("Press 3 for Scissor") x=int(input("Choose any one :- ")) y = random.randrange(1,4) # 1 = Rock , 2 = Paper , 3 = Scissor if x==1 or x==2 or x==3: if x == y: print("Its a Tie") elif x=...
65ec1272202e0e2a7b0e3682bf34b7dcb2ebc6c1
arifcahya/introduction
/KaushalSoni 21BCON368 5th file.py
438
4.03125
4
# This program is used to find total sale made, total transactions made and the avg sale made per transaction TT = 0 TS = 0 count = 1 while count<=7: T=int(input('Transactions Made on Day'+str(count)+':')) S=int(input('Items Sold on Day'+str(count)+':')) TT +=T TS += S count += 1 AS = TS/TT print('...
16574066eb37708218456a1875e6c3c9847ab213
arifcahya/introduction
/lokeshsethia21BCON195_6.py
5,647
4.21875
4
print("Press 1 for Square.") print("Press 2 for Rectangle.") print("Press 3 for Equilateral Triangle.") print("Press 4 for Regular Pentagon.") print("Press 5 for Regular Hexagon.") print("Press 6 for Regular Heptagon.") print("Press 7 for Regular Octagon.") print("Press 8 for Regular Nonagon.") print("Press 9 for Regul...
51ec2716816b79fd3d57e52ffa6095d8eb1aeb17
arifcahya/introduction
/Dev_Sum_and_Average_of_N_Natural_Numbers.py
372
4.21875
4
# Python Program to find Sum and Average of N Natural Numbers number = int(input("Please Enter any Number: ")) total = 0 for value in range(1, number + 1): total = total + value average = total / number print("The Sum of Natural Numbers from 1 to {0} = {1}".format(number, total)) print("Average of Natural Num...