blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
33103fb8b53fb56435e21c014a1fea4cc3d648a3
rettka30/CUS1166_rettka30_Lab1
/playground.py
1,748
4.28125
4
print("Basic program: ") print("\nHello Word") # Display a message # Get user input and display a message. myname = input("What is your name: ") print("Hello " + str(myname)) # Alternative way to format a string print("Hello %s" % myname) print("Done Practicing The Basic Program") print("\nVariables: ") i = 120 print(...
true
e24baf2bc6e4c75cabb9a650694c77a06cb409cf
nestorcolt/smartninja-july-2020
/project/lesson_004/lesson_004.py
2,086
4.65625
5
# List and dictionaries - data structures ############################################################################################## """ Resources: https://www.w3schools.com/python/python_ref_list.asp """ # Primitives data types some_num = 4 # integer (whole number) some_decimal = 3.14 # float (de...
true
224ad99452a12881e5e51bafe17d37a74b003602
Henrysyh2000/Assignment2
/question1_merge.py
1,125
4.34375
4
def merge(I1, I2): """ takes two iterable objects and merges them alternately required runtime: O(len(I1) + len(I2)). :param I1: Iterable -- the first iterable object. Can be a string, tuple, etc :param I2: Iterable -- the second iterable object. Can be a string, tuple, etc :return: List -- ...
true
6702c7ad5f3b4b1f11f09bb0e402f835909d7c53
KoryHunter37/code-mastery
/python/leetcode/playground/built-in-functions/bin/bin.py
758
4.375
4
# bin(x) # Convert an integer number to a binary string prefixed with "0b". # The result is a valid Python expression. # This method is reversed by using int() if the "0b" has been removed. # Alternatives include format() and f-string, which do not contain "0b". # > 0b1010 # The binary representation of 10, with 0b i...
true
cd0a7956774aec6af702ed12f3aa0cee380a121a
bss233/CS126-SI-Practice
/Week 3/Monday.py
2,002
4.25
4
#Converts a number less than or equal to 10, to a roman numeral #NOTE: You normally shouldn't manipulate your input, ie how I subtract from num, # but it saves some extra checking. There is most certainly a cleaner way to do # this function def romanNumeral(num): #define an empty string to add characters to res...
true
ca8ce04997f9d6fde7c2d45e0532bcf5e030693c
nishants17/Python3
/dictionaries.py
498
4.15625
4
friend_ages = {"Nish" : 10 , "Adam" : 10} print(friend_ages["Nish"]) friend_ages["Nish"] = 30 print(friend_ages["Nish"]) #Dictionaries have order kept in python 3.7 but cannot have duplicate keys friends = ({"name" : "Rolf SMith", "age" : 24}, {"name" : "John", "age": 33}) print(friends[0]["name"]) #...
true
15f5ca39b9bcab582fc777e42d4b38b997c82bb0
unixtech/python
/150_py/2_Area_box.py
308
4.5
4
# Enter the width & Length of a box. # The program should compute the area. Enter values as floating point numbers # Enter the units of measurement used. width = float(input("Enter the width: ")) length = float(input("Enter the length: ")) area = width*length print('Area is:\t', area, 'Centimeters')
true
1d3f7b5029c39a9389268e180900869a38459ead
adamabarrow/Python
/comparisonOperators/comparisonOutline.py
1,297
4.3125
4
''' This outline will help solidify concepts from the Comparison Operators lesson. Fill in this outline as the instructor goes through the lesson. ''' #1) Make two string variables. Compare them using the == operator and store #that comparison in a new variable. Then print the variable. a = "hi" b = "hello" c = (a ==...
true
19c7fb4bb5b612ef584ea7faab4eb1117d08783c
oguzhanun/10_PythonProjects
/challange/repdigit.py
553
4.4375
4
# A repdigit is a positive number composed out of the same digit. # Create a function that takes an integer and returns whether it's a repdigit or not. # Examples # is_repdigit(66) ➞ True # is_repdigit(0) ➞ True # is_repdigit(-11) ➞ False # Notes # The number 0 should return True (even though it's not a positive number...
true
93eaade2a4ba280220cc021ff2837b6534d5ee17
oguzhanun/10_PythonProjects
/challange/descending_order.py
584
4.15625
4
# Your task is to make a function that can take any non-negative integer as a argument and return it with its digits in descending order. Essentially, rearrange the digits to create the highest possible number. # Examples: # Input: 21445 Output: 54421 # Input: 145263 Output: 654321 # Input: 123456789 Output: 9876543...
true
89df322925cb3bd2cdad24105a4350b963f12c4a
fatemizuki/good-good-study-day-day-up
/python基础/basic/1-2.py
1,990
4.5
4
# 1-2.06 交互式编程 # 在pycharm里底下的python console点下可以开启交互式编程 # 直接在底下输代码就行,比如输3-5 # pycharm关项目:close project # 1-2.07 注释 # #号表示单行注释 ''' 三个单引号/双引号中间是多行注释 快捷键:command + / ''' print('hello world') # 按住command点print会跳出来这个函数的用法和注释 # 1-2.09 数据类型 ''' 数字类型: int 整型 float 浮点型 complex 复数 字符串类型: 要求使用一对单引号或双引号包裹 布尔类型: 只有两个值:True ...
false
d6af6d9581328120bc0a9130650caba6bb9ea818
Ferihann/Encrypted-Chat
/rsa.py
1,843
4.15625
4
# This class make encryption using RSA algorithm import random large_prime = [] # Is array for storing the prime numbers then select into it randomly class Rsa: def generate_prime(self, lower, upper): # this function simply generate prime numbers for num in range(lower, upper+1): if num >...
true
9cda8a2020ac38f5074f0be75666e825ca842856
skygarlics/GOF_designpattern
/builder.py
1,263
4.1875
4
import abc """ Example of string builder """ class Director: """ construct object using Builder interface """ def __init__(self): self._builder = None def construct(self, builder): self._builder = builder self._builder._build_part_a() self._builder._build_part_b(...
false
721e7a53934cff06f6b2dedca6224105f625e56e
marb61a/Course-Notes
/Artificial Intellingence/Python/Notebooks/PyImageSearch University/OpenCV 102/simple_thresholding.py
2,216
4.3125
4
# USAGE # python simple_thresholding.py --image images/coins01.png # The accompanying text tutorial is available at # https://www.pyimagesearch.com/2021/04/28/opencv-thresholding-cv2-threshold/ # Thresholding is a basic image segmentation technique # The goal is to segment an image into foreground and background pixel...
true
21c4e3dc082242c5efe4e4ee022ab830b01c6488
markk628/SortingAlgorithms
/IntegerSortingAlgorithm/bucket_sort.py
2,911
4.25
4
import time def merge(items1, items2): merged_list = [] left = 0 right = 0 while left < len(items1) and right < len(items2): if items1[left] < items2[right]: merged_list.append(items1[left]) left += 1 else: merged_list.append(items2[right]) ...
true
596bbb9f084a59722466deb904cd5b534541af20
EnusNata/conhecendo-linguagens
/python/exercicios/8.6.py
607
4.28125
4
#8.6 – Nomes de cidade: Escreva uma função chamada city_country() que #aceite o nome de uma cidade e seu país. A função deve devolver uma string #formatada assim: "Santiago, Chile" #Chame sua função com pelo menos três pares cidade-país e apresente o valor #devolvido. def city_country( cidade , país ): city_countr...
false
d47b7f3bc91e948d4295a99a506a66739aa6efe6
EnusNata/conhecendo-linguagens
/python/exercicios/4.1.py
1,002
4.5
4
#4.1 – Pizzas: Pense em pelo menos três tipos de pizzas favoritas. Armazene os #nomes dessas pizzas e, então, utilize um laço for para exibir o nome de cada #pizza. #• Modifique seu laço for para mostrar uma frase usando o nome da pizza em #vez de exibir apenas o nome dela. Para cada pizza, você deve ter uma linha #na ...
false
9b934134b5ceaf533479a7f92d34c95f36b26af8
EnusNata/conhecendo-linguagens
/python/exercicios/3.6.py
924
4.125
4
#3.6 – Mais convidados: Você acabou de encontrar uma mesa de jantar maior, #portanto agora tem mais espaço disponível. Pense em mais três convidados #para o jantar. #• Comece com seu programa do Exercício 3.4 ou do Exercício 3.5. Acrescente #uma instrução print no final de seu programa informando às pessoas que #você e...
false
c8eb5bbc98196f3fe7341e70136d98977822c81e
EnusNata/conhecendo-linguagens
/python/exercicios/4.8.py
385
4.25
4
#4.8 – Cubos: Um número elevado à terceira potência é chamado de cubo. Por #exemplo, o cubo de 2 é escrito como 2**3 em Python. Crie uma lista dos dez #primeiros cubos (isto é, o cubo de cada inteiro de 1 a 10), e utilize um laço for #para exibir o valor de cada cubo. cubos = [] for numero in range(1,11): cubos.a...
false
a52ed5c8d11c47a6f40b0d1981f6901d611af66b
priya8936/Codewayy_Python_Series
/Python-task-2/Dictionary.py
705
4.125
4
#Students detail student_detail = { "Name" : "Priya Aggarwal", "College" : "DIT University", "year" : "3rd" } print(student_detail) #Using key() function print(student_detail.keys()) #using get() function stu = student_detail.get("college") print("\nModel of the car :-",stu) #using va...
false
7de66659c2cfe58e23c57090703c6a788eb1eb1c
Klauss-Preising/Weekly-Challenges
/Fall - 2018/Week 4/Week 4.py
712
4.21875
4
""" Make a function that takes a list and returns the list sorted using selection sor The selection sort algorithm sorts an array by repeatedly finding the minimum element (considering ascending order) from unsorted part and putting it at the beginning. The algorithm maintains two subarrays in a given array. """ def ...
true
bbba0d4cfc89e9f65a1fcc9eaaa6a836c197daf5
fares-ds/Algorithms_and_data_structures
/00_algorithms_classes/merge_sort_iterative.py
1,328
4.125
4
def merge_sort(lst): sorted_lst = [None] * len(lst) size = 1 while size <= len(lst) - 1: sort_pass(lst, sorted_lst, size, len(lst)) print(sorted_lst) size = size * 2 def sort_pass(lst, sorted_lst, size, length): low_1 = 0 while low_1 + size <= length - 1: up_1 = low...
false
1c1aa1f96da08dbd95ed078b87e8e4bfc3a05a9d
fares-ds/Algorithms_and_data_structures
/04_recursion/reverse_string.py
207
4.125
4
def reverse_string(string): # Basic Case if len(string) <= 1: return string # Recursion function return reverse_string(string[1:]) + string[0] print(reverse_string('Hello world'))
false
661a13971faf750ec454dc6ce878c7bbf4bb1f92
NatalyaDomnina/leetcode
/python/05. [31.08.17] Merge Two Binary Trees.py
2,032
4.15625
4
''' Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not. You need to merge them into a new binary tree. The merge rule is that if two nodes overlap, then sum node values up as the new value of the merged node. Otherw...
true
42ae6ae0d309950914bdbc6350a180c24a1a5d92
fancy0815/Hello-Hello
/Python/5_Functions/1_Map and Lambda Function.Py
436
4.21875
4
cube = lambda x: x**3 # complete the lambda function def fibonacci(n): # return a list of fibonacci numbers if n==1: return [0] if n==0: return [] fib = [0,1] for i in range (2,n): fib += [sum(fib[i-2:i])] return fib # return fib[0:n] # return[sum(fib[i-2:i]) fo...
true
fe6bb27b70808ee72441d9aba87040d52d09b6a1
skybohannon/python
/w3resource/basic/4.py
378
4.59375
5
# 4. Write a Python program which accepts the radius of a circle from the user and compute the area. # The area of circle is pi times the square of its radius. # Sample Output : # r = 1.1 # Area = 3.8013271108436504 from math import pi radius = float(input("Please enter the radius of your circle: ")) area = pi * (rad...
true
334fb0bde5f0c2fddee9b27d104aa54a233f45d8
skybohannon/python
/w3resource/string/11.py
323
4.15625
4
# 11. Write a Python program to remove the characters which have odd index values of a given string. def remove_odds(str): new_str = "" for i in range(len(str)): if i % 2 == 0: new_str = new_str + str[i] return new_str print(remove_odds("The quick brown fox jumped over the lazy dog"...
true
6612b6f86f022b90b5e41f4aff4586aacf41e1ce
skybohannon/python
/w3resource/25.py
333
4.25
4
# 25. Write a Python program to check whether a specified value is contained in a group of values. # Test Data : # 3 -> [1, 5, 8, 3] : True # -1 -> [1, 5, 8, 3] : False def in_values(i, lst): if i in lst: return True else: return False print(in_values(3, [1, 5, 8, 3])) print(in_values(-1, [1...
true
d31125e3528c4ce3fbde12349bacfcc20d4fd5d9
skybohannon/python
/w3resource/string/32.py
256
4.125
4
# 32. Write a Python program to print the following floating numbers with no decimal places. x = 3.1415926 y = -12.9999 print("Original number: {}\nFormatted number: {:.0f}".format(x, x)) print("Original number: {}\nFormatted number: {:.0f}".format(y, y))
true
e6ad416dcbc20283cd2ed283872f6362118c1efc
skybohannon/python
/w3resource/string/26.py
461
4.34375
4
# 26. Write a Python program to display formatted text (width=50) as output. import textwrap text_block = "Python is a widely used high-level, general-purpose, interpreted, dynamic programming language. " \ "Its design philosophy emphasizes code readability, and its syntax allows programmers to express c...
true
6e63b95872bcfa0c0c2e5d81568a398c146cd393
skybohannon/python
/w3resource/string/38.py
366
4.25
4
# 38. Write a Python program to count occurrences of a substring in a string. str1 = "FYI man, alright. You could sit at home, and do like absolutely nothing, and your name goes through like 17 computers a day. 1984? Yeah right, man. That's a typo. Orwell is here now. He's livin' large. We have no names, man. No names...
true
c6a50a2cc4250618428fe74a9b35b215db56f07f
skybohannon/python
/w3resource/string/7.py
540
4.15625
4
# 7. Write a Python program to find the first appearance of the substring 'not' and 'poor' from a given string, # if 'bad' follows the 'poor', replace the whole 'not'...'poor' substring with 'good'. Return the resulting string. # Sample String : 'The lyrics is not that poor!' # Expected Result : 'The lyrics is good!' ...
true
e00cb16e158ea45b54c71ddfb6d8f2ece9db06b0
Dragnes/Automate-the-Boring-Stuff-with-Python
/Lesson 15 pg 89-92.py
1,211
4.375
4
#Lesson 15 pages 89-92 'Method is similar to function, except it is "called on" a value.' # Finding a Value in a List with the index() Method spam = ['hello', 'hi', 'howdy', 'heyas'] spam.index('hello') spam.index('heyas') # Adding Values to a List using append() and insert() Methods spam = ['cat', 'dog', ...
true
09afad6687e6dffbda763514f059c9c44b35f69a
byugandhara1/assessment
/polygon.py
432
4.21875
4
''' Program 1 : Check if the given point lies inside or outside a polygon? ''' from shapely.geometry import Point, Polygon def check_point_position(polygon_coords, point_coords): polygon = Polygon(polygon_coords) point = Point(point_coords) print(point.within(polygon)) polygon_coords = input('Enter polygon coord...
true
bf66df0a04e52ab210db84b47f24a3e575dfe0c4
Yozi47/Data-Structure-and-Algorithms-Class
/Homework 5/C 5.26.py
1,070
4.1875
4
B = [1, 2, 3, 3, 3, 3, 3, 4, 5] # considering B as an array of size n >= 6 containing integer from 1 to n-5 get_num = 0 for i in range(len(B)): # looping the number of elements check = 0 for j in range(len(B)): # looping the number of elements if B[i] == B[j]: # checking for common number ...
true
a464d3a8d375f0356655cc11f0ffa99763725055
jeysonrgxd/python
/nociones_basicas/programacion_funciones/arg_param_indeterminados.py
586
4.25
4
# Las colecciones listas conjuntos estos datos se envian por referencia y no una copia como los demas tipos, por ende si utilizamos una colleccion dentro de una funcion y la modificamos cambiara tambien en la afuera la funcion osea la global def doblar_valores(numeros): for i,n in enumerate(numeros): numeros[...
false
82a7eed51ebb8c98f1c1a027e62479f621b5d274
jeysonrgxd/python
/nociones_basicas/controladores_flugo/sentencia_For.py
1,613
4.25
4
# METODO CON EL WHILE DE IMPRIMIR UNA LISTA numeros = [1,2,3,4,5,6,7,8,9,10] # indice = 0 # while indice < len(numeros): # print(numeros[indice]) # indice +=1 # FORMA DE FOR tradicional print("\nFORMA DEL FOR") # for numero in numeros: # print(numero) # modificar elementos del array tenemos que agregarle un...
false
2b2765e7e51b754bdc6f580789c525dec86766a7
Shivanisarikonda/assgn1
/newfile.py
294
4.1875
4
import string def pangram(string): alphabet="abcdefghijklmnopqrstuvwxyz" for char in alphabet: if char not in string: return False return True string="five boxing wizards jump quickly" if(pangram(string)==True): print("given string is pangram") else: print("string is not a pangram")
true
9ae7ed690d2b3c60271b9ae0eb094e77bfde4797
heloise-steam/My-Python-Projects
/Turtle Time Trials
1,384
4.15625
4
#!/bin/python3 from turtle import* from random import randint print('Pick a turtle either green yellow blue red and chose a stage that the turtle you picked will get up. To make sure you bet with each other') print('Ok now let the time trials begin') speed(10) penup() goto(-140, 140) for step in range(15): write(s...
true
adc2e276f9795092034d9cb1942446a30c6a3755
eric-elem/prime-generator
/primegenerator.py
1,411
4.15625
4
import math import numbers import decimal def get_prime_numbers(n): # check if input is a number if isinstance(n,numbers.Number): # check if input is positive if n>0: # check if input is decimal if isinstance(n, decimal.Decimal): return 'Undefined' ...
true
2e6f198de36b43c6455ee8c11e425729d37cd8db
mjcastro1984/LearnPythonTheHardWay-Exercises
/Ex3.py
714
4.34375
4
print "I will now count my chickens:" # the following lines count the number of chickens print "Hens", 25.0 + 30.0 / 6.0 print "Roosters", 100.0 - 25.0 * 3.0 % 4.0 print "Now I will count the eggs:" # this line counts the number of eggs print 3.0 + 2.0 + 1.0 - 5.0 + 4.0 % 2.0 - 1.0 / 4.0 + 6.0 print "Is it true tha...
true
252ba707cb39ef0c0f3100c1586a94d34060ddd0
hmtareque/play-with-python
/numbers.py
1,975
4.1875
4
""" Number data types store numeric values. Number objects are created when you assign a value to them. """ num = 1076 print(num) """ Python supports four different numerical types: - int (signed integers) They are often called just integers or ints. They are positive or negative whole num...
true
9785f3ad0bbf239885768d4a4c046ad81c6c8930
holmanapril/01_lucky_unicorn
/01_test.py
2,028
4.25
4
#name = input("Hello, what is your name?") #fruit = input("Pick a fruit") #food = input("What is your favourite food?") #animal = input("Pick an animal") #animal_name = input("Give it a name") #print("Hi {} guess what? {} the {} is eating some {} and your {}".format(name, animal_name, animal, fruit, food)) #Setting s...
true
20891f3bcb76fb0be3f6de35ec847d39cae21f3f
ed18s007/DSA
/04_Trees/01_binary_tree.py
1,075
4.125
4
class Node(object): def __init__(self, value = None): self.value = value self.left = None self.right = None def get_value(self): return self.value def set_value(self, value): self.value = value def has_left_child(self): return self.left is not None def has_right_child(self): return self.right is ...
false
c8ad2e40362bfd97d43283cc79327facf385dd5c
yarmash/projecteuler
/python/p019.py
750
4.3125
4
#!/usr/bin/env python3 """Problem 19: Counting Sundays""" def is_leap_year(year): """Determine whether a year is a leap year""" return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0) def main(): numdays = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31) year, month, wday = 1901, 0, 2 # Tue...
false
c82a9e44ac4a78a843bb598c1cba56f8c6ffd773
lahwahleh/python-jupyter
/Errors and Exception Handling/Unit Testing/cap.py
259
4.15625
4
""" A script to captilize texts """ def cap_text(text): """ function takes text and capitalizes it """ # words = text.split() # for word in words: # print(word.capitalize()) return text.title() cap_text("hello world today")
true
a1582e358de014f841f145a9f473e6e62d89eb8e
ErenTaskin/Celsius-to-fahrenheit-conversation
/Celcius to fahrenheit.py
479
4.15625
4
def c_to_f(): print('Celcius to fahrenheit or fahrenheit to celcius?(c to f or f to c)') x = input() if x == 'c to f': print('How much celcius?') c = float(input()) f = float(c * 9/5 + 32) print('%s celcius is %s fahrenheit.'% (c, f)) elif x == 'f to c': print('How much fahrenheit?') f1 =...
false
6aa6cd6587b61ef3a44554f215d9b64fee69a2c3
Motiwala22/python-calculator
/calculator.py
653
4.1875
4
print("1: Addition") print("2: Subtraction") print("3: Multiplication") print("4: Division") choice = input("Enter your chocie here : ") num1 = int(float(input("Input Value: "))) num2 = int(float(input("Input Value "))) if choice == "1": print( num1, "+", num2, "=", (num1+num2)) elif choice == "2": print( ...
false
83727ced73caf7c95dfbbf9cc1a2087099123377
vikasmunshi/euler
/projecteuler/041_pandigital_prime.py
1,083
4.15625
4
#!/usr/bin/env python3.8 # -*- coding: utf-8 -*- """ https://projecteuler.net/problem=41 We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once. For example, 2143 is a 4-digit pandigital and is also prime. What is the largest n-digit pandigital prime that exists? Answer...
true
e25cf5ed10c5692653bfca95afe045a347f34219
Surbhi-Golwalkar/Python-programming
/programs.py/p4.py
348
4.25
4
# '''The int() function converts the specified value into an integer number. # We are using the same int() method to convert the given input. # int() accepts two arguments, number and base. # Base is optional and the default value is 10. # In the following program we are converting to base 17''' num = str(input("ENTER...
true
a3b1f0ccf64324a1a493c96b651fa127a64760da
Surbhi-Golwalkar/Python-programming
/loop/prime.py
280
4.1875
4
num = int(input("enter number:")) prime = True for i in range(2,num): if(num%i == 0): prime = False break if (num==0 or num==1): print("This is not a prime number") elif prime: print("This number is Prime") else: print("This number is not prime")
true
a318db450ffc3dc94bc00b0a413446a7e5e4723b
Surbhi-Golwalkar/Python-programming
/programs.py/washing-machine.py
1,547
4.5625
5
# A Washing Machine works on the principle of a Fuzzy system, # the weight of clothes put inside it for wash is uncertain. # But based on weight measured by sensors, it decides time and water # levels which can be changed by menus given on the machine control # area. For low Water level, time estimate is 25 minut...
true
773ce4110c657204df88c1653f277c8790b9e2af
CalebCov/Caleb-Repository-CIS2348
/Homework1/2.19.py
1,410
4.1875
4
#Caleb Covington lemon_juice_cups = float(input('Enter amount of lemon juice (in cups):\n')) water_in_cups = float(input('Enter amount of water (in cups):\n')) agave_in_cups = float(input('Enter amount of agave nectar (in cups):\n')) servings = float(input('How many servings does this make?\n')) print('\nLemonade ing...
true
04ed8d95e2d03a0b9c1aedbcaa1dcbd4a9121a21
PEGGY-CAO/ai_python
/exam1/question3.py
526
4.1875
4
# Given the following array: # array([[ 1, 2, 3, 4, 5], # [ 6, 7, 8, 9, 10], # [11, 12, 13, 14, 15]]) # write statements to perform the following tasks: # # a. Select the second row. # # b. Select the first and third rows. # # c. Select the middle three columns. import numpy as np array = np.array...
true
890ed31dfd858591a2850c17bf516d05eed46cf2
PEGGY-CAO/ai_python
/wk2/calCoins.py
607
4.21875
4
# This program is used to ask the user to enter a number of quarters, dimes, nickels and pennies # Then outputs the monetary value def askFor(coinUnit): coinCounts = int(input("How many " + coinUnit + " do you have?")) if coinUnit == "quarters": return 25 * coinCounts elif coinUnit == "dimes": ...
true
8f4d286e3c9cbdd2736972bbea43113805060cc0
manu-s-s/Challenges
/challenge2.py
412
4.15625
4
# Given a non-empty string s, you may delete at most one character. Judge whether you can make it a palindrome. # The string will only contain lowercase characters a-z import sys text=input('enter text: ') if text==text[::-1]: print('palindrome') sys.exit(0) for i in range(len(text)): k=text[0:i]+text[i+1:]...
true
d921eab7839c522018051a8ae3fb5d95d47fdbfa
Darkbladecr/ClinDev-algorithms
/06 queue/queue.py
1,206
4.15625
4
"""Queue implementation. A queue is an abstract data type that serves as a collection of elements, with two principal operations: enqueue, which adds an element to the collection, and dequeue, which removes the earliest added element. The order in which elements are dequeued is `First In First Out` aka. `FIFO`. The te...
true
f374e213211ff8a50aa6f9b0880ef0da146efe1f
MariaNazari/Introduction-to-Python-Class
/cs131ahw5Final.py
555
4.78125
5
""" The purpose of this program is to print out its own command line arguments in reverse order from last to first. Directions: enter file name following by inputs Example: filename.py Input1 Input2 ... Input n """ import sys # Get argument list: args = list(sys.argv) #Remove file name args.pop(...
true
2fe67867fe4bcd18aeda6179b6b1992873cda22a
polina-pavlova/epam_python_feb21
/homework7/tasks/hw1.py
819
4.15625
4
""" Given a dictionary (tree), that can contains multiple nested structures. Write a function, that takes element and finds the number of occurrences of this element in the tree. Tree can only contains basic structures like: str, list, tuple, dict, set, int, bool """ from typing import Any def find_occurrences(t...
true
920506e62c69aa9c45b6a658b351bf904623fd9f
jurayev/algorithms-datastructures-udacity
/project2/trees/path_from_root_to_node.py
757
4.15625
4
def path_from_root_to_node(root, data): """ :param: root - root of binary tree :param: data - value (representing a node) TODO: complete this method and return a list containing values of each node in the path from root to the data node """ def return_path(node): # 2 if not node: ...
true
926627cd357722cf552dadc7b0986c2420671b14
jurayev/algorithms-datastructures-udacity
/project2/recursion/palindrome.py
384
4.25
4
def is_palindrome(input): """ Return True if input is palindrome, False otherwise. Args: input(str): input to be checked if it is palindrome """ if len(input) < 2: return True first_char = input[0] last_char = input[-1] return first_char == last_char and is_palindrome(inp...
true
ab0129a56445630cccee1c997ed5994217d4ed17
jurayev/algorithms-datastructures-udacity
/project2/recursion/return_codes.py
1,400
4.3125
4
def get_alphabet(number): """ Helper function to figure out alphabet of a particular number Remember: * ASCII for lower case 'a' = 97 * chr(num) returns ASCII character for a number e.g. chr(65) ==> 'A' """ return chr(number + 96) def all_codes(number): # 23 """ :param: nu...
true
77b666b096790694700a2d2e725015d9c2b1fc2c
jurayev/algorithms-datastructures-udacity
/project2/recursion/key_combinations.py
1,827
4.15625
4
""" Keypad Combinations A keypad on a cellphone has alphabets for all numbers between 2 and 9. You can make different combinations of alphabets by pressing the numbers. For example, if you press 23, the following combinations are possible: ad, ae, af, bd, be, bf, cd, ce, cf Note that because 2 is pressed before 3, ...
true
bf3f684516a9a2cb16697ea3d129e6754a2d3af7
jurayev/algorithms-datastructures-udacity
/project2/recursion/staircase.py
1,310
4.28125
4
""" Problem Statement Suppose there is a staircase that you can climb in either 1 step, 2 steps, or 3 steps. In how many possible ways can you climb the staircase if the staircase has n steps? Write a recursive function to solve the problem-2. """ def staircase(n): """ :param: n - number of steps in the stairc...
true
7c6e3af24a972f2a23dc50669bc589e47e325cd5
rtduffy827/github-upload
/python_tutorial_the_basics/example_10_sets.py
1,466
4.5625
5
example = set() print(dir(example), "\n") print(help(example.add)) example.add(42) example.add(False) example.add(3.14159) example.add("Thorium") print(example) # Notice that data of different types can be added to the set # Items inside the set are called elements # Elements of a set could appear in a different ord...
true
2bc88f03339962830e865e32bcb8927bd5be1bab
sanjay2610/InnovationPython_Sanjay
/Python Assignments/Task4/Ques4.py
421
4.21875
4
# Write a program that accepts a hyphen-separated sequence of words as input and # prints the words in a hyphen-separated sequence after sorting them alphabetically. sample = 'Run-through-the-jungle' buffer_zone = sample.split("-") buffer_zone.sort(key=str.casefold) result='' for word in buffer_zone: if word==...
true
5ad636481a085eac73c53d1e4552488c5d8ee518
sanjay2610/InnovationPython_Sanjay
/Python Assignments/Task3/ques3and4.py
377
4.28125
4
#Write a program to get the sum and multiply of all the items in a given list. list1= [1,4,7,2] sum_total = 0 mul = 1 for num in list1: sum_total +=num mul *=num print("Sum Total of all elements: ", sum_total) print("Product of all the elements in the list", mul) print("Largest number in the list: ", max(l...
true
48eb98880e53c60893014a48660a8b3f80939240
trriplejay/CodeEval
/python3/rollercoaster.py
1,269
4.3125
4
import sys if __name__ == '__main__': if sys.argv[1]: try: file = open(sys.argv[1]) except IOError: print('cannot open', sys.argv[1]) else: """ loop through the file, read one line at a time, turn it into a python list, then call...
true
dc787b60b21add5ec63daed3e9d36b2a08248d3c
trriplejay/CodeEval
/python3/simplesorting.py
1,149
4.125
4
import sys if __name__ == '__main__': """ given a list of float values, sort them and print them in sorted order """ if sys.argv[1]: try: file = open(sys.argv[1]) except IOError: print('cannot open', sys.argv[1]) else: """ loop t...
true
178bb73f18ceb91470aefacac4f346f1e7a160ca
DLatreyte/dlatreyte.github.io
/premieres-nsi/chap-01/1ère Spé NSI/Chap. 7 - Dessins avec Turtle/exo9.py
2,460
4.1875
4
import turtle def rectangle(tortue: "Turtle", longueur: int, largeur: int) -> None: """ Trace un rectangle de longueur et largeur passées en argument grâce à la tortue (elle-même passée en argument). Les position et direction de la tortue ne sont pas modifiées. À l'issue du tracé la tortue se retr...
false
d65d85f6fad4f12e8ec52f2e77a9cc77b80c7cd2
DLatreyte/dlatreyte.github.io
/premieres-nsi/chap-01/1ère Spé NSI/Chap. 7 - Dessins avec Turtle/exo1.py
905
4.1875
4
import turtle def trace_rectangle(tortue: "Turtle", longueur: int, largeur: int) -> None: """ Dessine à l'écran à l'aide de la tortue passée en argument un rectangle de longueur et largeurs passées en argument. Le dessin est effectué à partir de la position de la tortue lorsque la fonction est appe...
false
354467448ca6536c7e875bdd4447d807cbf04258
go4Mor4/My_CodeWars_Solutions
/7_kyu_String_ends_with?.py
493
4.1875
4
''' Instructions Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string). Examples: solution('abc', 'bc') # returns true solution('abc', 'd') # returns false ''' #CODE def solution(frase, final): final = final[::-1] frase = frase[::-1]...
true
8ed5b0e9361b907f3d90601bcd216e2e795f6ee1
morbidlust/pythonCrashCourse
/ch2/math.py
880
4.6875
5
#Adding print(2+3) #Subtracting print(2/3) #Multiplication print(2*4) #Division print(2/4) #Exponent print(3**3) #3 to the power of 3, aka 27 #Don't forget the order of operations matter! print(2+3*4) # 3*4 =12 + 2 = 14 #Use parenthesis if needed to set the order as intended) print((2...
true
05afbea5731b30a155bd2b2ce6e1c2c98d1c4855
archambers/Data_Structures_And_Algorithms
/Misc/fibonacci.py
1,534
4.125
4
def naive_fibonacci(n: int) -> int: # Natural approach to recursive fibonacci function. if n <= 1: return n return naive_fibonacci(n - 1) + naive_fibonacci(n - 2) def iterative_fibonacci(n: int) -> int: # Bottom-up iterative approach first = 0 second = 1 for _ in range(n): ...
false
4d30cb1c0922cc09aa18f76f70393bdb624e4f65
kkeefe/py_Basic
/hello_py_stuff/self_test.py
1,085
4.34375
4
<<<<<<< HEAD # stuff to write as a silly test bench of py code to place in other note sections.. # use of a map function as applied to a lambda function # make some function you want my_func = lambda x: x ** x # lets make a map for this function sequence = [1, 2, 3] my_map = list(map(my_func, sequence)) print(my_map...
true
1819a769a857c24fa11e9af79f503f160ed0e61d
isheebo/ShoppingLister
/shoppinglister/models/user.py
2,089
4.125
4
from datetime import datetime class User: """ A user represents a person using the Application""" def __init__(self, name, email, password): self.name = name self.email = email self.password = password # a mapping of ShoppingList IDs to ShoppingList names self.shopping...
true
3b2b3340575fde0709fe7b8632c0f48d202ff814
MokahalA/ITI1120
/Lab 8 Work/magic.py
2,219
4.25
4
def is_square(m): '''2d-list => bool Return True if m is a square matrix, otherwise return False (Matrix is square if it has the same number of rows and columns''' for i in range(len(m)): if len(m[i]) != len(m): return False return True def magic(m): '...
true
bfd26facfdcd3a54f02140cca999585e22eff7da
MokahalA/ITI1120
/Lab 11 Work/Lab11Ex4.py
1,044
4.3125
4
def is_palindrome_v2(s): """(str) -> bool Return whether or not a string is a palindrome. While ignoring letters not of the english alphabet """ #Just 1 letter so its a palindrome if len(s) <= 1: return True #First letter is not in the alphabet if not s[0].isalpha(): ...
true
d851be7bee0b67d5d7a9f5dc04ab37a46155390d
MokahalA/ITI1120
/Lab 11 Work/Lab11Ex3.py
521
4.21875
4
def is_palindrome(s): """(str) -> bool Return whether or not a string is a palindrome. """ if len(s) <= 1: return True if s[0].lower() != s[-1].lower(): return False return is_palindrome(s[1:-1]) #test print(is_palindrome('blurb')) #False print(is_palindrome('a')) ...
false
5fc4e6f7732929cb1442da206a315a974555f5cf
Mamuntheprogrammer/Notes
/Pyhton_snippet/HackerRankString.py
2,110
4.3125
4
# Python_365 # Day-26 # Python3_Basics # Python Data Types : String # Solving String related problems: (src : hackerrank) # Problem title : sWAP cASE """ Problem description : You are given a string and your task is to swap cases. In other words, convert all lowercase letters to uppercase letters and vice versa. ...
true
972eea4d5a9c74cd3a9aae9e35c3037ce8d68a46
Sukhrobjon/Hackerrank-Challanges
/interview_kit/Sorting/bubble_sort.py
660
4.28125
4
def count_swaps(arr): """ Sorts the array with bubble sort algorithm and returns number of swaps made to sort the array """ count = 0 swapped = False while swapped is not True: swapped = True for j in range(len(arr)-1): if arr[j] > arr[j + 1]: ...
true
c77f6ee57e3500c56f4c64d920b343b600b9d1ea
Sukhrobjon/Hackerrank-Challanges
/ProblemSolving/plus_minus.py
718
4.15625
4
def plus_minus(arr): ''' print out the ratio of positive, negative and zero items in the array, each on a separate line rounded to six decimals. ''' # number of all positive numbers in arr positive = len([x for x in arr if x > 0]) # number of all negative numbers in arr negative = len(...
true
cf5900bc9115c2054ca19965281cd0ef2f1c4b93
Sukhrobjon/Hackerrank-Challanges
/interview_kit/reverse_list.py
1,076
4.4375
4
# Create a function that takes a list # Create an empty list # Iterate through the old list # Get the last index of the old list # Append to the new list # Return the new list # Shiv Toolsidass ''' 1 1 1 0 0 0 0 1 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 a b c d e f g -9 -9 -9 1 1 1 0 -9 0 4 3...
false
28a48c5b770cefdfb0dbc15828a9810d18cf27e5
RicardoAugusto-RCD/exercicios_python
/exercicios/ex058.py
672
4.28125
4
# Melhore o jogo do desafio 028 onde o computador vai "pensar" em um número entre 0 e 10. Só que agora o jogador vai # tentar adivinhar até acertar, mostrando no final quantos palpites foram necessários para vencer. import random numeroUsuario = int(input('Digite um número entre 0 e 10: ')) numeroPc = random.randin...
false
de583ba447a373cebea3725955037e02b13d7e04
RicardoAugusto-RCD/exercicios_python
/exercicios/ex041.py
708
4.1875
4
# A Confederação Nacional de Natação precisa de um programa que leia o ano de nascimento de um atleta e mostre sua # categoria, de acordo com a idade: # Até 9 anos: MIRIM. # Até 14 anos: INFANTIL. # Até 19 anos: JUNIOR. # Até 25 anos: SÊNIOR. # Acima: MASTER. from datetime import date anoAtual = date.today().year a...
false
848bb33a7961ed442c6e1622bec6cd9cabb21221
RicardoAugusto-RCD/exercicios_python
/exercicios/ex059a.py
1,638
4.1875
4
# Crie um programa que leia dois valores e mostre um menu na tela: # [1] Somar # [2] Multiplicar # [3] Maior # [4] Novos números # [5] Sair do programa # Seu programa deverá realizar a operação solicitada em cada caso. print('►◄' * 20) n1 = int(input('Primeiro valor: ')) print('►◄' * 20) n2 = int(input('Segundo Valor...
false
1b0a92c3b053416b530452f5509c978220d29e10
RicardoAugusto-RCD/exercicios_python
/exercicios/ex095.py
1,708
4.15625
4
# Aprimore o Desafio 093 para que ele funcione com vários jogadores, incluindo um sistema de visualização de detalhes do # aproveitamento de cada jogador. jogador = dict() jogadorLista = list() while True: jogador['nome'] = '' jogador['gols'] = list() jogador['total'] = 0 jogador['nome'] = str(inpu...
false
a5a8f8de8bc33c63123e9af60ef88222df0add72
RicardoAugusto-RCD/exercicios_python
/exercicios/ex093.py
1,066
4.15625
4
# Crie um programa que gerencie o aproveitamento de um jogador de futebol. O programa vai ler o nome do jogador e # quantas partidas ele jogou. Depois vai ler a quantidade de gols feitos em cada partida. No final, tudo isso será # guardado em um dicionário, incluindo o total de gols feitos durante o campeonato. jogad...
false
7b905d6a127cd3076cba642a7b40eb5fd3503288
blu3h0rn/AI4I_DataCamp
/07_Cleaning_Data/reg_ex.py
626
4.125
4
import re # Write the first pattern # A telephone number of the format xxx-xxx-xxxx. You already did this in a previous exercise. pattern1 = bool(re.match(pattern='\d{3}-\d{3}-\d{4}', string='123-456-7890')) print(pattern1) # Write the second pattern # A string of the format: A dollar sign, an arbitrary number of dig...
true
c9267081ab2a317066a7d5881eaac862579d2bbe
justin-tt/euler
/19.py
2,298
4.25
4
# approach is to run a loop for every day starting from 1 Jan 1901 until 31 Dec 2000 # have a dictionary that holds every day of the week with a list that appends every single date as the loop runs # have a way to read the list of sundays and parse how many "firsts" of the month. # create a number of days generator fo...
false
58c508b8b8a9f6a4935555649c91148fb0f7511c
ricardomachorro/PracticasPropias
/PythonEnsayo/Python6.py
791
4.5
4
#Otro tipo de dato que existe en python y que sirve mucho para bucles #es el tipo de dato range, ya que esta es una coleccion ordenada de numeros que los puede #controlar estricturas como el for #se declara con la palabra reservada range: #si se le pone solo un parametro este se toma como valor maximo rang1 = range(6...
false
19cbe0a02f0a73643b7a2ee1545536af3600fc95
ricardomachorro/PracticasPropias
/PythonEnsayo/Python14.py
2,605
4.40625
4
import math, cmath, operator #Algunas operaciones aritmeticas de python se pueden lograr o es necesario los modulos math,cmath u operator print("\nOperaciones aritmeticas de python con modulos math, cmath y operator\n") #Un ejemplo de estas formas son: print("\nLa division\n") #La division print("\nOperator para di...
false
6f8e0716bad3366dfa3e8ed5157500ac48c4f838
gustavo-detarso/engenharia_de_software
/concluidas/logica_de_programacao_e_algoritmos/Aula_2/c2_e4.py
423
4.25
4
# Desenvolva um algoritmo que converta uma temperatura em Celsius (C) para Fahrenheit (F). # Passo 1: criando as strings # Definição do que o algoritmo se propõe: print('Conversor de Celsius para Fahrenheit') celsius = float(input('Digite a temperatura em graus Celsius (ºC): ')) conversao = (9*celsius)/5+32 # Passo 2: ...
false
ca9e85d8c6d8304ad3d041cd663ada46603f1aa8
enriquerojasv/ejercicios_python
/Práctica 7/p07e11.py
479
4.21875
4
# Enrique Rojas - p07e11 # Escribe un programa que te pida una frase, y pase la frase como parámetro a una función. Ésta debe devolver si es palíndroma o no , y el programa principal escribirá el resultado por pantalla. def palindromo(a): alreves = "" for i in range(len(a)-1,-1,-1): alreves += (a[i]) ...
false
aff8db65519cf6c95930facf7e4a9f5794c261cc
0neMiss/cs-sprint-challenge-hash-tables
/hashtables/ex4/ex4.py
598
4.21875
4
def has_negatives(list): """ YOUR CODE HERE """ dict = {} result = [] #for each number for num in list: # if the number is positive if num > 0: #set the value of the dictionary at the key of the number equal to the number dict[num] = num #itera...
true
5ecf9ec9ff9ec7eafcda9f8c61fdb6493c338743
Andytrento/zipf
/bin/my_ls.py
606
4.1875
4
""" List the files in a given directory with a given suffix""" import argparse import glob def main(args): """Run the program""" dir = args.dir if args.dir[-1] == "/" else args.dir + "/" glob_input = dir + "*." + args.suffix glob_output = sorted(glob.glob(glob_input)) for item in glob_output: ...
true
52ae75e0bce95f04fe589a792ad38d11d08d2487
St1904/GB_python_1
/lesson3/easy.py
1,474
4.5
4
# Постарайтесь использовать то, что мы прошли на уроке при решении этого ДЗ, # вспомните про zip(), map(), lambda, посмотрите где лучше с ними, а где они излишни! # Задание - 1 # Создайте функцию, принимающую на вход Имя, возраст и город проживания человека # Функция должна возвращать строку вида "Василий, 21 год(а), ...
false
2ab455fa9d6bbba20a4c15c1e178ae6193255d43
Pavithjanum/PythonModule1
/Module1-Q2.py
490
4.40625
4
# 2 # Write a code which accepts a sequence of words as input and prints the words in a sequence after sorting them alphabetically. # Hint: In case of input data being supplied to the question, it should be assumed to be a console input. import sys inputs = sys.argv print('Raw inputs from user',inputs[1:]) String_...
true
1ea69e0bbaac2100ec90d25e707a3072a51e1b4d
faiderfl/algorithms
/recursion/Palindrome.py
708
4.15625
4
def reverse(string)->str: """[summary] Args: string ([type]): [description] Returns: str: [description] """ len_string= len(string) if len_string==1: return string[0] else: return string[len_string-1]+ reverse(string[:len_string-1]) def is_pali...
false
d21cef2ba8aa4d53ebff4a8e94996731b3b3ae91
A01377744/Mision-03
/calculoDelPagoDeUnTrabajador.py
1,098
4.15625
4
#Autor: Alejandro Torices Oliva #Es un programa que lee las horas normales y horas extra trabajadas en una semana #e imprime el pago por cada una y el pago total. #Calcula el pago para las horas normales. def calcularPagoNormal(horasNormales, pagoPorHora): pagoNormal = horasNormales * pagoPorHora return pagoNo...
false