blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
4efffd09c623ecf7c64ef4c4e1bac18dc2ec8af5
harris44/PythonMaterial
/02_Advanced/algorithms_and_data_structures/01_Guessing_Game_with_Stupid_search.py
1,272
4.25
4
#!/usr/bin/python # -*- coding: utf-8 -*- from random import randrange """ Purpose: Stupid Search. In a list of numbers, user guesses a number. if it is correct, all is good. Else, next time, he/she will guess among the unguessed numbers. """ __author__ = "Udhay Prakash Pethakamsetty" list_of_numbers = range(10,...
true
854b44a67d155c0c901d010a3e7ed5fc3735761a
liboyue/BOOM
/examples/BioASQ/extra_modules/bioasq/Tiler.py
671
4.3125
4
import abc from abc import abstractmethod ''' @Author: Khyathi Raghavi Chandu @Date: October 17 2017 This code contains the abstract class for Tiler. ''' ''' This is an Abstract class that serves as a template for implementations for tiling sentences. Currently there is only one technique implemented which is simpl...
true
9c86c21e8546fd8bde9a8b41187fd54e6c25b538
BumShubham/assignments-AcadView
/assignment8.py
1,591
4.46875
4
#Q1 #What is time tuple ''' Many of Python's time functions handle time as a tuple of 9 numbers, as shown below − Index Field Domain of Values 0 Year (4 digits) Ex.- 1995 1 Month 1 to 12 2 Day 1 to 31 3 Hour 0 to 23 4 Minute 0 to 59 5 Second 0 to 61 (60/61 are leap seconds) 6 Day of Week 0 to 6 (Monday to Sunday) 7 Day...
true
8dfe63e954810cead138b81ef4c5fdf813cf224e
ShahrukhSharif/Applied_AI_Course
/Fundamental of Programming/python Intro/Prime_Number_Prg.py
364
4.125
4
# Wap to find Prime Number ''' num = 10 10/2,3,4,5 ---> Number is not pN OW PN ''' num = int(input("Input the Number")) is_devisible = False for i in range(2,num): if(num%i==0): is_devisible = True break if is_devisible is True: print("Number is Not Prime {}".format(num)) else: pri...
true
612ace04b4af232ecc5408a2c92f06620e75a17b
kitsuyui/dict_zip
/dict_zip/__init__.py
2,086
4.375
4
"""dict_zip This module provides a function that concatenates dictionaries. Like the zip function for lists, it concatenates dictionaries. Example: >>> from dict_zip import dict_zip >>> dict_zip({'a': 1, 'b': 2}, {'a': 3, 'b': 4}) {'a': (1, 3), 'b': (2, 4)} >>> from dict_zip import dict_zip_longest ...
true
5afd548624578e174b04bec5374c778e1bbed79f
dbwebb-se/python-slides
/oopython/example_code/vt23/kmom04/a_module.py
1,048
4.15625
4
""" How to mock function in a module. In a unit test we dont want to actually read a file so we will mock the read_file_content() function. But still test get_number_of_line_in_file(). """ def get_number_of_line_in_file(): """ Return how many lines exist in a file """ content = read_file_content() n...
true
7bc58f3621d6e04206543d4b556929e56b1c3b0f
dbwebb-se/python-slides
/oopython/example_code/vt23/kmom03/get_post_ok/src/guess_game.py
1,766
4.21875
4
#!/usr/bin/env python3 """ Main class for the guessing game """ import random from src.guess import Guess class GuessGame: """ Holds info for playing a guessing game """ def __init__(self, correct_value=None, guesses=None): if correct_value is not None: self._correct_value = correct...
true
9902a96d8649184b27bafe7835742d13bcec0f07
yyyuaaaan/python7th
/crk/8.4subsets.py
1,655
4.25
4
"""__author__ = 'anyu' 9.4 Write a method to return all subsets of a set. gives us 2" subsets.We will therefore not be able to do better than 0(2") in time or space complexity. The subsets of {a^ a2, ..., an} are also called the powerset, P({aj, a2, ..., an}),or just P(n). This solution will be 0(2n) in time and space,...
true
c2ffda55f905b9d0bc11dd1cff64761490722eb0
yyyuaaaan/python7th
/crk/4.4.py
1,547
4.125
4
"""__author__ = 'anyu' Implement a function to check if a tree is balanced. For the purposes of this question, a balanced tree is defined to be a tree such that the heights of the two subtrees of any # this is so called AVL-tree node never differ by more than one. """ class Node(object): def __init__(self): ...
true
b5e756f9eec761edbd58127e9ad66d9d0ec3dae5
tnguyenswe/CS20-Assignments
/Variables And Calculations (2)/Nguyen_Thomas_daylight.py
1,071
4.28125
4
''' Name: Thomas Nguyen Date: 1/6/20 Professor: Henry Estrada Assignment: Variables and Calculations (2) This program takes the latitude and day of the year and calculates the minutes of sunshine for the day. ''' #Import math module import math #Gets input from user latitude = float(input("Enter latitude in degrees: "...
true
722b1e1ca439affec2aed8d27f674f281ebc36bb
gg/integer_encoding
/src/integer_encoding.py
1,339
4.34375
4
#!/usr/bin/env python # coding: utf-8 from collections import deque def encoder(alphabet): """ Returns an encoder that encodes a positive integer into a base-`len(alphabet)` sequence of alphabet elements. `alphabet`: a list of hashable elements used to encode an integer; i.e. `'0123456789'` is an...
true
273d638b3c2b9ea9bc8e8b32e59f8c45e61e7ef5
sassy27/DAY1
/OOP/Class instance.py
781
4.125
4
class employees: raised_amount = 1.04 num_emp = 0 def __init__(self,first,last,pay): self.first = first self.last = last self.pay = pay employees.num_emp += 1 # prints number of employees by adding after each emp created def fullname(self): return "{} {}". form...
true
4589928fdb9ae81e9d9d23b509b30a61539ebd8e
rohitx/Zelle-Python-Solutions
/Chapter2/question1.py
289
4.125
4
print "This program takes Celsius temperature as user \ input and outputs temperature in Fahrenheit" def main(): celsius = input("What is the Celsius temperature?") fahrenheit = (9/5.) * celsius + 32 print "The temperature is", fahrenheit, "degrees Fahrenheit." main()
true
7bcdb4a3550071c4ff668aa0f7977a1aad65ad16
rohitx/Zelle-Python-Solutions
/Chapter3/question1.py
349
4.25
4
import math print "This program computes the Volume and Surface of a sphere\ for a user-specified radius." def main(): radius = float(raw_input("Please enter a radius: ")) volume = (4/3.) * (math.pi * radius**3) surface = 4 * math.pi * radius**2 print "The Volume is: ", volume print "The S...
true
ca20faf4e6b8365bcbffe5f3fe94ce0c1d07c239
PeterParkSW/User-Logins
/UserLogins.py
1,525
4.4375
4
#dictionary containing paired usernames and passwords that have been created #keys are usernames, values are passwords credentials = {} #asks user for a new username and password to sign up and put into credentials dictionary def signup(): new_user = input('Please enter a username you would like to use: ') whi...
true
d5441ca9d8a467482c1341852a04c893850c10b5
KhoobBabe/math-expression-calculator
/mathmatical expression calculator.py
1,629
4.1875
4
import warnings print('Enter a mathematical expression to view its result') #we put a while to cotinously prompt the yser to input expressions cond = True while cond is True: #this ignores other warnings warnings.simplefilter('ignore') #input is taken here a = input("\nEnter a mathematical...
true
0a0e377ff207f57bafb2cd622c772080d4559fe4
AvyanshKatiyar/megapython
/app4/app4_code/backend.py
2,190
4.3125
4
import sqlite3 def connect(): conn=sqlite3.connect("books.db") cur=conn.cursor() cur.execute("CREATE TABLE IF NOT EXISTS book (id INTEGER PRIMARY KEY, title text, author text, year integer, isbn integer)") conn.commit() conn.close() #id checks how many entries def insert(title, author, ye...
true
eb740ea5b08d9f8b1cec289512d993ec5093ea42
AvyanshKatiyar/megapython
/Not_app_code/the_basics/forloops.py
889
4.1875
4
monday_temperatures=[9.1, 9.7, 7.6] #rounding print(round(monday_temperatures[0])) for temperature in monday_temperatures: print(round(temperature)) #loop goes through all the variables #looping through a dictionary student_grades={"Marry": 9.1, "Sim": 8.8, "John": 7.5} #chose what you want to iterate o...
true
cecf188d0a3425dbc83dac4b9caf56f1f428b4d2
meetashwin/python-play
/basic/countsetbits.py
392
4.5
4
# Program to count the set bits in an integer # Examples: # n=6, binary=110 => Set bits = 2 (number of 1's) # n=12, binary=1100 => Set bits = 2 # n=7, binary=111 => Set bits = 3 def countsetbits(n): count = 0 while(n): count += n & 1 n >>= 1 return count print("Enter the number to find set bits for:") n = ...
true
6b674887d7d590d12016e60aed03cce67d284b9d
remcous/Python-Crash-Course
/Ch04/squares.py
452
4.5625
5
#initialize an empty list to hold squared numbers squares = [] for value in range(1,11): # ** acts as exponent operator in python square = value**2 # appends the square into the list of squares squares.append(square) print(squares) # more concise approach squares = [] for value in range(1,11): squares.append(va...
true
b9854e8781e6261b6919999f85e782205aab07d1
BD20171998/holbertonschool-higher_level_programming
/0x0A-python-inheritance/2-is_same_class.py
686
4.46875
4
#!/usr/bin/python3 """ This is an example of the is_same_class function >>> a = 1 >>> if is_same_class(a, int): ... print("{} is an instance of the class {}".format(a, int.__name__)) >>> if is_same_class(a, float): ... print("{} is an instance of the class {}".format(a, float.__name__)) >>> if is_same_class(a, object...
true
36bcd1fc0ec00f9ca1da87c053a7813973b4d23d
BD20171998/holbertonschool-higher_level_programming
/0x0B-python-input_output/4-append_write.py
624
4.25
4
#!/usr/bin/python3 """This is an example of the append_write function >>> append_write = __import__('4-append_write').append_write >>> nb_characters_added = append_write("file_append.txt", "Holberton School \ ... is so cool!\n") >>> print(nb_characters_added) 29 """ def append_write(filename="", text=""): """ ...
true
b024737c383e9990ea898a749ec09a2ef3a42320
samaroo/PythonForBeginners
/Ch7_Exercise.py
1,064
4.3125
4
# Notes # Functions in "Math" Library # use "import math" to import math library # abs(x) will return the absolutw calue of x # "math.ceil(x)" will round x up to the nearest integer greater than it # "math.floor(x)" will round x down to the nearest integer less than it # "pow(x, y)" will return x^y # # Functio...
true
a3b988261743a290910d8c3110733d393ef01512
wolverinez/T_Mud
/dice.py
1,099
4.15625
4
"""this module contains functions for rolling dice from a cointoss to a one hundred sided dice the funtions are named with the letter 'd' and then a number forinstance the function to simulate a d20 is simply named d20(pluss=0) where the pluss argument makes it possible to modify the roll """ import random as R de...
true
2b953aeab24e60b0a44915565b05b7cb3f1a4dd6
kosskiev/University-of-Michigan
/turtle_and_color_figure.py
873
4.46875
4
#Write a program that asks the user for the number of sides, the length of the side, the color, and the fill color of a regular polygon. #The program should draw the polygon and then fill it in. import turtle number_side = int(input('How many sides would you like?(Сколько сторон у вашей фигуры?) ')) angle = 360 / nu...
true
429a1d0562b5385edfa9a443c0732272e82bef4d
hutor04/UiO
/in1000/oblig_3/ordbok.py
1,197
4.34375
4
# The program initiates a dictionary with product names as keys and their prices as values. It then prints out the list # Then the program asks the user to input a new product and its price two times. # It ads new products to the dictionary and then prints a new dictionary. # We create a dictionary that holds product ...
true
215b78a3a4ae410b55ea532938f4d337b338ee1f
hutor04/UiO
/in1000/oblig_1/hei_student.py
361
4.21875
4
# The following program prints salutation, asks the user to input its name. # Then it prints out salutation and the name that was provided by the # user. # Prints to screen the first salutation print('Hei Student!') # Asks to input the name of the user navn = input('Scriv navnet ditt nå: ') # Prints to screen new salu...
true
e4279841462864909d41865df0c27e91b156831d
CharlieHuang95/Algorithms
/Sorting/quick_sort.py
1,188
4.25
4
# Quicksort works by randomly selecting an element to be its pivot, and shifting # smaller elements to its left side, and larger elements to its right side. # At the end of all the shifting, the pivot should ultimately be in the correct # location. import random def quick_sort_helper(array, left, right): if left ...
true
fd2a94cec38175d7ff35a93814bc5815df69dcd0
MeenaRepo/augustH2K
/DictionaryTest.py
1,285
4.1875
4
sampleDictionary = { "Warm":"Red", "Cold":"Baige", "Nuetral":"Grey", "Common":"Black", } print(sampleDictionary) print(sampleDictionary["Cold"]) print(sampleDictionary.get("Warm")) # Add - replaces the old value sampleDictionary["Warm"] = "Blue" print(sampleDictionary) # Membership if...
true
10cd5c0f8f3bf6fae6e03e1e740a115f505a1aba
duthaho/python-design-patterns
/creational/builder.py
2,288
4.15625
4
from abc import abstractmethod from typing import Optional class Car: def __init__(self): self.seat = 0 self.engine = "" self.trip_computer = False self.gps = False def info(self): print(f"Car: {self.seat} - {self.engine} - {self.trip_computer} - {self.gps}") class B...
true
259d53c7b2581e146cc8b1c5c9d75da5f04ee845
joelbd/CSC110
/convertmiles.py
244
4.3125
4
# File: convertmiles.py # This program converts distance in miles to distance in kilometers # Day def main(): miles = eval(input("Enter the distance in miles:")) kilometers = miles * 1.60934 print("The distance is:",kilometers,"km") main()
true
a80ddf31a4e28b238ebd83d30c80ef432bd25a16
Raktacharitra/TrueCaller-search
/truecaller.py
1,022
4.125
4
from sys import argv choice = input("Tell us if you want to 'search' a particular contact or 'add' a contact (s / a): ") if choice.lower() == "s" or choice.lower() == "search": with open(argv[1], "r") as phone_book: search_type = input("search by name or number: ") try: a = int(search_t...
true
1f527d83890651daeebb1874a70225fa013d07e4
louisbranch/hello-py
/ProblemSet3/ps3_newton.py
1,757
4.21875
4
# 6.00x Problem Set 3 # # Successive Approximation: Newton's Method # # Problem 1: Polynomials def evaluatePoly(poly, x): ''' Computes the value of a polynomial function at given value x. Returns that value as a float. poly: list of numbers, length > 0 x: number returns: float ''' s =...
true
ae069876ea6409ad4a9ff29f1fb23a915d707e01
priyankagoma/learningpython
/src/python_scripts/print_examples/printexamples.py
290
4.15625
4
#below are few examples that how we can print numbers. print(2 + 8) print(3 * 5) print(6 - 3) #Example of a string. print("The end", "it should be nice", "we will able to make it") #Exapme of integers. print(1, 2, 3, 4, 5) #Example of words. print("one two three four five cat dog")
true
df53ec293bedda6a6954334daca394536dc0e02b
Junhee-Kim1/RandomNumber
/RandomNumberGuesser.py
442
4.15625
4
import random print("number Guessing Game!") number=random.randint(1,9) chance=0 print("guess number") while chance<5: guess=int(input("enter your guess!: ")) if guess == number: print("you win!") break elif guess<number: print("your number is too low") else: ...
true
2c4da32e1420daae3f9401ca78d4be75b6af5f9d
prathmesh2606/DSA_LU
/a1q1.py
344
4.4375
4
# Assignment 1 - Q1 # Write a python program that takes two numbers as the input such as X and Y and print the result # of X^Y(X to the power of Y). # Taking input x,y = [int(i) for i in input("Enter base value and then power value by giving space between them (eg: 2 3 ans: 8): ").split()] print(f"{x} to the pow...
true
b1b7f0de711f5d40447d83553dc3e8c4bbe3209f
charliettaylor/CSA231
/Projects/4/project4.py
2,286
4.28125
4
# Turtle Project by Charlie Taylor from turtle import * import random as rand SCALE = "Enter the size of the spiral (recommend 1-10): " LOW = "Enter low bound of shake (rec. negative or 0): " HIGH = "Enter high bound of shake (rec. positive or 0): " def draw_c(t) -> None: ''' draws letter C ''' t.do...
true
101cedb9b67c9004b1a4a5af955197ed7b71a4b9
yingl910/MongoDB
/Basics/mdb_update.py
1,899
4.25
4
'''These are examples of MongoDB example codes of save and update, two methods for updating''' '''update method one: save''' # a method on collection objects # find_one just returns the first document it finds city = db.cities.find_one({'name':"munchen",'country':'Germany'}) city['isoCountryCode'] = 'DEU' db.cities.s...
true
cd890912e0574154ac18385ac92f43fdd68f430d
PrabhudevMishra/PRO-97
/numberGuessingGame.py
497
4.15625
4
import random number = random.randint(0,10) chances = 0 while chances < 5 : guess = int(input("Enter your guess")) chances = chances + 1 if guess < number: print('Your guess is too low') if guess > number: print('Your guess is too high') if guess == number: brea...
true
c43c7f51aff65b851a591bf7d00c96a0d8a160be
shivesh01/Python-Basics
/Project&problems/Example_30.py
425
4.28125
4
# Shuffle Deck of cards import random # In the program, we used the product() function in itertools module to create a deck of cards. This function performs the Cartesian product of the two sequences. from itertools import product deck = list(product(range(1, 14), ["Spade", "Heart", "Club", "Diamond"])) random.sh...
true
65e62f4761054c0cf0ac8911e1715c5537608c7c
shivesh01/Python-Basics
/Project&problems/Example_10.py
233
4.375
4
# check number +,- or 0 num = float(input("Enter number")) if num == 0: print("your entered number is zero") elif num > 0: print("You have entered a positive number") else: print("You have entered a negative number")
true
dd701404bbf09b357bdd5faec5512de7093ca871
lmjim/year1
/cs210/p61_testfunc_key.py
1,584
4.21875
4
""" CIS210 Project 6-1 Fall 2017 Author: [Solution] Credits: N/A Implement a function to test the string reverse functions from project 5 (iterative and recursive). Practice: -- user-defined test functions -- functions as parameters """ import p52_stringreverse_key as p5 def test_reverse(f): '''(fun...
true
826fb885f233ea03edffde38cb2342bda0236dea
dudulydesign/python_web_pratice
/webserver/py_though/bubble sort.py
747
4.15625
4
#Bubble Sort sampleList = [6,5,4,3,2,1] def bubbleSort(sourceBubbleSortList): #how long the list listLength = len(sourceBubbleSortList) i = 0 # the i here to count how many value not in while i < listLength-1: j = listLength - 1 # here to compare two value while j > i: print(" sourceBubble...
true
62f8410ff45e2352f7ac48cf8327c35a62371895
geraldfan/Automate-The-Boring-Stuff
/Chapter_9_Organizing_Files/selectiveCopy.py
699
4.25
4
#! python3 # selectiveCopy.py - Walks through a folder tree, then searches and copies for files with a particular extension (i.e. .jpg) import shutil, os folder = input('Enter the absolute filepath of' ' the directory you wish to copy from: ') extension = input("Enter the extension you'd like to copy:...
true
578494d75a99a79091946b96a93a13fc485c6c50
Szkeller/TDD_lab
/FizzBuzz.py
867
4.125
4
class FizzBuzz: ''' This is for TDD sample Author: Keller Zhang create date: 04/27 description: FizzBuzz Quiz When given number just can be divided by 3, then return 'Fizz'; When given number just can be divided by 5, then return 'Buzz'; Whe...
true
383c7b66d2e6c025f09270cf1e547d64556954aa
Shilinana/LearnPythonTheHardWayPractices
/ex18.py
633
4.3125
4
""" @Author:ShiLiNa @Brief:The exercise18 for Learn python the hard way @CreatedTime:28/7/2016 """ # this one is like your scripts with argv def print_two(*args): arg1, arg2 = args print "arg1:%r, arg2:%r" % (arg1, arg2) # ok, that *arg is actually pointless, we can just do this def print_two_again(ar...
true
89768748cf4abc99b56f383e025fe37a851579f8
justinelai/Sorting
/src/iterative_sorting/iterative_sorting.py
2,598
4.5625
5
def insertion_sort(list): for i in range(1, len(list)): # copy item at that index into a temp variable temp = list[i] # iterate to the left until reaching correct . # shift items to the right j = i while j > 0 and temp < list[j-1]: list[j] = list[j-1] ...
true
2851a656bd9f2bdc1b7877c587dd09a17e0fe219
Tech-Amol5278/Python_Basics
/c5 - list/c5_more_methods_to_add_data.py
626
4.15625
4
# count # sort method # sorted function # reverse # clear # copy # Count: Counts the string available in list fruits = ['apple','orange','banana','grapes','apple','apple','guava'] print(fruits.count('apple')) # Sort: sort the list contains in alphabetical/numeric order fruits.sort() print(fruits) numbers = [3,51,8...
true
43bce6c540aa4ad249c33ab9650e4e1b739a73cb
Tech-Amol5278/Python_Basics
/c5 - list/c5e4.py
522
4.4375
4
# define a function which returns a lists inside list, inner lists are odd and even numbers # for example # input : [1,2,3,4,5,6,7,8] # returns : [[1,3,5,7],[2,4,6,8]] ####### Sol ############################################### num1 = [1,2,3,4,5,6,7,8] def separate_odd_even(list1): sep_list = [] odd = [] ...
true
f383537b4da9f340610aaa7e4ee2e1fbf5b73147
Tech-Amol5278/Python_Basics
/c2 - strings methods/c2e2.py
218
4.21875
4
# ask username and print back username in reverse order # note: try to maje your program in 2 lines using string formatting #### Sol ##########################3 u_name = input("Enter your name: ") print(u_name[::-1])
true
4e09df38fd41bfaa63801dffa2f1a822878deab4
Tech-Amol5278/Python_Basics
/c17 - debugging and exceptions/else and finally.py
675
4.28125
4
# Else and fianlly while True: ## Loop to accept input til true comes try: age = int(input("Enter a number: ")) except ValueError: # valueerror : optional only if we know the error which can come print("Please enter age only in integer ") except: # when error is unpredicta...
true
e3a71a4f1447e3fc0e6bf03654df9c63e1af56f2
Tech-Amol5278/Python_Basics
/c16 - oops/property and setter decorator.py
2,526
4.21875
4
# property and setter decorator # the below code from last slide it has below problems # 1. this accepts the negative amount for price # sol: write a validation not to accept negative numbers # using getter(),setter() # 2. After changing the price , complete specification shows the old price. ...
true
1990af0b8f76c76eaa907f985d091f44a32cad62
Tech-Amol5278/Python_Basics
/c5 - list/c5_list_intro.py
649
4.5
4
# Data Structures # List # List is ordered collection of items # We can store anything in lits like int, float, string numbers = [1,2,3,4] print(numbers) ## to print 2 from list print(numbers[1]) ## to access only and 1 and 2 print(numbers[:2]) ## to reverse the elements in list print(numbers[::-1]) ## to access only...
true
9fe26472b3e65060b858040cdacc132387283fbd
mansi135/mansi_prep
/practice/new_problems.py
2,850
4.1875
4
# Given two sorted lists, return the interesection (ie the common elements b/w the two sorted lists) # For example given l1 = [1, 2, 3] and l2 = [2, 3, 5, 10] (they can be different sizes) # return [2, 3] # LINEAR TIME # 4 def get_intersection(l1, l2): pass # given two sorted lists l1 and l2, merge them such that ...
true
bf5541aff5d60357f0a736f7689cfeb3aa8b46e7
snidarian/Algorithms
/factorial_recursion.py
429
4.46875
4
#! /usr/bin/python3 # Factorial recursive algorithm import argparse parser = argparse.ArgumentParser(description="Returns factorial of given integer argument") args = parser.add_argument("intarg", help="Int to be factored", type=int) args = parser.parse_args() def factorial_recursive(n): if n == 1: r...
true
aa952649de3e87a99472f6cc2b92e7b2b8bf57ea
Factumpro/HackerRank
/Python/Practice/Sets/intersection.py
535
4.15625
4
''' Set .intersection() Operation https://www.hackerrank.com/challenges/py-set-intersection-operation/problem ''' ''' The .intersection() operator returns the intersection of a set and the set of elements in an iterable. Sometimes, the & operator is used in place of the .intersection() operator, but it only operate...
true
9cd9cb9efd74fd3e3ff798b3865ace2590249fa4
Factumpro/HackerRank
/Python/Practice/Sets/union.py
481
4.1875
4
''' Set .union() Operation https://www.hackerrank.com/challenges/py-set-union/problem ''' ''' The .union() operator returns the union of a set and the set of elements in an iterable. Sometimes, the | operator is used in place of .union() operator, but it operates only on the set of elements in set. Set is immutable...
true
42d6fba978a62e664aad1dbb1aa10fe161d51fab
Epic-R-R/Round-robin-tournament
/main.py
1,536
4.125
4
from pprint import pprint as pp def make_day(num_teams, day): # using circle algorithm, https://en.wikipedia.org/wiki/Round-robin_tournament#Scheduling_algorithm assert not num_teams % 2, "Number of teams must be even!" # generate list of teams lst = list(range(1, num_teams + 1)) # rotate day ...
true
9f815235eb7c74e01c17cd19ef5622bd843c8f1d
Elsie0312/pycharm_code
/two_truths-lie.py
584
4.15625
4
print('Welcome to Two Truths and a Lie! /n One of the following statements is a lie...you need to identify which one!') print('1. I have a donkey living in my backyard.') print('2. I have three fur babies') print('3. I speak 4 languages') truth_or_lie = input('Now put in the number of the statement you think is the li...
true
2492520b1fc91cf095c964e1b178c483046766b6
besslwalker/algo-coding-practice
/4.1 Quicksort/quicksort.py
1,534
4.125
4
# Quicksort # Bess L. Walker # 2-21-12 import random def quicksort(unsorted): real_quicksort(unsorted, 0, len(unsorted)) def real_quicksort(unsorted, low, high): if high - low <= 1: return pivot_index = partition(unsorted, low, high) real_quicksort(unsorted, low, pivot_index) real_quicksort(unsorted, pivot_i...
true
c7c008011e3694dae55fa8a676721bd8e9f5e78b
jaypsingh/PyRecipes
/String_n_Text/Str_n_Txt_07.py
710
4.4375
4
''' This program demonstrates how can we specify a regular expression to search shortest possible match. By Default regular expression gives the longest possible match. ''' import re myStr = 'My heart says "no." but mind says "yes."' # Problem demonstration ''' Here we ar etrying to match a text inside a quote. So i e...
true
f8d563e8c1ce87996fe1f0df6ebe05e65ff8a543
jaypsingh/PyRecipes
/String_n_Text/Str_n_Txt_05.py
445
4.1875
4
''' This function demonstrates how can we search and replace strings ''' import re myStr = "Today is 03/09/2016. Game of Thrones starts 21/07/2017" # Simple replace using str.replace() print (myStr.replace('Today', 'Tomorrow')) # Replace using re.sub() - Approach 1 print(re.sub(r'(\d+)/(\d+)/(\d+)', r'\3\-2\-1', my...
true
c8913860b13c4619cd5119cacdce93fce0e6bcb7
DHSZ/programming-challenge-2
/seven-seg-words.py
300
4.40625
4
def longest_word(): longest_word = "" ## Write your Python3 code inside this function. ## Remember to find words that only use the following letters: ## A, B, C, E, F, H, I, J, L, N, O, P, S, U, Y ## Good luck!! return longest_word print(longest_word())
true
5f4313bc5806a145daf721c578f7120dd2755c01
HarrisonPierce/Python-Class
/pierce-assignment2.py
1,258
4.28125
4
##Harrison Pierce ##This program calculates the factorial of a user defined number ##Set factorial variable to 1 factorial = 1 k = int(input('Enter a postitive integer: ')) ##Ask user for an integer and set equal to the variable k for k in range(1,k + 1): ##start for loop for k. while between 1 and the n...
true
a9f0b22836ca6ae81e7d60383386fffdc7ef8011
Rayansh14/Term-1-Project
/rock paper scissors.py
2,289
4.25
4
import random score = 0 def generate_random(): return random.choice(["rock", "paper", "scissors"]) def is_valid(user_move): if user_move in ["rock", "paper", "scissors", "r", "p", "s"]: return True return False def result(comp_move, user_move): if comp_move == user_move: return "ti...
true
1bd93d500350c63fca4ba7e6a8ed3e1fb80bd1fe
UnKn0wn27/PyhonLearning-2.7.13
/ex11.py
505
4.21875
4
#raw_input() presents a prompt to the user(the optional arg of raw_intput([arg]) #gets input from the user and returns the data input by the user in a string. #Exemple: # name = raw_input("What is your name?") # print "Hello, %s." % name #raw_input was renamed input() in Python 3 print "How old are you?", age = raw_in...
true
4d7eb9d814d4cd5db77400c7a96e1c18900eb00f
cantayma/web-caesar
/caesar.py
1,197
4.21875
4
import string def alphabet_position(letter): """ receives a letter, returns 0-based numerical position in the alphabet; case-sensitive; assumes letters only input """ if letter in string.ascii_uppercase: position = string.ascii_uppercase.find(letter) elif letter in string.ascii_lowerc...
true
36d1432db82c986858bf650aa2c8281d494e01ac
tlananthu/python-learning
/00_simple_examples/06_maths.py
336
4.1875
4
number1=int(input('Please input a number')) number2=int(input('Please input another number')) operation=input('Please input an operation. +-/*') if operation=='+': print(number1+number2) elif operation=='-': print(number2-number2) elif operation=='/': print(number2/number2) elif operation=='*': print(...
true
90094aafd436e093d00d2300a8278938caa788c1
Shwebs/Python-practice
/BasicConcepts/3.strings/string-multiplication.py
567
4.15625
4
#Strings can also be multiplied by integers. This produces a repeated version of the original string. # The order of the string and the integer doesn't matter, but the string usually comes first. print("spam" * 3) #O/p:spamspamspam print (4 * '2') #O/p: 2222 #Strings can't be multiplied by other strings. #Strings ...
true
28b923b625a0d8e716f3a85b98cfea1ac81d285b
Shwebs/Python-practice
/ControlStructure/List/List-method-count.py
305
4.125
4
#list.count(obj): Returns a count of how many times an item occurs in a list letters = ['p', 'q', 'r', 's', 'p', 'u'] print(letters.count('r')) #O/P:-1 print(letters.count('p')) #O/P:-2 # index method finds the "first occurrence" of a list item and returns its index print(letters.count('z')) #O/P:-0
true
2fd82e086ef9fd6b383c2055f70ced123c94963d
Shwebs/Python-practice
/BasicConcepts/3.strings/string-methods/split.py
489
4.21875
4
#Splits string according to delimiter string, returns list of substrings. #Default delimiter is ' ' . str='Test My Skill' output=str.split() print(output) #o/p:- ['Test', 'My', 'Skill'] for x in output: print(x) #o/p:-Test # My # Skill #Delimiter can be change...
true
e21cba589f4928a7ad09bd7ad84d786b5a4fb73c
Shwebs/Python-practice
/ControlStructure/range/basic-range.py
727
4.75
5
#The range function creates a sequential list of numbers. #The call to list is necessary because range by itself creates a range object, # and this must be converted to a list if you want to use it as one. #If range is called with one argument, it produces an object with values from 0 to that argument. numbers = li...
true
909325fdb03654071ecb54104d622e35e96a3497
Shwebs/Python-practice
/python-fundamentals-by-pluralsight/Object_Reference.py
1,065
4.25
4
#Pass by Object Reference #The value of the reference is copied , not the value of the object # Helpful Link https://robertheaton.com/2014/02/09/pythons-pass-by-object-reference-as-explained-by-philip-k-dick/ m = [9, 15, 24] def modify(k): """Appending a value to function. Args: A any literal can be added. R...
true
79699f6e7d3ab0c9ad08ad75dcf510fae492166d
Shwebs/Python-practice
/ControlStructure/List/List-operation.py
1,186
4.53125
5
#The item at a certain index in a list can be reassigned. #In the below example , we are re-assigned List[2] to "Bull" nums = [7, 8, 9, 10, "spring"] nums[2] = "Bull" print(nums) print("===================================") #What is the result of this code? nums = [1, 2, 3, 4, 5] nums[3] = nums[1] # We are re-as...
true
18f795a10eb2da066a1599fd909069e2d00216fc
Shwebs/Python-practice
/ControlStructure/List/List-method-insert.py
797
4.25
4
#The insert method is similar to append, #except that it allows you to insert a new item at any position in the list, #as opposed to just at the end. words = ["Python", "fun"] index = 1 words.insert(index, "is") print (words) print("================================") nums = [1,2,3,5,6,7] index = 3 nums.insert(index,...
true
fba81294a158815848dded2ca40206fb46b6ccd5
Shwebs/Python-practice
/BasicConcepts/3.strings/string-methods/string-is-check.py
1,386
4.21875
4
str=input("Enter a String: ") #isalnum() #Returns true if string has at least 1 character and all characters are alphanumeric and false otherwise. print('Checking If it is an alphanumeric :-',str.isalnum()) #isalpha() #Returns true if string has at least 1 character and all characters are alphabetic and false otherwis...
true
9539c945b6063ffdcd398710f03d371056ec52f7
IlyaTroshchynskyi/python_education_troshchynskyi
/algoritms/algoritms.py
2,512
4.125
4
# -*- coding: utf-8 -*- """calc Implements algorithms: - Binary search - Quick sort (iterative) - Recursive factorial """ def factorial(number): """ Define factorial certain number. """ if number <= 0: return 1 return number * factorial(number-1) print(factorial(50)) tes...
true
e4b018aa44483d0eeed003818634cd3d785c2714
Zahidsqldba07/python_exercises-1
/exercise_7.py
348
4.4375
4
''' Write a Python program to accept a filename from the user and print the extension of that. Go to the editor Sample filename : abc.java Output: java ''' file_name = input('Enter file name with extension, example: abc.java') if file_name == '': file_name = 'abc.java' name = file_name.split('.')[0] ext = file_name...
true
31e0794ad9981a270497e4cd91c2b9dbe52ea0f3
tohungsze/Python
/other_python/palindrome.py
869
4.1875
4
''' check if a given word is a palindrome ''' def main(): input = ['abcba', 'abc1cba', 'abcba ', 'abc1cba1'] for word in input: if is_palindrome(word): print('\'%s\' is a palindrome'%word) else: print('\'%s\' is a NOT palindrome'%word) def is_palindrome(input): #...
true
9ce0cec8b92e20b92a39e6e5d1af707c3db4fb27
tohungsze/Python
/other_python/fibonacci.py
1,139
4.28125
4
# demonstrate fibonacci with and without caching ''' # this is really slow, can't handle more than 30 ish numbers def fibonacci_n(n): if n == 0 or n ==1: return 1 else: return fibonacci_n(n-1) + fibonacci_n(n-2) for i in range(1, 11): print("fibonacci(", i, ") is:", fibonacci_n(i)) ''' ''...
true
ff7c0a83280f5080fcef88e288d96fbeda29289e
prashantkgajjar/Machine-Learning-Essentials
/16. Hierarchical Clustering.py
2,929
4.15625
4
# Hierarchical Clustering ''' 1. Agglomerative Hierarchical Clustering (Many single clusters to one single cluster) 1. Make each data point as a single point Cluster. 2. Take the two closest datapoints, and make them one cluster. 3. Take to closest clusters, and make them one cluster. 4. Repeat STEP 3 ...
true
5f4d01e512104db3e264784891663d304937ed96
HsiaoT/Python-Tutorial
/data_structure/Sorting/Selection_sort.py
802
4.28125
4
# 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. # Time complexity (average): O(n^2) # Time complexit (best): O(n^2) (list already sor...
true
d9bc14d8ae35cb2475bb92bcc8d99446694bc590
sunDalik/Information-Security-Labs
/lab1/frequency_analysis.py
2,879
4.3125
4
import argparse # Relative letter frequencies in the English language texts # Data taken from https://en.wikipedia.org/wiki/Letter_frequency theory_frequencies = {'A': 8.2, 'B': 1.5, 'C': 2.8, 'D': 4.3, 'E': 13.0, 'F': 2.2, 'G': 2.0, 'H': 6.1, 'I': 7.0, 'J': 0.15, 'K': 0.77, 'L': 4.0, 'M': 2...
true
50d5314cda34ce36b4af6d37acdc81b3a87a17f8
luckychummy/practice
/queueUsingStack.py
1,222
4.28125
4
from queue import LifoQueue class MyQueue(object): def __init__(self): """ Initialize your data structure here. """ self.q1=LifoQueue() self.q2=LifoQueue() def push(self, x): """ Push element x to the back of queue. :type x: int ...
true
34f84a9883b3d57911b30aea2ab4470efa57e482
AsharGit/Python-ICP
/Source/ICP-3/Employee.py
1,137
4.28125
4
class Employee: num_employees = 0 total_salary = 0 def __init__(self, name, family, salary, department): self.emp_name = name self.emp_family = family self.emp_salary = salary self.emp_dept = department self.increment(salary) # Increment num_employees and total_...
true
e50d45dda524f0471a01371f202cb2f7384ca07f
stompingBubble/Asteroids
/shape.py
2,492
4.15625
4
# -*- coding: utf-8 -*- """ Gruppuppgift: Asteroids - Objektorienterad Programmering Nackademin IOT 17 Medverkande: Isa Sand Felix Edenborgh Christopher Bryant Stomme källkod: Mark Dixon """ from abc import ABC, abstractmethod import math from point import Point class Shape(ABC): def __init__( self, x=0, y=0,...
true
ffd1c6706c107f8fa4ca74bf33d36650046d0608
thechemist54/PYth0n-and-JaVa
/Area calculation.py
1,663
4.4375
4
#printing the options print("Options:") print("-"*8) print("1. Area of Rectangle") print("2. Area of Triangle") print("3. Area of Circle") print("4. Quit") #assigning a value to flag flag = False #analyzing responses and displaying the respective information #looping statement while f...
true
a948e2106b7150b3a41ae7486415a8dc17842292
AndrejLehmann/my_pfn_2019
/Vorlesung/src/Basic/example4_2.py
769
4.65625
5
#!/usr/bin/env python3 # Example 4-2 Concatenating DNA # store two DNA sequences into two variables called dna1 and dna2 dna1 = 'ACGGGAGGACGGGAAAATTACTACGGCATTAGC' dna2 = 'ATAGTGCCGTGAGAGTGATGTAGTA' # print the DNA onto the screen print('Here are the original two DNA sequences:') print(dna1) print(dna2) # concaten...
true
e2802f46eeb773f497cab112e4a74fe96b763f8f
pravalikavis/Python-Mrnd-Exercises
/finaltest_problem3.py
2,052
4.34375
4
__author__ = 'Kalyan' max_marks = 25 problem_notes = ''' For this problem you have to implement a staircase jumble as described below. 1. You have n stairs numbered 1 to n. You are given some text to jumble. 2. You repeatedly climb down and up the stairs and on each step k you add/append starting k chars fr...
true
2873efc5e996028da3dbe1d1a3a70e8046511c65
pankajdahilkar/python_codes
/prime.py
268
4.1875
4
def isPrime(a=0): i=2 if a==0 : return 0 while(i<a): if a%i==0: return 0 i=i+1 return 1 x=int(input("Enter The number : ")) if(isPrime(x)): print(x, "is Prime number ") else : print(x," is not Prime number")
true
44894e050247f38dc88e2184ed65b8e7fc3e868e
pravishbajpai06/Projects
/6.py
1,483
4.1875
4
#6-Change Return Program - The user enters a cost and then the amount of money given. The program will figure out the change and the number of quarters, dimes, nickels, pennies needed for the change. import math cent=0.01 penny=0.01 nickel=0.05 dime=0.1 quarter=0.25 do=1 cost=float(input("Enter the costt")) amount=flo...
true
b2b10777497bf79f6353bd04ac19ddb0d69fc281
0x0all/coding-challenge-practices
/python-good-questions/reverse_vowels.py
542
4.28125
4
""" The Problem: Write a function to reverse the vowels in a given string Example: input -> output "hello elephant" -> "halle elophent" "abcde" -> "ebcda" "abc" -> "abc" """ def reverse_vowels(s): vowels = 'aeiou' res = list(s) pos = [index for index, char in enumerate(s) if char in vowels] ...
true
6736443ed68910ee2e4d2d665da47667024e19c3
vasanth9/10weeksofcp
/basics/classesandobjects.py
1,491
4.21875
4
#classes and objects """ Python is an object oriented programming language. Almost everything in Python is an object, with its properties and methods. A Class is like an object constructor, or a "blueprint" for creating objects. """ class myclass: x=5 p1=myclass() print(p1.x) """ All classes have a function cal...
true
6bc780d508f837ca9c0428fa160e72932b2060c8
futurice/PythonInBrowser
/examples/session1/square.py
837
4.5625
5
# Let's draw a square on the canvas import turtle ##### INFO ##### # Your goal is to make the turtle to walk a square on the # screen. Let's go through again turtle commands. # this line creates a turtle to screen t = turtle.Turtle() # this line tells that we want to see a turtle shape t.shape("turtle") # this lin...
true
14207390dc1852453b97d8922b1f8b3607f26e64
futurice/PythonInBrowser
/examples/session1/wall.py
998
4.46875
4
# Goal: help the turtle to find a hole in the wall # We need to remember to import a turtle every time we want # to use it. import turtle ##### INFO ##### # The following code draws the wall and the target. You can # look at the code but to get to the actual exercise, scroll # down. # Here we create a wall to the m...
true
5f66bea9207f8a7149844204245dc09345a636aa
futurice/PythonInBrowser
/examples/session3/function.py
2,912
4.8125
5
# Computing with functions import turtle t = turtle.Turtle() ##### INFO ##### # Fucntions can be used for computing things. # # As an example, let's consider computing an area of a # circle. You may remember form a math class that the area # of a circle is computed by multiplying the radius of the # circle by itself ...
true
35c92a9c66af8bcf6ee2eeec1eb9f3743e375091
ShaneKoNaung/Python-practice
/stack-and-queue/linked_list_queue.py
1,222
4.25
4
''' implementing queue using linked-list''' class LinkedListQueue(object): class Node(object): def __init__(self, data, next=None): self._data = data self._next = next def __init__(self): self._head = None self._tail = None self._size = 0 def __len...
true
2f9976e9ae634c5d370e0a45e4484a9c63e7d363
ShaneKoNaung/Python-practice
/stack-and-queue/linked_list_stack.py
1,171
4.125
4
''' Implementation of stack using singly linked list ''' class LinkedListStack(object): class Node(object): def __init__(self, data, next=None): self._data = data self._next = next def __init__(self): ''' create an empty stack ''' self._head = None sel...
true
5151cfe22c6ba893660c49ba006b512c77a74e6b
Suryashish14/Suryashish-Programs
/SpecialCalculator 1.py
2,115
4.25
4
print('::::::::::::::::::::::::::: MENU ::::::::::::::::::::::::::::::::::') print('Press 1 To Check For Armstrong Number') print('Press 2 To Check For Duck Number') print('Press 3 To Check For Perfect Number') print('\t\t\t\t Instructions') print('''1.Provide Only Positive Numbers 2.For Using The Menu Use Only 1...
true
034c084055637a5c567c8c6b25e6ccd6c25a302e
u101022119/NTHU10220PHYS290000
/student/100021216/myclass.py
734
4.125
4
import copy import math class point(object): '''Represents a point in 2-D space.''' class rectangle(object): """ Represents a rectangle. attributes: width, height, corner. """ a=point() a.x=0.0 a.y=0.0 b=point() b.x=3.0 b.y=4.0 box=rectangle() box.width=100.0 box.height=200.0 box.corner=point()...
true