blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
de7cd735d609c6090ad37cc010ca0ee27992ab78
dim4o/python-samples
/dynamic-programming/box_stacking.py
2,675
4.34375
4
def find_max_height(boxes): """ Given boxes of different dimensions, stack them on top of each other to get maximum height such that box on top has strictly less length and width than box under it. For better context see: https://youtu.be/9mod_xRB-O0 This algorithm is actually like "longest increas...
true
5ff36bc06f94a32dab69de7398a305f891db2669
greseam/module5_python_practice_SMG
/Module 5/mod5_hw1_task1_SMG.py
647
4.28125
4
###### # String counter # # Sean Gregor # #desc: count the number of occurances in a string of characters for a specific character ###### def stringCounter(): userString = input("Please enter a string: ") searchChar = input('Enter a charater of this string to know its position: ') charCount = us...
true
7003780f6609399c2a290dcbba2f9a82be060a01
MuhammadYossry/MIT-OCW-6-00sc
/ps1/ps1a.py
1,132
4.53125
5
# A program to calculate and print the credit card balance after one year if a person only pays the # minimum monthly payment required by the credit card company each month. balance = float(raw_input('Enter the outstanding balance on your credit card:')) annual_interest_rate = float(raw_input('Enter the annual credit ...
true
afd25e49906b4dcf0f76a84f2ca098fa6a927693
venilavino/mycode
/palindrome_number.py
235
4.3125
4
num = raw_input("Enter any number: ") rev_num = reversed(num) # check if the string is equal to its reverse if list(num) == list(rev_num): print("Palindrome number") else: print("Not Palindrome number")
true
4a2ff55c0dbfb64e9500f13c939031c6241504f7
pmazgaj/tuition_advanced
/biblioteki/Pozostałe/[1] Dekoratory/zadania/[DEKORATORY] [3] przypadki_użycia.py
1,070
4.25
4
def argument_test_natural_number(f): """ Check, if given number is an integer, and then decorate with it, for factorial operation """ def helper(x): if isinstance(x, int) and x > 0: return f(x) else: raise Exception("Argument is not an integer") return helper @arg...
true
e92fed1a1019b98e68ebcf5c5e4a5a3b3fd529a6
Unkerpaulie/tyrone
/hangman/hangman.py
1,602
4.1875
4
import random import time # create list of words words = ["ADVICE", "BREATHE", "COMPLAIN", "DELIVER", "EXAMPLE", "FORGETFUL", "GRADUATE", "HIBERNATE", "INFERIOR", "JUSTIFY"] # choose a random word from the list word = random.choice(words) chances = 5 letters_guessed = [] letter = "" def clear(): ...
true
f27c46082da7df69872d5d588973a913192d8fd4
haoknowah/OldPythonAssignments
/Gaston_Noah_NKN328_Hwk19/fraction.py
2,117
4.1875
4
class Fraction: def __init__(self, numerator=1, denominator=1, decimal=0.5, numerator2=0, denominator2=0): self.numerator=numerator self.denominator=denominator self.decimal=decimal self.numerator2=numerator2 self.denominator2=denominator2 def simplify(self): ...
true
eea921d913b7fe42cb4cc2c77f3cb3f126a783df
haoknowah/OldPythonAssignments
/Gaston_Noah_NKN328_Hwk18/007_alphabeticalOrder.py
786
4.21875
4
def alphabeticalOrder(L): ''' alphabeticalOrder()=checks to see if input list of letters has letters in abc order @param L=input list ''' try: abc=False if len(L)==1: abc=True elif L[0]<=L[1]: abc=alphabeticalOrder(L[1:]) return abc except: ...
true
842c85348f7e451517ef5b13913fae33edbbb66c
haoknowah/OldPythonAssignments
/Gaston_Noah_nkn328_Hwk04/chapRev#6_lengthConversion.py
1,248
4.46875
4
def lengthConvertion(): ''' converts the units of miles, yards, feet, and inches to kilometers, meters, and centimeters @param m=miles @param y=yards @param f=feet @param i=inches @param ti=total inches @param tmeters=total meters @param km=kilometers @param meters=meters @param cm=centimeters Note the commentary, ...
true
151287d178e0acd653ceb0bcfc9ded9508d04790
singhwarrior/python
/python_samples/python-advance/01_oop/03_polymorphism/02_operator_overloading.py
1,230
4.625
5
# Operator Overloading # There are multiple kinds of operators in Python # For example : +, -, /, * etc. But what happens # behind the scene is there is function called for # every such operator. Like __add__, __sub__, __div__ # __mul__ etc. These are called "Magic Functions". # We can also apply such kinds of oper...
true
78a18efdd547fc5836c16269fd94e612c41337d4
dustinrubin/FiLLIP
/alternatingCharacters/alternatingCharactersDustin.py
417
4.15625
4
#!/bin/python3 # Complete the alternatingCharacters function below. def alternatingCharacters(string): lastCharater = '' deletedCharacters = 0 for charater in string: if not lastCharater: lastCharater = charater continue if lastCharater == charater: delet...
true
4397a6dbfd69f8db91620efcdefb408d4218791a
90sidort/exercises_Python
/domain_Name.py
709
4.25
4
# Description: https://www.codewars.com/kata/514a024011ea4fb54200004b/python # Short task summary: # Write a function that when given a URL as a string, parses out just the domain name and returns it as a string. For example: # domain_name("http://github.com/carbonfive/raygun") == "github" # domain_name("http://...
true
15cd9bee66293582f4ef789cd30527269b7d4a29
90sidort/exercises_Python
/the_Vowel_Code.py
988
4.1875
4
# Description: https://www.codewars.com/kata/53697be005f803751e0015aa # Short task summary: ##Step 1: Create a function called encode() to replace all the lowercase vowels in a given string with numbers according to the following pattern: ## ##a -> 1 ## ##e -> 2 ## ##i -> 3 ## ##o -> 4 ## ##u -> 5 ## ##For example, en...
true
69d051a8ac8a5e58e710f1ce69b527537403abc6
90sidort/exercises_Python
/hydrate.py
952
4.125
4
# Description: https://www.codewars.com/kata/5aee86c5783bb432cd000018/python # Short task summary: ##Welcome to the Codewars Bar! ## ##Codewars Bar recommends you drink 1 glass of water per standard drink so you're not hungover tomorrow morning. ## ##Your fellow coders have bought you several drinks tonight in th...
true
73a57d6fa0dd8ca1ef3e795b4bd95cf07f942355
rodcoelho/python-practice
/archived_problems/amazon_majority_element.py
968
4.1875
4
#!/usr/bin/env python3 # Given an array A of N elements. Find the majority element in the array. A majority element in an array A of size N is an element that appears more than N/2 times in the array. # Output: For each test case the output will be the majority element of the array. Output "-1" if no majority element...
true
3bc230e6df8bf0e597c4958bf9104cb9bc330a50
rodcoelho/python-practice
/archived_problems/amazon_pythagorean_triplet.py
940
4.125
4
#!/usr/bin/env python3 import itertools # Given an array of integers, write a function that returns true if there is a triplet (a, b, c) that satisfies a2 + b2 = c2. # Output: For each testcase, print True or False def bool_py_triplet(s): arr = s.split(" ") arr = [int(x) for x in arr] c2 = {} for i...
true
7ec80a2f8c691162457acc19d2ac9c0c170a859b
rodcoelho/python-practice
/archived_problems/amazon_how_many_x.py
1,396
4.28125
4
#!/usr/bin/env python3 # Given an integer X within the range of 0 to 9, and given two positive integers as upper and lower bounds respectively, find the number of times X occurs as a digit in an integer within the range, excluding the bounds. Print the frequency of occurrence as output. # Input: # The first line of i...
true
2a8cfb68d48ce33c6b19f724ede5390a4d49f08d
rodcoelho/python-practice
/cracking_coding_interview/ch_2/prob_5.py
1,016
4.15625
4
#!/usr/bin/env python3 import unittest from linkedlist import CustomLL """Given a circular linked list, implement an algorithm which returns node at the beginning of the loop.""" class LLLoopDetector: def __init__(self): pass def detect(self, ll): one_step, two_step = ll.head, ll.head while two_step and ...
true
82649227d51d64e935b51ad69a50226991271fc8
rodcoelho/python-practice
/archived_problems/keypad_typing.py
943
4.5
4
#!/usr/bin/env python3 # You are given a string S of alphabet characters and the task is to find its # matching decimal representation as on the shown keypad. # Output the decimal representation corresponding to the string. For ex: if # you are given “amazon” then its corresponding decimal # representation will be...
true
5433490f8d54b2ad207913346ec0d932cd01f14c
rodcoelho/python-practice
/archived_problems/majority_element.py
540
4.21875
4
#!/usr/bin/env python3 # Given an array A of N elements. Find the majority element in the array. # A majority element in an array A of size N is an element that appears # more than N/2 times in the array. def get_majority(nums): for num in nums: if nums.count(num) > len(nums)/2: return num ...
true
fbab0d8a7401c74c927a633cffaf3ed7a7ff9f51
varun531994/Python_bootcamp
/prime.py
202
4.375
4
#Prime numbers: x = int(input("Enter the number:")) if x % 2 == 0 or x % 3 == 0 or x % 5 == 0 or x % 7 == 0: print('Its not a Prime number!!') else: print(f'{x} is a prime number!')
true
74015d2bf08164f68a797dbde1cc600e92a04845
varun531994/Python_bootcamp
/count_prime.py
570
4.3125
4
#Write a function to print out the number of prime numbers that exist upto and including the given number: #0 and 1 are not considered prime def count_primes2(num): primes = [2] x = 3 if num < 2: return 0 while x <= num: for y in primes: if x%y == 0: ...
true
6257bb325f69bf1a4c9299f3d7ea114599eb6f66
Rptiril/pythonCPA-
/chapter-8-pracrtice-set_functions/pr1_greatestOf3.py
296
4.3125
4
# Write a program using the function to find the greatest of three numbers. def greatest(n1,n2,n3): if n1>=n2 and n1>=n3: return n1 elif n2>=n1 and n2>=n3: return n2 else: return n3 print(greatest(3,5,12)) print(greatest(3,55,12)) print(greatest(23,5,12))
true
e84977e22dd05a1ec59ee27b0389e9bf86394ec1
Rptiril/pythonCPA-
/chapter-7-practise_set-loops/pr_Q5_sumofNaturals.py
207
4.21875
4
# Write a program to find the sum of first n natural numbers using a while loop sum = 0 i = 0 last = int(input("Enter the number till sum is wanted : ")) while(i <= last): sum+=i i+=1 print(sum)
true
7b49d6ec8940e105410b31178fac3d06ad027544
Rptiril/pythonCPA-
/chapter-6-practice-set_if_logical/pr_4_len.py
253
4.28125
4
# Write a program to find whether a given username contains less than 10 characters or not. username = input("Enter your username : ") if len(username) < 10: print("username contains less than 10 characters.") else: print("username accepted.")
true
30a1094ba833c3b5bf675709ec9a783b0cd1d627
siddhanthramani/Data-Structures-and-Algorithms
/Using Python/Reading_lines_in_a_file/reading_single_lines.py
1,760
4.4375
4
import turtle def main(): # creates a turtle graphic window to draw in t = turtle.Turtle() # the screen is used at the end of the program screen = t.getscreen() filename = input('Enter name of file to be opened : ') file = open(filename, 'r') for line in file: # print(line) # ...
true
257b0735d0cbc8b15b87002abb0b56dc1dff37db
ManarJN/Automate-the-Boring-Stuff
/ch13_working_with_pdf_and_word/13.1_combine_pdfs.py
831
4.125
4
#! /usr/bin/env python3 # Automate the Boring Stuff # Chapter 13 - Working with PDF and Word # Combine PDFs - Combines all the PDFs in the current working directory # into a single PDF. import os import PyPDF2 # gets all the PDF filenames pdfFiles = [] for filename in os.listdir('.'): if filename....
true
809ab5a8fcad2a8d35e8fa6d171adb125f2459c1
ManarJN/Automate-the-Boring-Stuff
/ch7_pattern_matching_with_regex/7.2_strong_password_detection.py
1,297
4.65625
5
#! /usr/bin/env python3 # Automate the Boring Stuff # Chapter 7- Pattern Matching with Regex # Strong Password Detection - Ensures a password is strong. import re # creates password regex pwLowCase = re.compile(r'[a-z]') # checks for a lowercase letter pwUpCase = re.compile(r'[A-Z]') # checks for an uppercase let...
true
1226e7ac786317695fcaa47a97c0b124308b04f4
harrifeng/leet-in-python
/065_valid_number.py
1,543
4.21875
4
""" Validate if a given string is numeric. Some examples: "0" => true " 0.1 " => true "abc" => false "1 a" => false "2e10" => true Note: It is intended for the problem statement to be ambiguous. You should gather all requirements up front before implementing one. """ import unittest class MyTest(unittest.TestCase): ...
true
9c6bf0b39e3227009d5046396f9367cb5f9e9ec7
olaniyanjoshua/Joshua2
/area_of_a_cylinder_by_Olaniyan_Joshua[1].py
275
4.28125
4
""" This program calculates the area of a cylinder r is the radius of the cylinder h is the height of the cylinder """ r=float(input("Enter the value of r:")) h=float(input("Enter the value of h:")) π=22/7 area=2*π*(r**2)+2*π*r*h print("The area of the cylinder is",area)
true
e2a4f07d0dc2fed12cca426bd5a875edfce1fe15
laboyd001/python-crash-course-ch4
/my_pizza_your_pizza.py
387
4.4375
4
#add a new pizza to the list, add a different pizz to friends list, prove you have two lists pizzas = ['cheese', 'peperoni', 'supreme'] friends_pizzas = pizzas[:] pizzas.append('mushroom') friends_pizzas.append('bbq') print("My favorite pizzas are:") for pizza in pizzas: print(pizza) print("\nMy friends fa...
true
06cb80c8a2f44a1cb955fa474fc74857f43f5012
erjohnyelton/Tkinter-Tutorial
/entry1.py
315
4.125
4
from tkinter import * root = Tk() e = Entry(root, width=50, bd=5) e.pack() e.insert(0, "Enter your name") def myClick(): myLabel = Label(root, text="Hello " + e.get()) myLabel.pack() myButton = Button(root, text = 'Click here', padx = 50, pady = 50, bd=5,command=myClick) myButton.pack() root.mainloop()
true
99b9dc56857d1cec6515dcb1c881219efa28224a
Nicomunster/INF200-2019-Exercises
/src/nicolai_munsterhjelm_ex/ex04/walker.py
1,124
4.1875
4
# -*- coding: utf-8 -*- __author__ = 'Nicolai Munsterhjelm' __email__ = 'nicolai.munsterhjelm@nmbu.no' import random class Walker: def __init__(self, x0, h): self.position = x0 self.home = h self.steps = 0 def move(self): self.position += random.choice((-1, 1)) self....
true
11213be3a997c4ac49923eb3ebd1f0c559339a82
eunnovax/python_algorithms
/binary_tree/linked_list_from_tree.py
1,710
4.15625
4
class BTNode(): def __init__(self, data=0, left = None, right=None): self.left = left self.right = right self.data = data class BinaryTree(): # fills nodes left-to-right using queue def __init__(self, data=0): self.root = BTNode(data) def insert(self, data): if ...
true
eddfb81c30b6cb9e808f60112cfc8ead1d3e86ad
lenablechmann/CS50xPsets
/pset6/readability.py
836
4.21875
4
# Computes the approximate grade level needed to comprehend some text. from cs50 import get_string import re # Prompts user for text input. text = get_string("Enter your text: ") # Counting letters and words. # Found here https://stackoverflow.com/questions/24878174/how-to-count-digits-letters-spaces-for-a-string-in...
true
186f3b8180e6cef24c5e14b53606b265e93af50c
mikeodf/Python_Line_Shape_Color
/ch4_prog_3_repositioned_star_polygon_1.py
2,207
4.28125
4
""" ch4 No.3 Program name: repositioned_star_polygon_1.py Objective: Draw a series of stars each with their own start position. Keywords: polygon, anchor point, star ============================================================================79 Comments:Each separate star is drawn relative to a pair variables, x...
true
ff27021cd885bd28af1946db9cb3e62932f0fdcc
mikeodf/Python_Line_Shape_Color
/ch6_prog_3_text_width_overflow_1.py
1,096
4.5
4
""" ch6 No.3 Program name: text_width_overflow_1.py Objective: Draw text onto the canvas at a chosen location. Keywords: canvas,text ============================================================================79 Comments: The text is written starting at co-ordinate location (x,y) = 200,20. The "width=200" is t...
true
64d5c404615ae84d6cf146c91d07e4e65bc16b82
mikeodf/Python_Line_Shape_Color
/ch1_prog_3_line_styles_1.py
1,511
4.21875
4
""" ch1 No.3 Program name: line_styles_1.py Objective: Four straight lines, different styles on a canvas. Keywords: canvas, line, , color, dashed line, default ============================================================================79 Comments: When drawing lines you MUST specify the start and end points. Dif...
true
5def1bd799b63e16e9fe067bece1fa9b3d35141d
mikeodf/Python_Line_Shape_Color
/ch2_prog_9_rounded_rectangle_1.py
2,454
4.28125
4
""" ch2 No.9 Program name: rounded_rectangle_1.py Objective: Draw a rounded rectangle using similar specifications to a conventionl rectangle. The radius of the corners also needs to be stated. Keywords: arc circle, rounded rectangle. ============================================================================...
true
41da0cf9ef8c68bbdc2f84dfb3d24989f04dd417
parhamafsharnia/AI_search_algorithms_Maze
/Cell.py
663
4.3125
4
class Cell: """A cell in the maze. A maze "Cell" is a point in the grid which may be surrounded by walls to the north, east, south or west. """ def __init__(self, point, n: bool = True, e: bool = True, s: bool = True, w: bool = True): """Initialize the cell at (x,y). At first it is surrou...
true
28fbd5de71b5a0d4d483fb6ec95022a993f67b63
vikanksha/Python-Book-Exercises
/condition_loops_program/median.py
229
4.375
4
# Write a Python program to find the median of three values. val1 = int(input('Enter value 1:')) val2 = int(input('Enter value 2:')) val3 = int(input('Enter value 3:')) if val1 < val2 and val2 < val3: print('median is', val2)
true
884e4a7f77c0482425607c3ce1d4fa1e627213d6
vikanksha/Python-Book-Exercises
/devu_program/list_name.py
249
4.28125
4
# Write a program to return a list of all the names before a specified name. list_of_names = eval(input(" ")) speci_name = input(" ") list = [] for i in list_of_names: if i == speci_name: break list_of_names.append(i) print(list)
true
e40638d4b9cec1d2f668f3a1a32870e0fd315e36
vikanksha/Python-Book-Exercises
/chap3/ex1.py
406
4.25
4
# temp conversion choice = eval(input("Enter selection")) while choice !="F" and choice != "C": temp = int(input("enter temp to convert")) if choice == "F": converted_temp = (temp-32)*5/9 print(temp , "degree fahrenheit is equal to" , converted_temp, "degree celcius") else: converted_temp = (9/5*temp)+3...
true
2d087f0ac71902d13bcb45ec60dd6fb67108e7da
vikanksha/Python-Book-Exercises
/condition_loops_program/days_no.py
510
4.46875
4
# Write a Python program to convert month name to a number of days. print("list of month : January, February, March, April, May, June, July, August, September, October, November, December") Month = input("Enter month name :") if Month == "Februrary": print("no of days 28/29") elif Month in ("January" , "March", "Ma...
true
2793480aa76bb6f501a940ab321ce9c18d182579
af0262/week9
/bubble_sort2.py
627
4.375
4
import random def sort(items): # 1. TO DO: Implement a "bubble sort" routine here for outer in range(len(items)): for inner in range(len(items)-1-outer): if items[inner] > items[inner+1]: items[inner], items[inner+1] = items[inner+1], items[inner] # Swap! return items ...
true
705ab198790777f50fbf874d7beff92f974c7c43
juliaguida/learning_python
/week5/function_add.py
289
4.125
4
# Write a program that takes 2 numbers as arguments to a function and returns the sum of those 2 numbers def add_func(number1,number2): return number1 + number2 numb1 = int(input('Enter a number: ')) numb2 = int(input('Enter another: ')) result = add_func(numb1,numb2) print(result)
true
b9691374f143af16f1cdc6065a7d727f09b16964
juliaguida/learning_python
/week4/choose_a_side.py
385
4.28125
4
import turtle def shape(number_of_sides,side_length): angle = 360/number_of_sides for i in range(number_of_sides): turtle.forward(side_length) turtle.right(angle) turtle.done() number_of_sides = int(input('Please input the numbers of side: ')) side_length = int(input('Please ...
true
eec05c50c073b60c0bf7d04b046c3501e33580ff
juliaguida/learning_python
/homework.py/week8/check_numb.py
235
4.6875
5
# This code checks if a number is positive or negative number = float(input('Please enter a number to check if it is negative or positive.')) if number > 0: print('The input is positive') else: print( 'This input is negative')
true
4c79e7f0179e3220a55ec56c15845cb283abf844
wafarifki/Hacktoberfest2021
/Python/linked_list_reverse.py
853
4.1875
4
class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None # Head of list def reverse(self, head): if head is None or head.next is None: return head rest = self.reverse(head.next) head.next.next = head head.next = None return...
true
f5e60e6364aa94698b52f6bf9faf42cda94f19e7
franktank/py-practice
/fb/hard/145-binary-tree-postorder-traversal.py
1,324
4.125
4
""" Given a binary tree, return the postorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [3,2,1]. Note: Recursive solution is trivial, could you do it iteratively? """ # Definition for a binary tree node. # class TreeNode(object): # def __init__(s...
true
6fb49004c5a722c118e6ac007c4b58945f169f01
Selva0810/python-learn
/string_to_integer.py
2,814
4.25
4
''' String to Integer (atoi) Solution Implement atoi which converts a string to an integer. The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting from this character takes an optional initial plus or minus sign followed by as many nu...
true
3e818dbefab6bd432a04a9fa1332ef0aaa44ad70
asadiqbalkhan/shinanigan
/Games/guess.py
1,404
4.34375
4
# This is a guess the random number game # import random function # Author: Asad Iqbal # Language: python 3 # Date: 18 - June - 2017 import random # variable to store the total guesses done by the player guesses_taken = 0 # Display welcome message to the player # Input required by the player at this stage to proceed ...
true
7d770f3d71e16201a74e82b07fe793ca00679139
JunboChen94/Leetcode
/junbo/LC_173.py
1,378
4.125
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class BSTIterator: ''' Based on inorder ''' def __init__(self, root: TreeNode): self.stack = [] ...
true
b1fac02cb617d774d738774769c6a836fc15607c
smkrishnan22/python-basics-to-ml
/language/Product.py
753
4.375
4
''' class Product: # Default Constructor. def __init__(self): self.productid = 10 self.productname = "Ashok" _instance = Product() print(_instance.productid) ''' class Product: # This is Constructor. # We can have only one constructor in Python. def __init__(self, ids, name...
true
d9f51fbaf3cf11226bf18110aa04a79c3be58883
jyotsanaaa/Python_Programs
/find_lcm.py
341
4.21875
4
#Find LCM #LCM Formula = (x*y)//gcd(x,y) num1 = int(input("Enter lower num : ")) num2 = int(input("Enter greater num : ")) #To find GCD def gcd(x,y): while(y): x,y = y, x%y return x #To find LCM def lcm(a,b): lcm = (a*b)//gcd(a,b) return lcm print(f"LCM of {num1} and {num2} ...
true
3460833f74721665e81bd89924e6fcd2e33691df
jyotsanaaa/Python_Programs
/conversion.py
237
4.34375
4
#Convert decimal to binary, octal and hexadecimal num = int(input("Enter number in decimal : ")) print(f"\nConversion of {num} Decimal to :- ") print("Binary :",bin(num)) print("Octal :",oct(num)) print("Hexadecimal :",hex(num))
true
39a1712a4f8f9e2e3ed646a1e45fe209f34d3457
jyotsanaaa/Python_Programs
/armstrong_num.py
588
4.21875
4
#Armstrong Number """An Armstrong number is an n-digit base b number such that the sum of its (base b) digits raised to the power n is the number itself. Eg: 407 is sum of cube of three num i.e.4,0,7 && 1634 is sum of ^4 of 4 num i.e.1,6,3,4""" #import math n = int(input("Enter number : ")) order = len(str(n)) #order ...
true
b659bb7fa3f753e538e21d80c5708e24a877df7d
Anvitha-N/My-Python-Codes
/assign list.py
402
4.4375
4
#Assigning elements to different lists: animals = ["dog","monkey","elephant","giraffee"] print(animals) #replace animals[1] = "chrocodile" print(animals) #insert animals.insert(2,"squirrel") print(animals) #sort animals.sort() print(animals) #delete del animals[0] print(animals) #append animal...
true
1aba9eba32f19c6c6cf27ad8bd7ad508a36623cc
aniqmakhani/PythonTraining
/Assignment3.py
1,716
4.1875
4
# Question No: 01 Write a Solution to reverse every alternate k characters from a # string. Ex. k = 2 , Input_str ="abcdefg", Output_str = bacdfeg" print("Question 1: ") Input_str = input("Enter a string: ") k = int(input("Enter a value for k: ")) inp = list(Input_str) for i in range(0,len(inp),k+2): if i+1 < len(...
true
9e9d2b081559d045b18042e00fa8f2cb93ec737d
venkat79/java-python
/python/src/main/python/testscripts-master/inner/couple.py
1,016
4.5
4
''' Consider the following sequence of string manipulations - abccba abccba - "cc" is a couple as both appear together. Remove the couple from the string and count as "1 couple" abba - Resulting string after removing the couple abba - Now "bb" is a couple. Remove the couple from the string and increment the count to 2...
true
b4396c661758a357af1ce8df15fffe7cc527e0a4
JiteshCR7/Python_Lab
/lab2.py
2,537
4.125
4
Python 3.7.3 (default, Apr 3 2019, 05:39:12) [GCC 8.3.0] on linux Type "help", "copyright", "credits" or "license()" for more information. >>> 2**5 32 >>> a=20 >>> b=30 >>> c=a+b >>> c 50 >>> a=input("enter value of a;") enter value of a;20 >>> b=input("enter value of b;") enter value of b;30 >>> c=a+b >>> c '2030' >...
true
857a992f5c12f1730f642e0f3682746df4dabb19
abhiramvenugopal/vscode
/Spoj_test/String_Rotation.py
493
4.15625
4
def isSubstring(s1, s2): if s1.find(s2) != -1: return True if s2.find(s1) != -1: return True return False ## Do not change anything above def isRotation(s1,s2): s1s1=s1+s1 print(isSubstring(s2,s1s1)) ## You can only call isSubstring function from this function once. Use this fu...
true
b434bbb41e4676059a29526d553ffab35cb337aa
abhiramvenugopal/vscode
/5-26-2021/even_odd_seperator.py
616
4.28125
4
# Write a function with name even_odd_separator, you should exactly the same name # This even_odd_separator functions should take a list of integers and return a list # you can start from here def even_odd_separator(numbers): odd_list=[] even_list=[] for i in numbers: if i%2==0: even_li...
true
4435d655b68aa16413b065fcfcb71e78fdebd920
abhiramvenugopal/vscode
/5-16-2021/int_palindrome.py
384
4.125
4
# Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward # Input # 1 containing integer # Output # 1 line containing Boolean value # Example # Input: 121 # Output: True # Input: 10 # Output: False # ----------------------------------------------------...
true
771febd6086b7ad67fa38173fb1be2b77c08fb47
abhiramvenugopal/vscode
/special/odd_even_or_one_zero_subset.py
1,094
4.28125
4
# You are given an array A of N positive integer values. A subarray of this array is called Odd-Even subarray if the number of odd integers in this subarray is equal to the number of even integers in this subarray. # Find the number of Odd-Even subarrays for the given array. # Input # The input consists of two lines....
true
a30f89daa5285607b61fe43398259de765d1ba61
nfredrik/pyjunk
/regexps/notmatch.py
442
4.3125
4
import re # #I'm looking for a regular expression that will match all strings EXCEPT those that contain # a certain string within. Can someone help me construct it? #For example, looking for all strings that do not have a, b, and c in them in that order. #So #abasfaf3 would match, whereas #asasdfbasc would not r = r...
true
81a86c2aa78e6ed3f85d3d8a842548b99c0fe19a
CodaGott/introtopythonforcomputerscienceanddatascienceexercises
/Chapter_two_exercises/Exercise2.2.py
495
4.15625
4
""" (What’s wrong with this code?) The following code should read an integer into the variable rating: rating = input('Enter an integer rating between 1 and 10') """ rating = input('Enter an integer rating between 1 and 10') """ The above code can be casted on declaration or casted at calculation to cas...
true
2c64537f7f567b2dc9dda6f18049aad51798a4cc
CodaGott/introtopythonforcomputerscienceanddatascienceexercises
/Chapter_two_exercises/ChapterOneExercises.py
460
4.53125
5
""" (What does this code do?) Create the variables x = 2 and y = 3, then determine what each of the following statements displays: a) print('x =', x) b) print('Value of', x, '+', x, 'is', (x + x)) c) print('x =') d) print((x + y), '=', (y + x)) """ x = 2 y = 3 print('x=', x) #this will print 2 print('Value of', x, '+...
true
20549ee8b2bd75ddb1542eac4b074b2e94bafdc4
gordonmannen/The-Tech-Academy-Course-Work
/Python/Python 3 Essential Training - Py3.5.1/GettingStarted.py
2,247
4.125
4
print("Hello, World!") a, b = 0, 1 if a < b: print('a ({}) is less than b ({})'.format(a, b)) else: print('a ({}) is not less than b ({})'.format(a, b)) a, b = 5, 1 if a < b: print('a ({}) is less than b ({})'.format(a, b)) else: print('a ({}) is not less than b ({})'.format(a, b)) # blocks are call...
true
cb34d3c7a7399b0f513fb090182eef540f89adb8
Menelisi-collab/Classes-exercise
/izibalo.py
532
4.125
4
def task(self): a = int(input("Enter a Number: ")) b = int(input("Enter another Number: ")) total = (a + b) or (a - b) or (a * b) or (a / b) if total == (a + b): print(f"The added result is: {total}") elif total == (a - b): print(f"The subtracted result is: {total}") elif total ...
true
9ed540608eca140a8697e457b03b38d4095fe363
lakshay451/Deep-Neural-Networks-with-PyTorch
/Week 1/2_D Tensors.py
2,461
4.4375
4
# -*- coding: utf-8 -*- """ 2-D Tensors """ """ A 2d tensor can be viewed as a container the holds numerical values of the same type. In 2D tensors are essentially a matrix. Each row is a different sample and each column is a feature or attribute. We can also represent gray-scale images as 2D tensors. ...
true
afef11b98745fda79c08dfeada6308919b6f4e54
yerimJu/crawling_examples
/src/using_DB/sqlite3_test.py
604
4.46875
4
import sqlite3 # standard library for Python DB_PATH = 'test.sqlite' conn = sqlite3.connect(DB_PATH) cur = conn.cursor() cur.executescript(''' DROP TABLE IF EXISTS items; CREATE TABLE items( item_id INTEGER PRIMARY KEY, name TEXT UNIQUE, price INTEGER ); INSERT INTO items(name, price) VALUES ('Apple', 8...
true
7bc6de20ac5d4841019ad7c2917ea9750367f668
garciagenrique/template_project_escape
/template_project_escape/code_template_escape.py
1,213
4.15625
4
# -*- coding: utf-8 -*- # Template module with an example for the ESCAPE project import numpy as np import argparse def square_number(number): """ Function that returns the square of the input number. Parameters: ----------- number: int or float Number to square. Returns: ...
true
469bf83faa1aab82227c840113430b0b92437367
rebeccaAhirsch/frc-hw-submissions
/lesson5/hw_5.py
262
4.21875
4
words = ["red", "blue", "green", "purple", "magenta", "great", "wonderful", "yay!", "koala", "hi"] anything = raw_input("what's your favorite word?") if (anything in words) == True: print "i like that word too" else: words.append(anything) print words
true
56f8ba5742d98072231765d565a7a7d479c875b1
Ivanlxw/Exercises
/Mega Project LIst/Numbers/MortgageCalculator.py
2,426
4.34375
4
def calculate_payment(): """ Calculate the monthly payments of a fixed term mortgage over Nth terms at a given interest rate. Extra: add an option for users to select the compounding interval (Monthly, Weekly, Daily, Continually). """ interval = int(input("Select compounding interval:\n1.Monthly\n2...
true
89e882d4aae56b3c457f1398e4e775d1f5fc6220
yudianzhiyu/Notebook
/mystuff/ex30.py
446
4.15625
4
#!/usr/bin/python people = 30 cars = 40 buses = 15 if cars > people: print "we should take the cars." elif cars < people: print " we shoule not take the cars." else: print " we can't decide." if buses> cars: print "that's too many buses." elif buses<cars: print "may be we could take buses." else: print "we stil...
true
71ae734bbe1057377b22c9b5bf06ecfa649eee5d
silvesterriley/hello--world
/code.py
736
4.1875
4
message="hello python" print(message) #variables to hold my names firstname="Silvester" middlename="Muthiri" lastname="Marubu" Age=24 #i want to print my details print("My first name is", firstname) print("My middle name is" ,middlename) print("My last name is" ,lastname) print(Age,"years old") #p...
true
1081929f35684cb77485cbd588643048a6c142ae
sofide/ds_dices
/ds_dices.py
1,463
4.28125
4
black_dice = [0, 1, 1, 1, 2, 2] blue_dice = [1, 1, 2, 2, 2, 3] orange_dice = [1, 2, 2, 3, 3, 4] def convert_string_to_dict_dices(string_input): dices_str_list = string_input.split() if not dices_str_list: raise ValueError() try: dices_int_list = [int(n) for n in dices_str_list] excep...
true
730c640969690b391503c4446314d4a5148f787a
mxu007/daily_coding_problem_practice
/DCP_10_1.py
2,195
4.15625
4
# Determine if a cycle exists # Given an UNDIRECTED graph, determine if it contains a cycle # implement the solution using depth-first search. For each vertex in the graph, if it has not already been visited. we call our search function on it. This function will recursively traverse unvisited neighbors of the vertex a...
true
ec4f6c3dc4159ec63b7535f4bd9cd8696d811a6b
mxu007/daily_coding_problem_practice
/DCP_7_2.py
864
4.1875
4
# Given a sorted array, convert it into a height-balanced binary search tree # As asked for a height-balanced tree, we have to pick the middle value in the sorted array to be the root class Node: def __init__(self, data, left=None, right =None): self.data = data self.left = left self.right...
true
eaac00d6251b9da52cc54f0b2bde44f63b36a5db
mxu007/daily_coding_problem_practice
/DCP_1_2.py
2,088
4.15625
4
# Given an array of integers that are out of order, dtermine the bounds of the smallest window that must be sorted in order for the entire array to be sorted. # Example Input: [3,7,5,6,9], Sorted Input: [3,5,6,7,9] # Output: (1,3) # Example Input: [1,5,2,3,8,6,7,9] # Output: (1, 6) # use python built-in sort functio...
true
a268bd67d22631549b68cf6d40c59bda9b5b62ec
PBNSan/Python-Code-Samples
/building_sets.py
472
4.125
4
squares = set() # todo: populate "squares" with the set of all of the integers less # than 2000 that are square numbers # Note: If you want to call the nearest_square function, you must define # the function on a line before you call it. Feel free to move this code up! def nearest_square(limit): answ...
true
fdc53ef4c37d355099124759f0c888fb077baeb6
Bes0n/python2-codecademy
/projects/area_calculator.py
920
4.375
4
""" Area Calculator Python is especially useful for doing math and can be used to automate many calculations. In this project, we'll create a calculator that can compute the area of the following shapes: Circle Triangle The program should do the following: Prompt the user to select a shape. Calcula...
true
32cdc29f0c982373cb97107bafb3d9f0d1a16923
althafuddin/python
/Python_Teaching/introduction/addition.py
424
4.25
4
def calc_addition(int_a,int_b): """ Add the given two numbers """ try: print (int(int_a) + int(int_b)) except ValueError: print('You have to enter integers only!') while True: number_1 = input("Enter your first number: ") number_2 = input("Enter your second number: ") if (numbe...
true
e3c048c7444db6c50ada2f4ed8b4f2291e517443
Divya-vemula/methodsresponse
/strings/dict.py
699
4.59375
5
# Creating, accessing and modifying a dictionary. # create and print an empty dictionary emptyDictionary = {} print("The value of emptyDictionary is:", emptyDictionary) # create and print a dictionary with initial values grades = {"John": 87, "Steve": 76, "Laura": 92, "Edwin": 89} print("\nAll grades:", grades) # acces...
true
4e52a490ec4ac9b4b8f07bda697464cd41a0476b
puthalalitha/calculator
/calculator.py
1,990
4.3125
4
"""A prefix-notation calculator. Using the arithmetic.py file from Calculator Part 1, create the calculator program yourself in this file. """ from arithmetic import * # Your code goes here # No setup # repeat forever: # read input # tokenize input # if the first token is "q": # quit # else:...
true
c13188089e7d5e6d3359d5f8642befcdfb2f1aed
Tarajit-Singh/python-lab-programs-
/5.1)experiment.py
475
4.4375
4
""" 5.1) Implement a python script to count frequency of characters in a given string. """ s=input("enter the string") result = {} for letter in s: if letter not in result: result[letter.lower()] = 1 else: result[letter.lower()] += 1 print("count frequency of characters in given string:",res...
true
130500eda364a84fa4398a12cd625bf5a832c4a1
chasebleyl/ctci
/data-structures/interview-questions/arrays_and_strings/1_6.py
1,808
4.125
4
# String Compression: Implement a method to perform basic string compression using the counts of repeated characters. For example, the string aabcccccaaa would become a2blc5a3. If the "compressed" string would not become smaller than the original string, your method should return the original string. You can assume the...
true
eaa2834a381ad0a864cb9b5433d429ee183e0347
osluocra/pachito_python
/code/s04/RosetteGoneWild.py
457
4.15625
4
# RosetteGoneWild.py import turtle t = turtle.Pen() turtle.bgcolor('black') t.speed(0) t.width(3) # Ask the user for the number of circles in their rosette, default to 6 number_of_circles = int(turtle.numinput("Number of circles", "How many circles in your rosette?", 6)) color_of...
true
0d764e769012d326598de8bdeb714a665cda1354
sophiebuckley/cipher-project
/vigenerecipher.py
2,035
4.625
5
#A function which performs the Vigenere encryption algorithm on an input phrase. key = raw_input("Please enter the keyword that you would like to use for your encryption: ") message = raw_input("Please enter the message that you would like to encrypt: ") def encrypt_vigenere(key, plaintext): return vigenere_calc...
true
d2ad9df2d675da2a918b47c296940014d44dfaaf
Keegan-Cruickshank/CP1404
/prac_05/word_counter.py
557
4.5625
5
""" Simple application to display the frequency of all words from a users input. """ text_input = input("Text: ") word_count_dict = {} word_list = text_input.split(" ") for word in word_list: if word.lower() in word_count_dict: word_count_dict[word.lower()] += 1 else: word_count_dict[word.lowe...
true
fde1d6e88a167908ec38df2789a956294f4a8c92
CristinaHG/python-Django
/python-Django/ExampleCourse/HelloWord.py
1,072
4.3125
4
# -*- coding: utf-8 -*- print ("Hello World") #collections and comments #List fruits=['Banana','Strawberry','Apple','Grapes'] print(fruits[0]) print(fruits[-1]) print(fruits[-3]) #List slicing numbers=[0,1,2,3,4,5,6,7,8,9,10] from_2to7=numbers[2:7] print from_2to7 geatherThan3=numbers[3:] print geatherThan3 pairsNum...
true
f637759e6ebeac0ecc1bbb261f036568edad91d5
adebudev/holbertonschool-higher_level_programming
/0x0B-python-input_output/0-read_file.py
275
4.21875
4
#!/usr/bin/python3 """ function that reads a text file """ def read_file(filename=""): """ read_file - Read a text file filename - Name of a File """ with open(filename, mode="r", encoding="utf-8") as file_open: print(file_open.read(), end='')
true
d5c8046b9e8fa70ac2a690981311d8f29c89315c
heyjohnnie/MVA-Introduction-to-Python
/ShortStory/ShortStory/ShortStory/ShortStory.py
792
4.4375
4
#This program creates a short story based on user's input #Welcome message print("Welcome to Story Teller v1.0") print("Let's create a short story where you'll be the main character!") print("First, we need some info about you") #Getting data and making sure to correct the input firstName = " " firstName = input("Wha...
true
7256cea75dbad959fe52a797fa503fa3640b3c1e
mjruttenberg/battleships
/battleships_py3.py
1,416
4.15625
4
from random import randint # create and populate the board board = [] for x in range(5): board.append(["O"] * 5) # convert the board to space delimited and print the board def print_board(board): for row in board: print(" ".join(row)) print_board(board) # create the battleship X and Y axis position...
true
492ad5738e83acdf1f4427af015eb9f95b3e597c
lion137/Functional---Python
/trees.py
1,193
4.21875
4
# define an abstract data - binary tree - pairs and functional abstraction from functional_tools_python.immutable_lists import * def construct_tree(val, left, right): """constructs a tree as a List, holds as a first elem a value in a node, second and third elements are left, right branches (also trees)"""...
true
b520e97e73dd7cd2b9798ad22e3c6740286b913a
JustinDudley/Rubiks-Cube-One
/string_to_list.py
1,239
4.4375
4
# This module takes a Rubik's Cube algorithm, perhaps inputed by a user, and # converts it to a list, so that it can be manipulated by other programs as a list def convert_to_list(alg_stri): # Takes a string and converts it to a list, for better functionality in manipulation by other programs. # This function assum...
true
dc7235719a4d37ae8dd3fff65023a67fa644d9a3
Adam-Davey/cp1404_pracs
/prac_05/color_names.py
497
4.21875
4
COLOR_NAMES = {"turquoise": "#40e0d0", "yellowgreen": "#9acd32", "salmon": "#fa8072", "saddlebrown": "#8b4513"} color_length = max([len(color) for color in COLOR_NAMES]) for color in COLOR_NAMES: print("{:{}} is {}".format(color, (color_length), COLOR_NAMES[color])) color = input("enter a color").lower() while c...
true
eb39963bd2f6cec6467103bc8be21bff19c1e762
romannocry/python
/comparison.py
535
4.4375
4
# Python3 code to demonstrate # set difference in dictionary list # using list comprehension # initializing list test_list1 = ['ro','ma'] test_list2 = ['ro','man'] # printing original lists print ("The original list 1 is : " + str(test_list1)) print ("The original list 2 is : " + str(test_li...
true
d5fa47b98d799059ac50cd3cdd6a4df0ca6c4f41
reyllama/leetcode
/Python/C240.py
1,603
4.125
4
""" 240. Search a 2D Matrix II Write an efficient algorithm that searches for a target value in an m x n integer matrix. The matrix has the following properties: Integers in each row are sorted in ascending from left to right. Integers in each column are sorted in ascending from top to bottom. """ class Solution(obj...
true