blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
4f2487efd3bb2d56cb4e502bf08783ff5ef3f2a4
Nigirimeshi/leetcode
/0021_merge-two-sorted-lists.py
2,635
4.1875
4
""" 合并两个有序链表 链接:https://leetcode-cn.com/problems/merge-two-sorted-lists 将两个升序链表合并为一个新的升序链表并返回。 新链表是通过拼接给定的两个链表的所有节点组成的。 示例: 输入:1 -> 2 -> 4, 1 -> 3 -> 4 输出:1 -> 1 -> 2 -> 3 -> 4 -> 4 官方解法: 1. 迭代法。 当两个链表都不为空时,判断哪个链表的头节点的值更小,将较小值添加到结果里,之后将链表中的节点向后移动一位。 时间复杂度:O(n+m),n 和 m 分别是两个链表的长度,因为每次迭代循环时,只会放入一个链表元素,因此 while 循环次数不...
false
439445e18cb8260567be42e0e8df9eade0b3c9b5
Nigirimeshi/leetcode
/1249_minimum-remove-to-make-valid-parentheses.py
2,593
4.125
4
""" 移出无效的括号 链接:https://leetcode-cn.com/problems/minimum-remove-to-make-valid-parentheses 给你一个由 '('、')' 和小写字母组成的字符串 s。 你需要从字符串中删除最少数目的 '(' 或者 ')'(可以删除任意位置的括号),使得剩下的「括号字符串」有效。 请返回任意一个合法字符串。 有效「括号字符串」应当符合以下任意一条要求: 空字符串或只包含小写字母的字符串 可以被写作 AB(A 连接 B)的字符串,其中 A 和 B 都是有效「括号字符串」 可以被写作 (A) 的字符串,其中 A 是一个有效的「括号字符串」 示例 1: 输入:...
false
606fe3d50350078588bbbf2a1f07e3c46b9c66e9
Padma-1/100_days-coding
/Abundant_number.py
332
4.1875
4
#A number is abundant if sum of the proper factors of the number is greater than the given number eg:12-->1+2+3+4+6=16-->16>12 i.e., 12 is Abundant number n=int(input()) sum=0 for i in range(1,n//2+1): if n%i==0: sum+=i if sum>n: print("Abundant number") else: print("not Abundant number")...
true
b63c5ad4a138de403ef34297f1e05d4668c20339
Padma-1/100_days-coding
/sastry_and_zukerman.py
674
4.15625
4
###Sastry number:A number N is a Sastry Number if N concatenated with N + 1 gives a perfect square.eg:183 ##from math import sqrt ##def is_sastry(n): ## m=n+1 ## result=str(n)+str(m) ## result=int(result) ## if sqrt(result)==int(sqrt(result)): ## return True ## return False ##n=int(input...
true
96af38fcaf676e67b50112b713af0b4d4fa08022
aswanthkoleri/Competitive-codes
/Codeforces/Contests/Codeforces_Global_Round_3/Quicksort.py
2,073
4.34375
4
def partition(arr,low,high): i = ( low-1 ) # index of smaller element pivot = arr[high] # pivot # print("Pivot 1 = ",pivot) # What we are basically doing in the next few steps : # 1. Whenever we find an element less than the pivot element we swap it with the element starting from the 0th inde...
true
44e4a22c1318e44f75e74af86558246f9acecd83
lavish205/hackerrank
/time_conversion.py
913
4.3125
4
"""PROBLEM STATEMENT Given a time in AM/PM format, convert it to military (24-hour) time. Note: Midnight is 12:00:00AM on a 12-hour clock and 00:00:00 on a 24-hour clock. Noon is 12:00:00PM on a 12-hour clock and 12:00:00 on a 24-hour clock. Input Format A time in 12-hour clock format (i.e.: hh:mm:ssAM or hh:mm:ssPM...
true
336462673f1eccec9e6b8cd938c8d9c5af4c8018
alihasan01/CodingInterview_Python
/Chapter2/removeDuplicates.py
1,503
4.3125
4
class Node: def __init__(self, data, next=None): self.data = data self.next = next # Time Complexity O(n) # Space complexity Complexity O(n) class linkedList: def __init__(self): self.head = None def insertAtStart(self,data): node = Node(data , self.head) self.hea...
false
c7b26dd29739edb1e8aa671f1b7a41e03ad1134a
alihasan01/CodingInterview_Python
/Chapter2/Intersection.py
1,855
4.1875
4
class Node: def __init__(self, data, next=None): self.data = data self.next = next # Time Complexity O(n) # Space complexity Complexity O(1) class linkedList: def __init__(self): self.head = None def insertAtStart(self,data): node = Node(data , self.head) self.head =...
false
2f4d5d2c4a37041f53c26f8bb0cce084028b4183
tpraks/python-2.7
/recur_reverse.py
223
4.21875
4
def reverse(str): if len(str)==1: return str else: return reverse(str[1::]) + str[0] def main(): str1 = raw_input("Enter String: ") print str1 print reverse(str1) if __name__ == '__main__': main()
false
255a630ce8ac960c214b6758e771233d36f0a6bc
Mo-Shakib/DSA
/Data-Structures/Array/right_rotate.py
565
4.53125
5
# Python program to right rotate a list by n # Returns the rotated list def rightRotate(lists, num): output_list = [] # Will add values from n to the new list for item in range(len(lists) - num, len(lists)): output_list.append(lists[item]) # Will add the values before # n to...
true
7471c5beb138b6a39583083b4ea4173fa98e65b6
Misha-create/MK_MIPT_Python
/черепашка/12(1).py
291
4.15625
4
import turtle turtle.shape('turtle') def polygon (angle, l): for i in range(angle//2): turtle.forward(l) turtle.right(360/angle) big = int(input()) small = int(input()) n = int(input()) turtle.left(90) for i in range(n): polygon(big, 1) polygon(small, 1)
false
124bbb8ba9da101c72ffae44f897a2b8d71a4261
G00398792/pforcs-problem-sheet
/bmi.py
674
4.5625
5
# bmi.py # This program calculates your Body Mass Index (BMI). # author: Barry Gardiner #User is prompted to enter height and weight as a float # (real number i.e. 1.0) number. The users weight is divided # by the height in metres to the power of 2. The output # is printed to the screen. The code "{:.2f}'.format(BMI)...
true
f70c9a371369cb3ec1cd1f484c877704fa30b799
mre9798/Python
/lab 9.1.py
233
4.3125
4
# lab 9.1 # Write a recursive function to find factorial of a number. def fact(n): if n==1: return 1 else: return n*fact(n-1) n=int(input("Enter the nnumber : ")) print("Factorial is ",fact(n))
true
65abd6e3940706315542de8ba291bdd93b2c1dab
bajram-a/Basic-Programing-Examples
/Conditionals/Exercise2.4.py
505
4.25
4
"""Write a program that requires from the user to input coordinates x and y for the circle center and the radius of that circle, then another set of coordinates for point A. The program then calculates whether A is within the circle""" from math import sqrt Cir_x = float(input()) Cir_y = float(input()) r = float(inp...
true
c5ff2f18e9728e2e015be69bf7389b11c54f55ba
fantods/python-design-patterns
/creational/builder.py
1,258
4.4375
4
# decouples creation of a complex object and its representation # helpful for abstractions # Pros: # code is more maintainable # object creation is less error-prone # increases robustness of application # Cons: # verbose and requires a lot of code duplication # Abstract Building class Building(object): def __in...
true
77f8837147e6516faa44883791fc94cfe6f4e02b
BloodiestChapel/Personal-Projects
/Python/HelloWorld.py
461
4.1875
4
# This is a standard HelloWorld program. # It is meant for practice. import datetime print('Hello World!') print('What is your name?') myName = input() myNameLen = len(myName) print('It is good to meet you, ' + myName) print('Your name is ' + str(myNameLen) + ' characters long.') print('What is your age?') date ...
true
5a821cf368d6aac40b3e13a7ee6d3f9e3b73df24
miked49er/com.mikedeiters.learningpython
/12 Classes/classes.py
1,625
4.1875
4
#!/usr/bin/python3 # classes.py by Bill Weinman [http://bw.org/] # This is an exercise file from Python 3 Essential Training on lynda.com # Copyright 2010 The BearHeart Group, LLC class Animal: def talk(self):print('I have something to say') def walk(self):print("Hey I'm walking here") def clothes(self):pr...
false
7d6e84349dcb9c8ca76a35192e1bbbc5a6301142
TheRockStarDBA/PythonClass01
/program/python_0050_flow_control_nested_for_loop.py
1,158
4.1875
4
''' Requirement: There are 4 numbers: 1/2/3/4. List out all 3 digits numbers using these 4 numbers. You cannot use the same number twice in the 3 digits numbers. ''' #Step 1) How to generate 1 digit number? for i in range(1,5): print(i, end=' ') print('\n-------------------------------------') #Step 2) How to ge...
true
ad3979824471e652f79e74cf93ca18366b922436
TheRockStarDBA/PythonClass01
/program/python_0020_flow_control_if.py
1,262
4.28125
4
# Every python program we've seen so far is sequential exection. # Code is executed strictly line after line, from top to bottom. # Flow Control can help you skip over some lines of the code. # if statement today = input("What day is today?") print('I get up at 7 am.') print('I have my breakfast at 8 am.') # IMP...
true
e9fcd04639d97eef36e0891c5a4e8ad7513bd9c1
TheRockStarDBA/PythonClass01
/program/python_0048_practice_number_guessing_name.py
1,575
4.40625
4
''' Requirement: Build a Number guessing game, in which the user selects a range, for example: 1, 100. And your program will generate some random number in the range, for example: 42. And the user needs to guess the number. If his answer is 50, then you need to tell him. “Try Again! You guessed too high” If his answer...
true
45d32d880019054cbcc22f71c5cf0b62bc605ecf
TheRockStarDBA/PythonClass01
/program/python_0006_data_type_str.py
613
4.15625
4
# str - 字符串 str1 = "Hello Python!" str2 = 'I am str value, "surrounded" by single quote.' str3 = "I am another str value, 'surrounded' by doulbe quotes." print('variable str1 type is:', type(str1), 'str1=', str1) print('variable str2 type is:', type(str2), 'str2=', str2) print('variable str3 type is:', type(str3), '...
true
caf77761eb946bc292c8f0c9802bc0bfd75160a4
TheRockStarDBA/PythonClass01
/program/python_0031_practice_input_if_elif_else_bmi_calculator.py
1,132
4.53125
5
# Requirement: get input from the user about height in meters and weight in kg. # Calculate his bmi based on this formula: # bmi = weight / (height ** 2) # Print information based on user's bmi value # bmi in (0, 16) : You are severely underweight # bmi in [16, 18.5) : You are underweight # bmi in [18.5, 25) :...
true
e9a945d21935f5bb2e66d9323eeb5e26b5a97ec6
TheRockStarDBA/PythonClass01
/program/python_0039_library_random.py
1,221
4.5625
5
# IMPORTANT !!! ---------------------------------- # Import the random module into your python file # ------------------------------------------------ import random # IMPORTANT !!! ---------------------------------- # random.randint(1, 10) is composed of 4 parts. # # 1) random : module name # 2) . ...
true
587e9f60c46a7db78e6e1f78885eb0b405f16239
Alamin11/JavaScript-and-Python
/lecture02/sequeces.py
652
4.15625
4
from typing import OrderedDict, Sequence # Mutable and Ordered # Mutable means can be changed the Sequence # Orderd means can not be changed the sequence because order matters #string = oredered name = "Farjana" print(name[0]) print(name[6]) print(name) #Lists=mutable and ordered listName = ["Farjana", "Toma", "Nuntu...
true
71cdaa322abe4a1f266d5ce9704c11f3a759892c
alisaffak/GlobalAIHubPythonHomework
/proje.py
2,720
4.1875
4
student_name = "Ali".upper() student_surname = "Şaffak".upper() all_courses = ["Calculus","Lineer Algebra","Computer Science","DSP","Embeded Systems"] selected_courses = set() student_grades = {} def select_courses(): j = 1 for i in all_courses: print("{}-{}".format(j,i)) j +=1 ...
true
224f1cb5e79f927af38bffa0629d03d0eddbfe86
Surgeom/geekbrains
/algoritms/dz2/1.py
858
4.25
4
def calcul(): operation = input('Введите операцию (+, -, *, / или 0 для выхода):') if operation == "0": return 'bye' elif operation == "-" or operation == '+' or operation == '*' or operation == '/': num1 = int(input('Введите первое число')) num2 = int(input('Введите второе число')) ...
false
6a8f962aebd5ddd10742d907de30819d82ae5d1e
LaRenegaws/wiki_crawl
/lru_cache.py
2,955
4.125
4
import datetime class Cache: """ Basic LRU cache that is made using a dictionary The value stores a date field that is used to maintain the elements in the cache Date field is used to compare expire an element in the cache Persisted field is a boolean that determines whether it can be deleted """ def __...
true
448aa1aead420c84febe08b1d5dcecff30b28d85
canlasd/Python-Projects
/Assignment3.py
450
4.1875
4
wind=eval(input("Enter Wind Speed")) if wind>=74 and wind <=95: print ("This is a category 1 hurricane") elif wind<=96 and wind <=110: print ("This is a category 2 hurricane") elif wind<=111 and wind <=130: print ("This is a category 3 hurricane") elif wind<=131 and wind <=155: ...
true
bec4400de442d424a2594b4b76e1a3c72a713bd8
kailash-manasarovar/A-Level-CS-code
/algorithms/merge_sort.py
1,069
4.15625
4
def merge(a_list): print("Splitting ", a_list) if len(a_list)>1: mid = len(a_list) // 2 left_half = a_list[:mid] right_half = a_list[mid:] merge(left_half) merge(right_half) i=j=k=0 # while all lists have more than one element while i < len(left_h...
false
ac9a7f7dc8d38922d664e20b379d14109e0c7b0e
kailash-manasarovar/A-Level-CS-code
/challenges/number_table.py
317
4.1875
4
operator = input("Please input an operator, +,-,*,/ ") number = int(input("Please input a number ")) list_of_numbers = [i for i in range(number+1)] print(operator + " | " + str(list_of_numbers[:])) print("- - - - - - - - - -") for i in range(number+1): print(str(i) + " | " + str(list_of_numbers[i:])) pass
false
1b25840045d4858f9eec3deeda08f2373376ee25
osanseviero/Python-Notebook
/ex31.py
626
4.375
4
#Program 31. Using while loops def create_list(size, increment): """Creates a list and prints it""" i = 0 numbers = [] while i < size: print "New run! " print "At the top i is %d" % i numbers.append(i) i = i + increment print "Numbers now: ", numbers print "At the bottom i is %d\n \n" % i prin...
true
006a4070da536f4d42c65d93e0e5eb67db3b06b6
mirgags/pear_shaped
/fruit_script.py
1,896
4.21875
4
# An interactive script that prompts the user to accept or reject fruit # offerings and then asks if they want any other fruit that wasn't offered. # Responses are stored in the fruitlist.txt file for later reading. yeses = ['YES', 'OK', 'SURE', 'YEAH', 'OKAY', 'SI'] nos = ['NO', 'NOPE', 'NAH', 'UH-UH'] fruits = [] ...
true
1864a160dec53b2c9585bf05928daeafc23ff066
andrewdaoust/project-euler
/problem004.py
825
4.1875
4
""" 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 palindrome_check(n): s = str(n) length = len(s) for i in range(int(len(s)/2)): ...
true
c6ecdc710116054197d6d8f14f50f7af44700829
andrewdaoust/project-euler
/problem001.py
487
4.3125
4
""" 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. """ import numpy as np def run(): mult_3_5 = [] for i in range(1, 1000): if i % 3 == 0: mult_3_5.a...
true
688b44387560371c3262dd115f377c87f06eabb5
nickmallare/Leet-Code-Practice
/35-search-insert-position.py
851
4.1875
4
""" Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You must write an algorithm with O(log n) runtime complexity. """ class Solution(object): def searchInsert(self, nums, target): ...
true
f911c2170e7dcb50d4d0eef0eebe550926af2c87
Frank-LSY/Foundations-of-AI
/HW1/Puzzle8/bfs.py
1,650
4.15625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Sep 3 17:01:00 2019 vanilla breadth first search - relies on Puzzle8.py module @author: Milos Hauskrecht (milos) """ from Puzzle8 import * #### ++++++++++++++++++++++++++++++++++++++++++++++++++++ #### breadth first search def br...
true
4ad120e7f53162c10541c354acd1a30bc30cbeae
Nihila/python_programs
/begginer/positiveornegative.py
797
4.25
4
#------------------------------------------------------------------------------- # Name: module1 # Purpose: # # Author: Administrator # # Created: 04/02/2018 # Copyright: (c) Administrator 2018 # Licence: <your licence> #--------------------------------------------------------------------...
true
3cb7608386af892df8d2a09000e5461ff7abed11
essenceD/Python_algorythmes
/Lesson_2(Cycles, recursion, functions)/task_2.py
628
4.15625
4
# 2. # Посчитать четные и нечетные цифры введенного натурального числа. # Например, если введено число 34560, в нем 3 четные цифры (4, 6 и 0) и 2 нечетные (3 и 5). num = input('Enter number to check its digits on parity: ') even = '' n_even = 0 odd = '' n_odd = 0 for i in num: if int(i) % 2 == 0: ...
false
0e0b2a636417c19d1c9f728b727e48ce7aeab4bb
essenceD/Python_algorythmes
/Lesson_2(Cycles, recursion, functions)/task_8.py
876
4.25
4
# 8. # Посчитать, сколько раз встречается определенная цифра в введенной последовательности чисел. # Количество вводимых чисел и цифра, которую необходимо посчитать, задаются вводом с клавиатуры. match, line = 0, '' print('This program will count the digit you\'ll enter in numbers yo\'ll enter.') tries = int(inp...
false
327720b380ef7d2fa891f67c916ba51f91c74769
pandey-ankur-au17/Python
/coding-challenges/week03/Assignment/AssignmentQ2while.py
540
4.125
4
def by_while_loop(): print("by using while loop ") n = int(input("Enter the number of lines : ")) line = 1 while (line <= n): print(" " * (n - line), end="") digit = 1 while digit <= line: print(digit, end="") if line == digit: rev_digi...
true
158bdd6828bc4a720f962b5d329b5b8f8f5a045f
pandey-ankur-au17/Python
/coding-challenges/week04/day01/ccQ2.py
366
4.46875
4
# Write a function fibonacci(n) which returns the nth fibonacci number. This # should be calcuated using the while loop. The default value of n should be 10. def fibonacci(n=10): n1=0 n2=1 count=0 while count<n: print(n1) nth=n1+n2 n1=n2 n2=nth count=count+1 #n=...
true
c830897d5aa2bd691af45ccb59f3bcaa22307d75
pandey-ankur-au17/Python
/coding-challenges/week07/AssignmentQ1.py
991
4.15625
4
# Write a function that takes an unsigned integer and returns the number of '1' bits it has (also known as the Hamming weight). # Note: # Note that in some languages, such as Java, there is no unsigned integer type. In this case, the input will be given as a signed integer type. It should not affect your implementati...
true
58bfff25bede8b43e9e236d83d9326a8f0b4b125
pandey-ankur-au17/Python
/coding-challenges/week07/day04/ccQ3.py
591
4.25
4
# Given an array with NO Duplicates . Write a program to find PEAK # ELEMENT # Return value corresponding to the element of the peak element. # Example : # Input : - arr = [2,5,3,7,9,13,8] # Output : - 5 or 13 (anyone) # HINT : - Peak element is the element which is greater than both # neighhbours. def Peak_value(arr)...
true
d727b7c08eab9667089f1dd1fb10f31cf694e880
pandey-ankur-au17/Python
/coding-challenges/week08/day04/ccQ2.py
724
4.125
4
# 2) Write a program to print sum of border elements of a square Matrix # (5 marks) # Border elements: # 1 2 3 4 # 4 5 6 5 # 7 8 9 6 # 4 9 8 7 # Sum of border elements = 1+2+3+4+5+6+7+8+9+4+7+4 = 60 def Border_element(a, m, n): sum = 0 for i in range(m): for j in range(n): if (i == 0): ...
false
632564d4d1d0ed5f9c4cc1a8d9a36b67ab263810
alishalabi/binary-search-tree
/binary_search_tree.py
2,888
4.25
4
""" Step 1: Build a binary search tree, with add, remove and in methods. Step 2: Perform DFS's and BFS """ class BinaryTreeNode: def __init__(self, data, left_child=None, right_child=None): self.data = data self.left_child = left_child self.right_child = right_child self.is_leaf =...
true
f8c78f310b51c3af0ff82744fa7ac9a9118ce165
Hinal-Sonkusre/Python-Internship
/day4python.py
2,561
4.1875
4
# function # def myfunction(): # print("Hello world") # # # myfunction() # # # def myfunction1(name): # print("Name is:", name) # # # myfunction1("Hinal") # def myfunction2(name): # return name # # # name = myfunction2("Hinal") # print("Value is ", name) # def myfunction(): # ...
false
2871bbaccc81e158cd4f7ae714af0a1c53ef2fce
brunohprada/Python-para-zumbis
/lista-2/01_triangulo.py
903
4.25
4
''' Lista 2 - Exercicio 1. Faça um Programa que peça os três lados de um triângulo. O programa deverá informar se os valores podem ser um triângulo. Indique, caso os lados formem um triângulo, se o mesmo é: equilátero, isósceles ou escaleno. ''' lado1 = float(input('Informe o valor do primeiro lado: ')) lado2 = float...
false
f3fd05cd8a7ac17a0809891fd7fb7fcb338c6972
brunohprada/Python-para-zumbis
/lista-1/09_aluguel.py
539
4.125
4
''' Lista 1 - Exercício 9 Escreva um programa que pergunte a quantidade de km percorridos por um carro alugado pelo usuário, assim como a quantidade de dias pelos quais o carro foi alugado. Calcule o preço a pagar, sabendo que o carro custa R$ 60,00 por dia e R$ 0,15 por km rodado. Felipe Nogueira de Souza @_outrofelip...
false
0bb123d4261f05d1c3b1654c10cff9300a408135
pancakewaffles/Stuff-I-learnt
/Python Refresher/Python for Security Developers/Module 2 Apprentice Python/Activities/Apprentice_Final_Activity.py
1,475
4.125
4
import operator saved_string = '' def remove_letter(): #Remove a selected letter from a string base_string = str(raw_input("Enter String: ")); letter = str(raw_input("Letter to remove: ")); i = len(base_string) -1 ; while(i < len(base_string) and i >= 0): if(base_string[i] == le...
true
cb48aff62616fd3fe4888d6a4fde3aef185d99c1
pancakewaffles/Stuff-I-learnt
/Python Refresher/Python Math/1 Numbers, Fractions, Complex, Factors, Roots, Unit Conversion/quadraticRootsCalc.py
517
4.15625
4
#! quadraticRootCalc.py # Finds roots of quadratic equations, including even complex roots! def roots(a,b,c): # a,b,c are the coefficients D = (b*b - 4*a*c)**0.5; x_1 = (-b+D)/(2*a); x_2 = (-b-D)/(2*a); print("x1: {0}".format(x_1)); print("x2: {0}".format(x_2)); #print("x1: %f"%(x_1)); Doesn'...
true
38f8b6498b4d756f7f2255109323fa4112f48e8f
pancakewaffles/Stuff-I-learnt
/Python Refresher/Python Basics/collatz.py
280
4.1875
4
#Collatz Conjecture def collatz(number): if(number%2==0): print(number//2); return number//2; else: print(3*number + 1); return 3*number + 1; print("Enter number:"); number = int(input()); while(number > 1): number = collatz(number);
false
4e8a52d1b2563727ac655e2c84ad0b80af626e29
fpert041/experiments_in_ML_17
/LB_02_TestEx.py
1,274
4.21875
4
#PRESS <Ctrl>+<Enter> to execute this cell #%matplotlib inline #In this cell, we load the iris/flower dataset we talked about in class from sklearn import datasets import matplotlib.pyplot as plt iris = datasets.load_iris() # view a description of the dataset print(iris.DESCR) %matplotlib inline #above: directive ...
true
1adb144238abf3ad518e644c680a44e7b66cca15
ianjosephjones/Python-Pc-Professor
/8_11_21_Python_Classs/Exercise_5-11.py
723
4.5625
5
""" 5-11: Ordinal Numbers --------------------- Ordinal numbers indicate their position in a list, such as 1st or 2nd. Most ordinal numbers end in th, except 1, 2, and 3. Store the numbers 1 through 9 in a list. Loop through the list. Use an if-elif-else chain inside the loop to print the proper ordinal ending for each...
true
cd7df41cd3b77c163d2ce1eda9dc4500e1b038c9
Mooshoopork/Uh
/multiplcationtable1-10.py
777
4.25
4
#Mutiplication table from 1-10 while True: num = input("What number would you like to multiply? ") try: num = int(num) break except: print("Please input an integer.") print("Here is the multiplication table:") awn = num * 1 print(str(num) + " x 1 = " + str(awn)) awn = num * 2 print(s...
false
15a517a5443e03e322d9c2fbfcdbb31c9418cf25
awesomeleoding1995/Python_Learning_Process
/python_crash_course/chapter-9/user.py
1,773
4.125
4
class User(): """this class is used to create user-related profile""" def __init__(self, first_name, last_name): self.f_name = first_name self.l_name = last_name self.login_attempts = 0 def describe_user(self): formatted_name = self.f_name + " " + self.l_name return formatted_name.title() def greet_use...
true
27dc85dad52a603c8df7ca93ef2f35da27ed262d
danielvillanoh/conditionals
/secondary.py
2,425
4.59375
5
# author: Daniel Villano-Herrera # date: 7/23/2021 # --------------- # Section 2 # --------------- # # ---------- # Part 1 # ---------- # print('----- Section 2 -----'.center(25)) print('--- Part 1 ---'.center(25)) # 2 - Palindrome print('\n' + 'Task 1' + '\n') # # Background: A palindrome is a word that is the same...
true
7473187eb899dfaf8f409aae4424c0fbc4ccb6f1
interviewprep/InterviewQuestions
/trees/python/column_order_traversal.py
1,028
4.3125
4
# Column Order Traversal # Write a traversal method for Binary Tree that prints nodes that fall on a # line from leftmost to rightmost. # Example: For following Binary Tree, # # 4 # / \ # 2 5 # / \ \ # 1 3 7 # # Column order traversal = [1, 2, 4, 3, 5, 7] # # Explanation: If we draw lines v...
false
b74184838111476129625eb2f3b1f26e6f189b4f
interviewprep/InterviewQuestions
/stacksandqueues/python/reverse_parentheses.py
1,304
4.15625
4
# You are given a string s that consists of lower case English letters and brackets. # Reverse the strings in each pair of matching parentheses, starting from the innermost one. # Your result should not contain any brackets. # Example 1: # # Input: s = "(abcd)" # Output: "dcba" # # Example 2: # # Input: s = "(u(love)...
true
86196f2b2663b2b5a5da6a1a0ed3c5f5686c6654
ivo-pontes/Python3
/ed/Queue.py
1,035
4.375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -* ''' Classe Fila FIFO = FIRST IN FIRST OUT ''' class Queue: #Fila def __init__(self): self.queue = [] self.size = 0 ''' Insere ao fim da fila ''' def push(self, item): self.queue.append(item) self.size += 1 ''' Remove o primeiro item da fila ''' def pop...
false
d6ab5e83c842579911b3e6504ec2f9aa288604d6
natacadiz/Nata
/Ejercicios Unidad 1/1.4.py
299
4.125
4
# Escribe un programa que le pida al usuario una temperatura en grados Celsius, la convierta a grados Fahrenheit e imprima por pantalla la # temperatura convertida. celsius=float(input("Cuantos grados celsius hace?: ")) fahrenheit= (celsius*9/5)+32 print ("Hace",fahrenheit,"grados Fahrenheit")
false
66af55819c15092e3431065410c26c302cf2e279
Tayyab-Ilahi12/Python-Programs-for-practice
/FlashCard Game.py
1,900
4.46875
4
""" This flashcard program allows the user to ask for a glossary entry. In response,if user select show flash card the program randomly picks an entry from all glossary entries. It shows the entry. After the user presses return, the program shows the definition of that particular entry. If user select show_defi...
true
4f58cdbfa6c6e24a07ad1305632cca0e50dfb70b
Ananya31-tkm/PROGRAMMING_LAB_PYTHON
/CO2/CO2-Q1.py
213
4.1875
4
n=int(input("enter number:")) fact=1 if n<0: print("cannot find factorial") elif n==0: print("Factorial is 0") else: for i in range(1,n+1): fact=fact*i print("Fctorial of ",n," is",fact)
true
a22fca2b62384a297e2feea5dbfa57a3dc509313
ArtHouse5/python_progs
/simple_tasks.py
2,303
4.21875
4
#1 print('Create list of 6 numbers and sort it in ascending order') l=[4,23,15,42,16,8] print('The initial list is ',l) l.sort() print(l) print() #2 print('Create dictionary with 5 items int:str and print it pairwise') d = {1 : 'one', 2 : 'two', 3 : 'three', 4 : 'four', 5 : 'five'} print('The initial dictionaty is ',d...
true
d16fca91d7550b7a22417b6730d2d92cde1b217b
annamaryjacob/Python
/OOP/Polymorphism/2str.py
508
4.25
4
class Person(): def setPerson(self,age,name): self.age=age self.name=name def __str__(self): return self.name+str(self.age) ob=Person() ob.setPerson(25,"name") print(ob) #When we give print(ob) we get '<__main__.Person object at 0x7f92fee45ba8>'. This is the method called 2string met...
true
6c048cc77e200c6e6a379addf34afc63bf910e5a
mherr77m/pg2014_herrera
/HW2/HW2_q1.py
1,280
4.3125
4
# !env python # Michael Herrera # 10/18/14 # HW2, Problem 1 # Pass the function two arrays of x,y points and returns # the distance between all the points between the two arrays. import numpy as np def distance(array1,array2): """ Calculates the distance between all points in two arrays. The arrays don't...
true
ac8d4d04a1118995b2aba680aa09472a85a7d92d
nikhitha1997/studentproctor
/proct.py
1,817
4.25
4
#Student procter class Student(): def studentdetails(self): #adding the student details """ Attributes: self.student_name --- name of the student self.usn ---- usn of that perticutar student self.ph_no self.branch----branch of the student_details self.marks---student internal and exte...
false
ca7c7c91bf638b4e18660677fe8fb4f7630c4c01
Neenu1995/CHPC-PYTHON
/bisection_cuberoot.py
322
4.125
4
number = input('Enter the number : ' ) number = float(number) change = 0.00001 low =0.0 high = max(1.0,number) mid = (low+high)/2.0 while (abs(mid**3-number)>=change): if mid**3<number: low = mid else: high = mid mid =(low+high)/2.0 print 'The cube root of ', number ,' is ', mid...
true
236a2cea8c179cb2ce1d4a8c9fe1c53c22ff1226
ggoolsby/CS-101-HW
/graysongoolsby_HW5.py
1,496
4.125
4
# -*- coding: utf-8 -*- """ Created on Tue Mar 14 09:44:07 2017 @author: graygoolsby Name: Grayson Goolsby Date: 03-22-17 Lab: X """ import turtle def binary2decimal(bs): """converts a binary string to a decimal number""" if bs=='': return 0 else: return binary2decimal(bs[:-1])*2+(int...
false
185abd0b12115a2cf3f91ac799fccc664c403a14
LessonsWithAri/textadv
/next.py
1,803
4.15625
4
#!/usr/bin/env python3 INVENTORY = [] room_learning_took_soda = False def room_learning(): global room_learning_took_soda print("You are in room #312. You see a Kellan, a Maria, and a Brooke.") if not room_learning_took_soda: print("There is a can of soda on the table.") print("Exits: DOOR") comma...
true
6a8b4dab5c7639a003dc530cb9d4bf6c5fb5c552
Michaeloye/python-journey
/simp-py-code/Password_Validation_sololearn.py
1,044
4.40625
4
# Password Validation : You are interviewing to join a security team. They want to see you build a password evaluator for your technical interview to validate #the input. #task: Write a program that takes in a string as input and evaluates it as a valid password. The password is valid if it has a minimum 2 numbers, 2 ...
true
9940f0e66b71ed701e9ee4440772a39b4f0d8726
Michaeloye/python-journey
/simp-py-code/Tkinter_trial_DL.py
2,046
4.5625
5
from tkinter import * # Import all definitions from tkinter window = Tk() # Create a window label = Label(window, text = "Welcome to Python") # Create a label button = Button(window, text = "Click Me") # Create a button label.pack() # Place the label in the window button.pack() # Place the button in the window window...
true
338d446f53b76308220122fdd2b1115eaf3906db
Michaeloye/python-journey
/simp-py-code/raise_to_power.py
588
4.40625
4
#raise to power base_num = int(input("Enter the base number: ")) pow_num = int(input("Enter the power number: ")) def raise_to_power(base_num, pow_num): result = 1 for num in range(pow_num): '''since the pow_num is what the base_num will multiply itself by. so pow_num if 3 will cause the code lo...
true
a68f609d435c84d30dc569699894df16d8db9354
Michaeloye/python-journey
/simp-py-code/New_driver's_license_sololearn.py
1,372
4.1875
4
# New Driver's License #You have to get a new driver's license and you show up at the office at the same time as 4 other people. The office says that they will see everyone in #alphabetical order and it takes 20 minutes for them to process each new license. All of the agents are available now and they can each see one...
true
24f8a43e73503662cd2a930ad44a5fe1cb29e16f
Michaeloye/python-journey
/simp-py-code/task21.py
658
4.125
4
# Bob has a strange counter. At the first second t=1, it displays the number 3. At each subsequent second, the number displayed by the counter decrements by 1. # the counter counts down in cycles. In the second after the counter counts down to 1, the number becomes 2 times the initial number for that countdown cycle # ...
true
25b83260765a26cab0ba821ad5b69b5161ffc171
Michaeloye/python-journey
/simp-py-code/task7.py
672
4.1875
4
# Given a string input count all lower case, upper case, digits, and special symbols def findingchars(string): ucharcount = 0 lcharcount = 0 intcount = 0 symcount = 0 for char in string: if char.isupper(): ucharcount+=1 elif char.islower(): lcharcount+=1 ...
true
a802e0447e69c9e42b353305575d0762fcbc3f86
fish-py/PythonImpl
/collections/dict.py
237
4.125
4
dict1 = { "firstName": "Jon", "lastName": "Snow", "age": 33 } """ 遍历dict """ for key in dict1.keys(): print(key) for value in dict1.values(): print(value) for key, value in dict1.items(): print(key, value)
true
45df33b916bb8d19ac17790fb182f14166480437
fish-py/PythonImpl
/collections/sorted_list.py
449
4.1875
4
""" sorted函数可以将一个iterable进行排序 使用的时候我们需要传递一个函数作为排序规则 https://www.runoob.com/python/python-func-sorted.html """ # 自定义排序规则: 按照字符串的长度来排序 def key(item): return len(item) if __name__ == "__main__": list1 = ["Java", "Python", "C", "Go", "C++"] list2 = sorted(list1, key=key) print(list2) # ['C', 'Go',...
false
376948215d3a318897c6f836e31ef5b75a7a87e3
kangic/study
/ds_algo/sorting/insertion.py
374
4.1875
4
# -*- coding: utf-8 -*- def insertion_sort(ar): for i in range(1, len(ar)): idx = i - 1 value = ar[i] while (idx >= 0 and ar[idx] > value): ar[idx + 1] = ar[idx] idx = idx - 1 ar[idx + 1] = value return ar if __name__ == "__main__": changed_ar = inse...
false
e58d6c0bc2831729f65f722de7e4bb30b7291a4b
DanielSouzaBertoldi/codewars-solutions
/Python/7kyu/Isograms/solution.py
508
4.15625
4
# Calculates the ocurrence of every letter of the word. # If it can't find more than one ocurrence for every letter, # then it's an isogram. def is_isogram(string): string = string.lower() for char in string: if string.count(char) > 1: return False return True # That was my first try a...
true
b20046be773df17575d2c87213cc2c55aa70e186
n8951577/scrapy
/factorial.py
253
4.1875
4
def factorial(x): if x == 1: return 1 else: return x * factorial(x - 1) try: n = int(input("enter a number to find the factorial of a digit")) print ("The factorial of n is %d" % factorial(n)) except: print("Invalid")
true
dc0d64d1c54a204ecebbb0a589f354f13447c876
priyanshi1996/Advanced_Python_Course
/Ex_Files_Adv_Python/Exercise Files/04 Collections/defaultdict_finished.py
1,272
4.5
4
# Demonstrate the usage of defaultdict objects from collections import defaultdict def main(): # define a list of items that we want to count fruits = ['apple', 'pear', 'orange', 'banana', 'apple', 'grape', 'banana', 'banana'] fruitCount = {} # Count the elements in the list # This...
true
5af4158a8ff3d270b35e6b6b02332ca3cb82ce43
IfthikarAliA/python
/Beginner/3.py
261
4.125
4
#User input no. of Element a=int(input("Enter the number of Element: ")) #Empty List l=[] #Function to get list of input for i in range(a): l.append(int(input(f"Enter the {i+1} item: "))) #Iterator over a list for i in l: if(i%2==0): print(i)
true
f707d8fc6cf42c70d569c187792d1fa674f17bc0
austindrenski/GEGM-Programming-Meetings
/ProgrammingMeeting1_Python/Example.py
428
4.125
4
class Example: """Represents an example.""" def __init__(self, value): self.value = value def increase_value(self, amount): """Increases the value by the specified amount.""" self.value = self.value + amount return self.value > 0 def __repr__(self): """Returns a...
true
663c8604ccf16d20dd92c597ba4b5f33fd26bb39
austinrhode/SI-Practical-3
/shortest_word.py
488
4.4375
4
""" Write a function that given a list of word, will return a dictionary of the shortest word that begins will each letter of the alphabet. For example, if the list is ["Hello", "hi", "Goodbye", "ant", "apple"] your dictionary would be { h: "Hi", g: "Goodbye", a: "ant" } because those are the shortest wo...
true
0ea757ff04c81a1a53a6cba0275cc12433cc0c36
ikhlestov/computational_geometry
/algorithms/predicates.py
783
4.125
4
from algorithms.primitives import Point, LineSegment def cross_product(u, v): return u.x * v.y - u.y * v.x def points_turn_value(a: Point, b: Point, c: Point) -> float: return cross_product(b - a, c - a) def line_segments_turn_value(l1: LineSegment, l2: LineSegment) -> float: return cross_product(l1.p...
false
3f63aac86bed8b98276e9850fbb00421121d6eae
BridgitA/Week10
/mod3.py
713
4.125
4
maximum_order = 150.00 minimum_order = 5.00 def cheese_program(order_amount): if order_amount.isdigit() == False: print("Enter a numeric value") elif float(order_amount) > maximum_order: print(order_amount, "is more than currently available stock") elif float(order_amount) < minimum_order...
true
f8293c7294cc10da6dab7dfedf7328c865f899fe
michellesanchez-lpsr/class-sampless
/4-2WritingFiles/haikuGenerator.py
794
4.3125
4
# we are writing a program that ask a user for each line of haiku print("Welcome to the Haiku generator!") print("Provide the first line of your haiku:") # create a list to write to my file firstL = raw_input() print(" ") print("Provide the second line of your haiku:") secondL = raw_input() print(" ") print("Provide...
true
9e20d9bab577aba6e39590e3365b56b9325dd32a
michellesanchez-lpsr/class-sampless
/msanchez/university.py
584
4.1875
4
# print statements print(" How many miles away do you live from richmond state?") miles = raw_input() miles = int(miles) #if else and print statements if miles <=30: print("You need atleast 2.5 gpa to get in") else: print("You need atleast 2.0 gpa to get in") print(" What is your gpa?") gpa = float(raw_input()) gpa...
true
5ff742b0b2ec95157cc738b9668d911db3ee6e7e
ceden95/self.py
/temperature.py
445
4.46875
4
#the program convert degrees from F to C and the opposite. temp = input("Insert the temperature you would like to convert(with a 'C' or 'F' mark):") temp_type = temp[-1].upper() temp_number = float(temp[:-1]) C_to_F = str(((9*temp_number)+(160))/5) F_to_C = str((5*temp_number-160)/9) if (temp_type == "C"): pr...
true
76f0e060b29af72dd5420918b10a0b2034073891
ceden95/self.py
/9.3.1.fileFor_listOfSongs.py
2,791
4.34375
4
#the program uses the data of file made from a list of songs details in the following structure: #song name;artist\band name;song length. #the function my_mp3_playlist in the program returns a tuple of the next items: #(name of the longest song, number of songs in the file, the most played artist) def main(): ...
true
266f1eef9643832e942c30fec52406331b26b8ae
ceden95/self.py
/for_loop.py
816
4.3125
4
#the program creates a new list(from the list the user created) of numbers bigger then the number the user choosed. def main(): list1 = input('type a sequence of random numbers devided by the sign ",": ') my_list = list1.split(",") n = int(input("type a number which represent the smallest number in yo...
true
f55a6562de4c30e76723c61ef0a3a60ef178bec2
ceden95/self.py
/shift_left.py
713
4.4375
4
#the program prints the new list of the user when the first item moving to the last on the list. def shift_left(my_list): """the func receives a list, replace the items on the list with the item on the left :param my_list: list from user. :type my_list: list. :return: my_shift_list :rtype: l...
true
a840b3093757889fb34c8aaf13df449ea52dc3d0
ceden95/self.py
/dates_to_days.py
559
4.4375
4
#the program prints back the day of the date the user choosed. date = input(" please write a date which contains dd/mm/yyyy:") dd = int(date[:2]) mm = int(date[3:5]) yyyy = int(date[-4:]) import calendar what_day = calendar.weekday(yyyy, mm, dd) if what_day == 0: print("monday") elif what_day == 1: ...
false
c32e466c8f7004bc5e9b8fd23cfe9714d39cad09
Andrewctrl/Final_project
/Visting_Mom.py
744
4.25
4
import Visting_mom_ending import Getting_help def choice(): print("You get dressed up quicky as you rush out to visit your mom in the hospital. " + "You visit your mom in the hospital, she is doing well. But you have a pile of bills. You get a job working at In-and-Out. Balancing work and school is hard, your grad...
true
ea5a201812b6f4ad9ba49505a53e99bcbf207a42
ar021/control-flow-lab
/exercise-2.py
305
4.15625
4
# exercise-02 Length of Phrase while True: phrase = input('Please enter a word or phrase or "quite" to Exit:') if phrase == 'quite': print('Goodbye') break else: phrase_length = len(phrase) print(f'What you entered is {phrase_length} characters long')
true
d2cc0691e0e05128e98144d19206b7a6f2df3f70
EVgates/VSAproject
/proj02/proj02_02.py
1,100
4.3125
4
# Name: # Date: # proj02_02: Fibonaci Sequence """ Asks a user how many Fibonacci numbers to generate and generates them. The Fibonacci sequence is a sequence of numbers where the next number in the sequence is the sum of the previous two numbers in the sequence. The sequence looks like this: 1, 1, 2, 3, 5, 8, 13....
true
0c6f697432c64e2ff1dfd39192c3e2d5d7938ba9
H0bbyist/hero-rpg
/hero_rpg.py
2,112
4.1875
4
from math import * #!/usr/bin/env python # In this simple RPG game, the hero fights the goblin. He has the options to: # 1. fight goblin # 2. do nothing - in which case the goblin will attack him anyway # 3. flee class Character: def alive(self): if self.health > 0: return True def attack...
true
e2af114dca2a51f5802980c84b596e2e794ae15e
Percapio/Algorithms-and-Data-Structures
/lib/algorithms/quick_sort.py
1,957
4.15625
4
# Quick Sort: # Sort an unsorted array/list by first indexing an element as the pivot point, # check if this index is our target. If not, then check if target is more than # the indexed point. If it is then we check the right half of the list, otherwise # we check the left half. ####################################...
true
b8591c8775413e7a26139e3f362bb8338c6c6a4a
bhandarisudip/learn_python_the_hard_way_book_exercises
/ex7-studydrills.py
1,640
4.46875
4
#exercise 7--study drills #prints a string: 'Mary had a little lamb.' print("Mary had a little lamb.") #prints a string: 'Its fleece was white as snow.' print("Its fleece was white as %s." %'snow') #prints a string: 'And everything that Mary went.' print("And everything that Mary went.") #prints "." ten times prin...
false
48ff5efd50d6150ab8bf1b0e5e30fb7f0bd6e585
bhandarisudip/learn_python_the_hard_way_book_exercises
/ex6-studydrills.py
1,535
4.6875
5
#ex06-study drills #assign a string to x that includes a formatting character, which is then replaced by 10 x = "There are %d types of people."%10 #create a variable, binary, and assign the string "binary" to it binary = 'binary' #assign a new variable a string "don't" to a variable 'do_not' do_not = "don't" #cre...
true