blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
5f3742149ccb7d2f09cf2233de28e7339cd30777
16030IT028/Daily_coding_challenge
/InterviewBit/005_powerOfTwoIntegers.py
662
4.15625
4
# https://www.interviewbit.com/problems/power-of-two-integers/ """Given a positive integer which fits in a 32 bit signed integer, find if it can be expressed as A^P where P > 1 and A > 0. A and P both should be integers. Example Input : 4 Output : True as 2^2 = 4. """ import math def isPower(n): if n == 1: ...
true
a3f07f91380d0e530fb44c94b28f84855efba2f0
16030IT028/Daily_coding_challenge
/Algoexpert-Solutions in Python/Group by Category/Recursion/001_powerset.py
1,210
4.4375
4
# https://www.algoexpert.io/questions/Powerset """ ​ Powerset ​ Write a function that takes in an array of unique integers and returns its powerset. The powerset P(X) of a set X is the set of all subsets of X. For example, the powerset of [1,2] is [[], [1], [2], [1,2]]. Note that the sets in the powerset do not need ...
true
302f512a87c8f0dbd29c36cd9326e1ba73ab95e4
JacobJustice/Sneer
/sneer
2,956
4.21875
4
#! /usr/bin/python3 import sys import getopt # # sneer_default # # parameters: # word -word in the input string that the character you are considering to # upper or lower is from # index-index of the character you are considering to upper or lower # # return: # boolean (capitalize this character or not) # # paramet...
true
d9180832982a0a6edae7e16eacedb63e2a31f643
s-ankur/cipher-gui
/vigenere.py
1,111
4.21875
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- """ The Vigenère cipher is a method of encrypting alphabetic text by using a series of interwoven Caesar ciphers, based on the letters of a keyword. It is a form of polyalphabetic substitution. """ import random from itertools import cycle from collections import Counter impor...
true
66ce3651849839bafd55e0d1fe26eac975fb6ab5
s-ankur/cipher-gui
/caesar.py
2,164
4.21875
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- """ Caesar shift, is one of the simplest and most widely known encryption techniques. It is a type of substitution cipher in which each letter in the plaintext is replaced by a letter some fixed number of positions down the alphabet. For example, with a left shift of 3, D woul...
true
a50d97b6cea7967ac59ac5654f7cc23c4c5ff17d
mehedi-hasan-shuvon/python-ML-learing
/6.py
226
4.125
4
#........if else statements......... number =int (input ("enter your marked: ")) print(number) if number>=90 and number<=100: grade='A' elif number>=80: grade='B' else: grade='fail' print("the grade is" ,grade)
true
9c610e215d10acf6066a03c14a1d7afbc09a3903
beardedsamwise/AutomateTheBoringStuff
/Chapter 7 - Regexes/practiceQuestions.py
1,227
4.34375
4
import re # Question 21 # Write a regex that matches the full name of someone whose last name is Watanabe. # You can assume that the first name that comes before it will always be one word that begins with a capital letter. watanabeRegex = re.compile(r'([A-Z])(\w)+(\s)Watanabe$') print(watanabeRegex.search('haruto ...
true
26436225c9a4d34240e231b93ddf065ec78cdd0c
beardedsamwise/AutomateTheBoringStuff
/Chapter 7 - Regexes/passwordComplexity.py
1,387
4.4375
4
# Write a function that uses regular expressions to make sure the password string it is passed is strong. # A strong password is defined as one that is at least eight characters long, contains both uppercase and lowercase characters, and has at least one digit. import re def passStrength(password): capsRegex = re...
true
896f9f9eb299255024397cf01780615bfbb5e232
iamstmvasan/python_programs
/BinaryGap.py
953
4.1875
4
#BinaryGap #Find longest sequence of zeros in binary representation of an integer. ''' given a positive integer N, returns the length of its longest binary gap. The function should return 0 if N doesn't contain a binary gap. For example, given N = 1041 the function should return 5, because N has binary representation ...
true
8ca9ccbcc5fd6f66be9a640eb69332ced45ee797
Dfmaaa/transferfile
/Python31/factorial_finder.py
277
4.4375
4
print("This app will find the factorial of the number given by you.") def factorial(n): if n == 0: return 1 else: return n * factorial(n-1) n=int(input("Input a number to compute the factiorial : ")) print(factorial(n)) import factorial_finder
true
42c189f912652267b1bcfb2638774364f9ecfb11
foldsters/learn-git
/example.py
1,537
4.25
4
# # Decription: This program will analize the upper and lower case content of # a given string. # sampleString = ("We the People of the United States, in Order+ to form a more perfect Union," " establish Justice, insure domestic Tranquility, provide for the common defence, promote the general Welfare," " and secure ...
true
3ed20ff3deb2c1950cdbbf5e474f2d7b8003db5d
HoussemCharf/FunUtils
/Searching Algorithms/binary_search.py
775
4.125
4
# # Binary search works for a sorted array. # Note: The code logic is written for an array sorted in # increasing order. # T(n): O(log n) # def binary_search(array, query): lo, hi = 0, len(array) - 1 while lo <= hi: mid = (hi + lo) // 2 val = array[mid] if val == query: ...
true
fc78ce3ac616d51d2f5e8d7d862316e7d73c835c
zNIKK/Exercicios-Python
/Python_1/Conversor de bases numéricas.py
479
4.21875
4
num=int(input('digite um número inteiro: ')) print('escolha as bases de conversão:\n' '[ 1 ] converter para BINÁRIO\n' '[ 2 ] converter para OCTAL\n' '[ 3 ] converter para HEXADECIMAL') op=int(input('Escolha:')) if op==1: print('{} convertido para BINÁRIO: {}'.format(num,bin(num)[2:])) elif op=...
false
5cd6988aca1ca186b582e812a4c19bc40021d1d3
CruzJeff/CS3612017
/Python/Exercise3.py
1,448
4.4375
4
# -*- coding: utf-8 -*- """ Created on Mon Nov 27 13:44:36 2017 @author: User """ '''Very often, one wants to "Cast" variables of a certain type into another type. Suppose we have variable x = '123', but really we would like x to be an integer. This is easy to do in python, just use desiredtype(x) e.g. int(...
true
17223ef9ccbbfb48804dcbdcc8e544293f5c8c20
wsegard/python-bootcamp-udemy
/python-bootcamp/01-Nbers.py
612
4.28125
4
# Addition print(2+1) # Subtraction 2-1 # Multiplication 2*2 # Division 3/2 # Floor Division 7//4 # Modulo 7%4 # Powers 2**3 # Can also do roots this way 4**0.5 # Order of Operations followed in Python 2 + 10 * 10 + 3 # Can use parentheses to specify orders (2+10) * (10+3) # Let's create an object called "a" and assign...
true
205f7076b1b29a348c317117854b9b87751f6bb8
zaid-kamil/DP-21-PYTHON-DS-1230
/functions_in_python/param_fun1.py
777
4.25
4
# parameterized functions take input when you call them # there are 5 ways to call a parameterized function # 1. with required parameters ✔ # 2. with keyword/named parameters ✔ # 3. with default parameters ✔ # 4. with variable arguments ✔ # 5. with keyword arguments ✔ ###################################################...
true
9d7f39be8a14a8010e7cc3652024793e8ba65a9c
zumerani/Python
/Classes and Objects/inheritance.py
1,815
4.125
4
class Student: def __init__(self , name , school): self.name = name self.school = school self.marks = [] def average(self): return sum(self.marks) / len(self.marks) @classmethod def friend(cls , origin , friendName , salary): #return a new Student called 'friend...
true
47ecc6a3d81dbbf26acf7b3be532a12dda74c9f1
huayuhui123/prac05
/emails.py
464
4.1875
4
email=input("Email:") dict={} while email!=" ": nameread=email.split("@")[0].title() namecheck=' '.join(nameread.split(".")) choice=input("Is your name {}?(Y/n)".format(namecheck)) if choice.upper()=='Y': dict[email]=namecheck elif (choice.upper()=='N')or (choice=='no'): name=input("Na...
false
8e467824df7bbab58d2f56478b1311cfe79a5bc7
HalynaMaslak/Python_for_Linguists_module_Solutions
/Frequency_Brown_corpus.py
1,121
4.375
4
# -*- coding: utf-8 -*- """ Create a program that: Asks for a word; Checks whether it is more frequent as a Noun or a Verb in the Brown corpus. Display a message if it does not appear as a noun or a verb in the Brown corpus. """ from nltk.corpus import brown print('The program checks whether the entered word is more fr...
true
3e1a7e19c27eda447d07c27f8ee641f5c384f4bf
mnaiwrit52/git-practice
/fibonacci.py
693
4.28125
4
#This code helps in generating fibonacci numbers upto a certain range given as user input # f1 = 0 # f2 = 1 # n = int(input("Enter the range: ")) # print(f1,f2,end=' ') # for count in range(2,n): # f3 = f1 + f2 # print(f3,end=' ') # f1 = f2 # f2 = f3 def fibo_series(num): f1 = 0 f2 = 1 co...
true
3d8a796eb5dd1b4faae9d891632b68aadcc7f8b9
longLiveData/Practice
/python/20190404-Astar/Robotplanner.py
2,310
4.1875
4
import sys # 这里的输入文件每行结尾可能是\n也可能是\r 都要考虑到 # 输出格式python3和python2不一样 注意 格式转换 def getPath(arr, path, spath, cx, cy): arr[cx][cy] = '1' # if get to target position, print if(cx == endx and cy == endy): print (str(len(path)) + " " + str(len(spath))) res = "" for i in spath: ...
false
d429b8cdd4993081ced30d6e7d663a737d4adc54
claeusdev/Python-basics
/chapter 4/ques3.4.py
562
4.15625
4
temp = float(input('enter a temperature in Celsius:')) if temp < -273.15: print ('The temperature is invalid because it is below absolute zero') if temp == -273.15: print('the temperature is absolute 0') if -273.15 < temp < 0: print('the temperature below is freezing') if temp == 0: print('the t...
true
9102c4017af6a031a917b1d164448e8938654ad6
claeusdev/Python-basics
/chapter 4/ques4.4.py
267
4.1875
4
credit = int(input('how many credits have you taken:')) if credit <= 23: print('you are a freshman') if 24 <= credit <=53: print('you are a sophomore') if 54 <= credit <= 83: print('you are a junior') if credit >= 84: print('you are a senior')
false
39510b515c5c1bc0feb29b00bb5196a26809f907
MrWillian/BinarySearch
/binarySearch.py
615
4.125
4
# Returns index of x in array if present def binarySearch(array, l, r, x): # check base case if r >= l: middle = l + (r - l)//2 #Get the middle index # If element is present at the middle returns itself if array[middle] == x: return middle # If element is smaller than middle, then it can o...
true
85e9677dbff83dc06c7e2ad5142548e5ca5cf9a3
enzostefani507/python-info
/Funciones/Complementarios/Complementario15.py
725
4.15625
4
def verificarContraseña(pwd): return len(pwd)>=8 and verificarMinimoMayuscula(pwd) and verificarMinimoMinuscula(pwd) and verificarMinimoNumeros(pwd) def verificarMinimoMayuscula(pwd): for i in pwd: if i.isupper(): return True return False def verificarMinimoMinuscula(pwd): ...
false
46d784518804906896a865dbc781984d421e96fe
enzostefani507/python-info
/Listas/1/g.py
319
4.1875
4
#Cargar dos listas con la misma cantidad de elementos. Luego mezclarlas, cargándolas ordenadas en otra lista. lista_1 = list(range(0,5,2)) lista_2 = list(range(2,10,3)) mezcla = lista_1.copy() mezcla.extend(lista_2) mezcla.sort() print(f'Lista 1: {lista_1}') print(f'Lista 2: {lista_2}') print(f'Mezcla: {mezcla}')
false
e7e77532f52f3bf96455b8ee99396458e880cb9b
enzostefani507/python-info
/Funciones/Complementarios/Complementario4.py
945
4.15625
4
"""Ejercicio 4: Mediana de tres valores Escriba una función que tome tres números como parámetros y devuelva el valor medio de esos parámetros como resultado. Incluya un programa principal que lea tres valores del usuario y muestre su mediana. Sugerencia: El valor medio es el medio de los tres valores cuando se ord...
false
d53787419a05c209820d093634c65bb611dad43b
cristinarivera/python
/88 mayusculas minusculas.py
576
4.28125
4
#Programa que nos dice si una letra es mayuscula o minuscula. letra= raw_input('Dame un caracter: ') if letra>='a': if letra=='a' or (letra=='e' or (letra=='i' or (letra=='o' or letra=='u'))): print 'Es vocal minuscula' else: if letra<='z': print 'Es minuscula' if l...
false
60267fcab54ee1e742c9310db31443c53eb56df5
cristinarivera/python
/184 números binarios bis.py
325
4.125
4
bits=raw_input('Dame un numero binario: ') for bit in bits: valor=0 if bit!='1' or bit!='0': print 'Numero binario mal formado' bits=raw_input('Dame un numero binario: ') if bit=='1' or bit=='0': valor+=valor+int(bit) print 'Su valor decimal es' , valor ...
false
35e6b2d8cddef27fff93d9ae51fb0b6cf30e4185
ivansangines/Deep-Learning
/Assignment1_Sangines/PythonExamples/PythonExamples/First.py
1,262
4.1875
4
from math import pi import sys def computeAvg(a,b,c) : return (a + b + c)/3.0; def doComplexMath() : num1 = 3 + 4j num2 = 6 + 3.5j res = num1 * num2 return res; def mapTest(mylist) : ys = map(lambda x: x * 2, mylist) #ys is a map object, so we need to convert it to a list result = [] for elem in ys: res...
false
cd23ce139de38af256c594434e90b9e65a6ec98d
eloyekunle/python_snippets
/others/last_even_number.py
587
4.25
4
# An algorithm that takes as input a list of n integers and finds the location of the last even integer in the # list or returns 0 if there are no even integers in the list. def last_even_number(numbers): index = None for i in range(len(numbers)): if numbers[i] % 2 == 0: index = (numbers[i...
true
ad17e4a130882a927f4c2fe2f02aa4a29bf03682
eloyekunle/python_snippets
/search/ternary_search.py
1,130
4.375
4
# The ternary search algorithm locates an element in a list # of increasing integers by successively splitting the list into # three sublists of equal (or as close to equal as possible) # size, and restricting the search to the appropriate piece. def ternary_search(key, numbers): i = 0 j = len(numbers) - 1 ...
true
cf85ebff256f4345d2bd59332acf4cfe21b30a81
wagnersistemalima/Algoritimos-importantes-Python
/pacote dawload/Projetos de algoritimo em Python/Algoritimo para descobrir o fatorial Função.py
501
4.21875
4
# 3. # Considere o fatorial de um número n como a multiplicação dos números de 1 a n. # Assim, para n = 5, o fatorial de 5 é 5 * 4 * 3 * 2 * 1 = 120. # Implemente uma função chamada fatorial(n) usando For. Ela recebe um valor n retorna o seu fatorial. def fatorial(n): calculo = 1 for c in range(n, 0, -1): ...
false
5c8922df6c04bdc6d16903a96e8efee04537443a
Mona6046/python
/practicepython/Fibonacci.py
418
4.125
4
#Fibonacci #length of Fibonacci series length=input("Enter the length of Fibonacci series") series=[] def nextFibonacci(lastNumber,secondLastNumber): return lastNumber+secondLastNumber lastNumber=1 secondLastNumber=0 count=0 while(count<int(length)): series.append(lastNumber) temp=nextFibonacci(lastNumber...
true
51c7cdf895daf7909396c98145de469e35e384a4
Mona6046/python
/practicepython/Palindrome.py
425
4.53125
5
#Ask the user for a string and print out whether this string is a palindrome or not def isPalandrome(string): #reverse String reverseString=string[::-1] if(string==reverseString): return True return False #ask for input string inputString=input("Enter the string :") flag=isPalandrome(inputSt...
true
fefaf855f502ac0318244a948d76faa02acb5469
black-star32/cookbook
/2/2.2.2.py
2,030
4.15625
4
# 检查字符串开头或结尾的一个简单方法是使用 str.startswith() # 或者是 str.endswith() 方法。 filename = 'spam.txt' print(filename.endswith('.txt')) print(filename.startswith('file:')) url = 'http://www.python.org' print(url.startswith('http:')) # 检查字符串开头或结尾的一个简单方法是使用 str.startswith() # 或者是 str.endswith() 方法。 import os filenames = os.listdir('....
false
bab6b20b217df90aa53245a9188ac8744ba69082
learndevops19/pythonTraining-CalsoftInc
/training_assignments/Day_05/ExceptionHandling/Day05_Excp_Assignment3.py
955
4.21875
4
''' 3. Complete the below program to run successfully: a. Write user defined exception class for User_defined_exception1, User_defined_exception2 b. Handle the user defined exception writing #appropriate message to user # we need to guess this alphabet till we get it right ''' alphabet = 'k' class SmallerAlphabetE...
true
16a1aeb6af9b419aee184b8d7ea1d38db887d964
learndevops19/pythonTraining-CalsoftInc
/training_assignments/Day_01/Bhairavi_Alurkar/data_types_8.py
342
4.15625
4
#!/usr/bin/python """ Python program to add the 10 to all the values of a dictionary. """ def add_10_to_each_value(): sample_input = {1: 10, 2: 20, 3: 30, 4: 40, 5: 50} for each in sample_input: sample_input[each] += 10 return sample_input if __name__ == "__main__": res = add_10_to_each_val...
true
f9c58f1338d19540bcff6478b4e52eb5b1d56734
learndevops19/pythonTraining-CalsoftInc
/Day_04/Sample_Codes/sample_generator_expression.py
205
4.3125
4
# Initialize the list my_list = [1, 3] # List comprehension lst = [x ** 2 for x in my_list] print(lst) # Generator Expression gen = (x ** 2 for x in my_list) print(gen) print(next(gen)) print(next(gen))
true
2e2491a162c69e4682738bc5a915b5f8adf7d3be
learndevops19/pythonTraining-CalsoftInc
/training_assignments/Day_03/circle.py
402
4.25
4
import math from math import pi class Circle: def __init__(self, radius): self.radius = radius def area(self): return (pi * math.pow(self.radius,2)) if __name__ == "__main__": print("Enter the radius of circle: ",end = " ") radius = int(input("Enter radius of circle: ")) ci...
true
4c4b7384a09a591938f114853701218ce801fa44
learndevops19/pythonTraining-CalsoftInc
/Day_03/sample_class_and_object.py
1,679
4.8125
5
#!/usr/bin/env python """ Program shows how Class and Object are work in Python """ class Employee: """ Class Employee with employee name and pay details """ # Constructor def __init__(self, first, last, pay): """ Initialize method :param first: Employee first name ...
true
33cb5b2cf89af347803c101abededa4c8e1bfc9d
learndevops19/pythonTraining-CalsoftInc
/training_assignments/Day_01/Bhairavi_Alurkar/data_types_10.py
375
4.3125
4
#!/usr/bin/python """ Python program to print second largest number """ def find_second_largest_number(): sample_input = [-8] new_list = list(set(sample_input)) if len(new_list) >= 2: new_list.sort() return new_list[-2] else: return new_list[0] if __name__ == "__main__": ...
true
24ac2c73db874648bfe0d9098e2cacaf32545876
learndevops19/pythonTraining-CalsoftInc
/training_assignments/Day_03/ClassAbstarctOperation.py
1,148
4.375
4
from abc import ABC, abstractmethod class AbstractOperation(ABC): def __init__(self,operand1, operand2): self.op1 = operand1 self.op2 = operand2 @abstractmethod def operation(self): return None class Addition(AbstractOperation): def __init__(self,op1,op2): super()...
false
7f3d40b3e6db391218e051b870cd2213612912fb
learndevops19/pythonTraining-CalsoftInc
/Day_01/sample_flow_control.py
1,287
4.125
4
# Flow Control example # if, elif else example x = "one" if x == "one": print("one is selected") elif x == "two": print("two is selected") else: print("Something else is selected") # if -- else: if x == "one": print("one is selected") else: print("Something else is selected") for i in in ran...
true
2886a20c5d07a53e536f94750c7aee68f24ea8f2
learndevops19/pythonTraining-CalsoftInc
/Day_07/sample_asyncio_doesnot_reduce_cpu_time.py
801
4.28125
4
""" Module to understand time performance impact using asyncio for CPU extensive operations """ import asyncio import time COUNT = 50000000 # 50 M async def countdown(counter): """ function decrements counter by one each time, until counter becomes zero Args: counter (int): counter value ...
true
bd8e6a35ac8394229a5cfc596d2bda9be673ca1a
learndevops19/pythonTraining-CalsoftInc
/training_assignments/Day_01/Nitesh_Mahajan/assignment_1.py
1,149
4.59375
5
#!usr/bin/env python """ This program generates factorial or fibonacci series based on user inputs """ def find_factorial(): """ This function takes a number from user and generates it factorial Args: Returns: """ num = int(input("Enter number to find factorial:")) factorial = num ...
true
7a93506cd68520d63eb4106ea3a107965772aed5
learndevops19/pythonTraining-CalsoftInc
/training_assignments/Day_03/solution_01.py
260
4.21875
4
import math class Circle: def area_of_circle(radius): return (math.pi*(math.pow(radius,2))) if __name__ == '__main__': radius = int(input('Enter the radius of circle')) print('area of circle is {}'.format(Circle.area_of_circle(radius)))
true
9a859b29234323955e4c023cd9384819ccee01eb
learndevops19/pythonTraining-CalsoftInc
/Day_01/sample_list_operations.py
1,132
4.40625
4
"""List operations""" fruits = ["orange", "apple", "pear", "banana", "apple"] print("value of list: ", fruits) fruits.append("grape") # append element at end fruits.insert(0, "kiwi") # insert element at 0th index print("fruits after fruits.append('grape') & fruits.insert(0, 'kiwi'): ", fruits) fruits.extend(["orange"...
true
b97b17a502db05b99a82e2ddd612083cac4a06cb
learndevops19/pythonTraining-CalsoftInc
/training_assignments/Day_02/Nitesh_Mahajan/assignment_1.py
547
4.34375
4
def func(*args, a=[]): a.append(args) print(id(a)) print(a) func(1, 2, 3) """A new list 'a' is created with default value [] and all the arguments packed in a tuple because of *args will get append in the list""" func(7, 8, 9, a=[]) """As we are passing a list again, it will create a new list 'a' again ...
true
2a2ffe2a607939a4a05daf20808a2477145182d9
learndevops19/pythonTraining-CalsoftInc
/training_assignments/Day_03/ques4.py
1,016
4.1875
4
from abc import ABC, abstractmethod class AbstractOperation(ABC): def __init__(self, o1, o2): self.o1 = o1 self.o2 = o2 def operation(self): pass class Add(AbstractOperation): def __init__(self, o1, o2): super().__init__(o1, o2) def operation(self): return se...
false
ad17413c509743100ac3695ae4999576ecc30f76
learndevops19/pythonTraining-CalsoftInc
/training_assignments/Day_01/kshipra_namjoshi/select_operation.py
1,243
4.40625
4
""" Module to choose function and perform operation for the specified user input. """ import math def generate_factorial(num): """ Calculates factorial of a number. Args: num: Number whose factorial is to be calculated. """ print(f"Factorial of {num} is {math.factorial(num)}.") def fib...
true
7f1663fd43a3b34d9f6159bcd27bc1cda6eadc9c
andy90009/pythonLearn
/lesson01/sorted.py
1,026
4.40625
4
# sorted() # 排序算法 # 排序也是在程序中经常用到的算法。无论使用冒泡排序还是快速排序,排序的核心是比较两个元素的大小。 # 如果是数字,我们可以直接比较,但如果是字符串或者两个dict呢?直接比较数学上的大小是没有意义的, # 因此,比较的过程必须通过函数抽象出来 # sorted()函数就可以对list进行排序 print (sorted([36, 5, -12, 9, -21])) # sorted()函数也是一个高阶函数,它还可以接收一个key函数来实现自定义的排序,例如按绝对值大小排序 # key指定的函数将作用于list的每一个元素上,并根据key函数返回的结果进行排序 print (sorted(...
false
36a86e3737d5a7d868c2a77b3e512a6599e7c317
rachelli12/Module8
/more_fun_with_collections/dictionary_update.py
1,648
4.4375
4
""" Program: name: dictionary_update.py Author: Rachel Li Last date modified: 06/27/2020 The purpose of this program is to calculate average scores using dictionary """ def get_test_scores(): ''' use reST style :param scores_dict: this represents the dictionary :param num_score: this represents the nu...
true
d9c38a318ee421daa289ec14b5bfa05554830f2c
shcqupc/Alg_study
/AIE23/20191102_feature_engineering/a0_python/basic_syntax/4_List.py
630
4.21875
4
#Insert a element listT1=['a','b','c','d','e','f'] list = [] dic = {"name":"harry"} #json listT1.append('g') # at the end of the list print("1st") print(listT1) listT1=['a','b','c','d','e','f'] listT1.insert(0,'0') # at the particular position print("2nd") print(listT1) #Clear the position listT1=['a','b','c','d','...
false
0498fe45d30127d7e290df70e7a582d675855ea3
shreeyamaharjan/Assignment
/Functions/QN17.py
257
4.15625
4
result = (lambda c: print("The string starts with given character") if c.startswith(ch) else print( "The string doesnot start with given character")) ch = input("Enter any character : ") string = str(input("Enter any string : ")) print(result(string))
true
83dc56455d5a17ad6f8918f411a1216a94368709
YutoNakanishi/python_text
/bmi.py
443
4.1875
4
#BMI判定プログラム wight = float(input("体重(kg)は?")) height = float(input("身長(cm)は?")) #BMIの計算 height = height / 100 bmi = wight / (height * height) #BMIの値に応じて結果を分岐 result = "" if bmi < 18.5: result = "ヤセ型" #if(18.5 <= bmi) and (bmi < 25): if(18.5 <= bmi < 25): result = "標準" if 25 <= bmi: result = "でぶ" #結果を表示 pri...
false
6f55859a819e8f17a5a61ee9f93373b7857d6044
benben123/algorithm
/myAlgorithm/py/TwoPointer/isPalindrome.py
1,080
4.25
4
""" Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. Note: For the purpose of this problem, we define empty string as valid palindrome. Example 1: Input: "A man, a plan, a canal: Panama" Output: true Example 2: Input: "race a car" Output: false """ class...
true
f517ae85c0fd7014784ddda976194f084d8b4166
runmeat6/ETF-Comparator
/_0_read_data.py
1,052
4.1875
4
""" This file has the function to read in the data Key to naming conventions: camelCase global (and imported) variables and function parameters CamelCase class names snake_case variables not intended to be used globally and function names """ import csv def load_data_with_csv(fileName, delimiterChara...
true
49efdb4c3b918568218cee3ded8c594e4ff13e20
rush1007/Python-Assignment
/task3.py
2,638
4.1875
4
# 1. Create a list of 10 elements of four different data types like int, string, complex and float. lst = [1, "Hello", 3.2, 2+3j, "Consultadd", 4, 5.5, 4+9j, "Training", 20] print(lst) # 2. Create a list of size 5 and execute the slicing structure lst = [1, 2, 3, 4, 5] sli = lst[2:4] print(sli) # 3. Write a progra...
true
e6e420e5ff0d52c33140ed5122e5b6aceaa7c85c
HorseSF/xf_Python
/day13/code/11-子类重写父类方法.py
1,048
4.125
4
# 继承的特点:如果一个类A继承自类B,有类A创建出来的实例对象都能直接使用类B里定义的方法 class Person(object): def __init__(self, name, age): self.name = name self.age = age def sleep(self): print(self.name + '正在睡觉') class Student(Person): def __init__(self, name, age, school): # self.name = name # self....
false
37455f6ae7a52bbc82600ca4f920c315d51050f6
AbhishekJunnarkar/AWS_Configuration_Eval_using_Lambda_boto3
/pythonbasics/07_Control-statements_ifelse-elif_while_continue_break.py
879
4.15625
4
x = 10 y = 20 if x > y: print('x is greater then y') else: print('y is greater then x') # ------IF elif example -------# ''' If marks are >=60, first class if marks are <60 and >=50, second class if marks are <50 and >=35, third class if marks <35, failed ''' marks = 34 if marks >= 60: print("first class"...
true
a4524689f10677f3be217bcb9af0fc07816b28d7
Gabospa/30DaysOfCode
/day25.py
891
4.25
4
""" A prime is a natural number greater than 1 that has no positive divisors other than 1 and itself. Given a number, n , determine and print whether it's Prime or Not prime. Note: If possible, try to come up with a O(n**0.5) primality algorithm, or see what sort of optimizations you come up with for an O(n) algori...
true
9b0b9d5e3bc8b81fe0f7f21c87c4d730833d2038
Gabospa/30DaysOfCode
/day14.py
977
4.125
4
""" Complete the Difference class by writing the following: - A class constructor that takes an array of integers as a parameter and saves it to the elements instance variable. - A computeDifference method that finds the maximum absolute difference between any numbers in and stores it in the instance variable. """...
true
4692f2b7be7783a84b8e0d360ef670095b56909d
venkor/Python3Learning
/ex14.py
980
4.28125
4
#Imports the sys module (library) from sys import argv #requires 2 arguments to run script, user_name, nickname = argv #Our new prompt looks like this now, it's a string variable with two ">" and a space prompt = '>> ' #Some little chit-chat with the user - using formatting to input the variables given when running scr...
true
d189a891c35afa86029c686d28a7dc5b418a8401
venkor/Python3Learning
/ex37_Old_Style_String_Formats.py
1,360
4.25
4
print(""" OLD STYLE STRING FORMATS: --------------------------------- Escape: Description: Example: % d Decimal integers (not floating point). "%d" % 45 == '45' % i Same as %d. "%i" % 45 == '45' % o Octal number. ...
false
2b336be9bcf0c54898aa3c08669770fd875ef347
rahdirs11/CodeForces
/python/capitalize.py
223
4.125
4
# this is basically to perform capitalize operation where # you have to make just the first letter upper-case word = input().lstrip() try: print(word if word[0].isupper() else word[0].upper() + word[1: ]) except: pass
true
b408bdfea6160eb710eaf8cf126ecd7bea3848ad
lastduxson/Early-Python-Code
/test.py
244
4.15625
4
# Code for Assignment01 # print("Please enter your name as instructed below") first = input("What is your first name? ") last = input("What is your last name? ") print("Thank you ",first,last) input("Press ENTER to end this interview")
true
2665ed95928f883516190c7668d9dd21e3cefc3f
aman003malhotra/FlaskTwitterClone
/shopping_cart.py
254
4.125
4
num_of_items = int(input("Enter How many items did you buy?")) sum = 0 for i in range(1, num_of_items): amount = int(input("What is the amount of the {} item".format(str(i)))) sum += amount print("The total price of all the items is {}$".format(sum))
true
31d92732ea298e8cf28b9ab55cb9000055787fe0
TriniBora/ISFDyT166
/ProgramaciónOrientadaObjetos/RepasoPython/Funciones/Ejercicio1.py
1,131
4.125
4
'''Escribir una función que calcule el área de un círculo y otra que calcule el volumen de un cilindro usando la primera función.''' import math def calcular_area(radio): '''La función calcular_area recibe un valor numérico y devuelve el área del circulo cuyo radio es dicho valor numérico.''' return math.pi *...
false
1befe27d199a33e015e531e222d190cf48f43495
VolkRiot/LP3THW-Lessons
/lists.py
564
4.125
4
the_count = [1, 2, 3, 4, 5] fruits = ['apples', 'oranges', 'pears', 'apricots'] change = [1, 'pennies', 2, 'dimes', 3, 'quarters'] # simple for loop for number in the_count: print(f'This is count {number}') for fruit in fruits: print(f'The fruit is {fruit}') for i in change: print(f'The change value is ...
true
30ea9900d10c5e7228ef84b2f79604e5397b6086
jordanstarrk/DataStructures
/src/nodes.py
1,371
4.53125
5
# ----------------------------------------------------------- # Python3 implementation of a Node class with 3 methods. # This Node Class is used to implement more complex data # structures in the same directory, such as LinkedLists, # Stacks, Queues. # # ----------------------------------------------------------- cl...
true
704fe4dd3c0f54de4d68eaa077244bd3b07768b2
raijelisaumailagir0383/03_RPS
/01_get_userchoice_v2.py
635
4.375
4
# checks user enters rock / paper / scissors def rps_checker(): valid = False while not valid: # asks user to choose and puts their answer into lowercase response = input("Choose: ").lower() # checks user response and either returns it or asks question again if response == "r" ...
true
b47f8b7cef93dca5331f9b7fd19a857e8b389a12
mactheknight/Lab9
/Lab9-Finished.py
2,623
4.4375
4
############################################ # # # 70pt # # # ############################################ # Create a celcius to fahrenheit calculator. # Multiply by 9, then divide by 5, then add 32 t...
true
6934de03a1eda1c24790fde1071c2d90a5c8031e
roxana-hgh/change_number-base
/change_number-base.py
2,807
4.375
4
# convert postive decimal numbers to other base 2-10 # Author: Roxana Haghgoo # get base from user run = True while run: base = input(">>> Please enter the 'base' you want to convert to: ") try: base = int(base) if base >= 0 and base < 11: run = False else: ...
true
bb60c95442d8b734feb4159c2158b6cea9e03a1a
Moura93/CursoPython
/desafio3.py
637
4.1875
4
''' AUTOR: Felipe Moura Wanderley 3º desafio: RECEBER PESO, ALTURA E SEXO DE 3 PESSOAS CALCULAR O IMC E APRESENTAR NA TELA OS RESULTADOS IMC CLASSIFICAÇÃO <18,5 Magreza 18,5~24,9 Saudável 25,0~29,9 Sobrepeso 30,0~34,9 Obesidade grau 1 35,0~39,9 Obesidade grau 2 >40 Obesidade grau 3 ''' usuario =[] for x ...
false
5968f45a98d8284a6b98302579923deb3ab1425a
IngMosri/221-3_40129_DeSoOrOb
/proyecto final/search_book_menu.py
1,853
4.125
4
#!/usr/bin/python3 class Search_book: def search_book_menu(): correcto=False num=0 while(not correcto): try: num = int(input("choose the following option : ")) correcto=True except ValueError: print('Error, choose a vali...
true
f2a1f7f59785a573b6c891b8f75fd0f26bbaaa6c
alankrit03/Problem_Solving
/Jump_Search.py
1,018
4.125
4
# Python3 code to implement Jump Search import math def jumpSearch(arr, x, n): # Finding block size to be jumped step = int(math.sqrt(n)) # Finding the block where element is # present (if it is present) prev = 0 while arr[int(min(step, n) - 1)] < x: prev = step step += int(ma...
true
3a03ca36e458c2ec30ef34dcffab9c5da947feaa
rpural/DailyCodingProblem
/Daily Coding Problem/spiral.py
1,174
4.4375
4
#! /usr/bin/env python3 ''' Daily Coding Problem This problem was asked by Amazon. Given a N by M matrix of numbers, print out the matrix in a clockwise spiral. For example, given the following matrix: [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]] ...
true
eca6cc3641b8600347a1ae99eafba92851ec3348
rpural/DailyCodingProblem
/Daily Coding Problem/romanDecode.py
1,098
4.125
4
#! /usr/bin/env python3 ''' Daily Coding Problem This problem was asked by Facebook. Given a number in Roman numeral format, convert it to decimal. The values of Roman numerals are as follows: { 'M': 1000, 'D': 500, 'C': 100, 'L': 50, 'X': 10, 'V': 5, 'I': 1 } In addition, note that the...
true
1c0baa9eb202fa02110201b4c4783ab139dcdba7
rpural/DailyCodingProblem
/armstrong.py
621
4.375
4
#! /usr/bin/env python3 ''' An Armstrong number is one where the sum of the cubes of the digits add up to the number itself. Example 371 = 3**3 + 7**3 + 1**3. ''' def isArmstrong(value): svalue = str(value) digits = len(svalue) sum = 0 for i in svalue: sum += int(i) ** digits if sum ==...
true
d6924fa0196457a90bb8d5d63ac6c7d0b54d53e8
rpural/DailyCodingProblem
/Daily Coding Problem/palindromeInt.py
687
4.3125
4
#! /usr/bin/env python3 ''' Daily Coding Problem This problem was asked by Palantir. Write a program that checks whether an integer is a palindrome. For example, 121 is a palindrome, as well as 888. 678 is not a palindrome. Do not convert the integer into a string. ''' def reverseNum(num): result = 0 whil...
true
cea9ced7ae3899e22d61ade2f72a5c4b41cc339e
rpural/DailyCodingProblem
/multLab0.py
480
4.3125
4
#! /usr/bin/env python3 # Create a multiplication table for a given value, with a specified number # of elements. # Input the two variables base = 5 count = 10 # The input will be text (strings), so convert the values to integers base = int(base) count = int(count) # print a title for the table print("\n\nMultiplic...
true
8444ccbe55092a6fde4645df4b237eebd4211d98
rpural/DailyCodingProblem
/Daily Coding Problem/maxpath.py
1,142
4.15625
4
#! /usr/bin/env python3 ''' Daily Coding Problem This problem was asked by Google. You are given an array of arrays of integers, where each array corresponds to a row in a triangle of numbers. For example, [[1], [2, 3], [1, 5, 1]] represents the triangle: 1 2 3 1 5 1 We define a path in...
true
fd0b869540d974a50c65192bf2cbf67f6497c446
Endlex-net/KeepLearning-Py
/fluent_python/data_moudle/analog_vector.py
1,508
4.375
4
""" 这个demo中模拟了一个二维的变量 """ from math import hypot class Vector: def __init__(self, x=0, y=0): self.x = x self.y = y # def __str__(self): # """ # str只会在print() 和 str()中被调用 # """ # return "111" def __repr__(self): """ repry用在命令行的字符串标示上(应该以无歧义的...
false
523a2bc773dbf194591fb318503722ba465dd626
rakeshrana80/PyProject
/guessnumber.py
1,027
4.3125
4
#!/usr/bin/env python #Generate a random number between 1 and 9 (including 1 and 9). #Ask the user to guess the number, then tell them whether #they guessed too low, too high, or exactly right. import random,sys def main(): rand_number = random.randint(1,9) count = 0 choice = "yes" while choice.low...
true
45327fefb0e6ef0da43049eea53e24f431472ec0
pruebas-lau/ejemplospython
/prueba_uno.py
1,306
4.21875
4
nombre = "Oli" edad =17 #print(f"Hola {nombre} tirnes {edad} ") #nombre = input("Tu nombre: ") #Comentario #if edad>18: # print("Mayor de edad") #else: # print('eres una ninia') # ---CICLO FOR --- ''' variable=5 for i in [0,1,3,9]: print(variable, "x", i, "=", variable*i) print() print("Fin") ''' # ---LISTAS-...
false
8690b3af2aae3f4c2e237eee03ef94b6f46d5461
stanCode-Turing-demo/projects
/stanCode_Projects/weather_master/weather_master.py
2,088
4.40625
4
""" File: weather_master.py ----------------------- This program should implement a console program that asks weather data from user to compute the average, highest, lowest, cold days among the inputs. Output format should match what is shown in the sample run in the Assignment 2 Handout. """ EXIT = -100 def main():...
true
99091fe6b2729b61ecd90908e6549999302dd722
stanCode-Turing-demo/projects
/stanCode_Projects/boggle_game_solver/largest_digit.py
1,496
4.5625
5
""" File: largest_digit.py Name: Josephine ---------------------------------- This file recursively prints the biggest digit in 5 different integers, 12345, 281, 6, -111, -9453 If your implementation is correct, you should see 5, 8, 6, 1, 9 on Console. """ largest_dig = 0 def main(): """ This program recursively f...
true
ba696d1df208c62aa461fde8dfff3c50a7a6bbe3
nkuang123/MIT6001x
/Lesson 3/guess my number.py
907
4.21875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Dec 17 21:20:11 2017 @author: normankuang @title: Lesson 3 / Exercise: guess my number """ highBound = 100 lowBound = 0 guess = int((highBound + lowBound) / 2) print("Please think of a number between 0 and 100!") while True: guess = int((highBoun...
true
dbf8016beb130087b016bbdf0640f5fd657745b5
MitsurugiMeiya/Leetcoding
/leetcode/Array/Interval/56. 区间合并.py
1,539
4.25
4
""" 融合interval Example 1: Input: [[1,3],[2,6],[8,10],[15,18]] Output: [[1,6],[8,10],[15,18]] Explanation: Since intervals [1,3] and [2,6] overlaps, merge them into [1,6]. 注意,这题的intervals给的是没有排序过的 """ class Solution(object): def merge(self, intervals): """ :type intervals: List[List[int]] :rt...
false
4c98342d2c2274393d56ed7ace2157588e8a32a8
debojyoti-majumder/CompCoding
/2019/2019Q1/mlsnippets/linkedList.py
2,444
4.1875
4
# Simple Linked list implmentation to understand python class Node: def __init__(self, data = None): self.data = data self.next = None def setNext(self, nextNode): self.next = nextNode def getData(self): return self.data def getNext(self): return self.next ...
true
b3e6b79b57203ba1d3c78a632a2360f1f2ca3e48
zeeshan-emumba/GoogleCodingInterviewQuestions
/contiguousProduct.py
681
4.125
4
""" Contract: Given an integer array nums, find the contiguous subarray within an array (containing at least one number) which has the largest product. input = [2, 3, -2, 4] output = [6] input = [-2, 0, -1] output = 0 """ input = [2, 3, -2, 4] input1 = [-2, 0, -1] def contiguousProduct(input): largestProduct = 0...
true
1a3e3d6a385727f25aaba6872a750da2ff0d458d
yuanswife/LeetCode
/src/String/最长无重复字符子串_003_longest-substring-without-repeating-characters_medium.py
2,792
4.15625
4
# 给定一个字符串str,返回str的最长无重复字符子串的长度。 # 举例: # str="abcd",返回4. # str="abcb",最长无重复字符子串为"abc",返回3. # Given a string, find the length of the longest substring without repeating characters. # Example: # Given "abcabcbb", the answer is "abc", which the length is 3. # Given "bbbbb", the answer is "b", with the length of 1. # Giv...
false
1c30dbbf12cd68578b6a7536acad2c130dd95f2a
jaimienakayama/wolfpack_pod_repo
/eva_benton/snippets_challenge.py
2,086
4.5
4
print("Challenge 3.1: Debug code snippets") #Debug each snippet in order print() print("Code Snippet 1:") u = 5 v = 2 if u * v == 10: print(f"The product of u ({u}) and v ({v}) is 10") else: print(f"The product of u ({u}) and v ({v}) is not 10") # This equation requires the "==" comparison operator, "=" is ...
true
cbd6aec64bc11eb03d3f8f5ee88dc69331223071
Gabruuuu/Quadratic-Equation-Calculator
/Quadratic Formula.py
615
4.25
4
print("Quadratics calculator ") print("Created by Gabriel Palomero") print("Please enter A, B, and C from the standard quadratic equation") first_number = int ( input ( " Enter 'A' : ")) second_number = int ( input ( " Enter 'B' : ")) third_number = int ( input ( " Enter 'C' : ")) import math quadratic_formula =...
false
7e29c21d780749e600ee8e4b7c43ad58f0601c0d
qtccz/data-python
/algorithm/heapSort.py
2,383
4.28125
4
#!/usr/bin/python # -*- coding:utf-8 -*- """ 6、堆排序 堆排序(Heapsort)是指利用堆积树(堆)这种数据结构所设计的一种排序算法, 它是选择排序的一种。可以利用数组的特点快速定位指定索引的元素。 堆分为大根堆和小根堆,是完全二叉树。 大根堆的要求是每个节点的值都不大于其父节点的值,即A[PARENT[i]] >= A[i]。 在数组的非降序排序中,需要使用的就是大根堆,因为根据大根堆的要求可知,最大的值一定在堆顶。 参看引用: https://www.jianshu.com/p/d174f1862601 """ # 指定列表下标元素交换位置并返回交换位置后列表 def ...
false
283f488dbc72166d00576a9cf6d5ad0c4824d65a
smartDataDev/testing
/class_example.py
654
4.15625
4
# class example class MyClass: number = 0 name = 'noname' age = 'under 40' def Main(): me = MyClass() me.number = 55 me.name = 'Martin' me.age = 40 friend = MyClass() friend.number = 10 friend.name = 'Susan' friend.age = 25 default = MyClass() print('My name is ...
false
5fa92196a4b441bdd1a3e67c269ae94e06ce26b5
Libardo1/Monty-Hall-Problem
/monty_hall.py
1,442
4.1875
4
# Setup the Monty Hall problem to run simulations. """ NEEDS: 3 random values, 2 = goat, 1 = car place values into array """ import random import numpy as np def monty_hall(): GOAT = 0 CAR = 1 solution1 = 0 solution2 = 0 for x in range(10): doors = np.array([0,0,0]) car_locat...
true
ac490579f4cdd5b12bd6e6736b18e8af3bc6c9a7
mpsb/practice
/codewars/python/cw-iq-test.py
1,275
4.5
4
''' Bob is preparing to pass IQ test. The most frequent task in this test is to find out which one of the given numbers differs from the others. Bob observed that one number usually differs from the others in evenness. Help Bob — to check his answers, he needs a program that among the given numbers finds one that is di...
true
c3d1d8bbb3de9ade1c28f0e4758df3097656bf6b
devmfe/Fundamental-Python-Tutorial
/SidHW/gradientcalc.py
766
4.3125
4
m = 0 print("WELCOME TO SID'S GRADIENT CALCULATOR!") print("--------------------------------------------------") c = float(input("What is the constant term of the line? (c)\n")) print("--------------------------------------------------") x = float(input("Ok, now what is the x-value? (x)\n")) print("----------...
true