blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
5138570d9b2b9bd899bd759b2616808a36a2d588
sosooding/CTFs
/shellctf/Return-of-the-Caesar-Salad/Return-of-the-Caesar-Salad.py
242
3.515625
4
cipher = [115, 105, 103, 111, 112, 104, 122, 109, 131, 124, 82, 116, 114, 129, 63, 125, 119, 112, 104, 116, 128, 138, 73, 138, 149] cipher = [cipher[i] - i for i in range(len(cipher))] cipher = [chr(x) for x in cipher] print ''.join(cipher)
de8a94ec6d0d77fa8ae2589af53dd333b1d81052
behrouzmadahian/python
/sentiment-analysis/pythoncodes/05-sentiment-analysis-modeling-pre-trained-wordvecs.py
13,673
3.65625
4
import tensorflow as tf import numpy as np import random ''' We will use GloVe pre-trained word embeddings which have length =50 The word2Vec has 3 million words of each 300 length! a little memory intensive! Glove contains 400000 words with word vector representation of length 50! The training set we're going t...
d43f6443e05ff353f0508e350d007bcb0604bcbf
smart2rakesh-raks/91social-assignment
/answer_4.py
222
3.671875
4
l= [{'make':'Nokia', 'model':216, 'color':'Black'}, {'make':'Mi Max', 'model':'2', 'color':'Gold'}, {'make':'Samsung', 'model': 7, 'color':'Blue'}] sorted_l = sorted(l, key = lambda x: x['color']) print(sorted_l)
aa1f6427426d674790be1662af13daf335aa3bae
kalott/qga-framework
/deap/qga_gui_deap.py
5,419
3.515625
4
# import one_max_deap from tkinter import Tk, Button, Label, Text, END, Entry, Grid from tabulate import tabulate from statistics import mean import matplotlib.pyplot as plt import pandas # Global variables generations_population = pandas.DataFrame()#columns=['Generation', 'A', 'B', 'C', 'Fitness']) # Saves the po...
b6594b2fd0a82dd7b951344db9b63aaadf2f0473
Taporpone/Python
/PythonScripts/PS_numbers_to_words.py
4,995
4.03125
4
#created by taporpone@gmail.com """Simple script changing numbers to words - 123 - one hundred twenty three.""" def numberstowords(): ### wrapped it up in a function for looping purposes - see eof while True: inp = raw_input('Enter a number using digits > ') ###declare variable inp(ut) by user def i...
edfc00ca7cadb56c9672e500f437e1bfe85cf735
mniederschmidt/web-caesar
/caesar.py
700
3.796875
4
import string upper_offset = 65 lower_offset = 97 def alphabet_position(letter): if letter in string.ascii_uppercase: return ord(letter) - upper_offset elif letter in string.ascii_lowercase: return ord(letter) - lower_offset else: return -1 def rotate_character(char, rot): if ...
60db7d25241aa15900bf70d44a70ac5b47e3bf46
guo842917077/Exercise
/pythontest/com/crazyorange/project/tupletimes.py
626
3.8125
4
####统计元素出现的频次 from random import randint data=[randint(0,20) for x in range(30)] print(data) ####生成字典 data--key 0--defaultValue # dict_data=dict.fromkeys(data,0) # for x in dict_data: # dict_data[x]+=1 # print(dict_data) ###使用counter对象 查询出现频次最多的元素 from collections import Counter c2=Counter(data) print(c2.most_comm...
7977f4a92710a08621a40da774c464e3b92e2908
tuanavu/IPython-reference
/Python/algorithms-and-data-structures/linked_list.py
543
3.875
4
# new linked list class Node: def __init__(self, contents=None, next=None): self.contents = contents self.next = next def getContents(self): return self.contents def __str__(self): return str(self.contents) def print_list(node): while node: print(node...
5900c42386bfe97cede1f8544d36f836b1ebd115
KickItAndCode/Algorithms
/DynamicProgramming/MaxSubArrayContiguous.py
1,141
3.875
4
# 53. Maximum Subarray # Given an integer array nums, find the contiguous subarray # (containing at least one number) which has the largest sum # and return its sum. # Example: # Input: [-2,1,-3,4,-1,2,1,-5,4], # Output: 6 # Explanation: [4,-1,2,1] has the largest sum = 6. # Follow up: # If you have figured out the ...
fa9b071e28e932a27abb2249e6d66d09f45b0083
jeanjosephgeorge/python_exercises
/Week 1/listExercises.py
1,853
3.984375
4
# 1. SUM THE NUMBERS # list1 = [2,3,7,9,13] # total=0 # for x in list1: # total+=x # print ("Sum total is",total) # 2. LARGEST NUMBERS # list1 = [32,74,21,65,44] # list1.sort() # last = int(len(list1)) # print ("Largest number in the string is",(list1[len(list1)-1])) # 3. SMALLEST NUMBERS # lis...
7e3768c524c63700f06833618fc84061591b2d59
SivaGanesh-M/python-intenship
/day5.py
781
3.78125
4
def myFun(num): num[0] = 20 list = [1, 2, 3, 4, 5] myFun(list) print(list) def my_function(): print("Hello from a function") print("Day 5 - Functions") my_function() # Exercise 1 def arith_func(p, q): print("Addition of two numbers is: ", p+q) print("Subtraction of two ...
c73a6a979a4ef3685e1d92b657411b242062b6ad
MAPLE-Robot-Subgoaling/IPT
/data/HW5/hw5_132.py
525
4.03125
4
def main(): w=int(input("Enter the width: ")) h=int(input("Enter the height: ")) fill=input("Enter symbol for the fill: ") outline=input("Enter the symbol for the outline: ") top="" for i in range(0,w): top=str(top+outline) print(top) inner="" for i in range(1,h-1): f...
5a03e400798a9f78af40736123020bfae2b24a32
SergioRodas/Curso_Python_pildorasinformaticas
/expresiones_regulares/practica_regex.py
569
3.796875
4
import re cadena = "Vamos a aprender expresiones regulares en Python. Python es un lenguaje de sintaxis sencilla." texto_buscar = "Python" texto_encontrado = re.search(texto_buscar, cadena) if re.search(texto_buscar, cadena) is not None: print("He encontrado el texto.") else: print("No he encontrado el text...
c9c8dfd403b7b27ddd7c40f658a41c14ff7e7eb0
staceysv/safelife
/training/utils.py
3,409
3.9375
4
from collections import namedtuple from functools import wraps import numpy as np _no_default = object() def named_output(names): """ A simple decorator to transform a function's output to a named tuple. For example, @named_output(['foo', 'bar']) def my_func(): return 1, 2 ...
c0217cbc17b9713fc57cc3a2f7799641e031dc33
Oilman-programmer/NeuralSolvers
/PINNFramework/models/activations/snake.py
666
3.609375
4
import torch import torch.nn as nn class Snake(nn.Module,): """ Implementation of the snake activation function as a torch nn module The result of the activation function a(x) is calculated by a(x) = x + sin^2(x) With alpha is a trainab """ def __init__(self,frequency=10): """Construct...
deda65b19522503b046a6782c62feda8f6483113
hakimencem01/DFP40203-STUDY
/labexercise1.py
1,374
4.125
4
""" Nama : Mohammad Abdul Hakim Kelas : 4B No Matrik : 20DDT19F1050 """ for x in range(11): print("The square of "+str(x)+" is : "+str(x*x)); # 2,4,6,8,10 sum = 0; start = 0; stop = 10; stopindex = 11; for x in range(start,stopindex,2): sum+=x; print("\n\nThe total of even numbers from "+str(start)+" to "+s...
56b5de8bb839ed03862ce9c674c9ea73e6cddb3f
sumitkumar97/SPOJ-Solutions
/CANDY3.py
219
3.78125
4
#your code goes here test = input() for k in range ( 0 , test ) : s = raw_input() n = input() total = 0 for i in range ( 0 , n ) : total += input() if ( total % n == 0 ) : print "YES" else : print "NO"
03546be3f23ab6e16d746b6cd0b0ebc9ec41880a
rahmonov/python-exercism
/anagram/anagram.py
281
3.71875
4
def detect_anagrams(original, words): return [word for word in words if is_anagram(original, word)] def is_anagram(original, version): original, version = map(lambda x: x.lower(), [original, version]) return sorted(original) == sorted(version) and original != version
3722e212668ef7bd2b0aa97da5abfd819c237a46
samir-0711/Leetcode-Python
/441. Arranging Coins.py
1,029
3.546875
4
#Solution 1: brute force class Solution(object): def arrangeCoins(self, n): """ :type n: int :rtype: int """ if n == 0: return n i = 1 while n - i >= 0: n -= i i += 1 return i - 1 #Solution 2: binary search class ...
790fc616db8619e0dcef1d68a7b4e0b6ac6d6aee
XuefeiY/leetcode
/Algorithm/7-reverse integer.py
1,961
4.21875
4
# ============================================================================= # 7. Reverse Integer # ============================================================================= """ Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 click to show spoilers. Have ...
16cae8a095d1eea87e016a7bd36d9bd3ba7ec22f
ActoSoft/DjangoCourse-PythonFundamentals
/abc.py
226
3.71875
4
abc = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' ] word = abc[15].upper() + abc[-2] + abc[-7] + abc[7] + abc[14] + abc[13] print(word)
068efdc7bbeda5076205892b5bca3d7b0ff9b46e
ericvanular/PythonPractice
/largest_diff_two_arrays.py
616
4.3125
4
#You have two arrays with numbers in them. You have to stop the program once #you've found the largest difference between one number in the 1st array and one number in the #2nd array. You do not have to return the numbers, just stop once you've found it. def find_largest_diff(arr1, arr2): min_arr1 = min(arr1)...
0e226739bcdbe1b422a3aa59a9f734e1025deb54
WaterlooSpaceSoc/HAB
/Hardware/serialpythontest.py
1,368
3.5
4
## ##To be used in conjunction with serialpythontest.ino ## ##A simple test that allows Python to read in sensor data readings from the Arduino over serial. ## import serial ser = serial.Serial('/dev/ttyUSB1', 9600) while True: #testwrite = ser.read() #print(testwrite) line = ser.readline() print...
6b5e9c0762bdb14b383845a02eabb0923bfa8991
mathiasjepsen/Databases-Assignment_1
/Simple_db.py
1,336
3.53125
4
class Simple_db: def __init__(self, db): self.db = db self.in_memory_dict = {} def write_to_db(self, key, value): with open(self.db, "a") as db: self.in_memory_dict[key] = len(key) + 1 + db.tell() db.write(f"{key};{value}\n") def populate(self): wi...
df762f8f439a12be829e5c5f782a83225cb21aab
woosyume/python
/basic/data/variables.py
512
4
4
import math # 파이썬은 대부분의 수학 함수가 마련되어 있다. print(help(math)) num = 1 # num: int = 1 와 같이 형태 지정도 가능. 그런데 딱히 필요하지는 않다. name = 'Kim' is_os = True print(num, type(num)) print(name, type(name)) print(is_os, type(is_os)) test_num = '1' print(test_num) print('Hi', 'woosyume', sep=',', end='.\n') # Hi,woosyume. print(17 / 3)...
a0d410030e994adf82cbc55c048529c930d9e2c1
learlinian/Python-Leetcode-Solution
/38.Count and Say.py
796
3.5625
4
class Solution(object): def countAndSay(self, n): def calculate(nums): count = 0 # count the repetitive appeared item output = '' # output pre = '' # record the previous checked character for num in nums: if pre and num ...
117ffe6d931df8664bfc72f195147c8f12c53047
Pedro-H-Castoldi/descobrindo_Python
/Exercícios/EX 28 - Jogo da Adivinhação de Números.py
722
3.625
4
from random import choice from time import sleep print(f'-=-'*20) print('Eae! Está pronto???\nEm que número eu pensei de 0 a 5?') print(f'-=-'*20) pn = [0, 1, 2, 3, 4, 5] while True: pensei = choice(pn) na = int(input('Digite o número que pensei: ')) print('PROCESSANDO...') sleep(1) if na >= 0 and...
fba3983fb601fa412b7c081dbb2aadc9fd897cdb
hirenchalodiya1/ai-pl-prover
/operations.py
11,961
3.859375
4
class Operand(object): value = None def __init__(self, value): self.value = value def __str__(self): return f"{self.value}" def __repr__(self): return str(self) def __eq__(self, other): if type(other) is not Operand: return False return self.va...
7fc2904a4e4e467c9897fbf8655fc6e3b8a5d200
Swedeldsouza/python-project
/unitconverter/unitconverter.py
32,711
4.15625
4
'''Unit converter''' '''Length - meter,km,mm,Mile,Yard,foot,inch,Micrometer,Nanometer''' print("Welcome to unit converter") print("Enter input Value as 1 or 2 or 3 below ") type=int(input("Enter \n 1.Length \n 2.Mass \n 3.Temperature \n 4.Volume \n 5.Time\n 6.Currency \n")) j=0 def convert_S...
47156db16c80daff936e94cdb9fa30a76ed16de0
dishasahu/clgpythonprograms
/programs/fizzbuzz.py
309
3.984375
4
# -*- coding: utf-8 -*- """ Created on Sun Mar 31 18:25:32 2019 @author: abc """ num=int(input("enter the number:")) for i in range(1,num+1): if i%3==0 and i%5==0: print("FIZZBUZZ") elif i%3==0: print("RED") elif i%5==0: print("BLACK") else: print(i)
9c14f9807f8a5b9f8dd873a78dbac6f72167f1c2
clovery410/mycode
/python/chapter-1/hw3-Q4.py
418
3.625
4
from operator import mul, sub #fact = lambda n: 1 if n == 1 else mul(n, fact(sub(n, 1))) #print(fact(5)) def make_anonymous_factorial(): """Return the value of an expression that computes factorial. >>> make_anonymous_factorial()(5) 120 """ return lambda n: 1 if n == 1 else mul(n, make_anonym...
a86b5df139ed692752c45358918640fed1bd0cd5
AlbertoLejarraga/Metaheuristicas-UGR
/Practica 1-LocalSearch y Greedy/software/aleatorio.py
874
3.578125
4
__author__ = 'adaptacion generador aleatorio C++ de sci2s' class Random: #inicializar la semilla con el valor dado y las constantes necesarias def __init__(self, semilla): self.__mascara=2147483647 self.__primo=65539 self.__escala=0.4656612875e-9 self.__semilla=long(sem...
39c26bfc9342c3e4e2560bdccc347cd9f22d9a7f
daniriveradr/my-python-exercises
/looops/exercise1.py
186
4
4
''' Write a program that asks the user for a word and displays it on the screen 10 times ''' print("Escribe una palabra: ") palabra= input("") for i in range(1, 10): print(palabra)
d0b6b4ecffff21fa91dc5be4492d8a374ec144b2
mighto/algorithm
/selection-sort.py
692
3.90625
4
''' 选择排序 ''' # 获取数组中的最小值 def findSmallest(arr): # 存储最小的值 smallest = arr[0] # 存储最小元素的索引 smallest_index = 0 for i in range(1, len(arr)): if arr[i] < smallest: smallest = arr[i] smallest_index = i return smallest_index # 选择排序 def selectionSort(arr): newArr =...
1cf056ca0c8c7ca978cee24d279d76d6ddc53b87
IcyDevv/UnbelievaBoat-Python-Bot
/src/game_libs/roulette/__init__.py
3,088
3.53125
4
""" START OF ROOULETTE ROULETTE GAME SLOTS found on https://github.com/ntaliceo/roulette-simulator, rest is done here """ import random, discord, time # what will be called to play the game class roulette_discord_implementation: def __init__(self, bot, channel, currency_emoji): self.bot = bot self.channel = cha...
d614195bcf427db451457529606ca2d88a09c2fb
CodaGott/introtopythonforcomputerscienceanddatascienceexercises
/Chapter_two_exercises/Exercise2.5.py
615
4.53125
5
""" (Circle Area, Diameter and Circumference) For a circle of radius 2, display the diameter, circumference and area. Use the value 3.14159 for π. Use the following formulas (r is the radius): diameter = 2r, circumference = 2πr and area = πr2. [In a later chapter, we’ll introduce Python’s math module which contains a h...
c5cb6b8ad45ff591af89935b98df9177d64ba1f0
milson389/metode-numerik
/RungeKutta/runge.py
2,005
3.59375
4
import math def func(x, y): return (0.5*x**3) + 3 def func1(x, y): return y * x - y def func2(x, y): return (x+y-2) def euler(f, xAwal, yAwal, stepSize, xTarget, yEksak): temp = 0 index = 0 ea = 100 while (xAwal < xTarget): print('X : ', xAwal) print('Y Euler : ', yAw...
c38a09da25243e44b67d24d01f447fb1fe780335
dragonfly/dragonfly
/examples/synthetic/hartmann3_2/hartmann3_2_mf.py
1,118
3.671875
4
""" Hartmann function in 3 dimensions. This function assumes that the input is a list of 2 elements where the first is a one dimensional object and the second is a two dimensional object. The purpose is to demonstrate setting up complex spaces in dragonfly. -- kandasamy@cs.cmu.edu """ # pylint: disable=invali...
54119e522af9ba7f51e2dd2d96af6f3b85905020
Mayuri0612/Leetcode-Challanges
/week1/VerticalTraversal_sol1.py
1,064
3.90625
4
class Node: def __init__(self, val): self.val = val self.left = None self.right = None def verticalOrder(root, hd, m): if root is None: return #m.setdefault(hd, []).append(root.data) if hd in m: m[hd].append(root.val) else: m[hd] = [root.val] v...
d61cb2853e9429c710795ab5b469b35690487d3e
kira-95/bpm
/src/test_inputs.py
1,229
3.59375
4
#!/usr/bin/env python3 ''' @author: torlofski ''' import unittest from mock import patch from src.inputs import get_length, get_genre, get_speed class InputTestCase(unittest.TestCase): """Input tests""" def length_test(self, given_answer, expected_out): """Test get_length""" with patch('bui...
63d603d27e256d5d5b95a65e20a6b48819c26244
ayman-shah/Python-CA
/Python 2/3.2.py
562
4.15625
4
#List of computer's favorites favorites = ['blue', 9, 'pizza', 3.14159] #Print statement print(favorites[0].upper()) #Ask the user for their favorite food, check if it is the same as the computer food = input("What is your favorite food?") food = food.strip().lower() if food == favorites[2]: #A function...
c49cbedd09820811303f650d0f8ed9b1436b85ef
RuosongZhang/linux_win
/test/testd/testc.py
702
3.9375
4
numbers = ['abc', 'bnd', 'sdte'] for i in range(len(numbers)): numbers[i] = numbers[i] * 2 print(numbers) zzz = ['abd', 'ccc'] numbers = numbers + zzz numbers = numbers * 3 print(numbers) def add_all(t): total = 0 for x in t: total += x return total t = [1, 3, 4, 5, 6] print(add_all(t)) aa ...
e3e83d6430246e72511dc345ac99aaa9f91c3faf
EKonykhov/Less1
/les1.py
3,777
4.25
4
#====№1 (Поработайте с переменными, создайте несколько, выведите на экран)==== x = 2021 y = "Привет" i = "мир" n = "наступил" z = "год!" print(y + " " + i + ", " + n + " " + str(x) + " " + z) #(Pапросите у пользователя несколько чисел и строк и сохраните в переменные, выведите на экран) print("Скажите ...
1c6afb1c5058adec2c124f884da5fb7f732f1ffd
qingqibing/02.IOT_Django
/smartPip/interaction/libry.py
244
3.65625
4
import random def random_color(): color_arr = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 'A', 'B', 'C', 'D', 'E', 'F'] color = "" for i in range(6): color += color_arr[random.randint(0, 16)] return "#" + color
c2b908de374dadaa99810c182c9a3d0ea7b9b4b2
mivicker/python-coursework
/Python Problem Set 1/DreamHome3.py
2,171
4.28125
4
# -*- coding: utf-8 -*- """ You have got out of your dead end career and you're trying to save to build a blocky monstrosty to live in. You're going to need a lot of money to pay a shit eating architect. This program asks you how many months it will take before you have a down payment ready for your home, so you can ...
f16bfbf615bc103ce73b1ceddd26ee731c15a9bb
AkshatGarg-bot/Simple-OPENCV-programs
/transformations.py
1,032
3.5
4
import cv2 as cv import numpy as np img = cv.imread('photos/Screenshot from 2021-04-29 14-44-45.png') cv.imshow('Screenshot',img) #translation--> shifting the image in x and y pixels def translate(img,x,y): transMat = np.float32([[1,0,x],[0,1,y]]) dimensions = (img.shape[1],img.shape[0]) return cv.warpAff...
7aa56301cf3bd67b1b6467577ffb4184c1f2a6dd
migregal/bmstu-iu7-python
/Labs/sem_1/lab_07_Matrix/main_script_2.py
1,268
3.578125
4
''' Лабораторная работа №7-2 - Матрицы Данная программа вычисляет значение кусочно заданной функции Переменные x - Значение аргумента w - Значение функции i, j - Счетчики eps - Точность вычисления для участка, где функция задана бесконечным рядом ch - Числитель для того же участка n - Номер эл...
7e977ec81428c016109f9f716ca40b4e79df075d
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/meetup/7e41c0d6171e4a6e82c2529d3d6db0c8.py
1,029
4.1875
4
import datetime weekdays = { 'Monday': 0, 'Tuesday': 1, 'Wednesday': 2, 'Thursday': 3, 'Friday': 4, 'Saturday': 5, 'Sunday': 6 } def meetup_day(year, month, day_name, week_index_name): weekday_index = weekdays[day_name] cur_day = datetime.date(year, month, 1) # Get first occur...
8267eca0ff514465336dbea57465d67ac0f52441
varughese/CS8-Spring19-Recitation
/week7/SOL06a.py
1,567
4.125
4
# Lottery Numbers import random def generateLottoNumbers(): # Initialise an empty list that will be used to store the 6 lucky numbers! lottery_numbers = [] for i in range(0, 6): number = random.randint(1, 90) # Check if this number has already been picked and ... while ...
aa9bcca1503ce92a0213df069903fb074784543b
owshidahaigui/all_notes
/lvze/day01/Lvze/wrapper.py
800
4.21875
4
#带有参数的装饰器 def outer(*args,**kwargs): print("最外层") # 我们习惯的装饰器 def add(func): def wrapper(*args, **kwargs): print("a + b:") result = func(*args, **kwargs) print("over") return result return wrapper return add # add = outer(1000,2000) # ...
e2272a6c0f2df241bbddd93d40703022e71d94ca
ToxicRabbittt/CodeForces
/Nearly Lucky Number 110A.py
111
3.515625
4
n = input() print("YES") if (n.count("4")+n.count("7") == 4 or n.count("4")+n.count("7") == 7) else print("NO")
9ac513f66de6a4ea9df1e853a19fa6fe510b7002
ruberobo/labs-de-ironhack
/module-1/pandas-project/your-code/funciones.py
993
3.6875
4
#funciones pandas #función para actividad def activity(x): try: y = x.split() for z in y: if z.endswith('ing'): return z except: pass #funcion para la edad def age(x): try: y = x.split() for i in y: if i.isnumeric(): ...
7d7f05f3d91e0e686f6b21602d64b6f280f8b29d
YoupengLi/leetcode-sorting
/Solutions/0210_findOrder.py
3,705
4.21875
4
# -*- coding: utf-8 -*- # @Time : 2019/9/3 20:54 # @Author : Youpeng Li # @Site : # @File : 0210_findOrder.py # @Software: PyCharm ''' 210. Course Schedule II There are a total of n courses you have to take, labeled from 0 to n-1. Some courses may have prerequisites, for example to take course 0...
96ae8b80137bc7db6afbef56c75f8bc22823d0db
propenster/Api
/Sequence_file_format_checker.py
312
3.9375
4
#usr/bin/python3 print( """ This simple script checks and tells the file format of a sequence file fwd in """ ) def __seq_file_feed(ref_seq): f = open(ref_seq, "r") if(f.readline[0] == ">"): print("File.is fasta format") else: print("File is not fasta")
5bc599e90402de5d58264845d03256a3ea67b8c9
mustafaergan/Python101
/HellWorld/Example2VariableType/__init__.py
1,204
3.671875
4
#int from test.pickletester import REX_five myint = 7 print(myint) # float myfloat = 6.0 print(myfloat) #float funk floatNumber = float(7) print(floatNumber) #String mystring = "i love there" print(mystring) #sum one = 1 five = 5 summ = one + five print(sum) #concat text1 = "Mustafa Kemal" tex...
619697a21386c908ef3090e3c492e934804e0d5d
soqutto/practice
/AtCoder/ABC137/c_ans.py
426
3.59375
4
# -*- coding: utf-8 -*- import numpy as np N = int(input()) S = [] hash_table = {} a_ascii = ord('a') bins_of_char = np.zeros((N, 26),dtype=np.int) num_of_anagram = 0 for i in range(N): S.append(''.join(sorted(input()))) S = sorted(S) for i in range(N): if S[i] in hash_table: num_of_anagram += hash...
8c9fe8cfab9e27720ebebda270ff97391ed095d3
BruceEckel/ThinkingInPython
/Examples/Metaprogramming/SimpleMeta1.py
588
3.71875
4
# Metaprogramming/SimpleMeta1.py # Two-step metaclass creation in Python 2.x class SimpleMeta1(type): def __init__(cls, name, bases, nmspc): super(SimpleMeta1, cls).__init__(name, bases, nmspc) cls.uses_metaclass = lambda self: "Yes!" class Simple1(object): __metaclass__ = SimpleMeta1 def ...
d11506882ca009ccb5ee487067a55a5e09558e09
yzc1114/algorithm_A3
/main.py
445
3.890625
4
def func(): n = int(input("输入n:")) m = int(input("输入m:")) assert n > m greedy_choice = n // m + 1 smaller_choice = n // m num_of_greedy_choice = n % m num_of_smaller_choice = (n - num_of_greedy_choice * greedy_choice) // smaller_choice result = [smaller_choice] * num_of_smaller_choice + ...
b92d6b52150af63d5a6fa19213d98817535cb683
swati2728/function_questions
/more_eexercise.py
2,722
3.921875
4
# Question 1 # i=1 # while i<=1000: # if i%2==0: # print("nav") # if i%7==0: # print("gurukul") # if i%21==0: # print("navgurukul") # i=i+1 # Question 2 # Number_of_students=input("enter a name:") # Ek_student_ka_kharcha=int(input("enter a spending amount:")) # if Ek_student_ka_kharcha<=50000: # print("H...
8d5ce499f24203489cab5be9c2ae1fe4e6d17277
QunLeLZ/LeetCood
/剑指Offer/扑克牌顺子/扑克牌顺子.py
529
3.75
4
# -*- coding:utf-8 -*- class Solution: def IsContinuous(self, numbers): # write code here zero,count = 0,0 if not numbers: return False numbers.sort() for i in range(0,4): if numbers[i] == 0: zero += 1 continue ...
0f94e83e7de573c357fb2e299e2be9712e309328
daniel-reich/ubiquitous-fiesta
/mYGipMffRTYxYmv5i_19.py
376
3.859375
4
def simple_equation(a, b, c): if (a+b == c): return "{}+{}={}".format(a,b,c) if (a-b == c): return "{}-{}={}".format(a,b,c) elif(b-a == c): return "{}-{}={}".format(b,a,c) elif(b*a == c): return "{}*{}={}".format(a,b,c) elif(b/a == c): return "{}/{}={}".format(b,a,c) elif(a/b == c): ...
357b90f7ca47446b5a6ea967dfc7f4171e75fbf0
karthikjampani1999/Dictionary_telephone_data
/Dictionary.py
627
4.1875
4
Telephone_Data = {'karthik':'98485','krishna':'637285','Dilip':'2939405'} while True: print("Please enter your contact name: ") contact_name = input() if contact_name=='': break if contact_name in Telephone_Data: print(Telephone_Data[contact_name] + " is contact number of "+...
2c5d3297bf62fd42587b45196ba57a886a6b0165
agengsusila/pythonfrommosh
/part 4 strings.py
817
3.90625
4
# MATERIAL LESSON father_name = "My Father's name is Mulyadi" # 2 QUOTES WILL BE USED BECAUSE IN THE STRING THERE ARE HAS 1 QUOTES rag_sentences = 'In my heart is "ONLY" you' # OTHERWISE 1 QUOTES WILL BE USED BECAUSE IN THE STRING THERE ARE HAS 2 QUOTES email = ''' Hello Bening, I hear from my friends that you b...
a36a29dde9b5710288966af812a752ca33ffa58f
brandanmcdevitt/python.archive
/Ulster_University/COM661_Full_Stack_Development/Week_1_Practical_Session/t1-02.py
414
3.71875
4
import turtle def main(): turtle.hideturtle() square(100, 0, 50, 'red') square(-150, -100, -200, 'blue') square(-200, 150, 75, 'green') def square(x, y, width, color): turtle.penup() turtle.goto(x, y) turtle.fillcolor(color) turtle.pendown() turtle.begin_fill() for count in r...
bdf84a0bd3990fc70caff99cc91091eea1811b13
alibaizhanov/AlgoLeetCode
/160-IntersectionofTwoLinkedLists.py
1,100
3.5625
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def getIntersectionNode(self, headA: ListNode, headB: ListNode) -> ListNode: lenA = 0 lenB = 0 tailA = ListNode(0) tailB = L...
b36aa4c30c0ee95403b5d8101540976701545bb3
taro-masuda/leetcode
/0048_RotateImage.py
335
3.609375
4
class Solution: def rotate(self, matrix: List[List[int]]) -> None: """ Do not return anything, modify matrix in-place instead. """ n = len(matrix) a = [] for row in range(n): a.extend(matrix[row]) for row in range(n): matrix[row] = a[n*...
e1d4df6af4985995c4ae060db4ada9aabbe544e0
djulian2001/tut_udemy_django
/backend/part_two_exercise.py
2,439
3.578125
4
import unittest def array_check(given): if 1 in given and 2 in given and 3 in given: return True else: return False def string_bits( given ): return ''.join(''.join(given[i]) for i in range(0,len(given),2) ) def end_other( given ): if given[0].lower() in given[1].lower() or given[1].lower() in given[...
0b87a5740ce478b0c6d79416e5a94a898fcfefda
Nubstein/Python-exercises
/Condicionais e Loop/Ex4.py
732
4.25
4
#Faça um programa para a leitura de duas notas parciais de um aluno. # O programa deve calcular a média alcançada por aluno e apresentar: A mensagem "Aprovado", # se a média alcançada for maior ou igual a sete; # A mensagem "Reprovado", se a média for menor do que sete; # A mensagem "Aprovado com Distinção", se a m...
574d8be99b4025fc41c6c2433e0228c676087ffe
rtg0795/python_snippets
/chained_function.py
292
3.59375
4
# Source # https://towardsdatascience.com/30-helpful-python-snippets-that-you-can-learn-in-30-seconds-or-less-69bb49204172 # Chained Function call # logic def add(a, b): return a + b def substract(a, b): return a - b # test a, b = 4, 5 print((substract if a > b else add)(a, b))
4dd6e4515621c3bde93d765ecf714e144a65a1aa
ccollado7/UNSAM---Python
/5. Complejidad y Organización de programas/5.1 Scripting/Introduccion.py
599
3.59375
4
# -*- coding: utf-8 -*- """ Created on Thu Sep 3 10:22:26 2020 @author: Claudio Collado """ #%% #Definir nombres def cuadrado(x): return x*x a = 42 b = a + 2 z = cuadrado(b) print(z) #%% # Definir Funciones def leer_precios(nombre_archivo): precios = {} with open(nombre_archivo) as f: f_csv =...
815dfc546ddbb9801c4e6376240ae11df88c1250
Sandeep8447/interview_puzzles
/src/main/python/com/skalicky/python/interviewpuzzles/find_max_length_of_substring_without_repeating_chars.py
1,426
4.03125
4
# Task: # # Given a string, find the length of the longest substring without repeating characters. # # Here is an example solution in Python language. (Any language is OK to use in an interview, though we'd recommend # Python as a generalist language utilized by companies like Google, Facebook, Netflix, Dropbox, Pinter...
7eca4242884560b5950dae40370cafead7f618b9
athiraanilt/python_basic
/if1.py
380
4.25
4
#ask user to enter dish and print which cuisine is that dish# indian =['samosa', 'daal', 'naan'] chinese = ['egg roll', 'fried rice'] italian = ['pizza', 'pasta','risotto'] dish = input('Enter a dish name:') if dish in indian : print('Indian') elif dish in chinese : print('Chinese') elif dish in italian : ...
87959ee28aafccc3268430134ac588c2c5eb063c
joao-lucasilva/Caso-COH-PIAH
/COH-PIAH.py
6,045
3.984375
4
import re def le_assinatura(): '''A funcao le os valores dos tracos linguisticos do modelo e devolve uma assinatura a ser comparada com os textos fornecidos''' print("Bem-vindo ao detector automático de COH-PIAH.") print("Informe a assinatura típica de um aluno infectado:") wal = float(input("Entre o ...
14cc95c6fbe3b57842db771713703d4284ed88de
butchman/AI50-python-CS50
/ai50-projects-2020-x-tictactoe/tictactoe.py
5,021
4.0625
4
""" Tic Tac Toe Player """ import math import copy X = "X" O = "O" EMPTY = None def initial_state(): """ Returns starting state of the board. """ return [[EMPTY, EMPTY, EMPTY], [EMPTY, EMPTY, EMPTY], [EMPTY, EMPTY, EMPTY]] def player(board): """ Returns player who h...
30ea69fa6b205a14833c7b5fb311ce2b8d2c2031
maksudpranto/unit_testing
/assertion_test2.py
671
3.609375
4
import unittest from selenium import webdriver class Test(unittest.TestCase): def testName(self): self.driver = webdriver.Chrome( executable_path='B:\CSE Job Preparation\SQA\Automation Testing\Drivers\chromedriver.exe') self.driver.get('https://www.google.com/') title_of_page =...
85deda36b20f70d1903e36c00aeae5e2da073e7b
haeseoklee/design_pattern
/iterator_pattern/main.py
907
3.796875
4
from restaurant.menu import PancakeHouseMenu, DinerMenu class Waitress: def __init__(self, pancake_house_menu, diner_menu): self.pancake_house_menu = pancake_house_menu self.diner_menu = diner_menu def print_menu(self): p_iter = self.pancake_house_menu.create_iterator() d_ite...
e435a19d249b4e8641c427fe1f0a07b176650373
mouse-reeve/word-builder
/wordbuilder/WordBuilder.py
2,473
3.671875
4
''' Create words from an existing wordlist ''' import random import re class WordBuilder(object): ''' uses an existing corpus to create new phonemically consistent words ''' def __init__(self, initial='>', terminal='<', chunk_size=2): #indicators for start and ends of words - set if necessary to avoid...
3ad1bb4b5075c98e541677f8a5c744de7e95ad22
jennifernazario/Budget_App
/Budget_App.py
1,527
3.8125
4
class Category: # constructor def __init__(self, category, amount): self.category = category self.amount = amount # methods def deposit(self, amount): self.amount += amount return "You have successfully deposited {} into the {} category.".format(amount, self.category) ...
7058c54dc5b2905bf59ce99b69e04c7d159deb8e
daxingshen/living
/mynumpy/day01.py
541
3.71875
4
# -*- coding: utf-8 -*- import numpy as np data = np.random.randint(2, 3) print(data) data = np.array([1, 3, 4, 5]) print(data) print(data.shape) data = np.ndarray([1, 3, 4, 5]) print(data) print(data.shape) data = np.arange(10) print(data) data = data.astype(np.float64) print(data) data = np.array([[1, 2, 3], [2,...
f5d54f8477fa7eb7bb4f6833258bbbd4f288e5e8
kanglicheng/Coursera-CS-classes
/DS_Algorithms/week3/change.py
367
3.53125
4
# Uses python3 import sys def get_change(m): #write your code here cent, nickel, dime =1, 5, 10 count=0 change=[0]*3 while(m >0): change=[m-cent, m-nickel, m-dime] m= min(i for i in change if i >=0) count+=1 return count if __name__ == '__main__': m = i...
1bb8141a28160f734849d13f800b09909b1978eb
wattaihei/ProgrammingContest
/Codeforces/ECR64/probD.py
1,822
3.515625
4
class UnionFind(): def __init__(self, n): self.n = n self.root = [-1]*(n+1) self.rnk = [0]*(n+1) def Find_Root(self, x): if(self.root[x] < 0): return x else: self.root[x] = self.Find_Root(self.root[x]) return self.root[x] def Uni...
0cdfd467f31e9f092a60f613b7a4a636ce06790f
qmnguyenw/python_py4e
/geeksforgeeks/python/python_all/80_10.py
2,301
4.3125
4
Python | Rear stray character String split Sometimes, while working with Python Strings, we can have problem in which we need to split a string. But sometimes, we can have a case in which we have after splitting a blank space at rear end of list. This is usually not desired. Lets discussed ways in which this ...
c540ec399c3f28077ed7d2e5a9b86feffae22587
pedrobenevides2/Ciencia-de-Dados
/coursera/input_validacao.py
272
3.96875
4
def input_dig(): x=True while x: n = input("digite um número: ") x = n.isalpha() n = int(n) print(x) def input_str(): x=True while x: n =input ( "digite uma letra: ") x= n.isdigit() n= str(n) print(x)
0cba855eff16856b420a9c8fb183d853a2619653
Hamza-Abdullah/huddersfield_python_year1
/Week 7/uni_email.py
1,735
3.890625
4
import random import sys def random_name(): names = ["Hamza", "Rowan", "Atkinson", "Jackie", "Chan", "Tom", "Hardy"] selection = random.sample(names, 1)[0] return selection def random_phrase(): phrases = ["Maybe", "Tell me more", "I'm pleased to hear that", "Possibly", "Good to know"] selection ...
392c7c4a6aa9f1b956cb2f473056c6c1c9001a55
tonsam/Code-Storage
/Python/mxnetTest.py
1,265
3.5625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Jul 19 09:19:41 2018 mxnet test thingy @author: titan """ # We first import MXNet import mxnet as mx # Then we declare the data iterators to the training and validation datasets train = mx.io.MNISTIter( # image = "/media/titan/Storage 4/MN...
3a5ffed8f216db4123e2375c8caf28dd149934c2
markimoo999/MYPYTHONSTUFF
/thisisnotaturtle.py
232
3.75
4
import turtle t = turtle.Pen() colors = ["red", "green", "blue", "purple", "orange"] for x in range(300): t.forward(x) t.pencolor(colors[x%5]) t.left(90) t.backward(200) turtle.exitonclick()
98d1dac2e26623333f31ba0d43c686542ced7e5e
jake-basten/farkel-simulator
/src/players.py
532
3.625
4
class Player: def __init__(self, name): self.name = name self.score = 0 def __str__(self): return f"{self.name}: {self.score}" def add_to_score(self, points): self.score += points def has_score_to_win(self, score_to_win): return self.score >= s...
616c0da8f148925a780d7881d425a15fad6a2005
jklemm/curso-python
/pythonbrasil/lista_1_estrutura_sequencial/ex_04_notas_bimestrais.py
312
3.859375
4
print('Calcula notas bimestrais') print('Informe suas quatro notas bimestrais') nota1 = float(input('Nota 1: ')) nota2 = float(input('Nota 2: ')) nota3 = float(input('Nota 3: ')) nota4 = float(input('Nota 4: ')) media = (nota1 + nota2 + nota3 + nota4) / 4 print('A média das notas é {:.1f}'.format(media))
dbd6af74ca0d3a073997a92aa6cd36eec8a1bdf4
SeunginLyu/ToolBox-Geocoding
/mbta_finder.py
4,335
3.59375
4
""" Geocoding and Web APIs Project Toolbox exercise Find the MBTA stops closest to a given location. Full instructions are at: https://sites.google.com/site/sd15spring/home/project-toolbox/geocoding-and-web-apis """ import urllib.parse import urllib.request import json # Useful URLs (you need to add the appropriate...
e8f534e2a317c3316ad02b4304dbbee65744bd6d
kakakong/fluent-python
/docerate/clock.py
651
3.53125
4
import time def clock(func): def clocked(*args): t0 = time.perf_counter() result = func(*args) elapsed = time.perf_counter() - t0 args_str = ','.join(repr(arg) for arg in args) name = func.__name__ print('[%0.8fs] %s(%s) -> %s' % (elapsed, name, args_str, result)) ...
965e8a42154398a7c465848daa22697538716de2
darialyhenko/python_practice
/py/1LR/Tests/Weapon_Test.py
852
3.640625
4
import unittest from Weapon import Weapon class TestWeaponMethods(unittest.TestCase): def test_damage(self): weapon = Weapon("Оружие", 50) self.assertEqual(weapon.damage, 50) def test_damage_setter(self): weapon = Weapon("Оружие", 50) self.assertEqual(weapon.damage, 50) ...
d5d1d06e45e51678e7397af4a3203c79f764c23b
dhaarmaa/python
/guia1/caso1.py
226
3.9375
4
# Ingrese su nombre y dirección, luego muestre ambos datos. import os os.system('cls') name = input("ingrese su nombre:") address = input("ingrese su dirección:") print(f"su nombre es {name} y su dirección es {address}")
f3caf7175c8b3ae0bd3f0310e6aa9aac966d313b
flovera1/complejidad
/Proyecto_complejidadTexto/tf.py
6,885
3.578125
4
#Mineria de datos #POS TAGGER - Formato TF-IDF #Importaciones: import nltk # remove stop words (meaningless words for the language-meaning) from nltk.corpus import stopwords import os from sklearn.preprocessing import MinMaxScaler import numpy as np from pandas import DataFrame #Funcion que genera el POS tag de una...
2251eeb2ed41592fce84db6ddf9dbdbc0b2ccc42
jlucasldm/ufbaBCC
/2022.2/redes_de_computadores/trabalho/client.py
20,614
3.6875
4
""" MATA59 - REDE DE COMPUTADORES - UNIVERSIDADE FEDERAL DA BAHIA IMPLEMENTAÇÃO DE UMA APLICAÇÃO CLIENTE-SERVIDOR Discentes: João Lucas Melo Shaísta Câmara Docente: Gustavo Figueredo [RESUMO] Este trabalho possui como finalidade a implementação de uma aplicação de depósito de arquivo com recuperação. Atra...
7fd3ffcf715659fc0a144fdf8be91cf9933d3067
akarshn95/Coding_Challenges
/Buddy_Strings.py
1,033
3.9375
4
""" Given two strings A and B of lowercase letters, return true if you can swap two letters in A so the result is equal to B, otherwise, return false. Swapping letters is defined as taking two indices i and j (0-indexed) such that i != j and swapping the characters at A[i] and A[j]. For example, swapping at indices 0 ...
50aa72d53c088bac34f8c4c9c37aa5dd0eee333d
ThompsonHe/LeetCode-Python
/Leetcode0169.py
973
4
4
""" 169.多数元素 给定一个大小为 n 的数组,找到其中的多数元素。多数元素是指在数组中出现次数大于⌊ n/2 ⌋的元素。 你可以假设数组是非空的,并且给定的数组总是存在多数元素。 示例1: 输入: [3,2,3] 输出: 3 示例2: 输入: [2,2,1,1,1,2,2] 输出: 2 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/majority-element 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 """ class Solution: def majorityElement(self, nums): ...
5c3325960d60f2b3c2fb1e5a15837d41cc0d0361
Vasistareddy/pythonRLSA
/pythonRLSA/rlsa.py
3,334
4.15625
4
import numpy from typing import Tuple def iteration(image: numpy.ndarray, value: int) -> numpy.ndarray: """ This method iterates over the provided image by converting 255's to 0's if the number of consecutive 255's are less the "value" provided Parameter image numpy.ndarray value int """ ...
781d0ba5d036ffe5fdbf6e8feb1c285146bea028
Jesta398/project
/collections'/dictionary/wordcount.py
256
3.734375
4
lines="hi hello hi hello" # o/p #hai,2 #hello,2 #split function words=lines.split(" ") print(words) dic={} for word in words:#hai hello if(word not in dic):#hai not in dic,hello not in dic dic[word]=1 else: dic[word]+=1 print(dic)
aaf024208514d8de7d2e08722acc511625b4ad41
TheScouser/algorithms
/LinkedList/binary_search.py
316
4.03125
4
def binary_search(array,element): low = 0 high = len(array) - 1 while low <= high: mid = (low+high)/2 if array[mid] < element: low = mid + 1 elif array[mid] > element: high = mid - 1 else: return mid return False if __name__ == '__main__': array = [1,2,3,4,5] print binary_search(array,6)
538907b230d78eab31bbc58fa2bb4feee3e144f0
crystal2001/lesson7
/Lesson 7/problem3.py
338
4.0625
4
print('-' * 70) print('100th Birthday Program:') print() print('Description: This program asks you for your current age and tells you year that you will turn 100') print() age = input('What is your age today? ') age = int(age) result = 100 - age year = result + 2018 print() print('You will be 100 in the year ' ...