blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
5a770eec9865f4462e2cb412720b18cb1422829a
CQuinlan1/Programming_Python_Problemset
/Problem7.py
738
4.46875
4
#************************** # Created by Catherine Ann Celeste Quinlan. # This program will take a FLOATING POINT NUMBER as input and output its square root approximation. # QUESTION 7 #************************* import math Selectednumber = input ("Please enter a positive floating number bigger than 0 : \n " ) try: ...
true
895d715fb433475c1e0bbac0e0de220755191440
kmangub/data-structures-and-algorithms
/python/challenges/multi_bracket_validation/multi_bracket_validation.py
1,571
4.65625
5
def multi_bracket_validation(string): """ This function will check to see if the brackets are matching. It creates an empty list, which is our stack and we will iterate through each character. Any opening brackets will be appended to our stack. When it encounters a closing bracket, it wi...
true
42b0c03db3abb4932e1f8d6ff2471c339a8b5c4d
angusb/puzzles
/inversions.py
1,175
4.15625
4
# Inversions can be used to detect how similar two lists are (Kendall's #rank correlcation). This is applicable with search engine testing. Futhermore, # inversions can be used to match a user's preferences with those of others. # # Given a list L = x_1, x_2, ..., x_N of distinct integers between 1 and n # an invers...
true
f3eee113887465cafb2eebc4c7683489a6581ccb
Charlene-bot/FindAJob
/MoveZeros.py
556
4.1875
4
#Given an array of integers, write a function to move all 0's to the end #while maintaining the relative order of rest of the elements #Algorithm -- moving all numbers ahead #setting the rest of the numbers in the list to 0 def Move_Zeros(arr, length): j = 0 for num in arr: if num != 0: ...
true
b73f14ad6adfcb0005a19a66748fe3a594570b4b
Somanathpy/Py4e-Coursera
/Python_Data_Structures/scriptsandoutputs/ex7.2.py
1,558
4.15625
4
## Assignment 7.2 # Write a program that prompts for a file name, then opens that file and reads through the file, looking for lines of the form: # X-DSPAM-Confidence: 0.8475 # Count these lines and extract the floating point values from each of the lines and compute the average of those values and # produce an ou...
true
ef6fe1c287eb86fa59d09d1d79d854665d35ea43
chalk13/softformance_school_exercises
/module_4/convert_user_name.py
1,638
4.21875
4
"""Програми, які перетворюють ім'я користувача у: - послідовність байтів - unicode code points - бінарне представлення """ USER_NAME = input("Please, enter your name: ") # --------------------------------------------------------------------- # Sequence of bytes # The rules for translating a Unicode string into a sequen...
true
6e03ebaf48358ad05bc5677876d81bc54ed847f1
srajeevteaching/lab2-s923
/lab2.py
2,028
4.53125
5
# Lab Number: 2 # Program Inputs: Births per second (float), deaths per second (float), migration per second (float), # Program Inputs (2): Current population (integer), number of years in future (float) # Program Outputs: Estimated population (integer) # This block asks the user for the three inputs that change popul...
true
feb404742b6fafaaa68fd0ceecee57c38c67114c
uknamboodiri/z2m
/section-6/115.py
446
4.1875
4
# Given the below class: class Cat: species = 'mammal' def __init__(self, name, age): self.name = name self.age = age # 1 Instantiate the Cat object with 3 cat1 = Cat('Dhanya', 16) cat2 = Cat('Dhanya2', 18) cat3 = Cat('Dhanya3', 17) # 2 Create a function that finds the oldest cat def get_ol...
true
42d0ac0a8d6344bf06883958b2db071e1c9a44bf
smit-pate-l/HackerRank
/Sets/symmetric_difference.py
375
4.3125
4
# Given 2 sets of integers, M and N, print their symmetric difference in ascending order. # The term symmetric difference indicates those values that exist in either M or N but do not exist in both. m = int(input()) M = set(map(int,input().split())) n = int(input()) N = set(map(int,input().split())) r = sorted(list...
true
e6c56cf411afde329bc8da11a779e548a717a6b3
fpelaezt/devops
/Python/Workbook/1-2a.py
902
4.4375
4
# Makes a function that will contain the # desired program. def example(): # Calls for an infinite loop that keeps executing # until an exception occurs while True: test4word = input("What's your name? ") try: test4num = int(input("From 1 to 7, how many hours do you play in you...
true
4acae9de077b1b1497254d832c393afbff9f7288
fpelaezt/devops
/Python/Course/4_Managing_lists.py
1,692
4.5
4
#For loop magicians = ['alice', 'david', 'carolina'] for magician in magicians: print(magician) for magician in magicians: print(magician.title() + " that was a great trick!!") print("===") print("///") for number in range(2,9): print(number) print("That was it") print("###############") numbers = li...
true
f70fbdb665c0e479b32b240950618d59569cf037
Kunjal9/Project_Euler
/Problem01.py
598
4.21875
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. def multiple_of_3_and_5(num): list_of_i = [] for i in range(1,num): if (i %5 ==0) or (i%3==0): list_of...
true
d196796bb7db0463ae7f72305630c26d0648b587
askiefer/practice-code-challenges
/missing_element.py
619
4.21875
4
import collections def missing_element(lst1, lst2): lst1.sort() lst2.sort() count = 0 for item in lst1: if item != lst2[count]: return item count += 1 def missing_element_two(lst1, lst2): lst1.sort() lst2.sort() for num1, num2 in zip(lst1, lst2): if num1 != num2: return num1 return False # this i...
true
44c079d95ab1089fbd22e72db89baa863a6ef301
akshirapov/think-python
/15-classes-and-objects/ex_15_9_2.py
1,823
4.28125
4
# -*- coding: utf-8 -*- """ This module contains a code for ex.2 related to ch.15.9 of Think Python, 2nd Edition by Allen Downey http://thinkpython2.com """ import math import turtle from ex_15_9_1 import Point, Circle, Rectangle def polyline(t, n, length, angle): """Draws n line segments. :param t: turt...
true
af934bf769068533c84ccdff2976c26413f6274d
akshirapov/think-python
/12-tuples/ex_12_10_3.py
1,297
4.15625
4
# -*- coding: utf-8 -*- """ This module contains a code for ex.3 related to ch.12.10 of Think Python, 2nd Edition by Allen Downey http://thinkpython2.com """ def word_list(): """Makes a dictionary where the key is the word. :return: Dictionary """ d = {} with open('words.txt') as fin: f...
true
993f6d68415097284dcd543c5a96e6ac61c640ca
akshirapov/think-python
/14-files/ex_14_12_2.py
1,533
4.125
4
# -*- coding: utf-8 -*- """ This module contains a code for ex.2 related to ch.14.12 of Think Python, 2nd Edition by Allen Downey http://thinkpython2.com """ import shelve def word_list(filename): """Makes a dictionary where the key is the word. :param filename: file with words """ d = {} with...
true
407190295065104f1c25894e4f1722f5ed0f0f78
linus1211/Learn-Python-The-Hard-Way
/ex9.py
675
4.21875
4
# Here's some new strange stuff, remember type it exactly. # Set a variable called days to a string with shortened day names days = "Mon Tue Wed Thu Fri Sat Sun" yay111 = "Mon" # Set a variable called months to a string with shortened month names, separated by \n (newline) characters months = "Jan\nFeb\nMar\nApr\nMay\...
true
d63a5ae5a7391fb046373b832d416679fe80c389
BElgy123/Palindrome
/Palindrome.py
1,516
4.5625
5
def is_palindrome(test_string): """ A standalone function to check if a string is a palindrome. :param test_string: the string to test :return: boolean """ t = test_string #Change parameter name cause it's too long for laziness _t = [] #Will be expanded form of t t_ = [] #Will be _t backwar...
true
e3e22a551b6cf3a223f723ca175e7b5ac3056a9c
nkmcheng/Python-Training
/problem2.py
423
4.21875
4
# Question #2: # Write a program which can compute the factorial of a given numbers. # The results should be printed in a comma-separated sequence on a single line. # Suppose the following input is supplied to the program: # 8 Then, the output should be: 40320 sequence = [8, 5] results = [] for s in sequence: resu...
true
274346c96ad571b3fdc354db141863bdb99a14d5
udaypandey/BubblyCode
/Python/multiplication-table.py
360
4.40625
4
# Write a program that prints a multiplication table for numbers up to 12. def printTable() : num = 1 while num <= 12: end = 12 start = 1 while start <= end: print(f"{num} x {start} = {num * start}") start = start + 1 num = num + 1 ...
true
cb01451575debb5050b412cb3cb3cabb4ce6d30f
tbold5/A01072453_1510_assignments
/A1/phone_fun.py
2,574
4.125
4
"""COMP 1510 Assignment 1: PHONE FUN!""" # Trae Bold # A01072453 # Feb 03, 2019 import doctest def number_translator(): """Translates alphabetical numbers. A function that translates alphabetical numbers into numerical equivalent. PRECONDITION: promt user to input 10 character telephone number in the f...
true
0477c1ba458019c51f17f2e8d8689912f53baa8f
limikmag/python
/algorithms/math/fast_exponential.py
872
4.3125
4
# recursion def power(base: int, to_power: int) -> int: if to_power == 0: return 1 if to_power % 2 != 0: return base*power( base=base, to_power=(to_power - 1)) if to_power % 2 == 0: return power( base=base, to_power=to_power/2)*power(base=base, to_power=to_p...
true
50abb7adfbc7d82404e57138b1c3b649b092001e
trinhgliedt/100_days_of_Python
/2021_03_07_Guess_the_number/2021_03_07_Guess_the_number.py
2,024
4.28125
4
# Number Guessing Game Objectives: # Include an ASCII art logo. # Allow the player to submit a guess for a number between 1 and 100. # Check user's guess against actual answer. Print "Too high." or "Too low." depending on the user's answer. # If they got the answer correct, show the actual answer to the player. # Trac...
true
e935334b6eb589c4fbf104c5b6da44e29cd21918
trinhgliedt/100_days_of_Python
/2021_03_13_Turtle_Racing/main.py
1,045
4.25
4
from turtle import Turtle, Screen import random screen = Screen() screen.setup(width=500, height=400) user_bet = screen.textinput(title="Make your bet", prompt="Which turtle will win the race? Enter a color: ") colors = ["red", "orange", "yellow", "green", "blue", "indigo"] xCor = -240 yCors = [150, 100, 50, 0, -50,...
true
43d7d16a894ed49f2e25e30c15edb67cc22177b7
tangowithfoxtrot/beginner_project_solutions
/multi_table.py
713
4.1875
4
''' Created on Sun 04/20/2020 20:29:08 Multiplication Table @author: MarsCandyBars ''' def table(user_num): ''' Description: This function creates the table in a matrix format with nested for loops, left justifying the numbers, and not causing endlines until the loop is broken. Args...
true
43a5434f3ebce881b0baf474822522f08af9e18b
leomessiah10/Operations
/fibonacci_series.py
657
4.125
4
print('In this program we will play with fibonacci sequence') first_num = 1 sec_num = 1 fibo_list = [1,1] count = 0 while(count == 0): num = eval(input('Upto which number you want the sequence\n:-')) for i in range(num-2): temp = sec_num + first_num first_num = sec_num sec_num = temp ...
true
a88857c51d81f2bd872b60c9c42d6219b701e936
gvillena76/Tic-Tac-Toe-Game
/GUI.py
1,573
4.25
4
# import the tkinter module import tkinter def main(): # create the GUI application main window root = tkinter.Tk() # customize our GUI application main window root.title('CS 21 A') # instantiate a Label widget with root as the parent widget # use the text option to specify which t...
true
b50c1702b58fe728e04f26409a0d44dbb0a0287c
lunAr-creator/learning_python
/while_loops.py
1,427
4.375
4
''' Loops are used repeat a certain action multiple times. Python gives us two options for this: while and for ''' #This loop will print the numbers 1-5 because every time the loop is run (until count = 5) 1 is added to count count = 1 while count <= 5: print(count) count += 1 #Cancelling a loop using break while...
true
22679ff1d5e51d6f15bb9302712c0c6b914636b1
amssdias/python-books_db
/csv/app.py
1,408
4.28125
4
from utils import database USER_cHOICE = """ Enter: - 'a' to add a new book - 'l' to list all books - 'r' to mark a book as read - 'd' to delete a book - 'q' to quit Your choice:""" def menu(): database.create_book_table() menu = { 'a': prompt_add_book, 'l': list_books, 'r': prompt_r...
true
1d9b536b3134f72446d97acc5c1fa40ef07da0a2
FlorianWi89/A-problem-a-day
/Parking_System.py
1,117
4.375
4
# Design a parking system for a parking lot. The parking lot has three kinds of # parking spaces: big, medium, and small, with a fixed number of slots for each size. # # Implement the ParkingSystem class: # ParkingSystem(int big, int medium, int small) Initializes object of the ParkingSystem class. # The number of slo...
true
e262eee555c5f359df24f443b21d660799969cfa
Simranbassi/python_grapees
/ex2f.py
340
4.125
4
kilometer=int(input("enter the distance (in kilometer) between two cities")) meter=1000*kilometer print("the distance in meter is",meter) feet=kilometer*3280.8 print("the distance in feet is",feet) inch=kilometer*39370.078 print("the distance in feet is",inch) centimeter=kilometer*100000 print("the distance in ...
true
b8b0a1f73d8f245317e7235cd061ce7dc39bcacb
bopopescu/python-practice
/pycharm/telusko/generator.py
270
4.34375
4
#----- Generator is used to create iterators instead of using __iter__ and __next__ functions def square(): n = 1 while n <= 10: sq = n*n yield sq n+=1 sqvalues = square() print(sqvalues.__next__()) for i in sqvalues: print(i)
true
17a886fd906d09f08e10d59579334896757d4063
bopopescu/python-practice
/functions.py
1,665
4.1875
4
#-- Required arguments def printme(str): "This functions expects the required number of arguments to be passed" print(str) return; printme("Purushotham") #-- keyword arguments def keywordarguments(name,age): "This function expects the keyword arguments to be passed" print("My name is" + name + " ...
true
6666d89a9c98a30a2bc454f62c9c4ab22007edfa
bopopescu/python-practice
/lists.py
2,170
4.65625
5
#-- creating a list mylist = [] print("printing the empty list") print(mylist) #-- adding element to the list mylist=['purushotham'] print("adding element to the list") print(mylist) #-- Adding multiple elements to the list mylist=['hello','purushotham','reddy'] print('adding multiple elements to the list') print(...
true
169c04e53dafc83ebc3e03841ccec520321ab17a
xerifeazeitona/PCC_Alien_Invasion
/exercises/12_04_rocket/super_rocket.py
2,904
4.25
4
""" 12-4. Rocket: Make a game that begins with a rocket in the center of the screen. Allow the player to move the rocket up, down, left, or right using the four arrow keys. Make sure the rocket never moves beyond any edge of the screen. """ import sys import pygame from settings import Settings from rocket import Roc...
true
d328ed927f8ee05cc60eab542643e77fd3621419
iamanobject/Lv-568.2.PythonCore
/HW_5/serhiiburnashov/convert-boolean-values-to-strings-yes-or-no.py
275
4.21875
4
def bool_to_word(boolean): """ Method that takes a boolean value and return a "Yes" string for true, or a "No" string for false. """ message = "Yes" if boolean else "No" return message #Yes print(bool_to_word(True)) #No print(bool_to_word(False))
true
da99ef0ac07b7619c844d5c773d0b2b867bd6182
iamanobject/Lv-568.2.PythonCore
/HW_6/ruslanliska/Home_Work6_Task_1.py
558
4.25
4
def largest_number(a, b): """The function returns bigger numbers Input is 2 digits Output is bigger number """ # a = input("Please enter first number: ") # b = input("Please enter second number: ") if a>b: return ("First number {} is bigger than second number {}".format(a, b)) el...
true
dade4188c910ed8807267fb86e0d73723c13c9a1
iamanobject/Lv-568.2.PythonCore
/HW_3/serhiiburnashov/Home_Work3_Task_3.py
391
4.125
4
first_variable = input("Enter first variable: ") second_variable = input("Enter second variable: ") print( "Before:" ) print( "First variable:", first_variable, "Second variable:", second_variable ) first_variable, second_variable = second_variable, first_variable print( "After:" ) print( "First vari...
true
ce1ff5ae00abba12c3d9375fe612cda63b6a7727
iamanobject/Lv-568.2.PythonCore
/HW_6/ruslanliska/Home_Work6_Task_3.py
330
4.40625
4
def count_symbols (word): """This function calculates all symbols in string""" letter_dict = {} for letter in word: if letter not in letter_dict: letter_dict[letter] = 1 else: letter_dict[letter] = letter_dict[letter]+1 return letter_dict print(count_symbols(input("Please, enter your st...
true
d4f4a0bc5af0d6298952b9f1a2a6a7d98dab6607
iamanobject/Lv-568.2.PythonCore
/HW_9/Taras_Smaliukh/HW9_task2.py
368
4.15625
4
def dayName(day_num): days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"] return days[day_num-1] if 0 < day_num <= len(days) else None try: day_num = int(input('Enter the number of the day in the week : ')) if day_num == int(day_num): print(dayName(day_num)) except ValueErr...
true
a88171d80c41aaf2ff8a57f17c1328a8bb175bbc
iamanobject/Lv-568.2.PythonCore
/HW_8/serhiiburnashov/grasshopper-summation.py
300
4.21875
4
def summation(num): """ Function that finds the summation of every number from 1 to num. """ result = sum(list(range(num + 1))) return result # 1 print(summation(1)) # 36 print(summation(8)) # 253 print(summation(22)) # 5050 print(summation(100)) # 22791 print(summation(213))
true
393d64a2b8d98827137d8d22987c360418940da1
iamanobject/Lv-568.2.PythonCore
/HW_7/ruslanliska/Home_Work7_Task_2.py
1,317
4.28125
4
import re def password_check(): """This function validates password cheks if there is at least 1 capital letter if there us more than 6 or less than 16 characters, if there at least 1 lowercase letter, if there at least 1 specific character and 1 digit """ password = input("Please enter you...
true
1b9d5dbddc0dfdb51ba5828c0b54bb49227ae886
iamanobject/Lv-568.2.PythonCore
/HW_5/ruslanliska/Kata_1.py
367
4.1875
4
distance_to_pump = int(input("What is the distance to pump? ")) mpg = int(input("How many miles your car takes per gallon? ")) fuel_left = int(input("How many fuel left in your car?'")) def zero_fuel(distance_to_pump, mpg, fuel_left): if fuel_left >= distance_to_pump / mpg: return True return False pri...
true
50ba71168512a6c00adbe4cb45b92071aad8edf8
cdvillegas/datastructures
/datastructures/hash_table.py
1,323
4.21875
4
class HashTable: """ A HashTable is a data structure that provides a mapping between keys and values using a hashing function. It allows efficient retrieval, insertion, and deletion of elements. The keys are hashed into indices of an array, and values are stored at those indices. In case of hash collisions,...
true
3fc439fa20e1220659f7f5060341f242e3e25879
amiraHag/python-basic-course2
/set/set4.py
979
4.40625
4
# ------------------------------- # --------- Set Methods --------- # ------------------------------- # issuperset() return true if the set contains all elements in the second set set1 = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 } set2 = { 1, 2, 3, 4 } set3 = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 } set4 = { "A", "B", "C" } print(set...
true
a158334fdb3a8b335d0562453ee976d13512057b
Sanjay567-coder/NumberGuessingGame
/Number Guessing Game.py
1,098
4.28125
4
print("Number Guessing Game") #importing randit from random from random import randint guessesTaken = 0 print("What's your Name?") myName=input() #Telling the computer to pick a number between 1 and 15 number=randint(1,15) print("Hello!,", myName,",I am thinking a number between 1 and 15") print("You have on...
true
31259ca678b11249f5aa50a17427ed26e49ba71a
TechNestOwl/DigitalCrafts-COR
/Python/thursdayPython.py
321
4.25
4
# lists # --- How to create groceries = ["milk","eggs","bread","salmon"] print (groceries[-2]) print (groceries[-3]) # Adding to a list groceries.append("bacon") print(groceries) # How to remove items popped_item = groceries.pop(3) print(groceries) print(popped_item) # Remvoe bread del groceries[2] print(groceries)...
true
983e609a02c1e0095eb1fdfc1ef63484bfaba889
hugo-wsu/python-hafb
/Day1/gen.py
1,672
4.1875
4
#!/usr/bin/env python3 """ Author : hvalle <me@wsu.com> Date : 8/9/2021 Purpose: """ def take(count, iterable): """ Take items for the front of the iterable :param count: The maximum number or items to retrieve :param iterable: The source series :yield: At most 'count' items for 'iterable ""...
true
0bd33d1a36f0cba21689f4b2a1314219e2152827
umutcaltinsoy/Objected-Oriented-Programming
/oop_005.py
1,632
4.59375
5
#Special (Magic/Dunder[Double Underscores]) Methods: #These special methods allow us to emulate some built-in behavior within Python #And it's also how we implement operator overloading #These special methods are always surrounded by double underscores(dunder) #So a lot of people call the double underscores dunder # ...
true
1a716957853b41768565e2b262bc9e638e3fa55c
BhargavReddy461/Coding
/Binary Tree/Flip_BinaryTree_clockwise.py
1,463
4.4375
4
# Python3 program to flip # a binary tree # A binary tree node class Node: # Constructor to create # a new node def __init__(self, data): self.data = data self.right = None self.left = None def flipBinaryTree(root): # Base Cases if root is None: ...
true
f657636d845dea0e6870ab0fb92c26e63ddd2f96
BhargavReddy461/Coding
/LinkedList/insert_in_a_sorted_SLL.py
1,116
4.125
4
class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def push(self, new_data): new_node = Node(new_data) new_node.next = self.head self.head = new_node def t...
true
4ed287357b0c476a892091e0ac62a12e8f58ed0b
Pavana16/scripting-language
/prg2.py
568
4.46875
4
#demo classes in python #concept:use of delete attribute of obj and obj itself class Person: def __init__(self,name,age): #constructor of the class Person self.name=name; self.age=age; p1 = Person('supandi',14) print("\n the name of person1 is:",p1.name) print("\n the age of person1 is:",p1.age) print("\n **...
true
806f186357f7f6e9be6e07a8a7d67d11f126c8d9
data-modeler/prod-ready-ml
/src/models/train_model.py
581
4.125
4
''' Train Model ----------- Runs the training for the model. ''' def sample(x: int=1, letters: str='ABC') -> bool: '''Is a sample function. Note: This is an example of complete documentation. Args: x: The first value to pass in. letters: The second argument. Retur...
true
61980a8f48ea05db7f7e59d0f2d79db1bf3c61b2
sharamamule/Py_Learn
/Py_Udemy1/Numbers.py
831
4.125
4
int_num = 1000 # this is the way we define the number in python float_num = 20.5 print(int_num) print(float_num) print ('*******') a=10 b=50 add = a+b print(add) sub =b-a print(sub) multi = a*b print(multi) div = a/b print(div) exponents = 10 ** 20 # 10 to the power of 20 (10*10...20 time...
true
fcd418d51797e43cff669f3955752ac909c26ac3
sharamamule/Py_Learn
/Py_Udemy1/Postional-Optional Parameters.py
527
4.1875
4
""" Postiional Parameters They are like optional paramters And can be assigned a default value, if no value is provided from outside """ def sum_nums (n1=2, n2=4): # Optional Paramters # def sum_nums (n1,n2=4): we can declare this also return n1 + n2 sum1 = sum_nums(n1=5,n2=5) print(sum1) print("...
true
2c37d21ac32355a8bf6ca792e3a83fd8f8157e67
bharathmc92/python-coding
/challenge_1.py
316
4.1875
4
#program to check the age of a person and allow if he is eligible for 18-30 holiday name = input("Enter your Name:") age = int(input("Enter your age: ")) if 17 < age < 31: print("Welcome to the Holiday {0}".format(name)) else: print("Sorry, you are not eligible for this holiday trip {0}".format(name))
true
a4d89857aa782981d9fc2bb1e4dd738b89d51444
jraman/algos
/python/backtracking/permutations.py
822
4.125
4
''' Backtracking: Find all the permutations of the characters in a string or elements in an array. Note: * Time complexity: O(n!) * If letters are repeated in the input, the output set will have repeated strings. Ref: * http://www.geeksforgeeks.org/write-a-c-program-to-print-all-permutations-of-a-given-string/ '''...
true
2d4568d32b5f180dae7ac6d5928b971ffb2f5ec4
eiadshahtout/Python
/python3/album.py
798
4.34375
4
def make_album(artistName, albumTitle, numberOfSongs = None): album = { "Name": artistName, "Title" : albumTitle } if numberOfSongs: album["Number_Songs"] = numberOfSongs return album while True: print("--------------------------------------------") artist_n = input("What is the name o...
true
9d3f54aa3279a1a32f2be807b3b0e842460fce7f
Kritika05802/Functions
/Functions.py
451
4.28125
4
#!/usr/bin/env python # coding: utf-8 # In[ ]: #prints the letters in a string in decreasing order of frequency # In[4]: a=input("Please enter a string: ") def most_frequent(string): mydict=dict() for key in string: if key not in mydict: mydict[key]=1 else: mydict[...
true
35e2f1c5272886912bcc246e81a67fb08f1bf8a7
Trago18/master-python-programming-exercises
/exercises/11-Swap_digits/app.py
315
4.15625
4
#Complete the fuction to return the swapped digits of a given two-digit-interger. def swap_digits(num): first = num//10 second = num%10 return (str(second) + str(first)) #return ((second*10) + first) #Invoke the function with any two digit interger as its argument print(swap_digits(30))
true
7772d90cf1bad0eba6595d44255a550f3113fba3
JerameKim/CS325HW4
/mergeSort.py
1,873
4.21875
4
def merge_sort(my_list, sort_func: lambda x, y: x < y): # 1. Exit Statement # only gets called n number of times if len(my_list) <= 1: return my_list middle_idx = len(my_list) // 2 # 2. Recurse # left = merge_sort(my_list[0:middle_idx]) # will return a sorted list from "left sid...
true
93a83fcfd32fe85193cbc98707f5d8dc66ace4d9
lastbyte/dsa-python
/problems/easy/square_root.py
967
4.1875
4
''' 69. Sqrt(x) Given a non-negative integer x, compute and return the square root of x. Since the return type is an integer, the decimal digits are truncated, and only the integer part of the result is returned. Note: You are not allowed to use any built-in exponent function or operator, such as pow(x, 0.5) or x **...
true
3d46ad9e5bf15a187f1c7fef9c3f04b550cc3c58
lastbyte/dsa-python
/problems/medium/duplicate_number.py
950
4.125
4
''' Given an array of integers nums containing n + 1 integers where each integer is in the range [1, n] inclusive. There is only one repeated number in nums, return this repeated number. Example 1: Input: nums = [1,3,4,2,2] Output: 2 Example 2: Input: nums = [3,1,3,4,2] Output: 3 Example 3: Input: nums = [1,1] Outpu...
true
5bc257f8a71d3b297bb6174ef5e758be4cfa25b1
SamuelKelechi/My_First_Python_Calculator
/calc.py
1,656
4.125
4
# A simple Calculator Program Designed By Samuel, A Product of BrighterDays Codelab # This function will add two numbers def add(a, b): return a + b # This function will subtract two numbers def sub(a, b): return a - b # This function will multiply two numbers def mul(a, b): return a * b #...
true
839bb0fdcdaebf2954f4672c0b62f54d3804ac7b
spacetime314/python3_ios
/extraPackages/matplotlib-3.0.2/examples/ticks_and_spines/major_minor_demo.py
2,677
4.3125
4
""" ================ Major Minor Demo ================ Demonstrate how to use major and minor tickers. The two relevant userland classes are Locators and Formatters. Locators determine where the ticks are and formatters control the formatting of ticks. Minor ticks are off by default (NullLocator and NullFormatter). ...
true
f7d45210da3224eabc6a14b690d8eeb7b1abd9b0
spacetime314/python3_ios
/extraPackages/matplotlib-3.0.2/examples/mplot3d/polys3d.py
1,696
4.125
4
""" ============================================= Generate polygons to fill under 3D line graph ============================================= Demonstrate how to create polygons which fill the space under a line graph. In this example polygons are semi-transparent, creating a sort of 'jagged stained glass' effect. """ ...
true
45c1fcf62ecb2e1a1c1fca798373f537ea217eea
spacetime314/python3_ios
/extraPackages/matplotlib-3.0.2/examples/pyplots/annotation_basic.py
947
4.21875
4
""" ================= Annotating a plot ================= This example shows how to annotate a plot with an arrow pointing to provided coordinates. We modify the defaults of the arrow, to "shrink" it. For a complete overview of the annotation capabilities, also see the :doc:`annotation tutorial</tutorials/text/annota...
true
7cc9f9191275137a2f96164977cf17db7eec7d0f
mmattano/example_repo
/example_repo/linreg.py
1,848
4.46875
4
"""Example module.""" __all__ = ["LinearRegression"] import numpy as np class LinearRegression: """Linear Regression. Uses matrix multiplication to fit a linear model that minimizes the mean square error of a linear equation system. Examples -------- >>> import numpy as np >>> from ex...
true
c852c9b76434a825abd0564d4238e37720ac5360
heronsilva/udacity-unscramble-cs-problems
/Task4.py
1,427
4.21875
4
""" Read file into texts and calls. It's ok if you don't understand how to read files. """ import csv with open('texts.csv', 'r') as f: reader = csv.reader(f) texts = list(reader) with open('calls.csv', 'r') as f: reader = csv.reader(f) calls = list(reader) """ TASK 4: The telephone company want to i...
true
3c4813856d32ecd0aeb72075f7cbe93624d06a3b
CheolminConanShin/PythonTakeNote
/Day1/src/Day1/PassVSContinue.py
249
4.28125
4
list = [1,2,3,4,5,6,7] for item in list: print("inside for loop : " + str(item)) if item > 3: pass print("inside if statement : " + str(item)) # pass if ȿִ ó skip, continue for skip
true
a4ee30d6f29af76459338db82a548ece62994d27
nellybella/ICodeAI
/Set_adt.py
2,683
4.5625
5
class Set: """ implementation of the set ADT using lists """ def __init__(self): """ initialize the set adt """ self.set_ = [] def add_item(self,item): """ add an element to the set Algorithmic complexity: ...
true
889c0c0a5a954098078a1353f872dfcb800d5faa
oa0311/NetworkChuck-Python-Tutorial
/main.py
556
4.28125
4
#printing single strings with several print functions. #print("Hello there!!!") #print("I am Iron Man") #print("No, I am Tony Stark") #print("No, blah blah") #Pound sign is how you comment in Python. #This comment is just to test the Version Control #printing a Multiline string with one print function. #print("""I'm...
true
e78aea815a8195d1016d64bea3bc4e6c93e279ee
mshehan/pythonPractice
/MatthewShehanLab3.py
2,637
4.25
4
#################################################################### # CIS 117 Internet Programming # Lab #3: "Super Secret Password" #################################################################### # This program checks to see if a user provided password # is super secret enough. # a password is considered super s...
true
ef1d339722bc8734a041ba7337930aeeb4756844
Richardbmk/PythonFundamentals
/sqlite/friends2_SQL.py
451
4.21875
4
# 364. Selecting With Python import sqlite3 conn = sqlite3.connect("my_friends.db") # Create cursor object c = conn.cursor() #c.execute("SELECT * FROM friends") #c.execute("SELECT * FROM friends WHERE first_name IS 'Steve'") c.execute("SELECT * FROM friends WHERE closeness > 5 ORDER BY closeness") #for result in c:...
true
be06ce5c3dff120a3df341c463c0bcfc8f62a7be
Richardbmk/PythonFundamentals
/09dictionaries.py
2,984
4.28125
4
# Dictionaries in python instructor = { "name": "Colt", "owns_dog": True, "num_courses": 4, "favorite_language": "Python", "is_hilarious": False, 44: "my favorite number!" } cat = {"name": "blue", "age": 3.5, "isCute": True} # A combination of a list and Dictionaries cart = [{"name": "blue", "...
true
cfc3471428d81b3068444730ef162e7e491fb46f
IsaacStalley/Course_Open_Platforms
/laboratorio5.py
2,674
4.125
4
#!/usr/bin/python3 """ Created on Friday July 10 10:19:04 2020 @author: Isaac Stalley Matriz class, takes 2 parameters for rows and columns and creates a matrix, contains useful methods for modifying the matrices, like adding and subtracting them or printing them. """ class Matriz(): # Constructor me...
true
7a16a32c9b73fe4733b1e44255904fb6aacb7937
pranavv1251/python-programs
/Prac3/P33.py
222
4.3125
4
list1 = [] largest = '' line = input("Enter words:") while(line != ''): if(len(largest) <= len(line)): largest = line line = input() print(f'The largest word is {largest} and its length is {len(largest)}')
true
fb1a65926ab7532c0776af46ed234e868420b86a
gopi-123/Speech_To_Text
/convert_audio_mp3_file_to_text.py
912
4.15625
4
""" Audio transcription works by a few steps: input: .mp3 file output: .wav file ++ text recognized ouput How it works: first converts mp3 to wav conversion, loading the audio file, feeding the audio file to a speech recongition system """ import speech_recognition as sr from os import path from pydub import A...
true
ab3f0f0ff62d8bd50d79e0ffcde2beca51e477e9
alyslma/HackerRank
/Python/Strings/SwapCase.py
841
4.3125
4
# https://www.hackerrank.com/challenges/swap-case/problem # You are given a string and your task is to swap cases. In other words, convert all lowercase letters to uppercase letters and vice versa. # Examples: Www.HackerRank.com → wWW.hACKERrANK.COM || Pythonist 2 → pYTHONIST 2 #####################################...
true
77e61338c8b2849a671112c1ee59e03b303fae63
imckl/leetcode
/easy/263-ugly-number.py
724
4.25
4
# Write a program to check whether a given number is an ugly number. # Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. # https://leetcode.com/problems/ugly-number/ class Solution(object): def isUgly(self, num: int) -> bool: if num == 0: return False if num =...
true
7b3fd8bb8a7002bb4802f813a8c1e4fe976e64ca
karthikm999/python_101
/ex21.py
1,026
4.4375
4
# Python program to find the largest number among the three input numbers # change the values of num1, num2 and num3 # for a different result num1 = 10 num2 = 14 num3 = 12 # uncomment following lines to take three numbers from user num1 = float(input("Enter first number: ")) num2 = float(input("Enter second number: "...
true
0ff1ba5fe60d9f7c578f8f2b4aaecc313eea190f
VicArDAl/python-labs
/03_more_datatypes/2_lists/03_11_split.py
514
4.15625
4
''' Write a script that takes in a string from the user. Using the split() method, create a list of all the words in the string and print the word with the most occurrences. ''' script=str(input("type a script please: ")) script_split=script.split() print(script_split) bigger_amount=0 solution=[] for i in script_sp...
true
c852938281a5be533f6586233a236829987e4835
VicArDAl/python-labs
/02_basic_datatypes/2_strings/02_08_occurrence.py
317
4.15625
4
''' Write a script that takes a string of words and a letter from the user. Find the index of first occurrence of the letter in the string. For example: String input: hello world Letter input: o Result: 4 ''' string=str(input("Write a script:\n")) letter=str(input("letter to find:\n")) print(string.find(letter))
true
7ec3728efe5497597f628dd87260a4428a2557c1
VicArDAl/python-labs
/01_python_fundamentals/01_01_run_it.py
959
4.5625
5
''' 1 - Write and execute a script that prints "hello world" to the console. 2 - Using the interpreter, print "hello world!" to the console. 3 - Explore the interpreter. a - Execute lines with syntax error and see what the response is. * What happens if you leave out a quotation or parentheses? * How...
true
cb4c7047893f4165a75c1337931e95f6cca11b35
savirnosaj/codingDojo
/python_stack/Python/python_OOP/car.py
1,455
4.21875
4
# Assignment: Car # Create a class called Car. In the __init__(), allow the user to specify the following attributes: price, speed, fuel, mileage. # If the price is greater than 10,000, set the tax to be 15%. Otherwise, set the tax to be 12%. # Create six different instances of the class Car. In the class have a met...
true
2f2324f5026319012a5e608cc1343c9afa109a2c
dipesh1011/class6_functions
/combination.py
331
4.125
4
def factorial(num): res = 1 for i in range(1, num + 1): res = res * i return res def combination(): n = int(input("Enter value for 'n':")) r = int(input("Enter value for 'r':")) combi = factorial(n) / (factorial(r) * factorial(n-r)) print("The combination is:",combi) co...
true
717bca05b8a8d2018645de701f06918e166c9a41
viicrow/yes_no
/main.py
1,136
4.15625
4
# functions go here... def yes_no(question): valid = False while not valid: response = input(question).lower() if display_instructions == "yes" or display_instructions == "y": response = "yes" return response elif display_instructions == "no" or display_instructions == "n": resp...
true
efc3651e5beee8826f1307db4c171f096bdb6fe6
mooney79/python-number-guessing-game
/leveltwo.py
495
4.21875
4
from random import randint lucky_number = input('Enter the number for the computer to guess: ') guesses_remaining = 3 while guesses_remaining > 0: computer_guess = randint(1, 10) if computer_guess == int(lucky_number): print("Correct! The computer wins!") break elif computer_guess > int...
true
691c501f6686e05d6f053e1b28a5591bb70e5b6a
AJHudson2003/the-final-project
/final project.py/the-final-project.py
2,427
4.15625
4
''' AJ Hudson 3.7.19 This is a questions game that i am using for this fun questions game. this will ask five random questions for you to answer. This will be a few questions that will have a few different questions for you to answer. I hope that you will have ''' welcome = input('Welcome to the Questions game!') d...
true
528a6d078a64137c9f5d10bc97b78be7459c38b5
AHecky3/Arthas
/Chapter4_Challenge/Challenge_1.py
1,008
4.15625
4
""" 1) Write a program that counts for the user. Let the user enter the starting number, then ending number, and the amount by wich to count. """ #Andrew Hecky #10/23/2014 #Opening Regards print(""" Hello There! I will count for you! Please enter the number you wish to start at, end at, and what we ...
true
3d0dec4941eaeaa712e39ed1495879189e2429b4
essweinjacob/School
/ProgLanguages/project4.py
2,226
4.3125
4
'''' Jacob Esswein Professor Galina Completed 11/3/2019 This program has a 'Product' class and two child classes 'Book' and 'Movie' that inherit 'Product''s constructor and in that, its private variables name, price and discount percent. ''' # Parent class 'Product' class Product: name = "" price = 0 disc...
true
7a1cdf1af372986d74d8b8d7c5da1db0d4cbf231
annikathiele/mappython
/map.py
1,168
4.125
4
import time def sort_a(word_list): """ Recursive implementation of quick- or mergesort. Parameter --------- word_list : list of str list to be sorted Returns ------- int sum of all swaps and comparisons float time used in ms """ # return mergesort_or_quicksor...
true
f7fbaf7d026ece3fcf32abe32aaa86e38ea9ef62
PQCuongCA18A1A/Ph-m-Qu-c-C-ng_CA18A1A
/PhamQuocCuong_44728_CH04/Exercise/page_109_exercise_03.py
680
4.125
4
""" Author: Phạm Quốc Cường Date: 22/9/2021 Problem: You are given a string that was encoded by a Caesar cipher with an unknown distance value. The text can contain any of the printable ASCII characters. Suggest an algorithm for cracking this code Solution: """ def decoded(s): for i in ra...
true
574990b7a33979586402dbb0c7c1add1d3f777a8
PQCuongCA18A1A/Ph-m-Qu-c-C-ng_CA18A1A
/PhamQuocCuong_44728_CH03/Exercise/page_85_exercise_03.py
277
4.28125
4
""" Author: Phạm Quốc Cường Date: 8/9/2021 Problem: Write a loop that counts the number of space characters in a string. Recall that the space character is represented as ' '. Solution: """ a=input("How to use a for loop in Python") for i in a: print(i.count(' ') + 1)
true
c77c3dff6b5509d49e04e6b59f780e740a1ee0a9
kushckwl/python_project
/guess_number.py
484
4.125
4
import random def guess(x): random_number = random.randint(1, x) guess = 0 while guess != random_number: guess = int(input(f"Guess a number between 1 and {x}:")) if guess < random_number: print('Sorry , again guess, too low') elif guess > random_number: prin...
true
b8221fd9e4d6c21951d3db47378cbb240709bd46
anselmos/coding-problem
/solutions/2019_10_29.py
1,210
4.125
4
#! /usr/bin/env python # -*- coding: utf-8 -*- # vim:fenc=utf-8 # # Copyright © 2019 [Anselmos](github.com/anselmos) <anselmos@users.noreply.github.com> # # Distributed under terms of the MIT license. """ Given a list of numbers and a number k, return whether any two numbers from the list add up to k.abs For example,...
true
d6331e71856771b33e5d69ddaf18b10ee03be5a6
ThomsonTang/python-tutorials
/python-cookbook/src/data-structures-algorithms/1-3-kepping-last-items.py
1,477
4.46875
4
"""1.3 Keeping the last N items The following code performs a simple text match on a sequence of lines and yields the matching line along with the previous N lines of context when found. When writing code to search for items, it is common to use a generator function involving yield, as shown in this recipe's solutio...
true
aa6c4f363adbf3ed4e9d11cd8d36fa413d30d599
one-last-time/python
/controlFlow/ConditionalStatement.py
1,995
4.4375
4
# ''' # You decide you want to play a game where you are hiding # a number from someone. Store this number in a variable # called 'answer'. Another user provides a number called # 'guess'. By comparing guess to answer, you inform the user # if their guess is too high or too low. # Fill in the conditionals below t...
true
283667a72bf6107d54cf1f6f1c09af1577b2f9e7
one-last-time/python
/functions/function.py
746
4.125
4
#Write a function named population_density that takes two arguments, population and land_area, and returns #a population density calculated from those values. I've included two test cases that you can use to verify #that your function works correctly. Once you've written your function, use the Test Run button to test ...
true
01aa1b0165b4533b6869071f5885fd4874bc9392
one-last-time/python
/list.py
392
4.34375
4
animal=["tiger","lion","dog","cat"] #shows full list print(animal) #get size print(len(animal)) #show an element print(animal[0]) #show an element from last print(animal[-4]) print(animal[-3]) #delete an element in list del animal[2] print(animal) #sort animal.sort() print(animal) #sort animal.so...
true