blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
419e9c5cbb652df0abccd13ca68273bc18327cd9
jadugnap/python-problem-solving
/Task4-predict-telemarketers.py
1,300
4.15625
4
""" Read file into texts and calls. It's ok if you don't understand how to read files. text.csv columns: sending number (string), receiving number (string), message timestamp (string). call.csv columns: calling number (string), receiving number (string), start timestamp (string), duration in seconds (string) """ impor...
true
a4b024fe5edf1f5da39078c8d52034ba303a98cc
schirrecker/Math
/Math with Python.py
397
4.15625
4
from fractions import Fraction try: a = Fraction(input("Enter a fraction: ")) b = Fraction(input("Enter another fraction: ")) except ValueError: print ("You entered an invalid number") except ZeroDivisionError: print ("You can't divide by zero") else: print (a+b) def is_factor (a, b): ...
true
9fa0e009c15e00016bfae128e68515f6aaa87e5d
rohanyadav030/cp_practice
/is-digit-present.py
865
4.1875
4
# Python program to print the number which # contain the digit d from 0 to n # Returns true if d is present as digit # in number x. def isDigitPresent(x, d): # Breal loop if d is present as digit if (x > 0): if (x % 10 == d): return(True) else: return(False) ...
true
18bde0bbb7b8f371cbbab5d3a73310f823fa3570
amrutha1352/4040
/regularpolygon.py
280
4.28125
4
In [46]: X= float(input("Enter the length of any side: ")) Y= int(input("Enter the number of sides in the regular polygon: ")) import math numerator= math.pow(X,2)*Y denominator= 4*(math.tan(math.pi/Y)) area= numerator/denominator print("The area of the regular polygon is:",area)
true
34c467f6bcb628d403321d30b29644d35af003f3
jonesm1663/cti110
/cti 110/P3HW2.py
543
4.28125
4
# CTI-110 # P3HW2 - Shipping Charges # Michael Jones # 12/2/18 #write a program tha asks the user to enter the weight of a package #then display shipping charges weightofpackage = int(input("Please enter the weight of the package:")) if weightofpackage<= 2: shippingcharges = 1.50 elif weightofpackag...
true
619ebd59a6875ca0c6feb9a2074ba5412215c4ae
jonesm1663/cti110
/cti 110/P3HW1.py
820
4.4375
4
# CTI-110 # P3HW1 - Roman Numerals # Michael Jones # 12/2/18 #Write a program that prompts the user to enter a number within the range of 1-10 #The program should display the Roman numeral version of that number. #If the number is outside the range of 1-10, the program should display as error message. u...
true
698b8212c16b1a11a5fb9d63af5db687d404039f
beyzakilickol/week1Friday
/algorithms.py
953
4.1875
4
#Write a program which will remove duplicates from the array. arr = ['Beyza', 'Emre', 'John', 'Emre', 'Mark', 'Beyza'] arr = set(arr) arr = list(arr) print(arr) #-------Second way------------------------ remove_dups = [] for i in range(0, len(arr)): if arr[i] not in remove_dups: remove_dups.appen...
true
32f05d2f45e3bad3e2014e1ba768a6b92d4e67b6
soumyadc/myLearning
/python/statement/loop-generator.py
575
4.3125
4
#!/usr/bin/python # A Generator: # helps to generate a iterator object by adding 1-by-1 elements in iterator. #A generator is a function that produces or yields a sequence of values using yield method. def fibonacci(n): #define the generator function a, b, counter = 0, 1, 0 # a=0, b=1, counter=0 while True: ...
true
7400c080f5ce15b3a5537f436e3458772b42d801
soumyadc/myLearning
/python/tkinter-gui/hello.py
737
4.21875
4
#!/usr/bin/python from Tkinter import * import tkMessageBox def helloCallBack(): tkMessageBox.showinfo( "Hello Python", "Hello World") # Code to add widgets will go here... # Tk root widget, which is a window with a title bar and other decoration provided by the window manager. # The root widget has to be c...
true
29c1733f39888ca54099d2e15a762d8d748c06f9
opiroi/sololearn_python
/assistant/python_iterators_and_generators.py
1,556
4.5
4
def iteration_over_list(): """Iteration over list elements. :return: None """ print("##### ##### iteration_over_list ##### #####") for i in [1, 2, 3, 4]: print(i) # prints: # 1 # 2 # 3 # 4 def iteration_over_string(): """Iteration over string characters. :re...
false
7b3a4e66395735192270abc17f1c77bc8d5ee5bd
newjoseph/Python
/Kakao/String/parentheses.py
2,587
4.1875
4
# -*- coding: utf-8 -*- # parentheses example def solution(p): #print("solution called, p is: " + p + "\n" ) answer = "" #strings and substrings #w = "" u = "" v = "" temp_str = "" rev_str = "" #number of parentheses left = 0 right = 0 count = 0 # flag correct ...
true
40834ff71cc6200a7028bd1d8a7cacf42c9f886e
nicolaetiut/PLPNick
/checkpoint1/sort.py
2,480
4.25
4
"""Sort list of dictionaries from file based on the dictionary keys. The rule for comparing dictionaries between them is: - if the value of the dictionary with the lowest alphabetic key is lower than the value of the other dictionary with the lowest alphabetic key, then the first dictionary is smaller than the second. ...
true
4fe12c2ab9d4892088c5270beb6e2ce5d96debb1
chapman-cs510-2016f/cw-03-datapanthers
/test_sequences.py
915
4.3125
4
#!/usr/bin/env python import sequences # this function imports the sequences.py and tests the fibonacci function to check if it returns the expected list. def test_fibonacci(): fib_list=sequences.fibonacci(5) test_list=[1,1,2,3,5] assert fib_list == test_list # ### INSTRUCTOR COMMENT: # ...
true
bd7938eb01d3dc51b4c5a29b68d9f4518163cc92
jguarni/Python-Labs-Project
/Lab 5/prob2test.py
721
4.125
4
from cisc106 import * def tuple_avg_rec(aList,index): """ This function will take a list of non-empty tuples with integers as elements and return a list with the averages of the elements in each tuple using recursion. aList - List of Numbers return - List with Floating Numbers """ ...
true
8656ff504d98876c89ead36e7dd4cc73c3d2249e
jlopezmx/community-resources
/careercup.com/exercises/04-Detect-Strings-Are-Anagrams.py
2,923
4.21875
4
# Jaziel Lopez <juan.jaziel@gmail.com> # Software Developer # http://jlopez.mx words = {'left': "secured", 'right': "rescued"} def anagram(left="", right=""): """ Compare left and right strings Determine if strings are anagram :param left: :param right: :return: """ # anagram: left ...
true
846cc6cd0915328b64f83d50883167e0d0910f6a
Teju-28/321810304018-Python-assignment-4
/321810304018-Python assignment 4.py
1,839
4.46875
4
#!/usr/bin/env python # coding: utf-8 # ## 1.Write a python function to find max of three numbers. # In[5]: def max(): a=int(input("Enter num1:")) b=int(input("Enter num2:")) c=int(input("Enter num3:")) if a==b==c: print("All are equal.No maximum number") elif (a>b and a>c): prin...
true
22b5a162408555fa5aea974ebafc6dbd56ea8f18
BercziSandor/pythonCourse_2020_09
/DataTransfer/json_1.py
1,153
4.21875
4
# https://www.w3schools.com/python/python_json.asp # https://www.youtube.com/watch?v=9N6a-VLBa2I Python Tutorial: Working with JSON Data using the json Module (Corey Schaefer) # https://lornajane.net/posts/2013/pretty-printing-json-with-pythons-json-tool # http://jsoneditoronline.org/ JSON online editor ###########...
false
f81b9e4fdf5b0d1dc28194beb061bd140d6996b9
BercziSandor/pythonCourse_2020_09
/Functions/scope_2.py
2,977
4.21875
4
# Változók hatásköre 2. # Egymásba ágyazott, belső függvények # global kontra nonlocal # https://realpython.com/inner-functions-what-are-they-good-for/ # Függvényen belül is lehet definiálni függvényt. Ezt sok hasznos dologra fogjuk tudni használni. # Első előny: információrejtés. Ha a belső függvény csak segé...
false
a9169a0606ef75c17087acce0c610bb5aa8e1660
vivek28111992/DailyCoding
/problem_#99.py
624
4.1875
4
""" Given an unsorted array of integers, find the length of the longest consecutive elements sequence. For example, given [100, 4, 200, 1, 3, 2], the longest consecutive element sequence is [1, 2, 3, 4]. Return its length: 4. Your algorithm should run in O(n) complexity. """ def largestElem(arr): s = set(arr) ...
true
f96e8a52c38e140ecf3863d1ea138e15b78c7aa8
vivek28111992/DailyCoding
/problem_#28_15032019.py
1,687
4.125
4
""" Good morning! Here's your coding interview problem for today. This problem was asked by Palantir. Write an algorithm to justify text. Given a sequence of words and an integer line length k, return a list of strings which represents each line, fully justified. More specifically, you should have as many words as p...
true
c80b26a41d86ec4f2f702aab0922b86eec368e84
Brucehanyf/python_tutorial
/file_and_exception/file_reader.py
917
4.15625
4
# 读取圆周率 # 读取整个文件 # with open('pi_digits.txt') as file_object: # contents = file_object.read() # print(contents) # file_path = 'pi_digits.txt'; # \f要转义 # 按行读取 file_path = "D:\PycharmProjects\practise\\file_and_exception\pi_digits.txt"; # with open(file_path) as file_object: # for line in file_object: # ...
true
62bd9b81b6ace8f9bab84fb293710c50ca0bcf29
thekevinsmith/project_euler_python
/4/largest_palindrome_product.py
1,778
4.125
4
# Problem 4 : Statement: # A palindromic number reads the same both ways. The largest palindrome # made from the product of two 2-digit numbers is 9009 = 91 × 99. # Find the largest palindrome made from the product of two 3-digit numbers. def main(): largest = 0 for i in range(0, 1000, 1): count = 0 ...
true
e604fb50261893929a57a9377d7e7b0e11a9b851
georgeyjm/Sorting-Tests
/sort.py
2,686
4.34375
4
def someSort(array): '''Time Complexity: O(n^2)''' length = len(array) comparisons, accesses = 0,0 for i in range(length): for j in range(i+1,length): comparisons += 1 if array[i] > array[j]: accesses += 1 array[i], array[j] = array[j], arr...
true
a82eb08a4de5bab1c90099a414eda670219aeb95
eliaskousk/example-code-2e
/21-async/mojifinder/charindex.py
2,445
4.15625
4
#!/usr/bin/env python """ Class ``InvertedIndex`` builds an inverted index mapping each word to the set of Unicode characters which contain that word in their names. Optional arguments to the constructor are ``first`` and ``last+1`` character codes to index, to make testing easier. In the examples below, only the ASC...
true
639d50d4d0579ee239adf72a08d7b4d78d9b91b6
blaise594/PythonPuzzles
/weightConverter.py
424
4.21875
4
#The purpose of this program is to convert weight in pounds to weight in kilos #Get user input #Convert pounds to kilograms #Display result in kilograms rounded to one decimal place #Get user weight in pounds weightInPounds=float(input('Enter your weight in pounds. ')) #One pound equals 2.2046226218 kilograms weightI...
true
c3a23f4391d29250c7ff9ee4fa0ad9cd133abbe7
priancho/nlp100
/05.py
900
4.3125
4
#usage example: #python3 05.py 2 "This is a pen." import re import sys # extract character n-grams and calculate n-gram frequency def char_n_gram(n, str): ngramList = {} n=int(n) str = str.lower() wordList=re.findall("[a-z]+",str) for word in wordList: if len(word) >= n: for i in range(len(word)-n+1): i...
false
8a56d576c3c6be23f5fdbb3ad70965befbac04f7
juancebarberis/algo1
/practica/7-10.py
898
4.3125
4
#Ejercicio 7.10. Matrices. #a) Escribir una función que reciba dos matrices y devuelva la suma. #b) Escribir una función que reciba dos matrices y devuelva el producto. #c) ⋆ Escribir una función que opere sobre una matriz y mediante eliminación gaussiana de- #vuelva una matriz triangular superior. #d) ⋆ Escribir una f...
false
04dcc88ad0fb461fa9aafe3e290ab9addb03c08e
juancebarberis/algo1
/practica/5-4.py
1,135
4.125
4
#Ejercicio 5.4. Utilizando la función randrange del módulo random , escribir un programa que #obtenga un número aleatorio secreto, y luego permita al usuario ingresar números y le indique #si son menores o mayores que el número a adivinar, hasta que el usuario ingrese el número #correcto. from random import randrange ...
false
e08f787de4a2297aa6884dbb013e92f612423cc5
juancebarberis/algo1
/practica/7-7.py
877
4.21875
4
#Ejercicio 7.7. Escribir una función que reciba una lista de tuplas (Apellido, Nombre, Ini- #cial_segundo_nombre) y devuelva una lista de cadenas donde cada una contenga primero el #nombre, luego la inicial con un punto, y luego el apellido. data = [ ('Viviana', 'Tupac', 'R'), ('Francisco', 'Tupac', 'M'), ...
false
53439bc9fed95069408cec769fddd8fc2fc9376d
BryCant/Intro-to-Programming-MSMS-
/Chapter13.py
2,435
4.34375
4
# Exception Handling # encapsulation take all data associated with an object and put it in one class # data hiding # inheritance # polymorphism ; function that syntactically looks same is different based on how you use it """ # basic syntax try: # Your normal code goes here. # Your code should include function ...
true
2679e524fb70ea8bc6a8801a3a9149ee258d9090
daviscuen/Astro-119-hw-1
/check_in_solution.py
818
4.125
4
#this imports numpy import numpy as np #this step creates a function called main def main(): i = 0 #sets a variable i equal to 0 x = 119. # sets a variable x equal to 119 and the decimal makes it a float (do you need the 0?) for i in range(120): #starting at i, add one everytime the program gets to t...
true
0d4aad51ef559c9bf11cd905cf14de63a6011457
mvinovivek/BA_Python
/Class_3/8_functions_with_return.py
982
4.375
4
#Function can return a value #Defining the function def cbrt(X): """ This is called as docstring short form of Document String This is useful to give information about the function. For example, This function computes the cube root of the given number """ cuberoot=X**(1/3) retur...
true
53cee6f939c97b0d84be910eee64b6e7f515b12f
mvinovivek/BA_Python
/Class_3/7_functions_with_default.py
680
4.1875
4
# We can set some default values for the function arguments #Passing Multiple Arguments def greet(name, message="How are you!"): print("Hi {}".format(name)) print(message) greet("Bellatrix", "You are Awesome!") greet("Bellatrix") #NOTE Default arguments must come at the last. All arguments before default are...
true
3cb1bc2560b5771e4c9ec69d429fcfd9c0eadd2c
mvinovivek/BA_Python
/Class_2/7_for_loop_2.py
1,009
4.625
5
#In case if we want to loop over several lists in one go, or need to access corresponding #values of any list pairs, we can make use of the range method # # range is a method when called will create an array of integers upto the given value # for example range(3) will return an array with elements [0,1,2] #now we can...
true
c9a6c2f6b8f0655b3e417057f7e52015794d26d6
316126510004/ostlab04
/scramble.py
1,456
4.40625
4
def scramble(word, stop): ''' scramble(word, stop) word -> the text to be scrambled stop -> The last index it can extract word from returns a scrambled version of the word. This function takes a word as input and returns a scrambled version of it. However, the letters in the beginning and ending do not change. ...
true
d24514f8bed4e72aaaee68ae96076ec3921f5898
ChanghaoWang/py4e
/Chapter9_Dictionaries/TwoIterationVariable.py
429
4.375
4
# Two iteration varibales # We can have multiple itertion variables in a for loop name = {'first name':'Changhao','middle name':None,'last name':'Wang'} keys = list(name.keys()) values = list(name.values()) items = list(name.items()) print("Keys of the dict:",keys) print("Values of the dict:",values) print("Items of th...
true
6d325039a3caa4c331ecc6fa6bb058ff431218f8
ChanghaoWang/py4e
/Chapter8_Lists/note.py
921
4.21875
4
# Chapter 8 Lists Page 97 a = ['Changhao','Wang','scores',[100,200],'points','.'] # method: append & extend a.append('Yeah!') #Note, the method returns None. it is different with str a.extend(['He','is','so','clever','!']) # method : sort (arranges the elements of the list from low to high) b= ['He','is','clever','!'] ...
true
d593ffafc59015480c713c213b59f6304914d660
Ayush10/python-programs
/vowel_or_consonant.py
1,451
4.40625
4
# Program to check if the given alphabet is vowel or consonant # Taking user input alphabet = input("Enter any alphabet: ") # Function to check if the given alphabet is vowel or consonant def check_alphabets(letter): lower_case_letter = letter.lower() if lower_case_letter == 'a' or lower_case_letter == 'e' or...
true
2676477d211e0702d1c44802f9295e8457df21a8
Ayush10/python-programs
/greatest_of_three_numbers.py
492
4.3125
4
# Program to find greatest among three numbers # Taking user input a = int(input("Enter first number: ")) b = int(input("Enter second number: ")) c = int(input("Enter third number: ")) # Comparison Algorithm and displaying result if a > b > c: print("%d is the greatest number among %d, %d and %d." % (a, a, b, c)) ...
true
e50f8e37210054df2e5c54eb55e7dee381a91aff
super468/leetcode
/python/src/BestMeetingPoint.py
1,219
4.15625
4
class Solution: def minTotalDistance(self, grid): """ the point is that median can minimize the total distance of different points. the math explanation is https://leetcode.com/problems/best-meeting-point/discuss/74217/The-theory-behind-(why-the-median-works) the more human language ...
true
63825db8fd9cd5e9e6aaa551ef7bfec29713a925
Rohit439/pythonLab-file
/lab 9 .py
1,686
4.28125
4
#!/usr/bin/env python # coding: utf-8 # ### q1 # In[2]: class Triangle: def _init_(self): self.a=0 self.b=0 self.c=0 def create_triangle(self): self.a=int(input("enter the first side")) self.b=int(input("enter the second side")) self.c=int(input("e...
true
69b848ed2eeae8f3090a9c35b2cdf12bc4dd29e5
Rita626/HK
/Leetcode/237_刪除鏈表中的節點_05170229.py
1,671
4.21875
4
#題目:请编写一个函数,使其可以删除某个链表中给定的(非末尾)节点,你将只被给定要求被删除的节点。 # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def deleteNode(self, node): """ :type node: ListNode :rtype: void Do not return anything, ...
false
2991c345efe646cedda8aeaeeebe06b2a4cc6842
drmason13/euler-dream-team
/euler1.py
778
4.34375
4
def main(): """ If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. """ test() print(do_the_thing(1000)) def do_the_thing(target): numbers = range(1, target) answer =...
true
6f1aa43d0614cd211b0c92a48b182cf662e230fa
nmaswood/Random-Walk-Through-Computer-Science
/lessons/day4/exercises.py
720
4.25
4
def fib_recursion(n): """ return the nth element in the fibonacci sequence using recursion """ return 0 def fib_not_recursion(n): """ return the nth element in the fibonacci sequence using not recursion """ return 0 def sequence_1(n): """ return the nth element in the sequ...
true
42d3e9a30261a005a547a0957c4e53d2a19d5911
jfernand196/Ejercicios-Python
/examen_makeitreal.py
610
4.21875
4
# Temperaturas # Escribe una función llamada `temperaturas` que reciba un arreglo (que representan temperaturas) y # retorne `true` si todas las temperaturas están en el rango normal (entre 18 y 30 grados) o `false` de # lo contrario. # temperaturas([30, 19, 21, 18]) -> true # temperaturas([28, 45, 17, 21,...
false
42bb3d5df47e7eb91425f7a92e19872ed16e3483
piranna/asi-iesenlaces
/0708/repeticiones/ej109.py
861
4.21875
4
# -*- coding: utf-8 -*- """ $Id$ Calcula el factorial de un número entero positivo que pedimos por teclado Si tienes dudas de lo que es el factorial, consulta http://es.wikipedia.org/wiki/Factorial """ # Presentación print "*" * 50 print "Programa que calcula el factorial de un número" print "*" * 50 # Petición del n...
false
b976f86e302748c97bcd5033499a0f2a928bcbdc
taddes/python-blockchain
/data_structures_assignment.py
1,053
4.40625
4
# 1) Create a list of “person” dictionaries with a name, age and list of hobbies for each person. Fill in any data you want. person = [{'name': 'Taddes', 'age': 30, 'hobbies': ['bass', 'coding', 'reading', 'exercise']}, {'name': 'Sarah', 'age': 30, 'hobbies': ['exercise', 'writing', 'crafting']}, ...
true
e1ddd1d2897462bc6d6831993acdd9b9257554b2
changfenxia/gb-python
/lesson_1/ex_2.py
503
4.3125
4
''' 2. Пользователь вводит время в секундах. Переведите время в часы, минуты и секунды и выведите в формате чч:мм:сс. Используйте форматирование строк. ''' time_seconds = int(input("Enter time in seconds: ")) hours = time_seconds // 3600 minutes = (time_seconds % 3600) // 60 seconds = time_seconds - (hours * 3600) - (...
false
7cdaebe77cfb044dfc16e01576311244caae283f
roshna1924/Python
/ICP1/Source Code/operations.py
590
4.125
4
num1 = int(input("Enter first number: ")) num2 = int(input("Enter Second number: ")) operation = int(input("Enter 1 for addition\n" "Enter 2 for Subtraction\n" "Enter 3 for multiplication\n" "Enter 4 for division\n")) def arithmeticOperations(op): switcher = { 1: "Result of addition : " + str(num1 + num2),...
true
26cf949e46bd2bb958eca1241fe25beef76bbb1d
kamadforge/ranking
/algorithms/binary_tree.py
1,273
4.25
4
class Tree: def __init__(self): self.root=None def insert(self, data): if not self.root: self.root=Node(data) else: self.root.insert(data) class Node: def __init__(self, data): self.left = None self.right = None self.data = data ...
false
2185999943f7891d33a7519159d3d08feba8e14d
tim-jackson/euler-python
/Problem1/multiples.py
356
4.125
4
"""multiples.py: Exercise 1 of project Euler. Calculates the sum of the multiples of 3 or 5, below 1000. """ if __name__ == "__main__": TOTAL = 0 for num in xrange(0, 1000): if num % 5 == 0 or num % 3 == 0: TOTAL += num print "The sum of the multiples between 3 and 5, " \ ...
true
ac4244195cf8ecf1330621bd31773f3b211f4d5c
HaNuNa42/pythonDersleri
/python dersleri/tipDonusumleri.py
1,286
4.1875
4
#string to int x = input("1.sayı: ") y = input("2 sayı: ") print(type(x)) print(type(y)) toplam = x + y print(toplam) # ekrana yazdirirken string ifade olarak algiladigindan dolayı sayilari toplamadi yanyana yazdi bu yuzden sonuc yanlis oldu. bu durumu duzeltmek için string'ten int' ve...
false
68372dfabb4a768815176fd77acbab0dca4cfd68
AngelLiang/python3-stduy-notes-book-one
/ch02/memory.py
635
4.28125
4
"""内存 对于常用的小数字,解释器会在初始化时进行预缓存。 以Python36为例,其预缓存范围是[-5,256]。 >>> a = -5 >>> b = -5 >>> a is b True >>> a = 256 >>> b = 256 >>> a is b True # 如果超出缓存范围,那么每次都要新建对象。 >>> a = -6 >>> b = -6 >>> a is b False >>> a = 257 >>> b = 257 >>> a is b False >>> import psutil >>> def res(): ... m = psutil.Process().memory_info() ...
false
78b2dadaa067264258ed93da5a4e13ebf692ec6a
klq/euler_project
/euler41.py
2,391
4.25
4
import itertools import math def is_prime(n): """returns True if n is a prime number""" if n < 2: return False if n in [2,3]: return True if n % 2 == 0: return False for factor in range(3, int(math.sqrt(n))+1, 2): if n % factor == 0: return False ret...
true
1ba8cda2d2376bd93a169031caa473825b3912da
QaisZainon/Learning-Coding
/Practice Python/Exercise_02.py
795
4.375
4
''' Ask the user for a number Check for even or odd Print out a message for the user Extras: 1. If number is a multiple of 4, print a different message. 2. Ask the users for two numbers, check if it is divisible, then print message according to the answer. ''' def even_odd(): num = int(input('Enter a n...
true
6426ac00f17c7d1c5879ddf994938cfa0a412e62
ChienSien1990/Python_collection
/Ecryption/Encrpytion(applycoder).py
655
4.375
4
def buildCoder(shift): """ Returns a dict that can apply a Caesar cipher to a letter. The cipher is defined by the shift value. Ignores non-letter characters like punctuation, numbers, and spaces. shift: 0 <= int < 26 returns: dict """ ### TODO myDict={} for i in string.as...
true
1105fd4cb3e9b95294e5e918b0017e7f109d1aac
sujit4/problems
/interviewQs/InterviewCake/ReverseChars.py
1,023
4.25
4
# Write a function that takes a list of characters and reverses the letters in place. import unittest def reverse(list_of_chars): left_index = 0 right_index = len(list_of_chars) - 1 while left_index < right_index: list_of_chars[left_index], list_of_chars[right_index] = list_of_chars[right_index]...
true
934bdc157134659f5fc834ea4bce96bd6df629a2
JuanSebastianOG/Analisis-Numerico
/Talleres/PrimerCorte/PrimerTaller/Algoritmos/Metodo_Newton.py
1,285
4.25
4
#Implementación del método de Newton para encontrar las raices de una función dada from matplotlib import pyplot import numpy import math def f( x ): return math.e ** x - math.pi * x def fd( x ): return math.e ** x - math.pi def newton( a, b ): x = (a + b) / 2 it = 0 tol = 10e-8 errorX = [] ...
false
72f12e63fbac4561a74211964ab031f5ffb29212
derick-droid/pythonbasics
/files.py
905
4.125
4
# checking files in python open("employee.txt", "r") # to read the existing file open("employee.txt", "a") # to append information into a file employee = open("employee.txt", "r") # employee.close() # after opening a file we close the file print(employee.readable()) # this is to check if the file is readable prin...
true
95a9f725607b5acc0f023b0a0af2551bec253afd
derick-droid/pythonbasics
/dictexer.py
677
4.90625
5
# 6-5. Rivers: Make a dictionary containing three major rivers and the country # each river runs through. One key-value pair might be 'nile': 'egypt'. # • Use a loop to print a sentence about each river, such as The Nile runs # through Egypt. # • Use a loop to print the name of each river included in the dictionary. # ...
true
935e0579d7cbb2da005c6c6b1ab7f548a6694a86
derick-droid/pythonbasics
/slicelst.py
2,312
4.875
5
# 4-10. Slices: Using one of the programs you wrote in this chapter, add several # lines to the end of the program that do the following: # • Print the message, The first three items in the list are:. Then use a slice to # print the first three items from that program’s list. # • Print the message, Three items from the...
true
5a827e2d5036414682f468fac5915502a784f486
derick-droid/pythonbasics
/exerdic.py
2,972
4.5
4
# 6-8. Pets: Make several dictionaries, where the name of each dictionary is the # name of a pet. In each dictionary, include the kind of animal and the owner’s # name. Store these dictionaries in a list called pets . Next, loop through your list # and as you do print everything you know about each print it rex = { ...
true
d65f32a065cc87e5de526a718aeea6d601e1ac06
derick-droid/pythonbasics
/iflsttry.py
2,930
4.5
4
# 5-8. Hello Admin: Make a list of five or more usernames, including the name # 'admin' . Imagine you are writing code that will print a greeting to each user # after they log in to a website. Loop through the list, and print a greeting to # each user: # • If the username is 'admin' , print a special greeting, such as ...
true
0ed70af907f37229379d7b38b7aaae938a7fc31a
adamkozuch/scratches
/scratch_4.py
584
4.15625
4
def get_longest_sequence(arr): if len(arr) < 3: return len(arr) first = 0 second = None length = 0 for i in range(1, len(arr)): if arr[first] == arr[i] or (second and arr[second]== arr[i]): continue if not second: second = i continue ...
true
228c27b3406c45f10f3df2588de29e1d4ad5bfcb
AjayHao/helloPy
/demos/basic/list.py
684
4.21875
4
#!/usr/bin/python3 # 元祖 list1 = ['Google', 'Runoob', 1997, 2000] list2 = [1, 2, 3, 4, 5, 6, 7, 8] # 随机读取 print ("list1[0]: ", list1[0]) print ("list1[-2]: ", list1[-2]) print ("list2[1:3]: ", list2[1:3]) print ("list2[2:]: ", list2[2:]) # 更新 list1[2] = '123' print ("[update] list1: ", list1) # 删除 d...
false
0b303dde589390cf6795a2fc79ca473349c5e190
SeanLau/leetcode
/problem_104.py
1,203
4.125
4
#!/usr/bin/env python # -*- coding:utf-8 -*- # 此题可以先序遍历二叉树,找到最长的即可 # Definition for a binary tree node. class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def maxDepth(self, root): """ :type root: TreeNode :r...
true
e3fc26f817596ff52cf7a97933ea0c192c5cef42
dsintsov/python
/labs/lab1/lab1-1_7.py
989
4.125
4
# № 7: В переменную Y ввести номер года. Определить, является ли год високосным. """ wiki: год, номер которого кратен 400, — високосный; остальные годы, номер которых кратен 100, — невисокосные (например, годы 1700, 1800, 1900, 2100, 2200, 2300); остальные годы, номер которых кратен 4, — високосные """ # Checking the ...
false
24ef3ae3700fb03f7376673ee39067c362eee76a
billdonghp/Python
/stringDemo.py
877
4.25
4
''' 字符串操作符 + * 字符串的长度 len 比较字符串大小 字符串截取 [:] [0:] 判断有无子串 in not in 查找子串出现的位置 find() index() 不存在的话报错 encode,decode replace(old,new,count)、count(sub,start,end) isdigit()、startswith split、join '-'.join('我爱你中国') 隔位截取str1[::2] = str1[0:-1:2] start 和end不写时为全部;step=2 如果 step为负数时,倒序截取; ''' str1 = 'hello' a = 'a' b = 'b'...
false
144aadab9b2167c896838ae99747d606b91834a3
skad00sh/algorithms-specialization
/Divide and Conquer, Sorting and Searching, and Randomized Algorithms/0.4 week1 - bubble-sort.py
691
4.21875
4
def bubble_sort(lst): """ ------ Pseudocode Steps ----- begin BubbleSort(list) for all elements of list if list[i] > list[i+1] swap(list[i], list[i+1]) end if end for return list end BubbleSort ------ ...
false
60cff1227d0866a558d88df56dad871a8d189d9e
mac912/python
/calender.py
1,021
4.3125
4
# program to print calender of the month given by month number # Assumptions: Leap year not considered when inputed is for February(2). Month doesn't start with specific day mon = int(input("Enter the month number :")) def calender(): if mon <=7: if mon%2==0 and mon!=2: for j in range(1,31...
false
773d9211d4e6037aff180f87f135d11e0f660d7e
dr2moscow/GeekBrains_Education
/I четверть/Основы языка Python (Вебинар)/lesson-3/hw_3_3.py
696
4.15625
4
''' Задание # 3 Реализовать функцию my_func(), которая принимает три позиционных аргумента, и возвращает сумму наибольших двух аргументов. ''' def f_max_2_from_3(var_1, var_2, var_3): return var_1 + var_2 + var_3 - min(var_1, var_2, var_3) my_vars = [] for count in range(3): try: var = float(input(f...
false
a3c81c5b91daffbd7de1fbe55e2fce7eac26cd80
dr2moscow/GeekBrains_Education
/I четверть/Основы языка Python (Вебинар)/lesson-3/hw_3_4.py
1,434
4.125
4
''' Задание # 3 Реализовать функцию my_func(), которая принимает три позиционных аргумента, и возвращает сумму наибольших двух аргументов. ''' def f_my_power(base, power): base__power = 1 for count in range(power*(-1)): base__power *= base return 1 / base__power try: var_1 = float(input('Вве...
false
ef1ebb2ba1f95a2d8c09f3dc32af9d2ffec17499
CyberTaoFlow/Snowman
/Source/server/web/exceptions.py
402
4.3125
4
class InvalidValueError(Exception): """Exception thrown if an invalid value is encountered. Example: checking if A.type == "type1" || A.type == "type2" A.type is actually "type3" which is not expected => throw this exception. Throw with custom message: InvalidValueError("I did not expect that value!")"...
true
c61d5128252a279d1f6c2b6f054e8ea1ead7b2af
rup3sh/python_expr
/general/trie
2,217
4.28125
4
#!/bin/python3 import json class Trie: def __init__(self): self._root = {} def insertWord(self, string): ''' Inserts word by iterating thru char by char and adding '*" to mark end of word and store complete word there for easy search''' node = self._root for c in string: if c not in node: ...
true
23f20f17dc25cc3771922706260d43751f2584c5
rup3sh/python_expr
/generators/generator
1,446
4.34375
4
#!/bin/python3 import pdb import sys ##Reverses words in a corpus of text. def main(argv): generatorDemo() def list_of_even(n): for i in range(0,n+1): if i%2 == 0: yield i def generatorDemo(): try: x = list_of_even(10) print(type(x)) for i in x: print("EVEN:" + str(i)) the_li...
true
8fe1986f84ccd0f906095b651aa98ba62b2928b8
rup3sh/python_expr
/listsItersEtc/listComp
1,981
4.1875
4
#!/bin/python3 import pdb import sys ##Reverses words in a corpus of text. def main(argv): listComp() def listComp(): the_list = ["stanley", "ave", "fremont", "los angeles", "istanbul", "moscow", "korea"] print(the_list[0:len(the_list)]) #Slicing #the_list[2:] = "paz" #['stanley', 'ave', 'p', 'a', '...
true
3b597cae9208d703e6479525625da55ddc18b976
DahlitzFlorian/python-zero-calculator
/tests/test_tokenize.py
1,196
4.1875
4
from calculator.helper import tokenize def test_tokenize_simple(): """ Tokenize a very simple function and tests if it's done correctly. """ func = "2 * x - 2" solution = ["2", "*", "x", "-", "2"] assert tokenize.tokenize(func) == solution def test_tokenize_complex(): """ Tokenize a...
true
4b7dbbf640d118514fa306ca39a5ee336852aa05
francoischalifour/ju-python-labs
/lab9/exercises.py
1,777
4.25
4
#!/usr/bin/env python3 # coding: utf-8 # Lab 9 - Functional Programming # François Chalifour from functools import reduce def product_between(a=0, b=0): """Returns the product of the integers between these two numbers""" return reduce(lambda a, b: a * b, range(a, b + 1), 1) def sum_of_numbers(numbers): ...
true
ba5bce618d68b7570c397bc50d6f96766b600fd9
francoischalifour/ju-python-labs
/lab4/exercises.py
1,024
4.1875
4
#!/usr/bin/env python3 # coding: utf-8 # Lab 4 - Dictionaries # François Chalifour def sums(numbers): """Returns a dictionary where the key "odd" contains the sum of all the odd integers in the list, the key "even" contains the sum of all the even integers, and the key "all" contains the sum of all integer...
true
a81ce65a4df9304e652af161f5a00534b35cc844
Abuubkar/python
/code_samples/p4_if_with_in.py
1,501
4.25
4
# IF STATEMENT # Python does not require an else block at the end of an if-elif chain. # Unlike C++ or Java cars = ['audi', 'bmw', 'subaru', 'toyota'] if not cars: print('Empty Car List') if cars == []: print('Empty Car List') for car in cars: if car == 'bmw': print(car.upper()) elif cars ==...
true
b583554675d3ec46b424ac0e808a8281a339de67
NandanSatheesh/Daily-Coding-Problems
/Codes/2.py
602
4.21875
4
# This problem was asked by Uber. # # Given an array of integers, # return a new array such that each element at index i of the # new array is the product of all the numbers in the original array # except the one at i. # # For example, # if our input was [1, 2, 3, 4, 5], # the expected output would be [120, 60, 40, 3...
true
e08d5430b054d56ae0ac12b818ad476158cfa51f
susoooo/IFCT06092019C3
/elvis/python/bucle5.py
645
4.125
4
# Escriba un programa que pregunte cuántos números se van a introducir, pida esos números # y escriba cuántos negativos ha introducido. print("NÚMEROS NEGATIVOS") numero = int(input("¿Cuántos valores va a introducir? ")) if numero < 0: print("¡Imposible!") else: contador = 0 for i in range(1, numero + 1...
false
16ec073e55924a91de34557320e539c750f377a3
susoooo/IFCT06092019C3
/jesusp/phyton/Divisor.py
215
4.125
4
print("Introduzca un número") num = int(input()) if(num > 0): for num1 in range(1, num+1): if(num % num1 == 0): print("Divisible por: ", num1) else: print("Distinto de cero o positivo")
false
b2ba8e45c360ae96a08209172ba05811dd3a3b96
susoooo/IFCT06092019C3
/jesusp/phyton/Decimal.py
201
4.15625
4
print("Introduzca un número") num = int(input()) print("Introduzca otro número") num1 = int(input()) while(num > num1): print("Introduzca un numero decimal: ") num1= float(input())
false
19bfe557a5e0d351be9215b2f8ea501587337fda
Chelton-dev/ICTPRG-Python
/except_div_zero.py
242
4.1875
4
num1 = int (input("Enter num1: ")) num2 = int (input("Enter num2: ")) # Problem: # num3 = 0/0 try: result = num1/num2 print(num1,"divided by", num2, "is ", result) except ZeroDivisionError: print("division by zero has occured")
false
371ed66d667edb14d59347994462ddf30dde6a84
Liraz-Benbenishti/Python-Code-I-Wrote
/hangman/hangman/hangman-unit7/hangman-ex7.3.1.py
836
4.25
4
def show_hidden_word(secret_word, old_letters_guessed): """ :param secret_word: represent the hidden word the player need to guess. :param old_letters_guessed: the list that contain the letters the player guessed by now. :type secret_word: string :type old_letters_guessed: list :return: string that comprise...
true
fda16aa729c019888cb2305fcfb00d782e620db6
cnulenka/Coffee-Machine
/models/Beverage.py
1,434
4.34375
4
class Beverage: """ Beverage class represents a beverage, which has a name and is made up of a list of ingredients. self._composition is a python dict with ingredient name as key and ingredient quantity as value """ def __init__(self, beverage_name: str, beverage_composition: dict): ...
true
7762d9a8c0b8ebb97551f2071f9377fe896b686f
itstooloud/boring_stuff
/chapter_3/global_local_scope.py
922
4.1875
4
## ####def spam(): #### global eggs #### eggs = 'spam' #### ####eggs = 'global' ####spam() ####print(eggs) ## ####using the word global inside the def means that when you refer to that variable within ####the function, you are referring to the global variable and can change it. ## ####def spam(): #### global e...
true
46c128c433288c3eed04ecb148693e52828c6975
itstooloud/boring_stuff
/hello_age.py
358
4.15625
4
#if/elif will exit as soon as one condition is met print('Hello! What is your name?') my_name = input() if my_name == "Chris": print('Hello Chris! Youre me!') print('Your age?') my_age = input() my_age = int(my_age) if my_age > 20: print("you're old") elif my_age <= 10: print("you're young") else: pri...
false
f85f89d07de9f394d7f95646c0a490232bc3b7bc
whoismaruf/usermanager
/app.py
2,605
4.15625
4
from scripts.user import User print('\nWelcome to user management CLI application') user_list = {} def create_account(): name = input('\nSay your name: ') while True: email = input('\nEnter email: ') if '@' in email: temp = [i for i in email[email.find('@'):]] if...
true
4da19128caf20616ecbd36b297022b1d3ccb92ce
PraneshASP/LeetCode-Solutions-2
/234 - Palindrome Linked List.py
1,548
4.1875
4
# Solution: The idea is that we can reverse the first half of the LinkedList, and then # compare the first half with the second half to see if it's a palindrome. # Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution...
true
869edf4c975e41ccdee0eacfbda1a636576578fc
jigarshah2811/Python-Programming
/Matrix_Print_Spiral.py
1,741
4.6875
5
""" http://www.geeksforgeeks.org/print-a-given-matrix-in-spiral-form/ Print a given matrix in spiral form Given a 2D array, print it in spiral form. See the following examples. Input: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Output: 1 2 3 4 8 12 16 15 14 13 9 5 6 7 1...
true
4a5fc85b209138408683797ef784cbd59dd978fe
jigarshah2811/Python-Programming
/LL_MergeSort.py
2,556
4.625
5
# Python3 program merge two sorted linked # in third linked list using recursive. # Node class class Node: def __init__(self, data): self.data = data self.next = None # Constructor to initialize the node object class LinkedList: # Function to initialize head def __init__(self): s...
true
f9e0bf6998f5ee9065ca8b27e56baa95907cb486
jigarshah2811/Python-Programming
/Advance-OOP-Threading/OOP/ClassObject.py
1,422
4.53125
5
""" This is valid, self takes up the arg! """ # class Robot: # def introduce(self): # print("My name is {}".format(self.name)) # # r1 = Robot() # r1.name = "Krups" # #r1.namee = "Krups" # Error: Because now self.name wouldn't be defined! # r1.introduce() # # r2 = Robot() # r2.name = "Pasi" # r2.intr...
false
28a8e6ee2b125056cfe0c3056d6e3a92ba5e4a65
sabeeh99/Batch-2
/fathima_ashref.py
289
4.28125
4
# FathimaAshref-2-HelloWorldAnimation import time def animation(word): """this function takes the input and displays it character by character with a delay of 1 second""" for i in word: time.sleep(1) print(i, end="") animation("Hello World")
true
d2f96447565c188fcc5fb24a24254dc68a2f5b60
hanucane/dojo
/Online_Academy/python-intro/datatypes.py
763
4.3125
4
# 4 basic data types # print "hello world" # Strings # print 4 - 3 # Integers # print True, False # Booleans # print 4.2 # Floats # print type("hello world") # Identify data type # print type(1) # print type(True) # print type(4.2) # Variables name = "eric" # print name myFavoriteInt = 8 myBool = True myFloat = 4.2 ...
true
eb392b54023303e56d23b76a464539b70f8ee6e8
shamim-ahmed/udemy-python-masterclass
/section-4/examples/guessinggame6.py
507
4.1875
4
#!/usr/bin/env python import random highest = 10 answer = random.randint(1, highest) is_done = False while not is_done: # obtain user input guess = int(input("Please enter a number between 1 and {}: ".format(highest))) if guess == answer: is_done = True print("Well done! The correct ans...
true
3d1946247a3518c4bd2128786609946be2ae768c
shamim-ahmed/udemy-python-masterclass
/section-4/exercises/exercise11.py
638
4.21875
4
#!/usr/bin/env python3 def print_option_menu(options): print("Please choose your option from the list below:\n") for i, option in enumerate(options): print("{}. {}".format(i, option)) print() if __name__ == "__main__": options = ["Exit", "Learn Python", "Learn Java", "Go swimming", "Have di...
true
bcd6ddba72d2fe2c22112c11f6dbea95fe536d37
shamim-ahmed/udemy-python-masterclass
/section-12/examples/example_kwargs.py
323
4.3125
4
#!/usr/bin/env python def print_keyworded_arguments(arg1, **kwargs): print("arg1 = {}".format(arg1)) for key, value in kwargs.items(): print("{} = {}".format(key, value)) # you can mix keyworded args with non-keyworded args print_keyworded_arguments("Hello", fruit="Apple", number=10, planet="Jupiter...
false
047b6808f400db0906409e22fb7e3897f9bda51a
kirillrssu/pythonintask
/PMIa/2014/Samovarov/task_3_17.py
810
4.1875
4
#Задача №3, Вариант 7 #Напишите программу, которая выводит имя "Симона Руссель", и запрашивает его псевдоним. Программа должна сцеплять две эти строки и выводить полученную строку, разделяя имя и псевдоним с помощью тире. #Samovarov K. #25.05.2016 print("Герой нашей сегодняшней программы - Симона Руссель") ps...
false