blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
399608502371ffab488a84b475910e2b1cd342cc
sotomaque/Python-Coding-Interview-Questions
/intersection.py
1,420
4.28125
4
''' if you have two sorted arrays, find the common elements of the arrays ''' def intersection(givenArray1, givenArray2): common = [] x = y = maxLength = 0 if (len(givenArray1) >= len(givenArray2)): maxLength = len(givenArray1) else: maxLength = len(givenArray2) for i in range(maxLength): print('x', x) ...
5a0dd1454539783f7f14d49ef47f07ad2830bed1
godaipl/python3study
/2python基础/2字符串和编码/Python的字符串.py
544
3.640625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # 在最新的Python 3版本中,字符串是以Unicode编码的,也就是说,Python的字符串支持多语言 print('我是中国人') print(ord("我")) print(chr(ord("我"))) # print(bytes(b'我')) #会报异常 print("我".encode("UTF-8")) # print("我".encode("ascii")) print("我".encode("UTF-8").decode("UTF-8")) # 格式化 print('HELLO %s' % '波波') print(...
ece9551a5922f844dc267a0fb2724a42ea49a086
Emily1988/mantis
/bugs2018/date.py
1,663
3.8125
4
import datetime #给定日期,返回对应当年第几周 def week_date(year,month,day): year = int(year) month = int(month) day = int(day) date = datetime.date(year,month,day).isocalendar() return date def dateRange(beginDate, endDate): dates = [] dt = datetime.datetime.strptime(beginDate, "%Y-%m-%d") date = ...
ed2ba9f41e32620d40b79c802e5106bc95fcaefd
CamA-JCU/cp1404practicals
/prac_02/files.py
1,020
4.15625
4
# 1. Write code that asks the user for their name, # then opens a file called "name.txt" and writes that name to it. open_file = open("name.txt", 'w') name = str(input("Name: ")) print(name, file=open_file) open_file.close() # 2. Write code that opens "name.txt" and reads the name (as above) then prints, # "Your name...
9d0837ea18774ea2674a89c2299508ea55b87c1d
AnnapoorniRavi/Udacity_Nanodegree
/Exploring Weather Trends.py
1,378
3.6875
4
#!/usr/bin/env python # coding: utf-8 # In[1]: ## Calling Libraries: import numpy as np import pandas as pd # for loading data into the notebook from matplotlib import pyplot as plt #for making line chart # In[16]: ## Importing the extracted Data Set: data = pd.read_excel (r'C:\Users\Sahi\Des...
c46532a64303538bf1cf67c7a49b71d6b66e74d7
bimri/learning-python
/chapter_4/files.py
718
3.921875
4
''' File objects are Python code’s main interface to external files on your computer ''' # Opening & Writing to a file store to your CWD f = open('data.txt', 'w') # Make a new file in output mode('w' is write) print(f.write('Hello bimri, here we meet again\n')) # Write string of char...
995395737719142be9a6f293aa9b2800d1a37b4b
yangboyubyron/DS_Recipes
/zSnips_SQLite/CreateDBfromPythonDF.py
2,280
4
4
#---------------------------------------------------------- # EXAMPLE 1 import pandas as pd import sqlite3 import pandas.io.sql # reads files in dfcust=pd.read_csv('cust.csv', delimiter=',', header='infer', low_memory=False) dfmail=pd.read_csv('mail.csv', delimiter=',', header='infer', low_memory=False) dfitem=pd.re...
75c521ac2d894998e55f64a408177f32d9ef1222
sforrester23/SlitherIntoPython
/chapter8/Question1.py
200
3.65625
4
my_words = input("Input some words to make a list: ").split() num = int(input("Number please: ")) i = 0 while i < len(my_words): if len(my_words[i]) >= num: print(my_words[i]) i += 1
646e1b340a784f91f537bdb9ac2e806745bf785a
jacksonkohls/Snakify
/4; Loops/Sum of N.py
78
3.609375
4
n=int(input()) y=0 for i in range(n): x = int(input()) y= y+x print(y)
e7b2a86607d79801c30d5e63de7277f731e70209
jinjuleekr/hackerrank_algorithms
/SimpleArraySum.py
394
3.609375
4
''' Title : Simple Array Sum Domain : Python Created : 01 OCT 2018 ''' get_number = int(input()) get_array = input('Input' + str(get_number) + 'numbers with space') get_list = get_array.split(' ') #print(get_number) #print(get_list) total = 0 while get_number > 0 : number = int(get_list[get_number-1]...
a7e2f348e6f22fbd667fb6837b048e4f4c2be04d
HussainPythonista/Data-Structure
/linkedList/Circular.py
2,386
3.796875
4
from linkedList import * #Load the data circular=linkedList() def createCircularLinkedList(head): #Create circular linkedlist forRemember=head circular.last.nextReference=head pointer=head while pointer!=None: print(pointer.data) if pointer.nextReference==forRemember: ...
31bad158227177fe165a5bd9043125c8b9677c70
danveb/python-data-structure-practice
/36_find_the_duplicate/find_the_duplicate.py
1,080
4.09375
4
def find_the_duplicate(nums): """Find duplicate number in nums. Given a list of nums with, at most, one duplicate, return the duplicate. If there is no duplicate, return None >>> find_the_duplicate([1, 2, 1, 4, 3, 12]) 1 >>> find_the_duplicate([6, 1, 9, 5, 3, 4, 9]) 9 ...
87ab9eed4ef5a3cfe087cae8de85f7fda0b961a1
Crasti/Homework
/Lesson5/Task5.4.py
993
3.734375
4
""" Создать (не программно) текстовый файл со следующим содержимым: One — 1 Two — 2 Three — 3 Four — 4 Необходимо написать программу, открывающую файл на чтение и считывающую построчно данные. При этом английские числительные должны заменяться на русские. Новый блок строк должен записываться в новый текстовый файл. """...
7ae12d15668d03c85609965aecaa38d7d0d180f8
Aadhya-Solution/PythonExample
/list_compranstion/lambda_map.py
387
4.3125
4
''' map map() applies the function func to all the elements of the sequence seq. It returns a new list with the elements changed by func map(func,seq) ''' def fahrenheit(T): return ((float(9)/5)*T + 32) def celsius(T): return (float(5)/9)*(T-32) temp = (36.5, 37, 37.5,39) F = map...
1e92c886f6220c9c65b5f978703209f9f4eb38b0
kapppa-joe/leetcode-practice
/daily/20201202-random-node.py
1,116
3.734375
4
from random import randint # Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def __init__(self, head: ListNode): """ @param head The linked list's head. Note that the head i...
655ebc39613806f031d45bc7969c765f665c5ecd
SymmetricChaos/MyOtherMathStuff
/GEB/Chapter8TNT/StripSplit.py
3,124
3.640625
4
import re from Utils.StringManip import left_string # CANNOT IMPORT FROM PROPERTIES # Functions for splitting strings to be used for checking well formedness def split(x,left,right): L,lo,hi = left_string(x,left,right,inner=True,warn=False) R = x[hi+2:-1] return L,R def split_add_mul(x): return spli...
d19b0f9fa19615bc50e85c27049b6c4fc4ab3889
greymliu/Compsci_final_proj
/attempt_3.py
1,952
4.03125
4
class Trillium: name = "Trillium" color = "white" size = "ground cover" properties = "xxx" petal_shape = "rounded" latin_binom = "xxx" petal_num = 3 additional_info = "xxxx" class LadySlipper: name = "Lady Slipper" color = "white" size = "knee height" petal_shape = "cup-l...
3105ca8d77fa1f0b31162c8335c18614e5222094
ravalrupalj/BrainTeasers
/Edabit/Day 7.6.py
735
3.5
4
#Hitting the Jackpot #Create a function that takes a list (slot machine outcome) and returns True if all elements in the list are identical, and False otherwise. The list will contain 4 elements. #test_jackpot(["@", "@", "@", "@"]) ➞ True #test_jackpot(["abc", "abc", "abc", "abc"]) ➞ True #test_jackpot(["SS", "SS", "SS...
e161efadb7dd79b98168f1111123507463d9fdbe
svkirillov/cryptopals-python3
/cryptopals/set1/challenge03.py
556
3.578125
4
#!/usr/bin/env python3 from functions.xor import bruteforce_xor_single_byte_key, xor_byte_arrays CIPHER_TEXT = bytes.fromhex( "1b37373331363f78151b7f2b783431333d78397828372d363c78373e783a393b3736" ) RESULT = b"Cooking MC's like a pound of bacon" def challenge03(cipher: bytes) -> bytes: key = bruteforce_xo...
0e5efedd53841f8799b8b3319d420f092512e92f
anjalikrishna98/lab
/fibonacci.py
282
3.953125
4
n=int(input("enter the number of terms:")) f1,f2=0,1 f3=f1+f2 if n<=0: print("please enter a positive integer") else: print("fionacci series of first",n,"terms") print(f1) print(f2) for i in range (3,n+1): print(f3) f1=f2 f2=f3 f3=f1+f2
eeb588fd3dea17d5a6e9f6aec0e826474603288c
Tjcooper4/Visual_sorting
/main.py
466
4.1875
4
from algorithms import bubbleSort import random import time #def setSpeed(speed): #speed = input((float("Enter a number between 0 and 1")) speed = float(input("Enter a number between 0 and 1: ")) # Test array arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25] r...
0e5411ef07aed838e1571b5e77883d6eaa11ae77
stefan-gherman/pair_programming_ex
/passwordgen/passwordgen_module.py
600
3.515625
4
import string import random as rd def passwordgen(): all_possible_chars = list(string.printable[:-6]) len_passw = 0 passw = "" while len_passw <= 20: passw += all_possible_chars[rd.randint(0,len(all_possible_chars)-1)] len_passw += 1 return passw def main(): in1 = input("Passwo...
a94aecd43a814191d901a3d309f960eaff56b554
jadhavmayur/innomatics_internship_APR_21
/Task4(python programming/Capitalize!.py
356
3.5
4
def solve(s): first,last=s.split() c_name='' c_last='' for i in range(len(s)): if first[0].islower()==True: c_name=first[0].upper()+first[1:] if last[0].islower()==True: c_last=last[0].upper()+last[1:] return print(c_name+' '+c_last) ...
0e027b5f1212b8e21a1e74b95339ac5382ba041c
ivanbjarni/PokeDevs
/Deck.py
1,385
3.859375
4
from Card import * import random class Deck(object): cards = [] #Card[] List of cards in the deck name = "" #String a name to identify the deck in presets def __init__(self): self.cards = [] def __str__(self): s = "" for c in self.cards: s = s + str(c) return s # Usage: deck.shuffle() #...
bfdef10ab6c8cdd2ec8872512fe4b24d94a3020b
jmcuy/CMSC123
/#LabExercise1/liststack/__init__.py
630
3.9375
4
from linkedlist import LinkedList class Stack: def __init__(self): self.items = LinkedList() def push(self, item): self.items.append(item) def pop(self): current = self.items.head if current is not None: return self.items.remove(self.peek()).value els...
9069a87aa657cfeac2deee75275b585f0bae2a12
Aasthaengg/IBMdataset
/Python_codes/p03729/s710890288.py
115
3.53125
4
a, b, c = input().split() f = lambda x, y, z : x[-1] == y[0] and y[-1] == z[0] print("YES" if f(a, b, c) else "NO")
7898b87600089a13ed23e4c8d4715cbc24b867dc
pulengmoru/string_calculator
/test/string_calculator.py
799
4.03125
4
import re # Creating the add function def add(num_string): num_string = r'{}'.format(num_string) extracted_numbers = re.findall(r"-?\d+", num_string) negatives = getAllNegatives(extracted_numbers) total_sum = 0 # check if there are negative numbers and throw a relevant exception if len(negatives) > 0: error_m...
f5874baff3fb0087cdec2b0591f356f3724f6476
8563a236e65cede7b14220e65c70ad5718144a3/python3-standard-library-solutions
/Chapter01/0033_re_groups.py
906
4.53125
5
""" Dissecting Matches with Groups Searching for pattern matches is the basis of the powerful capabilities provided by regular expressions. Adding groups to a pattern isolates parts of the matching text, expanding those capabilities to create a parser. Groups are defined by enclosing patterns in parentheses. Any comp...
eaddd475e1197ce8d3ff4cd051a6938f3e340ca5
usuaero/PyProp
/pyprop/electronics.py
10,622
3.890625
4
"""Classes defining electronic components for the propulsion unit.""" import os import numpy as np import sqlite3 as sql from random import randint class Battery: """Defines a battery. Parameters ---------- name : str, optional Name of the battery to be used. manufacturer : str, o...
ad790b0794a14247df5ea4bf1b99266eadee25b1
Lorthevan/MyLeetcode
/easy/Valid Parentheses.py
459
3.71875
4
class Solution: def isValid(self, s): """ :type s: str :rtype: bool """ if s == '': return True mapping = {")": "(", "}": "{", "]": "["} s = s.replace(' ','') if s == '': return False for i in range(len(s)//2+1): ...
7c64196f59a44d7ab789650e21379eea885f49c9
ruirodriguessjr/Python
/ManipulandoArquivos/ManipulaçãoDeArquivos.py
3,726
4.65625
5
""""r"- Ler - Valor padrão. Abre um arquivo para leitura, erro se o arquivo não existir "a" - Anexar - Abre um arquivo para anexar, cria o arquivo se ele não existir "w" - Write - Abre um arquivo para gravação, cria o arquivo se ele não existir "x" - Criar - Cria o arquivo especificado, retorna um erro se o arquivo ...
e74f483ec431b74a3658a2f9eb061838faed45df
easmah/topstu
/variables_strings.py
992
4.09375
4
message = "Hello Python world!" print(message) message = "Hello Python Crash Course world!" print(message) # Strings # title() converts the first character to upper case AND any uppercase in a word to lower name = "ada LoveLace money" print(name.title()) print(name.lower()) print(name.upper()) # Concatenating String...
214139f20e4e985006912192e1c9b9bcf00f8bb5
Haveon/TeachPython
/2 - Functions and OOP/fib.py
322
3.859375
4
def fib(n): if n <= 2: return [1]*n # list times int is the same as list+list+...+list (n times) else: fibList = [1,1] for i in range(n-2): # We need to substract since we already have the first two numbers fibList.append(fibList[-2] + fibList[-1]) return fibLis...
fbad29ad49b63317ed450ff2a66c3709680ac6b5
xiaoxiaojiangshang/LeetCode
/leetcode_python/Binary_Tree_Inorder_Traversal_94.py
2,512
3.96875
4
#-*-coding:utf-8-*- # 作者:jgz # 创建日期:2018/11/24 15:55 # IDE:PyCharm import numpy as np # Definition for a binary tree node. class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class Solution1(object): def recursive(self,root,inorder_trav...
2b2efcc9a8f602efb9ba5d23d95c6193f7997068
JosephEmmanuel/python_files
/sharkinfo.py
788
4.03125
4
# This is a program to display shark data from data in list. # # Developed by : Joseph Emmanuel # Date : May 2019 sharkNameList=["Blacktip", "Silvertip", "Whitetip", "Megamouth","WhaleShark", "DwarfLantern", "Hammerhead","Bonnethead"] sharkLengthList=[1.5, 2.25, 1.8, 4.5, 12.6, 0.2, 6, 1.5] #in meters sharkWeightLis...
be6bede8a9004f5ff4203bca841708bb265f5976
TonyBoy22/gittest
/Python/optimization/scipy_minimize.py
2,492
3.671875
4
''' Script to use minimize to solve most common optimization problems LP QCQP result object: result.fun: result of the function to optimize at the value of result.x result.x: minimal value found by optimization result.success: Boolean to indicate that optimization process went well ''' from scipy.optimize import mi...
cd2375f33affe6ba582ae8b9635a935880dc262e
mnabywan/Kompilatory-lab4
/ast_new.py
3,454
3.609375
4
class Node(object): def __init__(self): self.line = 0 self.column = 0 def accept(self, visitor): return visitor.visit(self) class Program(Node): def __init__(self, instructions): self.instructions = instructions class Instructions(Node): def __init__(sel...
18d7175cd9bd6f6c6377755ad2b8584220e0c294
Sherin1998/3-assignment-3
/3ass3.py
913
3.921875
4
#!/usr/bin/env python # coding: utf-8 # In[ ]: #1 a=int(input("enter no ")) if(a>0): print("positive") elif(a<0): print("negative") else: print("zero") # In[1]: #2 a=int(input("enter no ")) if(a%2==0): print("even") else: print("odd") # In[2]: #3 a=int(input("enter year ")) if(a%4==0 and ...
6271d4621d98e8be412659fbcf61df5f16fcf363
wellington16/BSI-UFRPE
/2016.1/Exércicio LAB DE PROGRAMAÇÃO/Exercício 2016.1/Exercícios/E11/E11.py
6,600
3.8125
4
#coding:utf-8 import sys #Autor Wellington Luiz ''' UNIVERSIDADE FEDERAL RURAL DE PERNAMBUCO - UFRPE Curso: Bacharelado em Sistemas de Informação Disciplina: Laboratório de Programação - 2016.1 Professor: Rodrigo Soares Exercício 11 - Laboratório de Programação título: Juvenal se perdeu. E...
e58cca47181af187db75c67f35678762657c6d9d
ferdlgr/Compilers19
/PARSER_A01366101/lexer.py
2,473
3.59375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ This program is expected to pass throug its function the variables received throught the script and file reading to the global variables, making use of the globalTypes program, its values and tools, print each token found in the iput file and its definition previo...
6519f77fff9130d644a0d161a4bc6f792d477480
malluri/python
/23.py
176
3.9375
4
#23. Write a program to findout big of two numbers num1=input("enter the num1:") num2=input("enter the num2:") big=0 if(num1>num2): big=num1 else: big=num2 print(big)
e7d2d969242fd3f5593bc491f6eb50b2acafd530
giveseul-23/give_Today_I_Learn
/80_pythonProject/mss06.py
112
3.71875
4
for i in range(1, 6, 1): # print() for j in range(0, i, 1): print("🌹", end=" ") print()
420f1ca50e7c9f031673083b61c91bda706aa0b3
muru4a/python
/Leetcode/removeDuplicates.py
475
4.0625
4
def removeDuplicates(s: str) -> str: """ use the stack check the element equal to last element in stack and pop the element current string character not equal to last element in stack and add the element in stack """ result = [] for row in s: if result and row == result[-1]: ...
1d8760a431ea943c6b87b47d445921aa962d8b7b
theodormunteanu/bond_and_swap
/bond_prices.py
5,159
3.6875
4
# -*- coding: utf-8 -*- """ Created on Sat Nov 24 19:33:23 2018 @author: theod """ def bond_price(FV, c, T, rate, freq=4, t=0, freq2=0, **opt): r""" Returns the price of a bond given the zero-rates or a yield Parameters ---------- `FV` : face value of the bond (float/int). ...
03af04dc18cc77b611d748331e67226bb92f1776
minhd2/time2code
/sort_by_date/sort_by_date.py
592
3.796875
4
import re from datetime import datetime def sort_by_date(file): file_date_dict = {} pattern = r"\w* \d+, \d{4}" with open(file, 'r') as file: for line in file: columns = line.split() date = re.search(pattern, line) print(line) file_date_dict[columns[-1]] = file_date_dict.get(columns[3], date.group(0)...
db84345e8acb1882fdaecfec8a7536ec5920ba38
mprotti/CursoPhyton
/examen04.py
799
3.78125
4
def romano_a_numero(numero_romano): resultado = 0 valores = { 'M' : 1000, 'D' : 500, 'C' : 100, 'L' : 50, 'X' : 10, 'V' : 5, 'I' : 1 } if len(numero_romano) > 0: valor_anterior = 0 for letra in numero_romano: if letra in val...
f018e1f0412108c3756ffb441ff0eec4dea8c93b
rahuldbhadange/Python
/Python/__File handling/files/6 readlines/readlines.py
274
4.125
4
#readlines() f=open("hello.txt") x=f.readlines() # reads all the lines and stores in a list x print(x) # printing the list x #printing each line seperately for p in x: print(p) f.close() # whenever we close a file, it will be used by #another person
7f2995d3eeeb9dd1468bf326943f496709e958e3
mennatarek204/GPA-calculator
/GPA Calculator.py
1,458
4.125
4
# new dictionary to save keys with their right values score_map = { 'A+' : 4, 'A' : 3.83, 'A-' : 3.66, 'B+' : 3.33, 'B' : 3, 'B-' : 2.66, 'C+' : 2.33, 'C' : 2, 'C-' : 1.66, 'D+' : 1.33, 'D' : 1, 'F' : 0, } #lists of needed data grades = [] CreditHours =...
000b65a98ba01cf22a91dcc4fcd274528d5f7d2f
hamil168/Data-Science-Misc
/Misc Learning/HackerRank 30 Days of Code/Additional Practice Problems/CountDiv.py
1,904
3.75
4
"""CountDiv Practice Problem by Codility Solution by B Hamilton 7/24/2018 given three integers A, B and K, return the number of integers within the range [A..B] that are divisible by K, i.e.: { i : A ≤ i ≤ B, i mod K = 0 } For example, for A = 6, B = 11 and K = 2, function should return 3, because there are three n...
53fa6cb89a3723b11d2a2f542fcc887f81d3b1e2
ssarangi/algorithms
/hackerrank/strings/morgan_and_a_string.py
1,015
3.671875
4
__author__ = 'sarangis' """ Jack and Daniel are friends. Both of them like letters, especially upper-case ones. They are cutting upper-case letters from newspapers, and each one of them has their collection of letters stored in separate stacks. One beautiful day, Morgan visited Jack and Daniel. He saw their collection...
3f27e150d659df7b73892fed64173fc543d7559b
eanshuk/Python-Assignment
/Python Assignment/Exercise6.py
1,624
3.6875
4
import random class Aircraft: x=0 y=0 acceleration=1 def __init__(self, obj_no, new_x=0, new_y=0): print "Aircraft # ",obj_no self.flight_number = obj_no self.x=new_x self.y=new_y class Boeing_747(Aircraft): destination_x=0 destination_y=0 def __init__(self, ...
a63cb23be4f85f4726f45a3e21ef2354ac9f9940
YazanAhmad18/data-structures-and-algorithms-python
/data_structures/hash_table/hash_table/linked_list.py
1,471
4.03125
4
class Node: def __init__(self,value): self.value= value self.next= None class Linkedlist: def __init__(self): self.head = None def insert(self, value): node = Node(value) if self.head == None: self.head = node return self.head.value ...
5af707aea2edc11a15856fc247d0b0ca1c2816e0
spradeepv/dive-into-python
/hackerrank/contests/accel/balanced_string.py
2,037
3.875
4
""" A balanced string is a string having the following properties: Both the left and right halves contain the same characters. Both the left and right halves contain unique characters. For example, abbaabba is balanced because the left half (abab) and the right half (baba) both contain the same unique characters. Xav...
6f62b109afb9bf94716e6b91d592969d6dfd11dd
Pruthvi77/Cent
/ML/Exception_Handling.py
304
3.59375
4
#1 try: val = 5/0 except : print("Error : incorrect mathmatical expression") #2 subjects=["Americans ","Indians "] verbs=["play ","watch "] objects=["Baseball","Cricket"] FinalList = [sub+ ver+ obj for sub in subjects for ver in verbs for obj in objects] for item in FinalList: print(item)
a8be3bdafb0b75bdd14e52fd6d1f3d2cec1bf94c
Phyopyosan/Exercises
/Variable.py
773
3.609375
4
#27.12.2019 + _ * / % ** >>> 2 + 2 4 >>> 50 - 5 * 6 20 >>> (50 -5 * 6) / 4 5.0 >>> round(5.0) 5 >>> 5.123456 5.123456 >>> round(5.123456,2) 5.12 >>> 17 / 3 5.6666666667 >>> 17 // 3 5 >>> 18 // 4 4 >>> 20 // 5 4 >>> 17 % 3 2 >>> 17 * 4 % 3 2 a = 1 a (variable) = (assign) 1 (value) weigh...
9d1804617c28fa2f8de8a9323163ea8027a4cc6d
USER0721/AE401-20200720
/random.py
264
3.65625
4
# -*- coding: utf-8 -*- """ Created on Mon Aug 3 17:30:50 2020 @author: user """ import random thm = random.randint(1,10) n = input("猜一個數字:") n = int(n) if thm == n: print("yes") else: print("no")
eecb5dc89c55a0a71342e9775495a73be2f4d46c
joanwanjiku/marvel-comics
/tests/test_character.py
291
3.515625
4
import unittest from app.models import Character class CharacterTest(unittest.TestCase): def setUp(self): self.new_character = Character(1, 'thor', 'he is amazing', '/hsfhdhgd') def test_instance(self) self.assertTrue(isinstance(self.new_character, Character))
3fe0e5c3fd08074abc2d7b60f5b799b5b0acb538
kunal-singh786/basic-python
/loop hackerrank.py
176
4.09375
4
'''Task Read an integer . For all non-negative integers , print . See the sample for details''' if __name__ == '__main__': n = int(input()) for i in range(n): print(i**2)
3d943455fc233dd6ac9ba3f714d366077aea9129
greeshma0601/Python-Language
/Dictionary/Set in Python - II.py
2,557
4.40625
4
''' Set in Python - II This is the last practice question of Python Set. You are familiar with working on set in Python. Now, let's move on to work on two sets using some inbuilt functions which are used widely. They are: union(): Used to find union() between two sets. This is performed using '|' operator. intersection...
6538b5231fe4b7d5af5c6a605dc98ecf976433a9
jxhangithub/lintcode
/Easy/141. Sqrt(x)/Solution.py
532
4
4
class Solution: """ @param x: An integer @return: The sqrt of x """ def sqrt(self, x): # write your code here if (x == 0): return x start, end = 1, x while (start + 1 < end): mid = (end - start) // 2 + start if (mid ** 2 == x): ...
941c08d45bcaaf8ba13ffff395b5a2596ec45aa9
anshuman2197/Python-Internshala
/prob32.py
634
3.953125
4
class Polygon: def __init__(self,sides): self.sides= sides def display_info(self): print("A polygon is a two dimensional shape with straight lines") def get_perimeter(self): perimeter=sum(self.sides) return perimeter class Triangle(Polygon): def display...
1323be42087cfd794ba2b544f5024abd370d879a
notconfusing/tulsa-early-warning-system
/tulsa/learn/splits.py
6,416
3.65625
4
import pandas as pd import numpy as np from sklearn.cross_validation import train_test_split def make_splits(split_strategy, stuterm_df, label_feature_df, engine): """ Makes a list of (X_test, X_train, y_test, y_train) splits :param split_strategy: refers to type of split used :param stuterm_label_fe...
1e300bc0dabebd7e2845f6633e6981d12ff574c1
nagesh-animineni/Helloworld
/list_test.py
83
3.640625
4
list1=[2,3,4,56,6] #for var in list: print(",".join( repr(e) for e in list1))
25e8093fe936ba70c51830c9a6ccba8a10d14184
luizhuaman/platzi_python
/practica.py
559
4
4
#AREA DE UN TRIANGULO base=int(input("Ingresar base\n")) altura=int(input("Ingresar altura\n")) print("El area del triangulo es:",int(base*altura/2)) #dolares a soles dolares=float(input("Ingresar los dolares a cambiar\n")) # print("Su cambio en soles es ",(dolares*3.52)) #otra forma print(f'Cambio: ${float(dolares *...
4a357fa110d38c62a3dd3ee46b3301328b225d4b
airlay/test
/isInterleaving.py
1,084
4.34375
4
def isInterleaving(str1, str2, str3): ''' str3 is interleaving of str1 and str2 if it can be form by interleaving the characters of str1 and str2 in a way that maintains the left to right order of the characters from each string e.g. aabx, bbax, aabbxax -> true, aabx, bbax, axabbbx -> false ''' st...
b765508ec890622681d48ca9a45a929064f9992a
jimmykobe1171/leetcode
/linked_list/linked_list_cycle_2.py
728
3.859375
4
# Linked List Cycle II # tortoise and hare algorithm # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: # @param head, a ListNode # @return a list node def detectCycle(self, head): faster_node = head...
230fd3cbf46e262852dc09e1ebfbcdeb8f049dfd
res0nat0r/exercism
/python/diffie-hellman/diffie_hellman.py
826
3.84375
4
""" Alice and Bob use Diffie-Hellman key exchange to share secrets. They start with prime numbers, pick private keys, generate and share public keys, and then generate a shared secret key. """ from random import randint def private_key(p): """ Return the private key :param int p: private key :return...
257984583d2a8bb07bcb36f9656436b2912aadb9
1633376/NUR-Assigment-2
/Code/mathlib/statistics.py
8,395
3.6875
4
import numpy as np import mathlib.sorting as sorting def kstest(x, cdf): """ Perform the Kolmogorov-Smirnov test for goodness of fit and return the p-value. In: param: x -- An array with value's who's CDF is expected to be the same as the provided CDF. Must be ...
f40b6ed9480827f1b8b90a68b3f0e37f9925fd6d
anatcruz/FEUP-MNUM
/Exames/2010/P5.py
756
3.609375
4
# -*- coding: utf-8 -*- """ Created on Sun Jan 12 16:03:03 2020 @author: ANA """ def z(x,y): return 6*x**2 - x*y + 12*y + y**2 - 8*x def dzx(x,y): return 12*x - y - 8 def dzy(x,y): return -x + 12 + 2*y def gradient(x, y, h, numItr): xn = 0 yn = 0 print("x: ",x) print("y: ",y) print("...
ee0d952387016dc6cbd9bf848f2be041cc12acf8
mikio1998/LeetCode
/leetcode/twosum.py
3,517
3.875
4
""" TWO SUM return indexes of two digits in array that add up to target. ex. Inputs: [2, 7, 11, 15], 9 Output: [0, 1] """ def twoSum(array, target): sortedArray = sorted(array) sums = [] for i in sortedArray: if i > target: return sums else: if target - i in ar...
0459b5a50b24fd834c1a21ebc3f092811c62e5ab
AmitAps/learn-python
/oops_python/coordinate_ex.py
633
4.125
4
class Coordinate(object): def __init__(self, x, y): self.x = x self.y = y def distance(self, other): x_diff_sq = (self.x-other.x)**2 y_diff_sq = (self.y-other.y)**2 return(x_diff_sq + y_diff_sq) ** 0.5 def __str__(self): return "<" + str(self.x)+","+str(self...
d15a83404db316ae47e7c61e7ffda77c5f0a2dc4
rgov/sqlite_protobuf
/example/create_database.py
1,323
3.546875
4
#!/usr/bin/env python import random import sqlite3 from AddressBook_pb2 import Person # Create the database db = sqlite3.connect('addressbook.db') db.execute('CREATE TABLE IF NOT EXISTS people (protobuf BLOB)') # Populate it with some random people names = ''' Kaila Dutton Collin Felps Lou Ohearn ...
1cf6d84616905cfbdb871a71617a81781d2f4732
hakubishin3/nlp_100_knocks_2020
/ch01/07.py
351
3.734375
4
""" 07. テンプレートによる文生成 引数x, y, zを受け取り「x時のyはz」という文字列を返す関数を実装せよ.さらに,x=12, y=”気温”, z=22.4として,実行結果を確認せよ. """ def temp(x, y, z): return f"{x}時の{y}は{z}" x = 12 y = "気温" z = 22.4 answer = temp(x, y, z) print(answer)
287ca8d5497e8817af93fdfaa5cc1e70a8833884
iayushguptaaa/Open-Algorithms
/Python/kosaraju_algorithm.py
2,696
3.78125
4
# Kosaraju's algorithm # ======================== # Given one direct graph, the algorithm finds his SCC( strongly connected components ) V = ['A','B','C','D','E','F','G','H','I'] T = { 'A':['B'], 'B':['C','D','F'], 'C':['A'], 'D':['E'], 'E':['F', 'G'], 'F':['D', 'H'], 'G':['F'], 'H':['I'], 'I':['H'], } ''' =...
250ddb97f42ab196f193ef55478a09ecd921256c
green-fox-academy/ZaitzeV16
/python_solutions/week-01/day-4/mile_to_km_converter.py
202
4.3125
4
# Write a program that asks for a double that is a distance in miles, # then it converts that value to kilometers and prints it mile = float(input("mile: ")) print("in km: {}".format(mile * 1.609344))
ccfaa8fae09aea086ec858f197f4e222268be92f
AdamZhouSE/pythonHomework
/Code/CodeRecords/2902/60825/263366.py
326
3.78125
4
def printSandD(numS, numD): for i in range(numS/2): print('*', end='') for i in range(numD): print('D', end='') for i in range(numS/2): print('*', end='') print() N=int(input()) for i in range(1, N+1, 2): printSandD(N-i, i) for i in range(N-2, 0, -2): printSandD(N...
98f25a7d72f2c0d3b47ad75b27c4028a7232dd79
patnir/TronBotAI
/mySim/direction.py
928
3.890625
4
class direction: def __init__(self, x, y, width): self.x = x self.y = y self.width = width def moveRight(self, board): if self.x + 1 >= self.width or board[self.y][self.x + 1] != 0: print("cannot move right!") return False self.x += 1 retu...
942c99431e31b9b24b777c6fa024928f4e1645ad
robert75RG/python_bootcamp
/zjazd1/podstawy_zad06.py
172
3.5
4
liczba = int(input('Podaj liczbę całkowitą: ')) print(f'Większa od 10 {liczba > 10}') print(f'Mniejsze od 15 {liczba <= 15}') print(f'Podzielne przez 2 {liczba%2==0}')
d471954e93951279159992754a3f2e54d29e4bc0
newcombh5629/CTI110
/P2HW2_MealTip_HoiNewcomb.py
610
4.3125
4
# Creat a program that calculates the amount of the tip percentages. # 2/12/2019 # CTI-110 P2HW2 - Meal Tip Calculator # Hoi Newcomb # Pseudocode # 1. Give the meal charge # 2. tip 15% = meal charge times 0.15 # 3. tip 18% = meal charge times 0.18 # 4. tip 20% = meal charge times 0.20 # 5. display the differe...
11f1aeab884210daf9ceb8d6f7cfa7107409ac56
NikilReddyM/python-codes
/itertools.combinations_with_replacement().py
249
3.5
4
# -*- coding: utf-8 -*- """ Created on Fri Nov 17 13:58:39 2017 @author: HP """ from itertools import combinations_with_replacement a = input().split() for i in combinations_with_replacement(sorted(a[0]),int(a[1])): print(''.join(i))
22f00d095bd4cf8c6ccbf3c8b6eca2303ab5c862
yummy1221/data_science
/1_intro_to_ds_in_python/week2/assignment.py
2,709
3.59375
4
import pandas as pd df = pd.read_csv('olympics.csv', index_col=0, skiprows=1) for col in df.columns: if col[:2]=='01': df.rename(columns={col:'Gold'+col[4:]}, inplace=True) if col[:2]=='02': df.rename(columns={col:'Silver'+col[4:]}, inplace=True) if col[:2]=='03': df.rename(columns...
9aca5975f136ec7a9820b7a03e5d6dd5762e2739
greenfox-velox/oregzoltan
/week-05/day-3/project/todo.py
3,821
3.609375
4
import sys import csv def main(): todo = TodoApp() if len(sys.argv) > 1: todo.menu(sys.argv) else: print(todo.usage()) class TodoApp(): def __init__(self): self.name = 'todo.csv' def menu(self, arg): self.arg = arg if self.arg[1] == '-l': print(...
6618df064156113921057af50bcf99556a80d528
stgodussaillant/P0
/Entrega 4/Laplaciana.py
377
3.59375
4
# -*- coding: utf-8 -*- from numpy import zeros def laplaciana(N, dtype): #En clases se usa un archivo distinto, y se llama al archivo A = zeros((N,N), dtype=dtype) for i in range (N): A[i,i] = 2 for j in range (max(0,i-2),i): if abs(i-j)==1: A[i,...
8d024274e7592e6ca0e02eeafac6fbe1ae1fb703
Deaseyy/algorithm
/数组系列/leetcode 75 颜色分类(排序).py
838
3.8125
4
# -*- coding: utf-8 -*- """ 1. 问题描述: 给定一个包含红色、白色和蓝色,一共 n 个元素的数组,原地对它们进行排序,使得相同颜色的元素相邻,并按照红色、白色、蓝色顺序排列。 此题中,我们使用整数 0、 1 和 2 分别表示红色、白色和蓝色。 注意: 不能使用代码库中的排序函数来解决这道题。 示例1: 输入: [2,0,2,1,1,0] 输出: [0,0,1,1,2,2] [2,0,2,1,1,0] [0,2,2,1,1,0] """ def sortColors(nums: list) -> list: p = 1 while p < len(nums): i ...
f520c308b356ebb21d39694d40f86b8b94065471
Aasthaengg/IBMdataset
/Python_codes/p02717/s024835056.py
101
3.578125
4
x,y,z=map(int,input().split()) temp=x x=y y=temp temp=x x=z z=temp print("{0} {1} {2}".format(x,y,z))
77f56d6013eff7bd9e988e2ab47ec6e3fb1eaaf2
PrihanNimsara/python-variables
/Project/src/code/HelloPython.py
394
4.03125
4
variable1 = variable2 = variable3 = 100; print(variable1) print(variable2) print(variable3) variable1,variable2,variable3 = 10,20,30 print(variable1) print(variable2) print(variable3) tuple = (1,"prihan") print(tuple[0]) tuple2 = (2,"nimsara") print(tuple2[0]) print(tuple2) print(tuple + tuple2) dictionary = {1:'p...
c2c7836739ffe353861741376730b868a5a267ef
AyratTatlybaev/LearnPython_lesson1
/test.py
179
3.765625
4
def summ_str(x,y): return str(x) + str(y) first_var = input('Enter first variable: ') second_var = input('Enter second variable: ') print(summ_str(first_var,second_var).upper())
216169d01fd5b805bf8db41b167d8c1967a96ed7
thesharpshooter/codeforce
/day11/game.py
118
3.65625
4
temp = map(int,raw_input().split(" ")) n1 = temp[0] n2 = temp[1] if n2<n1: print "First" else: print "Second"
4e3efcdedf46fbea4f32071343c3faf8cb3f3820
zjohnson5455/fileFormatter
/addColumn.py
748
3.5625
4
import csv linkMap = { "1": "form1@cognito.com", "2": "form2@cognito.com", "3": "form3@cognito.com", "4": "form4@cognito.com" } def editFile(): with open("testData1.csv", mode= 'r') as file: csvFile = csv.reader(file) firstLine = True listOfLists = [] for line in ...
fc0519c9b50de3639c8b93997d4af960cca70068
caoxiang104/-offer
/10.py
712
3.859375
4
# -*- coding:utf-8 -*- """ 我们可以用2*1的小矩形横着或者竖着去覆盖更大的矩形。 请问用n个2*1的小矩形无重叠地覆盖一个2*n的大矩形, 总共有多少种方法 i*1 铺i*n f(n) = f(n-1) + f(n-i) """ class Solution: def __init__(self): self.times = [1, 2] def rectCover(self, number): # write code here if number == 0: return 0 elif num...
1f1a074db424fff62638645e7968353e144db344
Wonderpol/Python-mini-projects
/expenses-tracker.py
2,370
4.375
4
expenses = [] months = { 1: "January", 2: "February", 3: "March", 4: "April", 5: "May", 6: "June", 7: "July", 8: "August", 9: "September", 10: "October", 11: "November", 12: "December" } def show_menu(menu: dict): for key in menu.keys(): print(f"{key}. {men...
9a38e546a6b1ce8ac37c2917d4657949434a250b
VictorStankov/Python_Crash_Course
/Try it Yourself/Chapter 8/Album.py
327
3.671875
4
def make_album(artist, title, n_tracks=""): output = {"artist name": artist, "album title": title} if n_tracks: output['tracks'] = n_tracks return output print(make_album('idk', 'any albums', str(3))) print(make_album('how tf', 'should I know')) print(make_album('the point is', "I'm doing it", str...
20dda1f1e1870930c37424df70eb4a54bc17e937
kobohuong/data_wrangling_exercises-1
/chapter_5_examples/standalone_files/MTA_turnstiles_data_download.py
2,399
3.609375
4
# include the requests library in order to get data from the web import requests # the built-in `operating system` or `os` Python library will let us create # a new folder in which to store our downloaded data files import os # the built-in `time` Python library will let us `pause` our script for 2 # seconds between ...
a8b20fc1fd2faf31cae75c4efaa115843f86c84a
yuyi-7/python
/base_code/条件.py
417
3.9375
4
# -*- coding: utf-8 -*- weight=float(input('请输入你的体重(/kg):')) high=float(input('请输入你的身高(/m):')) bmi=weight/(high**2) print('你的BMI指数是:%.1f'%bmi) if bmi<18.5: print('你的体重过轻') elif bmi<25: print('你的体重正常') elif bmi<28: print("你的体重过重") elif bmi<32: print('你属于肥胖') else: print('你属于严重肥胖')
6b9abd6d6e90d2925809fe38fb95cf571b12da00
yeqingyan/CCI_code
/Chapter2/q2_7.py
440
3.8125
4
""" Question 2.7 """ from LinkedList import * def intersection(a, b): """ Determine if two linked list intersect, return the intersecting node """ a_nodes = [] while a: a_nodes.append(a) a = a.next while b: if b in a_nodes: return b b = b.next return ...
83448b18b8b7fad07a799f99b937c79d74b0f8c9
BCookies222/Python-Codes
/Longevity.py
1,497
3.875
4
# Longevity : Secret to lIve a Long Life from Tkinter import * class Application(Frame): # Frame is Super Class of Application def __init__(self, master): # CONSTRUCTOR Frame.__init__(self, master) # master =root (Window) self.grid() self.ans="" self.create_widgets() def create_widgets(self): # Creati...
d2b299b44f8224042bb70a6401bffad120332f52
mikebpedersen/python_med_gerth
/uge_3/opgave3_1.py
1,379
4.25
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Feb 1 15:20:46 2020 @author: JensTrolle """ from math import pi print("A string: '%s'" % "Hello World") # prints the string and inserts "Hello World" as a string inside ''. print("An integer: %s" % 27) # prints the string and inserts 27 as a string. ...
f13ed725396710fcda3a5b7197272520a0d69299
sana9056/HomeWork
/HomeWork1_2.py
1,607
3.5625
4
my_list = [] for i in range(1, 1000, 2): my_list.append(i ** 3) sum_counter = 0 sum_of_number = 0 print("Список, состоящий из кубов нечётных чисел от 0 до 1000:") print(my_list) #Выполнение условия А второй задачи for i in range(0, len(my_list), 1): count = my_list[i] while my_list[i] > 0: ...
8af2a3f7566b619a966a354aef468cf5f0328a90
TJ021/QueryLanguageEngine
/reading.py
1,490
3.8125
4
import glob from database import * def read_table(table_file): '''(str) -> Table Given a file name without the extension, the function will read the table and return it. REQ: table_file must have proper format. ''' if (".csv" not in table_file): table_file = table_file + ".c...
c215e8238f21a9acedfc13e0e7bb15aa0854c263
alisonjo315/pythonclass-playtime
/lesson2/lesson02_states_alison.py
2,601
4.59375
5
# Difficulty Level: Intermediate # Goal: Create a program that prints out an HTML drop down menu for all 50 states # Step 1: Define your list of states # These should all be strings, since they're names of places # Instead of having to type them all out, I really like liststates.com -- you can even customize the form...