blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
a9a02bab5f2a12dfd0d6b32a5a76c116006de19c
allekmott/longestsentence
/sentence.py
1,533
3.9375
4
import re """Container for a sentence, stored in a string""" class Sentence(object): """Create new sentence object""" def __init__(self, text): self._text = None self.text = text """Get the sentence's text""" @property def text(self): return self._text """Set the sentence's text Validates for length, ...
08116ea949e55a064c14e16a1567011803514a77
Nahia9/COMP301-Python-Assignment03
/copyfile.py
461
3.5
4
#!/usr/bin/env python3 ''' Filename: copyfile.py Author: Nahia Akter Student no.: 301106956 Description: Copies the source file content to the specified destination ''' infile = input("Enter the source file name: ") outfile = input("Enter the destination file name: ") source_file = open(infile, "r"); target_file = op...
0a31524fb775f07633ce9858b633afdd9d2bf80b
albert4git/bTest
/bPot/Py3Robot/pendulum.py
378
3.78125
4
def firstn(g, n): for i in range(n): yield next(g) def abc(): for ch in "abcde": yield ch def pendulum(g): while True: reverse = [] for el in g(): reverse.insert(0,el) yield el for el in reverse: yield el if __name__ == "__main__...
bf2dced76a087396202427c189174e35eedadf80
AshTiwari/Standard-DSA-Topics-with-Python
/Array/Array_Union_and_Intersection_of_Sorted_Array.py
300
3.515625
4
# Union And Intersection of sorted Array: from sortedArrays import Union from sortedArrays import Intersection if __name__ == "__main__": sorted_array_1 = [1,1,3,5,7] sorted_array_2 = [0,1,1,2,4,6,7] print(Union(sorted_array_1,sorted_array_2)) print(Intersection(sorted_array_1,sorted_array_2))
a94a2d78b122b1d9dfb68ba25853f4ed9dd69ce2
onestarshang/leetcode
/reconstruct-original-digits-from-english.py
3,520
3.625
4
''' https://leetcode.com/problems/reconstruct-original-digits-from-english/ Given a non-empty string containing an out-of-order English representation of digits 0-9, output the digits in ascending order. Note: Input contains only lowercase English letters. Input is guaranteed to be valid and can be transformed to its...
7a276e337f8928d3f8ae6a7dfc9d6bc971ea0205
barua-anik/python_tutorials
/break.py
275
4.1875
4
#Example 1: Type exit to break print("Example 1: ") while True: command = input("type 'exit' to exit \n") if (command == "exit"): break #Example 2: exit from the program with a certain value print("Example 2: ") for x in range(1,101): print(x) if x==30: break
f84cb4f84081acf104912f7da38bf02c20a20467
vcaitite/hangman
/read_txt_archive.py
441
3.625
4
from pathlib import Path import random path = Path('./word_list.txt') def archive_lines(): if path.is_file(): with open(path, 'r') as f: lines = (f.readlines()) return lines else: raise Exception("Word list archive doesn't exist 😞") def read_random_word(): line...
c4fa8ad7e557142e6a911223da9cdc52d93aa596
bharatvarmap/Python
/Algorithms/Sorting/bubbleSort.py
364
4
4
# -*- coding: utf-8 -*- """ Created on Tue May 28 12:13:21 2019 @author: Bharath """ def bubbleSort(alist): n = len(alist) for num in range(n-1,0,-1): for i in range(num): if alist[i]>alist[i+1]: temp = alist[i] alist[i] = alist[i+1] alist[i+...
a77cbac124a0fe733088145e62eee368c9a179ef
het1613/CCC-Solutions-1996-to-2005
/1997/Nasty Numbers Problem B CCC 1997.py
763
3.625
4
def NastyNumber(num): factor_limit=round(num**0.5)+2 factors=[] for factor_1 in range(1,factor_limit): if (num%factor_1==0): factor_2=int(num/factor_1) factors.append([factor_1,factor_2]) for pair_1 in factors: for pair_2 in factors: ...
76e5191b05f41cb110dd6222655fc2692f2640c9
armijoalb/CRIP
/Práctica 2/siguientePrimoFUerte.py
1,996
3.703125
4
import random as rnd def potencia(a,b,m): x = 1 while( b > 0): if (b%2 ==1): x = (x*a)%m a = (a**2)%m b = b//2 return x def PrimalidadMillerRabin(p,lista): """ Descripción: devuelve si p es posible primo o no Argumentos: p:(int)Número sobre el que se ...
85ac500649d9431a6eb627474ddd64a1099dfd5e
RomanenkoRIS/PythonStudying
/ex.py
681
3.890625
4
#types_of_people = 10 #x = f"Существует {types_of_people} типов людей" #print(x) #w = "зачем это {}" #r = "отак" #print(w.format(r)) print("У Мери был маленький барашек.") print("Его шерсть была белой как {}.".format('снег')) print("И всюду, куда Мери шла,") print("Маленький барашек всегда следовал за ней.") print("."...
d2d7f16c9fbe184e29b5a45263bc8ca93c273583
szfwl/J_TEST
/old/test20180530.py
1,258
4.0625
4
# a=0 # b=0 # while a <= 4: # a += 1 # if a==3: # continue # print (a) # b += a # # # print (b) # # row=1 # while row<=5: # # print("*"* row) # # row+=1 # row = 1 # while row<=5: # col=1 # while col<=row: # print ("*",end="") # col+=1 # print ("") # row ...
977474f56fedf488bfcfdeca86205c357faa8348
esfoliante/python_class_final_project
/main.py
2,962
4.21875
4
import random # ? This sys right here (not step sis, sadly) will let us # ? close the program import sys import os options = ["Dizer olá", "Calculadora", "Sair"] # ? After getting the data from other functions we greet the user, as asked def greetings(): name = getName() print(chooseGreeting() + " " + name) ...
09dcb97644ff6f2346d6c4c61607b51f4fc48898
bhavya-singh/Algorithmic-Toolbox
/Week1 - Introductory Challenges/1-2 sum_of_two_digits.py
143
3.546875
4
# python3 def sum_digits(a, b): return a+ b if __name__ == '__main__': p, q = map(int, input().split()) print(sum_digits(p, q))
79eb248b4eedf1bc69a435af4b8b01b4588f5f7e
kamieliz/Udemy_Python_Projects
/Lecture 9 - Sorts/insertion_sort.py
1,246
4.4375
4
# starting with a list and a key that starts at index 1. keep track of key # if condition for a swap is reached, keep track of the current item bc it will be compared over and over # Assignment implement insertion sort algorithm using Python # Test it for lists of various sizes # See if you can work out why it has O(n*...
596261800b198f7f946513cf4b6ecc0a34291d21
dankodak/Programmierkurs
/Abgaben/Blatt 3/Aufgabe 1/Team 44141/Shirokikh_Emil_EmilShirokikh_1761423/Aufgabe1.py
492
3.6875
4
# Kurzform der Mengen- und Listenoperationen in Python Emil Shirokikh # a. # Werte Selber auswaehlen, wobei a der Anfang und B das Ende des Intervalls ist. a = 3 b = 6 n = 4 deltaX = (b - a) / n seq = [] for i in range(0, n + 1): seq.append(a + i * deltaX) print(seq) #b. N = {1, 2, 3, 4, 5,...
9f99211d0fe01a065be615a0cdc582dcfbd0a504
thenixan/CourseraPythonStarter
/src/week4/task3.py
335
4
4
x1 = float(input()) y1 = float(input()) x2 = float(input()) y2 = float(input()) x3 = float(input()) y3 = float(input()) def distance(x1, y1, x2, y2): return ((x2 - x1) ** 2 + (y2 - y1) ** 2) ** 0.5 s1 = distance(x1, y1, x2, y2) s2 = distance(x2, y2, x3, y3) s3 = distance(x3, y3, x1, y1) print("{0:.6f}".format(...
9fdc0eefc771ff3625fa6d67d5cf4955a53370be
abaez004/Python-Assignments
/Assignment1/Assignment1.py
818
3.9375
4
#Angel Baez 9:30 AM This is the updated version import math minutes = 42; seconds = 42; totalTime = minutes * 60 + seconds; print("The total time is:", totalTime); radius = 6; radius2 = 4; volume = 4 / 3 * math.pi * (math.pow(radius,3)); volume2 = 4 / 3 * math.pi * (math.pow(radius2,3)); print("The volume...
3ecdbb87bd71ee44a1e3e9de2fb685cc3f13a935
redkad/100-Days-Of-Code
/Day 7/Challenges/replace.py
871
3.921875
4
import random import hangman, hangmanWords print(hangman.logo) blanks = [] lives = 0 chosen_word = random.choice(hangmanWords.word_list) for _ in range(len(chosen_word)): blanks.append('_') while '_' in blanks and lives < 7: entered = input('\nEnter a letter: ').lower() if entered in blanks : ...
8991fb819b58bb250852e26a0d0852427e1f58fb
mantoshkumar1/interview_preparation
/design/find_median_from_data_stream.py
2,251
4.125
4
""" Find Median from Data Stream ----------------------------- Median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two middle value. For example, [2,3,4], the median is 3 [2,3], the median is (2 + 3) / 2 = 2.5 Design a dat...
6724d381f952b55c7ec7d26262c45c94cfc48ea7
gomesgr/python-conversor
/zenit_polar.py
1,257
3.640625
4
class ZenitPolar: def __init__(self): self.zenit_polar_dict = {'Z': 'P', 'E': 'O', 'N': 'L', 'I': 'A', 'T': 'R', 'Í': 'Á', 'É': 'Ó', 'z': 'p', 'e': 'o', 'n': 'l', 'i': 'a', 't': 'r'} def encriptar(self, palavra): """ # Criado por Gabriel R. Gomes ...
a3bb9f15abdc945ff754a0e906164820082e063c
ryanjames1729/computer-programming-python
/Unit 1 Python Files/is-odd.py
184
3.796875
4
# CDS - Programming # Is Odd Assignment # # Student Name: # Ask for input # Determine if the number is even or odd odd = False # Print a statement with the result
5f4d87c2d3a4097a35026dd24bf21c8a09b3fd2f
hiei17/Crawler_Learning_Record
/用python3原生的urllib/1.1百度返回二进制转成str.py
1,207
3.796875
4
# coding=utf-8 import urllib.request def load_data(): url = "http://www.baidu.com/" # response:http相应的对象 mark urllib.request 是 python3 自带了 是一切的基础 response = urllib.request.urlopen(url) # http请求 没传参 就是 mark get的请求 如果有data=? 就是post print(response) # 读取内容 bytes类型 data = response.read() # ...
c0cdf588c040a9e887d020137b2550bf62887bab
lee362/Learn-Python-3-the-Hard-Way
/codes/ex44.py
2,018
3.859375
4
#Inheritance vesus Composition #summary: #When you are doing this kind of specialization, there are three ways that the parent and child classes can interact: # 1. Actions on the child imply an action on the parent. # 2. Actions on the child override the action on the parent. # 3. Actions on the child alter the actio...
d54ee3b14c4e0d355ceada5abf0307177e7c42db
it57070028/The-Examer
/Project.py
1,495
4.46875
4
''' This program can help you create the examination How to use: 1.Enter the number of your question 2.Enter your question 3.Enter you answer choices 4.Enter the correct answer You can reset your question by enter "_reset" in question You can submit all of your question when you finish it by enter "_submit" Author : Y...
50895c35c54f4f4fae4bb008a2c39f6d45d94ef0
INT-NIT/generateGUID
/doc/test_duplicates/TEST_GUID_Python2.py
5,605
3.65625
4
#!/usr/bin/python # Test possibilty of Duplication of GUID for first 10 characters of hash # Dipankar Bachar # Written in 29/10/2019 # Updated Version # Runs with Python 2 """This scripts produces more then 1million unique combination of name,surname,dateofbirth,sex from the file name.csv which is a tsv file and produ...
7160dccef02e156cb33332f7ed1087fb8d67d84c
CatchTheDog/py
/py/logiccontrol.py
316
3.5
4
#!/usr/bin/python # -*- coding: UTF-8 -*- flag = False name = 'luren' if name == 'python': flag = True print('welcome boss') else: print(name) # python 不支持switch num = 5 if num == 3: print('boss') elif num == 2: print('user') elif num == 1: print('worker') else: print('roadman')
6514d77e2a163f60bfc57e9c4aa89ae3c298332f
michaelyzq/Python-Algorithm-Challenges
/021mergeTwoLists.py
1,278
4.09375
4
""" Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. Example: Input: 1->2->4, 1->3->4 Output: 1->1->2->3->4->4 """ class Solution(object): def mergeTwoLists(self, l1, l2): """ :type l1: ListNode :...
4923adfb43f82c7efde7c82676a6d80e84756751
mikolajwr/Projects
/My Projects/e to n.py
384
3.6875
4
import math from decimal import Decimal from decimal import getcontext n = input('Enter how many decimal points of e you want to view: ') max = 100 e = Decimal(1) getcontext().prec = 40 def fact(p): silnia =1 for i in range(1, int(p)+1): silnia *= i return (int(silnia)) for k in range(1, max): ...
96bc61d92c71f9e641a0948b82f330b8821117ab
alievgithub/MIPT_advanced_python_fall
/w1/Dictionary.py
288
4.15625
4
#3 dict1 = {'A': 1, 'B': 2, 'C': 3} # (2 вариант) #dict2 = dict([(value, key) for (key, value) in zip(dict1.keys(), dict1.values())]) dict2 = {value: key for key, value in dict1.items()} # (1 вариант) #for key, value in dict1.items(): # dict2[value] = key print(dict2)
ec23149d5fd3826a8afeaad36872d19ee7e55800
liuminzhao/pythoncourse
/guessnumber.py
2,036
4.125
4
# template for "Guess the number" mini-project # input will come from buttons and an input field # all output for the game will be printed in the console import random import simplegui import math # initialize global variables used in your code secret = 0 myguess = 0 num_range = 100 count = 0 maxcount = 0 # define even...
469b1e8822ec80e20ef2c9c110a4b969a6709584
aritse/practice
/palindrome_linked_list.py
1,819
3.78125
4
# Approach 1 class Solution(object): def isPalindrome(self, head): rev = None slow = fast = head while fast and fast.next: fast = fast.next.next rev, rev.next, slow = slow, rev, slow.next if fast: slow = slow.next while rev and rev.val == s...
50988873c2393c330b1ee5c96d5be0389f6dd5b4
CateGitau/Python_programming
/Packt_Python_programming/Chapter_3/exercise50.py
137
3.71875
4
def countdown(n): if n == 0: return "Liftoff!!" else: print(n) return countdown(n-1) print(countdown(3))
1fe6e6d14f2464fb5b550635afe66acf0beec88e
Geokenny23/Basic-python-batch5-c
/Tugas-2/Soal-1.py
2,009
3.96875
4
semuakontak = [] kontak = [] def menu(): print("----menu---") print("1. Daftar Kontak") print("2. Tambah Kontak") print("3. Keluar") def tampilkankontak(): print("Daftar Kontak: ") for kontak in semuakontak: print("Nama : " + kontak["nama"]) print("No. Telepon : " + kontak["te...
65e950537d3adc987c720d33da21ecbef38f3f83
jaiprakashrenukumar/mypython_lab
/python_basic/013_split_join.py
533
4.0625
4
names = 'jai, suresh, vikram, santhosh' print(names) # this prints as a long string print("\n") # now we are going to split this string l = names.split(", ") # we are spliting using , and space print(l) print("\n") print("another example") newlist = 'jai1suresh1vikram1santhosh' print(newlist) print("\n") nl = new...
f9abcdd993a09c0e3078ce172007652744fd6ec2
Maria105/python_lab
/lab4_1.py
194
4.09375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import math a=float(input('enter a>=0: ')) b=float(input('enter b>0: ')) e=math.e x=math.sqrt(a*b)/(math.exp(a)*b)+a*math.exp(2*a/b) print(x)
34e7af40d5c01d9a8802be5731f16d11049b3f51
FilipMohyla/Cycles-in-Python
/pentagon_to_octagon.py
266
3.671875
4
from turtle import forward, left, right, shape, exitonclick, penup, pendown, pencolor shape("turtle") for h in range(4): for i in range(8-h): forward(45) left(360/(8-h)) penup() forward(110) pendown() exitonclick()
a6c4220ce76f5574a5078a7455efc7efbf96bf95
TimLeeTY/compPhyEx
/ex1/numInt.py
2,510
3.953125
4
""" =================================================== Ex.1 Numerical Integration using Monte-Carlo method =================================================== """ import numpy as np import matplotlib.pyplot as plt def MCint(N, n): # N holds number of samples and n is the number of trials per N D, s = 8, np.pi...
7bc3443e285952e129c6161066448e516f3fbf0b
abriggs914/Coding_Practice
/Python/Resource/textprint.py
2,723
3.8125
4
import pygame import datetime # Class to print text to a pygame window. # Borrowed from: # https://stackoverflow.com/questions/49887874/pygame-xbox-one-controller # Version............1.0 # Date........2022-03-05 # Author....Avery Briggs pygame.init() BLACK = pygame.Color('black') WHITE = pygame.Color('white') # T...
c481ee852934f1e8625d7849130aa5b7859125f8
burakhanaksoy/PythonOOP
/corey_schafer/magic_methods.py
1,545
3.875
4
# magic methods help us change built in methods and/or operations from datetime import timedelta import math class Employee: raise_amt = 1.04 def __init__(self, f_name, l_name, pay): self.f_name = f_name self.l_name = l_name self.email = self.f_name.lower() + '.' + self.l_name.lower()...
93a3dfb2bb3c27f5308a6688a05437c85a380903
wellingtond2271/old-files
/practice2.py
395
3.96875
4
print(" Give Me Numbers. ") Num1 = input(" Whats your first number?! ") Num2 = input(" Whats The Second One? ") Num1 = int(Num1) Num2 = int(Num2) print(str(Num1) + "+" + str(Num2) + "=" + str(Num1 + Num2)) print(str(Num1) + "-" + str(Num2) + "=" + str(Num1 - Num2)) print(str(Num1) + "*" + str(Num2) + "=" + str...
2a00ac4c9779ba9fb157713c025855961129fe94
hakepg/operations
/Basic/pattern_durga.py
146
3.671875
4
#pattern 55 n=5 for row in range(n,0,-1): print(' '*(n-row),end=' ') for column in range(1,n+1): print('*', end=' ') print()
a730eb4b33e4f45ea9b7b1ac8020d269f651474b
Klausop/python_practical-tscs
/21332_prac_5c.py
105
3.8125
4
dict={'data1':10,'data2':20,'data3':30} print("sum of dict values are :") print(sum(dict.values()))
64d928cb5450e0fc4728e0fa8562c73ed62b94b2
wilkice/Algorithms
/a3+b3=c3+d3.py
717
3.578125
4
''' find integer under 1000 to make a3+b3=c3+d3 ''' all_result = {} pairs_result = [] def add(num): for i in range(1,num+1): for j in range(i, num+1): result = i ** 3 + j ** 3 # 不在字典里就添加 if result not in all_result.keys(): all_result[result]=[(i,j)] ...
7b97716012a012dddd4e602a08f5bfe6ad2e892d
Moss89/Python_Semester_1
/p19/ass.py
4,518
3.71875
4
import emoji from random import choice import sys def run_slot_machine(): class Purse: def __init__(self): self.money = 10 def debit(self, amount): print(amount,"this") self.money -= amount def credit(self, amount): self.money ...
e765792ab99db70cfaf7422eb17b9220222d1fc2
tallsam/shifting_hands
/sh_item.py
1,267
3.53125
4
# Shifting Hands # Item Classes # Sam Hassell class Item(object): def __init__(self, name, description, material, item_type, weight, base_value, actions): self.name = name self.description = description self.material = material #wood, gold, silver, food, steel self.item_type = item_type...
e0f890117ec5ff0cb5fd9c721b2db24afee8ff83
akatzuka/ML-and-Neural-Nets-CST-463-
/HW and Exams/HW's/HW5.py
4,826
3.65625
4
# -*- coding: utf-8 -*- """ Created on Wed Oct 3 14:12:23 2018 @author: Remilia """ import numpy as np import numpy.linalg as LA from sklearn.datasets import load_boston, load_iris from sklearn.linear_model import LogisticRegression from sklearn.metrics import accuracy_score import matplotlib.pyplot as plt import ma...
8cfa321aa6c665d02aa5014dc3e435a5b5e6c5c8
Konchannel/ABC_AtCoder_past-ques
/ABC159/C.py
327
3.53125
4
""" 問題文 正の整数Lが与えられます。 縦、横、高さの長さ (それぞれ、整数でなくてもかまいません) の合計が Lの直方体としてありうる体積の最大値を求めてください。 制約 1≤L≤1000 Lは整数 """ # === tried-01 === L = int(input()) s = L / 3 print(s ** 3)
f3d6d104d9a0eda528985bf9841e16d3d13979fd
DT-1236/leetcode-practice
/hard/freedom_trail.py
3,501
3.75
4
from collections import defaultdict class Solution: def findRotateSteps(self, ring: str, key: str) -> int: """Keeps track of all paths using a single array representing the ring As each letter is used, all costs for that letter are updated with the best cost at that time >>> test = Solutio...
86eae087c5fc1a8398c6d83cc7d9f0a5c1df3c09
liuhadong/7.21
/53.py
226
3.953125
4
def judge(string): print(string.islower()) if string.islower(): print('是由小写字母和数字组成') else: print('不是由小写字母和数字组成') word = input('请输入:') judge(word)
ff18b5eed66d9985cf4292eb96c47563ddea939e
inghgalvanIA/Master_Python
/python/17parametros.py
327
3.796875
4
nombre = input("Introduce tu nombre") edad = int(input("Ingresa tu edad")) def saludar(nombre,edad): mensaje = None if edad >= 18: mensaje = "Eres mayor de edad" else: mensaje = "Eres menor de edad" return "Hola " + nombre + " tienes " + str(edad) + " y " + mensaje print(saludar(nombre...
5bdc07ac7fe5bc83c041000d7a655b6a078e0e7f
Abnernnetto/estudoParaTestesUnitarios-Python
/teste_aplicacao/test_comparador.py
2,031
3.53125
4
import unittest from aplicacao.comparador import compara_numeros_simples, compara_numeros_quadraplos class MyTestCase(unittest.TestCase): def test_comparacao_de_valores_a_maior(self): resultado = compara_numeros_simples(5, 2) self.assertTrue(resultado) def test_comparacao_de_valores_...
dba2ec352e0c5c7d9d07d58a28de804ae71b89f1
MissSheyni/HackerRank
/Python/DateAndTime/calendar-module.py
300
3.765625
4
# https://www.hackerrank.com/challenges/calendar-module import calendar [month, day, year] = map(int, raw_input().split()) weekdayInt = calendar.weekday(year, month, day) weekdays = ["MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY", "SUNDAY"] print(weekdays[weekdayInt])
b700d05fc9080f218984db8cb0b78cacec758944
lenniecottrell/Python-Projects
/Mini projects/birthday_IF_statements.py
663
4.3125
4
import datetime today = datetime.date.today() checkDate = datetime.datetime(2020, 6, 30) allisonBday = datetime.datetime(2020, 5, 9) print(today) print(checkDate) print(allisonBday) if today.month == checkDate.month and today.day == checkDate.day: print("Happy birthday!") elif today.month == allisonBday.month an...
fb6808329e16b306a9bdf671d4e06e9d91c5c7ae
Aasthaengg/IBMdataset
/Python_codes/p02963/s465488423.py
462
3.671875
4
def divisor(n): ass = [] for i in range(1,int(n**0.5)+1): if n%i == 0: ass.append(i) if i**2 == n: continue ass.append(n//i) return ass #sortされていない def main(): S = int(input()) X1, Y1 = 0, 0 Y2 = 1 X2 = 10 ** 9 Y3 = S // X2 if...
839e5569d99e906703c338501ec2b1e85c174f7d
karbekk/Python_Data_Structures
/Interview/TechieDelight/Array/sort_0_1_2.py
273
3.984375
4
def sort_three(nums): from collections import Counter my_list = [] for k , v in Counter(nums).items(): while v != 0: my_list.append(k) v -= 1 return my_list print sort_three( nums = [7, 1, 1, 2, 2, 1, 0, 0, 2, 0, 1, 1, 0])
4131dd87d173a164fe7d104a5061f55399e22d0f
raghubgowda/python
/beginer/converters.py
220
3.640625
4
def lbs_to_kg(weight: float): if weight > 0.0: return weight * 0.45 else: return 0.0 def kg_to_lbs(weight: float): if weight > 0.0: return weight / 0.45 else: return 0.0
5d16ef05e6a74d384a07ec837c8d6df55d2df293
LyriCeZ/py-core
/Python Data Structures/print.py
145
3.578125
4
text = raw_input("Enter a file name: ") texted = open(text) inside = texted.read() inside = inside.upper() inside = inside.rstrip() print inside
3b9180f6f3acaa3c93647037594b64726eb7e5da
PriscylaSantos/estudosPython
/TutorialPoint/05 - Numbers/2 - Random Number Functions/04 - seed()_method.py
411
3.703125
4
#!/usr/bin/python3 #The seed() method initializes the basic random number generator. Call this function before calling any other random module function. # seed ([x], [y]) import random random.seed() print ("random number with default seed", random.random()) random.seed(10) print ("random number with int seed", random....
3254d5987a9537dbc7a69502431667628d6f10c2
KevinVargis/Breakout
/Paddle.py
576
3.703125
4
class paddle: def __init__(self): self.x = 25 self.y = 1 self.oldx = 25 self.oldy = 1 self.size = 5 self.oldsize = 5 self.speed = 2 def move(self, dir): # print(dir) self.oldx = self.x self.oldy = self.y if dir == 'a' or d...
a7b55848abbb88a94997e6304eb564af957d682f
janakiraam/ML-ToyProbelm
/grdient_decent.py
511
3.609375
4
import numpy as np def gradient_decent(x,y): m_curr=0 b_curr=0 iteration=100 n = len(x) learning_rate=0.001 for i in range(iteration): y_predict=m_curr*x+b_curr md=-(2/n)*sum(x*(y-y_predict)) bd=-(2/n)*sum(y-y_predict) m_curr=m_curr - learning_rate*...
f34128088a213795dfa4a912f86cdfc5140eff13
vincent507cpu/Comprehensive-Algorithm-Solution
/LintCode/ladder 08 memorized search/必修/683. Word Break III/solution.py
1,021
3.90625
4
class Solution: """ @param: : A string @param: : A set of word @return: the number of possible sentences. """ def wordBreak3(self, s, dict): # Write your code here if not s or not dict: return 0 lower_dict = set() for piece in dict: ...
7331bd829344fdddafaf6fbcd77adab81e5ce098
patheticGeek/competitive-code
/strings/valid-palindrome.py
379
3.90625
4
class Solution(object): def isPalindrome(self, s): """ :type s: str :rtype: bool """ string = "" for char in s: if(char.isalnum()): string += char.lower() res = string == string[::-1] return res sol = Solution() ans = sol...
78089443a30ea5354b17a56823828240e9248a0d
weijiew/cs61a
/lab/lab08/lab08.py
16,394
4.1875
4
""" Lab 08: Midterm Review """ # Linked lists def insert(link, value, index): """Insert a value into a Link at the given index. >>> link = Link(1, Link(2, Link(3))) >>> print(link) <1 2 3> >>> insert(link, 9001, 0) >>> print(link) <9001 1 2 3> >>> insert(link, 100, 2) >>> print(lin...
174437c1bf703c59eaffde53b5b9a8b93e292d21
lebull/AnotherAGC
/cpu.py
2,910
3.640625
4
class Registers(object): REG_A = "A" REG_P = "P" REG_Q = "Q" REG_LP = "LP" class AGC(object): def __init__(self): #The AGC had four 16-bit registers for general computational use, called the central registers: # A: The accumulator, for general computation # Z: The program ...
292d677d9555c1b84da932863a1c897fcc1a4689
SergiBaucells/DAM_MP10_2017-18
/Tasca_3_Python/src/exercici_3_python.py
703
3.9375
4
def comptador(): while True: caracter = input("Introdueix una lletra: ") if(len(caracter)>1 or len(caracter)==0): print("Te que ser un caràcter i/o no pot estar buit!!!") caracter = "caracter" continue else: break while True: cade...
7f3d32aa201c0ab408cab474b6490a9179154c8c
Fouad-Karam/Python-DieRoll-Game
/main.py
1,028
4.1875
4
from art import logo from random import randint print(logo) print("") print("Welcome to Do-Not-Roll-1 game.\n") print("") print("Rules:\n1. Roll a single die, and as long as you don't roll 1, you keep adding the values you get.\n2. Feel lucky? keep rolling.\n3. The moment you roll a 1, you loose and the accumul...
6b01ee8e288c830414a7dbc7d0d3cc018f3ef480
Piratelhx/UrbanGen
/utils.py
6,276
3.640625
4
def crop(image, new_shape): ''' Function for cropping an image tensor: Given an image tensor and the new shape, crops to the center pixels (assumes that the input's size and the new size are even numbers). Parameters: image: image tensor of shape (batch size, channels, height, width) new_shape: a torch....
cadeca818aff82697f119f9f4ce30cecbca9cf9c
Shmelnick/lyrics
/collect_data/merge_songs.py
875
3.609375
4
""" merge two songs.csv files in one """ import csv # set input1, input2 and output filenames here INPUT1 = "songs1.csv" INPUT2 = "songs2.csv" OUTPUT = "songs_merged.csv" if __name__=='__main__': csvfile = open(INPUT1, 'rb') reader = csv.reader(csvfile, delimiter=' ', quotechar='|', quoting=csv.QUOTE_MI...
880bdde2cbb91a1caf2ba6447b45a066d2a385e2
navnee22/Ineuron_MLDL
/python assignment 2.py
593
4.5
4
#!/usr/bin/env python # coding: utf-8 # 1. Create the below pattern using nested for loop in Python # # * # * * # * * * # * * * * # * * * * * # * * * * # * * * # * * # * # In[2]: n=5 for i in range(n): for j in range(i): print("*",end="") print("") for i in range(n,0,-1): for j in range(i...
8521c07ce8db1afcf06ee6f09888450474da4e2f
nischalshk/IWPython
/DataTypes/6.py
710
4.25
4
# Write a Python program to find the first appearance of the substring 'not' and # 'poor' from a given string, if 'not' follows the 'poor', replace the whole 'not'...'poor' # substring with 'good'. Return the resulting string. # Sample String : 'The lyrics is not that poor!' # 'The lyrics is poor!' # Expected Result :...
a34aa1edd835953dd7853763a6d185d0a5b5c75f
eddiequezada/Python-Projects
/Story.py
437
3.984375
4
def begin_story(): user_name = input("Please enter your name") print('You are a bandit and have just escaped prison and ran into an alley way that splits in three directions. Which way do you go?') print('Enter the number that corresponds to your decision') user_response = int(input('1. You decide to go right \...
d720e18755de710e9dbacca7252f58ce9f6e0ea6
bharat-kadchha/tutorials
/core-python/Core_Python/exception/ExceptionMethods.py
552
3.59375
4
''' e. and use all methods ''' ''' also try different exception like java file,array,string,numberformat ''' ''' user define exception ''' try: raise Exception('spam,','eggs') except Exception as inst: print("Type of instance : ",type(inst)) # the exception instance print("Arguments of instance : ",inst.ar...
7af99d0d92ca6be5257f30b7629eb3f06c704f3c
MadhanArts/PythonInternshipBestEnlist
/day9_task1.py
177
4.1875
4
multiply = lambda x, y: x * y a = int(input("Enter 1st number : ")) b = int(input("Enter 2nd number : ")) print("Result after multiplying using lambda :", multiply(a, b))
f944441bffd12a80f5c7b8f47719c762b1ae1d24
tsafay/PycharmProjects
/book_learning/automation_py/ch5_字典/ticTacToe.py
788
4.125
4
# -*- coding: utf-8 -*- # @Author : leejufe # @Date : 2020/4/22 10:39 board = {'top_L':' ', 'top_M':' ', 'top_R':' ', 'mid_L':' ', 'mid_M':' ', 'mid_R':' ', 'low_L':' ', 'low_M':' ', 'low_R':' ' } def printBoard(board): print(board['top_L'] + '|' + board['top_M'] + '|' + board['t...
963feb8fc4aaa22815d0988e12d038b4b60f7ee4
LorranSutter/URI-Online-Judge
/Beginner/1009.py
115
3.53125
4
NAME = input() SALARY = float(input()) MONTANTE = float(input()) print("TOTAL = R$ %.2f" % (SALARY+MONTANTE*0.15))
b521d3660841137b275eb19f4dee6ce4d17b472e
anjinsung/receipt_account
/receipt.py
3,300
3.6875
4
from operator import itemgetter, attrgetter class Receipt: def __init__(self,description,price): self.description = description self.price = price def print_data(self): print("Receipt Description : " + self.description + "\n" + "Receipt Price : " + str(self.price)) # def __l...
a3d10c634fcf053dbac02eb5d911b8b930fc87fa
otomori-k/python
/Demo0926_A.py
1,198
4.03125
4
# 四則演算 1 + 2 1 - 2 4 * 5 7 / 5 # べき乗 3 ** 2 # データ型 type(10) type(2.718) type("hello") # 変数 x = 10 print(x) x = 100 print(x) y = 3.14 x * y type(x * y) # リスト a = [1, 2, 3, 4, 5] print(a) len(a) a[0] a[4] a[4] = 99 print(a) # スライシング # 0番目から2番目まで(2番目は含まない) a[0:2...
58ead9ce3f69b1fa997cbdfb9d3f111dc08c728a
scqsryws/DemoPractice
/blg/drawTree.py
653
3.984375
4
# 分支树 from turtle import Turtle def tree(plist, l, a, f): if l > 5: lst = [] for p in plist: p.forward(l) q = p.clone() p.left(a) q.right(a) lst.append(p) lst.append(q) tree(lst, l * f, a, f) def main(): p = Tu...
9580a8dadb970abf8e60d917fe7af2f0f5e24ca3
drudolpho/Sorting
/src/iterative_sorting/iterative_sorting.py
1,265
4.09375
4
# TO-DO: Complete the selection_sort() function below def selection_sort(arr): # loop through n-1 elements for i in range(0, len(arr) - 1): cur_index = i smallest_index = cur_index # TO-DO: find next smallest element # (hint, can do in 3 loc) for ii in range(cur_index +...
9cd1b812b933b27bff4369a88f049283a914edd1
awuerf4505/caesar-crypt-decrypt
/caesar_cipher.py
971
3.9375
4
def shift(letter, n): unicode_value = ord(letter) + n if unicode_value > 126: value = unicode_value - 126 unicode_value == 32 + value return chr(unicode_value) if unicode_value < 32: n = 32 - unicode_value unicode_value = 126 - n return chr(unicode_value)...
7cee8ab79039f50ab96616f2b1d13c4f1e6074b0
reinaaa05/python
/paiza_02/paiza_02_002_001.erb
313
3.71875
4
# coding: utf-8 # if文による条件分岐 import random number = random.randint(1, 5) print("あなたの順位は" + str(number) + "位です") # ここにif文を追加する if number == 1: print("おめでとう") elif number == 2: print("あと少し") else: print("よくがんばったね")
257f1bfd2a75bea5ed865d19570878995cff1ebe
jiwon-0129/likelion_jw
/파이썬과제1_jiwon.py
397
4.03125
4
the_answer = {"현숙": "이화여대 멋사 대표님", "세은": "파이썬 세션 튜터", "두희": "멋사 창립자", "마루": "야옹"} for i in the_answer: print("다음은 누구에 대한 설명일까요?") print(the_answer[i]) n=input() if the_answer[i]==the_answer.get(n): print("정답입니다.") else: print("오답입니다.") continue
56e9dd46ca8d3e2cba9186400404d4353914a0fc
chloeward00/CA117-Computer-Programming-2
/labs/swap_v2_042.py
377
3.703125
4
def swap_unique_keys_values(b): swapped_dictionary = {} for i in b: if b[i] in swapped_dictionary: del (swapped_dictionary[b[i]]) else: swapped_dictionary[b[i]] = i return swapped_dictionary def main(): x = {1: "a", 2: "b", 3: "c", 4: "c"} print (swap_uniqu...
61501ecef813f8f4dec7680aecbc9da114f67ea5
sgozen/BootCamp2018
/ProbSets/Comp/ProbSet1/Calculator.py
229
3.578125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Jun 25 19:47:41 2018 @author: suleymangozen """ import math def sum (a, b): return a + b def sqrt(a): return math.sqrt(a) def prod(a,b): return a*b
1058c5012d8cbd4777dba24f6f94e36525b888ee
yogeshoyadav08/sample_repo
/Day 3/city.py
256
4.03125
4
l1={"mumbai":"maharashtra","ranchi":"Jharkhand","ahemdabad":"gujarat"} #st=str(raw_input("Enter a city:")) print(l1[str(raw_input("Enter a city:"))]) #s=str(raw_input("Enter a state:")) print l1.keys()[l1.values().index(str(raw_input("Enter a state:")))]
4ff162f01df4ce1e7227f829379987f9f494303a
codeamt/udacity-dsa-nand
/3_004_Project_3_dsa/04_Problem_4.py
3,438
4.0625
4
def sort_012(input_list): """ Given an input array consisting on only 0, 1, and 2, sort the array in a single traversal. Args: input_list(list): List to be sorted Note: """ if input_list is None or len(input_list) <= 1: return input_list # positional indices low = 0 # ...
2960d2b03cdb474be1e51c4e1d1227adcefef5b2
JohannesBuchner/pystrict3
/tests/data23/recipe-302697.py
3,882
3.828125
4
'''\ An experiment with python properties using TVM equations as an example A TVM object works like a financial calculator. Given any four of (n, i, pmt, pv, fv) TVM object can calculate the fifth. This version assumes payments are at end of compounding period. Example: >>> loan=TVM() >>> loan.n=3*12 # set ...
f86b71ecfff7440fc417ca0bd50ab03710be1ab3
creep1g/Datastructures-RU
/practice-tests/FinalExamSpring2020_solutions/P4/wait_list.py
4,099
3.703125
4
class Student: def __init__(self, id, name, phone, address): self.id = id self.name = name self.phone = phone self.address = address def __str__(self): return str(self.id) + " " + str(self.name) + " " + str(self.phone) + " " + str(self.address) def _...
efd1f9e5cdd1e5fee46f652f28e62cfd1ac09976
Mynuddin-dev/Practice-Python-01
/Function/factorial.py
847
4.09375
4
# -*- coding: utf-8 -*- """ Created on Sun May 31 22:18:00 2020 @author: Mynuddin """ def factorial(n): fact=1 for i in range(1,n+1): fact=fact*i return fact x=int(input("Please enter your value:")) result=factorial(x) print("The factorial of", x," is :",result) #...
7e75f8025c0b58f8c1f1130d3f62d8a5a7eba82e
Nicola-Nardella/SomeCode
/BinarySerch.py
629
3.921875
4
# Serch algorithm in an ordered list def binary_search(list, n, x): '''Binary serch.''' i = 0 j = n - 1 while (i <= j): middle = int((i + j) / 2) if (x < list[middle]): j = middle - 1 elif (x > list[middle]): i = middle + 1 else: return...
d7632bef393acee0420b68d6cd09c5188275e05a
yuyuOWO/source-code
/Python/拓扑排序.py
1,381
3.875
4
def topo_sort(graph): queue = [] for x in graph: if graph[x]["indegree"] == 0: queue.append(x)#首先将孤立的点都加入队列中 order_list = [] while len(order_list) != len(graph):#如果没有将所有顶点排完序 cur = queue.pop(0) order_list.append(cur) #每添加完一个新的顶点,将该顶点的所有邻接顶点入度都减1 for x...
7f0f303a4a5578f1ef864e4f5f6decd65c5e4877
AdamZhouSE/pythonHomework
/Code/CodeRecords/2313/60787/312181.py
215
3.609375
4
n,root=[int(x) for x in input().split()] tree=dict() for i in range(n): p,l,r = [int(x) for x in input().split()] tree[p] = tuple([l,r]) print(n,root) #if n==3 and root==2: #print(true) #print(true)
07392e6c7de160cf7ad07723989c40407e306664
Combatd/learn_python
/timedeltas_start.py
900
4.03125
4
from datetime import date from datetime import time from datetime import datetime from datetime import timedelta def main(): print(timedelta(days=365, hours = 5, minutes = 1)) now = datetime.now() print("Today is: " + str(now)) print("One year from now it will be: " + str(now + timedelta(days = 36...
071816373de2e12d580f63af6a62e60a51fc18ae
vieiraguivieira/PhytonStart
/ifchallenge.py
474
4.1875
4
name = input("What's your name? ") age = int(input("How old are you? ")) if 18 < age <= 29: print("Welcome to the holidays {}!".format(name)) else: print("Go away {}!! You are {} years old!".format(name, age)) # tim solution # name = input("Please enter your name: ") # age = int(input("How old are you? ")) #...
9d6cf0eb03f0fd8b98014601d597dd31b79ce84f
vitalii-vorobiov/lab_one
/task5.py
1,730
3.59375
4
def read_file(path): """ (str) -> (set) Return set of lines from file """ lst = set() f = open(path,'r') for one_line in f.readlines()[1:]: lst.add((one_line.split()[0], float(one_line.split()[1]), int(one_line.split()[2]))) f.close() return ...
4cb91c7683538505af257238da6c4885ec5daf06
algometrix/LeetCode
/Assessments/MathWorks/power_generator.py
441
3.5
4
import collections def segment(x, space): window = collections.deque() out = [] for i, n in enumerate(space): while window and space[window[-1]] > n: window.pop() window += i, if window[0] == i - x: window.popleft() if i >= x - 1: out += sp...
c971bf5502e0f44f6c9242b3c45b973d0ffd0c90
nakhan98/CodeEval
/moderate/sum_to_zero.py
731
3.84375
4
#!/usr/bin/env python2 """ - CodeEval: Sum to Zero - https://www.codeeval.com/open_challenges/81/ """ from sys import argv from itertools import combinations N = 4 def find_sums_to_zero(numbers, n): """ Find and return combinations of n which sum to zero """ combs_to_zero = [] for comb in com...
754f50bb3f50a8eb94335149e30aee59aa13ef6d
cbass2404/bottega_classwork
/python/file_systems/file_systems.py
335
3.75
4
""" open takes two arguments (file_name, how_to_open_it) w+ tells it to write """ # file_builder = open("logger.txt", "w+") # file_builder.write("Hey, I'm in a file!") # file_builder.close() # file_builder = open("logger.txt", "w+") # # for i in range(1000): # file_builder.write(f"I'm on line {i+1}\n") # # file_b...
07e77b6f044244e7a7f916cb4a1de2acb19ebc8c
rtminerva/hybrid-simulation
/Old Files (Unused)/For Testing Only/solve_lin_sys.py
816
4.09375
4
import numpy from numpy import matrix from numpy import linalg # A = numpy.zeros(shape=(3,3)) # A = numpy.eye(3, k = 1) # print A # A = numpy.zeros(shape=(3,3)) A = matrix( [[1,2,3],[11,12,13],[21,22,23]] ) # Creates a matrix. B = matrix( [[1,2,3],[11,12,13],[21,22,23]] ) # Creates a matrix. x = matrix( [[1],[2],[3]] )...