blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
e9bac2547bac4dc0637c3abee43a3194802cbddc
tab0r/Week0
/day2/src/dict_exercise.py
1,762
4.15625
4
def dict_to_str(d): ''' INPUT: dict OUTPUT: str Return a str containing each key and value in dict d. Keys and values are separated by a colon and a space. Each key-value pair is separated by a new line. For example: a: 1 b: 2 For nice pythonic code, use iteritems! Note: ...
true
360f00f7d38fa89588606cf429e0c1e9321f8680
mounika123chowdary/Coding
/cutting_paper_squares.py
809
4.1875
4
'''Mary has an n x m piece of paper that she wants to cut into 1 x 1 pieces according to the following rules: She can only cut one piece of paper at a time, meaning she cannot fold the paper or layer already-cut pieces on top of one another. Each cut is a straight line from one side of the paper to the other side of t...
true
12b9d7a90eb7d3e8fbec3e17144564f49698e507
BenjaminNicholson/cp1404practicals
/cp1404practicals/Prac_05/word_occurrences.py
401
4.25
4
words_for_counting = {} number_of_words = input("Text: ") words = number_of_words.split() for word in words: frequency = words_for_counting.get(word, 0) words_for_counting[word] = frequency + 1 words = list(words_for_counting.keys()) words.sort() max_length = max((len(word) for word in words)) for word in wo...
true
a44221832be1eece6cbcbd78df99a8dcc4aea9ab
mcampo2/python-exercises
/chapter_03/exercise_04.py
539
4.59375
5
#!/usr/bin/env python3 # (Geometry: area of a pentagon) The area of a pentagon can be computed using the # following formula (s is the length of a side): # Area = (5 X s²) / (4 X tan(π/5)) # Write a program that prompts the user to enter the side of a pentagon and displays # the area. Here is a sample run: # En...
true
66106c9065c8dcabaa8a094326a2b601cdf07524
mcampo2/python-exercises
/chapter_03/exercise_11.py
523
4.34375
4
#!/usr/bin/env python3 # (Reverse numbers) Write a program that prompts the user to enter a four-digit int- # ger and displays the number in reverse order. Here is a sample run: # Enter an integer: 3125 [Enter] # The reversed number is 5213 reverse = "" integer = eval(input("Enter an integer: ")) reverse += str(...
true
09fb28996aa732c01df70d674a369fafa05e0939
mcampo2/python-exercises
/chapter_01/exercise_18.py
410
4.5
4
#/usr/bin/env python3 # (Turtle: draw a star) Write a program that draws a star, as shown in Figure 1.19c. # (Hint: The inner angle of each point in the star is 36 degrees.) import turtle turtle.right(36+36) turtle.forward(180) turtle.right(180-36) turtle.forward(180) turtle.right(180-36) turtle.forward(180) turtle....
true
b0c6434539536ee3c7db23fb6977ca940037d147
mcampo2/python-exercises
/chapter_03/exercise_02.py
1,594
4.53125
5
#!/usr/bin/env python3 # (Geometry: great circle distance) The great circle distance is the distance between # two points on the surface of a sphere. Let (x1, y2) and (x2, y2) be the geographical # latitude and longitude of two points. The great circle distance between the two # points can be computed using the follow...
true
e4c59a6991788b320fdfd4aeea0e8c894d403d39
mcampo2/python-exercises
/chapter_02/exercise_06.py
680
4.46875
4
#!/usr/bin/env python3 # (Sum the digits in an integer) Write a program that reads an integer between 0 and # 1000 and adds all the digits in the integer. For example, if an integer is 932, the # sum of all it's digits is 14. (Hint: Use the % operator to extract digits, and use the //) # operator to remove the extract...
true
ebb74354b22feb3d6d6a27b546111115d4ae8964
praisethedeviI/1-course-python
/fourth/pin_checker.py
788
4.125
4
def check_pin(pin): nums = list(map(int, pin.split("-"))) if is_prime_num(nums[0]) and is_palindrome_num(nums[1]) and is_a_power_of_two(nums[2]): message = "Корректен" else: message = "Некорректен" return message def is_prime_num(num): tmp = 2 while num % tmp != 0: ...
true
65378f3f4696073f33c1708935fc45f8deb2e5d1
ishaansathaye/APCSP
/programs/guessingGame.py
1,677
4.125
4
# from tkinter import * # # root = Tk() # root.title("Computer Guessing Game") # root.geometry("500x500") # lowVar = StringVar() # highVar = StringVar() # labelVar = StringVar() # guessVar = StringVar() # # def range(): # lowLabel = Label(root, textvariable=lowVar) # lowVar.set("What is the lower bound of the r...
true
920ed667628f9fbb5783d72dd234a372c1f0ab87
Asish-Kumar/Python_Continued
/CountingValleys.py
743
4.25
4
""" A mountain is a sequence of consecutive steps above sea level, starting with a step up from sea level and ending with a step down to sea level. A valley is a sequence of consecutive steps below sea level, starting with a step down from sea level and ending with a step up to sea level. example input : UDDDUDUU """ d...
true
5e36170af1209383fed6749d2c7302971cd6c354
dhalimon/Turtle
/race.py
1,883
4.25
4
import turtle import random player_one = turtle.Turtle() player_one.color("green") player_one.shape("turtle") player_one.penup() player_one.goto(-200,100) player_two = player_one.clone() player_two.color("blue") player_two.penup() player_two.goto(-200,100) player_one.goto(300,60) player_one.pendown() player_one.circl...
true
e346adc9388fadbb152c9c5698b5425a8f78afd1
hungnv21292/Machine-Learning-on-Coursera
/exe1/gradientDescent.py
1,511
4.125
4
import numpy as np from computeCost import computeCost def gradientDescent(X, y, theta, alpha, num_iters): #GRADIENTDESCENT Performs gradient descent to learn theta # theta = GRADIENTDESENT(X, y, theta, alpha, num_iters) updates theta by # taking num_iters gradient steps with learning rate alpha ...
true
5cce1caf8666c82ea5f180d45188272a82e290d3
Anupam-dagar/Work-with-Python
/Very Basic/remove_vowel.py
435
4.5625
5
#remove vowel from the string. def anti_vowel(text): result = "" for char in text: if char == "A" or char == "a" or char == "E" or char == "e" or char == "I" or char == "i" or char == "O" or char == "o" or char == "U" or char == "u": result = result else: result = ...
true
0fb68f202520e3370e544f8b7d53a2ad0ad69c42
Anupam-dagar/Work-with-Python
/Very Basic/factorial.py
228
4.1875
4
#calculate factoial of a number def factorial(x): result = 1 for i in range(1,x+1): result = result * i return result number = int(raw_input("enter a number:")) answer = factorial(number) print answer
true
fb067a66d72ae73131adf2dc34c0ce568ab87cad
kushagraagarwal19/PythonHomeworks
/HW2/5.py
876
4.15625
4
johnDays = int(input("Please enter the number of days John has worked")) johnHours = int(input("Please enter the number of hours John has worked")) johnMinutes = int(input("Please enter the number of minutes John has worked")) billDays = int(input("Please enter the number of days bill has worked")) billHours = int(inp...
true
df23c42f672c812f81c6f10ee3558bce3f51946c
BarnaTB/Level-Up
/user_model.py
2,023
4.28125
4
import re class User: """ This class creates a user instance upon sign up of a user, validates their email and password, combines their first and last names then returns the appropriate message for each case. """ def __init__(self, first_name, last_name, phone_number, email, password): ...
true
d5a2414bc8d3e3fb711cc0c43fac1122173d4388
mitchellroe/exercises-for-programmers
/python/02-counting-the-number-of-characters/count.py
381
4.3125
4
#!/usr/bin/env python3 """ Prompt for an input string and print the number of characters """ def main(): """ Prompt for an input string and print the number of characters """ my_string = input("What is the input string? ") num_of_chars = len(my_string) print(my_string + " has " + str(num_of_cha...
true
5d9192fb3a7f91af57e796ab3325891af0c2cabe
siraiwaqarali/Python-Learning
/Chapter-05/10. More About Lists.py
582
4.15625
4
# generate list with range function # index method generated_list = list(range(1, 11)) print(generated_list) # output: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 3] print(numbers.index(3)) # gives the index of the provided element print(numb...
true
9e0d8659be7a01bfaccc5d978b4b495e571491a1
siraiwaqarali/Python-Learning
/Chapter-03/ForLoopExample1.py
405
4.125
4
# sum of first ten natural numbers total=0 for i in range(1,11): # for sum of 20 numbers range(1,21) total+=i print(f"Sum of first ten natural numbers is {total}") # Sum of n natural numbers n=input("Enter the number: ") n=int(n) total=0 for i in range(1,n+1): # Second argument is excluded so to reach...
true
bf1c0a0d7e98d1d89ff053e71fdd374152848ae6
siraiwaqarali/Python-Learning
/Chapter-01/PythonCalculations.py
758
4.375
4
print(2+3) print(2-3) print(2*3) print(2/4) # This gives answer in fraction print(4/2) # This gives 2.0 print(4//2) # This gives 2 beacuse it is integer division print(2//4) # This gives 0 beacuse it is integer division print(11//3) # This gives 3 beacuse it is integer division print(6%2) ...
true
9ebdd87c5067140b6e3d5af41a58569552b85a11
siraiwaqarali/Python-Learning
/Chapter-16/Exercise3.py
652
4.15625
4
''' Exercise#03: Create any class and count no. of objects created for that class ''' class Person: count_instance = 0 def __init__(self, first_name, last_name, age): self.first_name = first_name self.last_name = last_name self.age = age # Increment count_instance ea...
true
d1ecd5f71b352f254142854248f00f9188a11718
siraiwaqarali/Python-Learning
/Chapter-05/6. is vs equals.py
392
4.15625
4
# compare lists # ==, is # == check values inside list # is checks address inside memory fruits1 = ['orange', 'apple', 'pear'] fruits2 = ['banana', 'kiwi', 'apple'] fruits3 = ['orange', 'apple', 'pear'] print(fruits1==fruits2) # False print(fruits1==fruits3) ...
true
d351fdf978fde1ea7045c7681b8afe871e25d6d4
siraiwaqarali/Python-Learning
/Chapter-09/4. Nested List Comprehension.py
388
4.4375
4
example = [[1, 2, 3], [1, 2, 3], [1, 2, 3]] # Create a list same as above using nested list comprehension # new_list = [] # for j in range(3): # new_list.append([1, 2, 3]) # print(new_list) # nested_comp = [ [1, 2, 3] for i in range(3)] # but also generate nested list using list comprehension nested_com...
true
d6c33d2dc1ca4b5913aaa65fbc33f4c9622ec43d
EEsparaquia/Python_project
/script2.py
420
4.25
4
#! Python3 # Print functions and String print('This is an example of print function') #Everything in single quots is an String print("\n") print("This is an example of 'Single quots' " ) print("\n") print('We\'re going to store') print("\n") print('Hi'+'There') #Plus sign concatenate both strings print('Hi','There')...
true
5e1d7603eec9b98a94386628eed855ce39e05199
EEsparaquia/Python_project
/script25.py
911
4.40625
4
#! Python3 # Programming tutorial: # Reading from a CSV spreadsheet ## Example of the content of the file ## called example.csv: # 1/2/2014,5,8,red # 1/3/2014,5,2,green # 1/4/2014,9,1,blue import csv with open('example.csv') as csvfile: readCSV = csv.reader(csvfile, delimiter=',') for row in readCSV: print(row...
true
07ecbbc1a8bf0e46b6432dbea343063da6d55a7b
medisean/python-algorithm
/quick_sort.py
645
4.125
4
''' Quick sort in python. Quick sort is not stable. Time complexity: O(nlogn) Space complexity: O(log2n) ''' def quick_sort(lists, left, right): if left >= right: return lists first = left last = right key = lists[first] while first < last: while first < last and lists[last] >= key: last = last - 1 ...
true
4eec7dce66ee380c61c8e0c1b5b680a03b6fa4ad
ccaniano15/inClassWork
/text.py
338
4.25
4
shape = input("triangle or rectangle?") if shape == "triangle": width = int(input("what is the length?")) height = int(input("what is the height?")) print(width * height / 2) elif shape == "rectangle": width = int(input("what is the length?")) height = int(input("what is the height?")) print(width * height) else:...
true
953f98b68c708b40b32bdc581a3eaeaf74662549
Floreit/PRG105
/KyleLud4.1.py
994
4.15625
4
#Declare variables to be used in the while loop stop = 0 calories = 4.2 minutes = 0 time = 0 #while loop with if statements to count the intervals, increments by 1 minute every iteration, when it hits an interval it will display the calories burned while stop != 1: minutes = minutes + 1 if minutes == ...
true
1885b7c5930b016b448bff1741f70d7b2ab74941
Hank310/RockPaperScissors
/RPS1.py
2,028
4.1875
4
#Hank Warner, P1 #Rock, Paper Scissors game # break int0 pieces # Welcome screenm with name enterable thing # Score Screen, computer wins, player wins, and ties # gives options for r p s & q # Game will loop until q is pressed # Eack loop a random choice will be generated # a choice from thge player, compare,...
true
8098951d28b3ca5f954b63e74ab6d887b0664e9f
lyndsiWilliams/cs-module-project-iterative-sorting
/src/searching/searching.py
1,337
4.25
4
def linear_search(arr, target): # Your code here # Loop through the length of the array for i in range(len(arr)): # If this iteration matches the target value if arr[i] == target: # Return the value return i return -1 # not found # Write an iterative impleme...
true
f04167639ad0509853dc1c01fa872b250fc95863
mraguilar-mahs/AP_CSP_Into_to_Python
/10_23_Lesson.py
429
4.1875
4
#Lesson 1.3 Python - Class 10/23 #Obj: #Standard: #Modulus - Reminder in a division: # Ex 1: 9/2 = 4 r 1 # Ex 2: 4/10 = 0 r 4 # modulus: % --> 9 mod 2 print(9%2) print(234%1000) print(10%2) print(9%2) # <- with mod 2, check for even/odd # Mod can check for divisibility, if equal to 0 #User Input: user_name = str(in...
true
a1f4cc9a7b531b3bcbd01ac5eb1285ee44d1e51f
abhishekk26/NashVentures
/Random number Generation.py
2,066
4.1875
4
import math, time class MyRNG: # MyRNG class. This is the class declaration for the random number # generator. The constructor initializes data members "m_min" and # "m_max" which stores the minimum and maximum range of values in which # the random numbers will generate. There is another variable ...
true
c95c502184424b7d7f56da51ec7df1bd24c11499
rosexw/LearningPython
/Exercise Files/Ch2/loops_start.py
843
4.25
4
# # Example file for working with loops # def main(): x = 0 # define a while loop # while (x < 5): # print(x) # x = x+1 # define a for loop # for x in range(5,10): # print (x) # use a for loop over a collection # days = ["Mon","Tue","Wed","Thu","Fri","Sat","Sun"] # for d in days: # p...
true
914544f42b91b5d6b7c17378a310add1ea9a67a6
Adarsh2412/python-
/python11.py
663
4.21875
4
def calculator(number_1, number_2, operation): if(operation=='addition'): result=number_1+number_2 return result elif(operation=='subtract'): result=number_1-number_2 return result elif(operation=='multiply'): result=number_1*number_2 return result ...
true
dbe00f7712f950e33b36e69e05d56d7465609c04
StevenM42/Sandbox
/password_check.py
389
4.3125
4
"""Password check program that returns asterisks of password length""" Minimum_character_limit = 6 password = input("Please enter password at least {} characters long: ".format(Minimum_character_limit)) while len(password) < Minimum_character_limit: password = input("Please enter password at least {} characters ...
true
ffac4f7a078c8221458dbba66af1ee4f95ad374c
shreesha-bhat/Python
/reverseofanumber.py
309
4.28125
4
#program to accept a number from the user and find the reverse of the entered number number = int(input("Enter any number : ")) rev = 0 while (number > 0): remainder = number % 10 rev = (rev * 10) + remainder number //= 10 print("Reverse of the entered number is ",rev)
true
45d3281927b36d539619554889b92fac37af3460
shreesha-bhat/Python
/Series1.py
339
4.15625
4
#Program to accept a number “n” from the user; then display the sum of the series 1+1/2+1/3+……….+1/n num = int(input("Enter the value of N : ")) for i in range(1,num+1): if i == 1: print(i,end='+') if i != 1 and i != num: print(f"1/{i}",end='+') if i == num: print(f"1/{i}...
true
3c23bc4b31be19db9439b1b1e8e96b5069c3bd35
shreesha-bhat/Python
/Swapnumbers.py
376
4.1875
4
#Program to swap numbers Number1 = int(input("Enter the First number : ")) Number2 = int(input("Enter the Second number : ")) print(f"Before swap, the values of num1 = {Number1} and num2 = {Number2}") Number1 = Number1 + Number2 Number2 = Number1 - Number2 Number1 = Number1 - Number2 print(f"After swa...
true
92a5b52e620fabf557ff30f4d1e471d783db4f2c
shreesha-bhat/Python
/series3.py
417
4.125
4
#Program to accept a number “n” from the user; find the sum of the series 1/23+1/33+1/43……..+1/n3 num = int(input("Enter the value of N : ")) sum = 0 for i in range(1,num+1): if i == 1: print(i,end='+') if i != 1 and i != num: print(f"1/{i}^3",end='+') if i == num: print(f...
true
a452c61845d7ec8f285b3aec32bbb707b8ac38e8
rcmhunt71/hackerrank
/DLLs/insert_into_dllist.py
2,038
4.15625
4
#!/bin/python3 class DoublyLinkedListNode: def __init__(self, node_data): self.data = node_data self.next = None self.prev = None class DoublyLinkedList: def __init__(self): self.head = None self.tail = None def insert_node(self, node_data): node = Doubly...
true
d9b437283616b1d92f2881a77c4505c421a7f10b
mariasilviamorlino/python-programming-morlino
/PB_implementations/backward_hmm.py
2,510
4.21875
4
""" Backward algorithm implementation for hmms ########### INPUT: model parameters sequence to evaluate OUTPUT: probability of sequence given model ########### Setup Read list of states Read transition probabilities Read emission probabilities Read sequence rows = n. of states cols = length of sequence Create a ro...
true
7dab3037afa1f2cf84dd957060a094840efe7308
gibbs-shih/stanCode_Projects
/stanCode_Projects/Weather Master/quadratic_solver.py
1,207
4.5
4
""" File: quadratic_solver.py ----------------------- This program should implement a console program that asks 3 inputs (a, b, and c) from users to compute the roots of equation ax^2 + bx + c = 0 Output format should match what is shown in the sample run in the Assignment 2 Handout. """ import math def main(): ""...
true
9139e03d276b2d33323343e59a2bf01ad9600911
gibbs-shih/stanCode_Projects
/stanCode_Projects/Hangman Game/similarity.py
1,801
4.34375
4
""" Name: Gibbs File: similarity.py ---------------------------- This program compares short dna sequence, s2, with sub sequences of a long dna sequence, s1 The way of approaching this task is the same as what people are doing in the bio industry. """ def main(): """ This function is used to find the most sim...
true
0619ec96483920be456730016ece7f7ef5b3ed57
takisforgit/Projects-2017-2018
/hash-example1.py
2,939
4.1875
4
import hashlib print(hashlib.algorithms_available) print(hashlib.algorithms_guaranteed) ## MD5 example ## ''' It is important to note the "b" preceding the string literal, this converts the string to bytes, because the hashing function only takes a sequence of bytes as a parameter ''' hash_object = hashli...
true
d64e446e9730ed833bb0dfd669d3c6aba98e6653
Deepti3006/InterviewPractise
/Amazon Interview/OccuranceOfElementInArray.py
370
4.15625
4
def numberOfOccurancesOfNumberinArray(): n = int(input("Enter number of Elements")) arr =[] for i in range(n): elem = input("enter the array number") arr.append(elem) print(arr) find_element = input("Enter the element to be found") Occurances = arr.count(find_element) print...
true
2eb7016701c2f1b1d6368a1ba08994e89930be57
Jenell-M-Hogg/Codility-Lesson-Solutions
/Lesson1-FrogJmp.py
1,296
4.125
4
'''A small frog wants to get to the other side of the road. The frog is currently located at position X and wants to get to a position greater than or equal to Y. The small frog always jumps a fixed distance, D. Count the minimal number of jumps that the small frog must perform to reach its target. Write a function: d...
true
74b87ea175e4c7ef7ac9802e865783101a87097d
JennSosa-lpsr/class-samples
/4-2WritingFiles/writeList.py
405
4.125
4
# open a file for writing # r is for reading # r + is for reading and writing(existing file) # w is writing (be careful! starts writing from the beginning.) # a is append - is for writing *from the end* myFile = open("numlist.txt", "w") # creat a list to write to my file nums = range(1, 501) # write each item to the ...
true
715cfb565d350b68bf0d20367cedcde62562e66c
JennSosa-lpsr/class-samples
/remotecontrol.py
1,080
4.40625
4
import turtle from Tkinter import * # create the root Tkinter window and a Frame to go in it root = Tk() frame = Frame(root) # create our turtle shawn = turtle.Turtle() myTurtle = turtle.Turtle() def triangle(myTurtle): sidecount = 0 while sidecount < 3: myTurtle.forward(100) myTurtle.right(120) ...
true
f623fbc9ad297294904cf231202e7e2ae1282524
AJoh96/BasicTrack_Alida_WS2021
/Week38/2.14_5.py
476
4.25
4
#solution from Lecture principal_amount = float(input("What is the principal amount?")) frequency = int(input("How many times per year is the interest compounded?")) interest_rate = float(input("What is the interest rate per year, as decimal?")) duration = int(input("For what number of years would like to calculate th...
true
92077bb80eda2fe5208c7b2eeeac3d53c4251ebc
PriyankaBangale/30Day-s_Code
/day_8_DictionaryMapping.py
1,381
4.34375
4
"""Objective Today, we're learning about Key-Value pair mappings using a Map or Dictionary data structure. Check out the Tutorial tab for learning materials and an instructional video! Task Given names and phone numbers, assemble a phone book that maps friends' names to their respective phone numbers. You will th...
true
015cac95f4680a6fa0f62999caff7e8d500634b9
assuom7827/Hacktoberfest_DSA_2021
/Code/game_projects/word guessing game/word_guessing_game.py
1,088
4.28125
4
from random import choice # list of words(fruits and vegetables) words=["apple","banana","orange","kiwi","pine","melon","potato","carrot","tomato","chilly","pumpkin","brinjol","cucumber","olive","pea","corn","beet","cabbage","spinach"] c_word = choice(words) lives=3 unknown = ["_"]*len(c_word) while lives>0: gue...
true
fb278d9975471e74e188f621cc722444410ada76
Sarthak1503/Python-Assignments
/Assignment4.py
1,100
4.28125
4
#1.Find the length of tuple t=(2,4,6,9,1) print(len(t)) #2.Find the largest and smallest element of a tuple. t=(2,4,6,8,1) print(max(t)) print(min(t)) #3.Write a program to find the product os all elements of a tuple. def pro(t): r=1 for i in t: r=r*i return r t=(1,2,3,4) p=pro(t) print(p) #4.Cal...
true
9b7380e82a01b8a68bec953a32119f10b2f34ad1
Sarthak1503/Python-Assignments
/Assignment11.py
1,317
4.34375
4
import threading from threading import Thread import time #1. Create a threading process such that it sleeps for 5 seconds and # then prints out a message. def show(): time.sleep(5) print(threading.current_thread().getName(),"Electronics & Communication Engineering") t= Thread(target=show) t.setName("B.tech...
true
a1e326537c4cadefbae38f73356c33a3cb920f1c
ArnabC27/Hactoberfest2021
/rock-paper-scissor.py
1,678
4.125
4
''' Rock Paper Scissor Game in Python using Tkinter Code By : Arnab Chakraborty Github : https://github.com/ArnabC27 ''' import random import tkinter as tk stats = [] def getWinner(call): if random.random() <= (1/3): throw = 'Rock' elif (1/3) < random.random() <= (2/3): throw = 'Scissors' ...
true
c66911b7118dfe6ca6dde2d28c00b8eeaf0ace72
MacHu-GWU/pyclopedia-project
/pyclopedia/p01_beginner/p03_data_structure/p03_set/p01_constructor.py
1,219
4.28125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Set Constructor ============================================================================== """ import random import string def construct_a_set(): """Syntax: ``set(iterable)`` """ assert set([1, 2, 3]) == {1, 2, 3} assert set(range(3)) == {0, 1, 2...
true
96290a7e696a0c6c70bcf234648877536d5c53e2
DiQuUCLA/python_59_skill
/3_python_bytes_str_unicode.py
1,180
4.1875
4
""" Two types that represent sequence of char: str and bytes(Python3), unicode and str(Python2) Python3: str: Unicode character bytes: 8 bits raw data Python2: unicode: Unicode character str: 8 bits raw data """ import sys version = sys.version_info[0] if version is 3: #encoding will take unicode ...
true
e5d3d5fcc86b340efb23b0cf99b4652daa6e3e4d
juanjosua/codewars
/find_the_odd_int.py
599
4.1875
4
""" Find the Odd Int LINK: https://www.codewars.com/kata/54da5a58ea159efa38000836/train/python Given an array of integers, find the one that appears an odd number of times. There will always be only one integer that appears an odd number of times. """ def find_it(seq): numbers = set(seq) return[n for n in numbers ...
true
6115fe58abcf4cedf25d90d87613590919ec494a
lisamryl/oo-melons
/melons.py
2,057
4.15625
4
"""Classes for melon orders.""" import random import datetime class AbstractMelonOrder(object): """Abstract for both domestic and international melon orders.""" def __init__(self, species, qty): """Initialize melon order attributes.""" self.species = species self.qty = qty se...
true
96a58d71f67b01d07897d83fca08c3beb5c718cd
loudsoda/CalebDemos
/Multiples_3_5/Multiples_3_5.py
1,228
4.125
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. Finish the solution so that it returns the sum of all the multiples of 3 or 5 below the number passed in. Note: If the number is a multiple of both 3 and 5, only count it once. Courte...
true
ee7195c77b6de0b24df33b938058b4a2f45ec48e
sunnysunita/BinaryTree
/take_levelwise_input.py
1,353
4.25
4
from queue import Queue class BinaryTree: def __init__(self, data): self.data = data self.left = None self.right = None def print_binary_tree(root): if root is None: return else: print(root.data, end=":") if root.left != None: print("L", root.lef...
true
c368badfeda0bd1f7079c807eb072dbbb6938641
weinbrek8115/CTI110
/P4HW2_RunningTotal_WeinbrennerKarla.py
628
4.15625
4
#CTI-110 #P4HW2 #Karla Weinbrenner #22 March 2018 #Write a program that asks the user to enter a series of numbers #It should loop, adding these numbers to a running total #Until a negative number is entered, the program should exit the loop #Print the total before exiting #accumulator variable runningTota...
true
9f7ab2ec4f7747b7c72e3815310403bcaf53bac8
ShushantLakhyani/200-Python-Exercises
/exercise_7.py
570
4.28125
4
# Q7) Write a Python program to construct the following pattern, using a nested for loop. # * # * * # * * * # * * * * # * * * * * # * * * * # * * * # * * # * #step 1: let a variable have the value 5, because of the final number of asterisks is 5 x = 5 # step 2: first 'for loop' to output the asterisks for the ...
true
f4753e41101f6702cad27b5c62848e3afc1662a3
ShushantLakhyani/200-Python-Exercises
/exercise_5.py
538
4.4375
4
#Write a python program to check if a triangle is valid or not def triangle_validity_check(a,b,c): if (a>b+c) or (b>a+c) or (c>a+b): print("This is not a valid triangle.") elif (a==b+c) or (b==c+a) or (c==a+b): print("This can form a degenerated triangle.") else: print("These values ...
true
2de6e4f4e6b61f97dc19627994d5d7fe04c0bcfd
ShushantLakhyani/200-Python-Exercises
/square_root__positive_number.py
247
4.21875
4
# Q3) Find the square root of a positive number #Declare a number in a variable a = 8 #to find thhe square root we raise the number to the power of 0.5, so raise a to the power of 0.5 a = a ** 0.5 # Now, print a to get the square root print(a)
true
ba5ab5edaf9b9f85d5b95bc454e418d7cfc0cc6c
Paulvitalis200/Data-Structures
/Sorting/sort_list.py
1,641
4.125
4
# Definition for singly-linked list. class ListNode(object): def __init__(self, val=0, next=None): self.val = val self.next = next class Solution(object): def sortList(self, head): """ :type head: ListNode :rtype: ListNode """ if not head or not head.nex...
true
20cb8f53226940b8b42a70cc1d524d2a37e1d1e8
Ornella-KK/password-locker
/user_test.py
1,841
4.125
4
import unittest from user import User class TestUser(unittest.TestCase): def setUp(self): self.new_user = User("Ornella")#create user object def test_init(self): ''' test_init test case to test if the object is initialized properly ''' self.assertEqual(self.new_user.us...
true
ba7389bd2476a80e1bd31936abce463963884f4d
DerrickChanCS/Leetcode
/426.py
1,837
4.34375
4
""" Let's take the following BST as an example, it may help you understand the problem better: We want to transform this BST into a circular doubly linked list. Each node in a doubly linked list has a predecessor and successor. For a circular doubly linked list, the predecessor of the first element is the last e...
true
164ab46dfc6364b49b06b0bd442fe5e85bd6ca37
sushmeetha31/BESTENLIST-Internship
/Day 3 task.py
1,042
4.40625
4
#DAY 3 TASK #1)Write a Python script to merge two Python dictionaries a1 = {'a':100,'b':200} a2 = {'x':300,'y':400} a = a1.copy() a.update(a2) print(a) #2)Write a Python program to remove a key from a dictionary myDict = {'a':1,'b':2,'c':3,'d':4} print(myDict) if 'a' in myDict: del myDict['a'] print(myD...
true
125eaf98db6359cb6d899c8e6aea55556c6c99f3
DKumar0001/Data_Structures_Algorithms
/Bit_Manipulation/Check_Power2.py
366
4.4375
4
# Check wheather a given number is a power of 2 or 0 def Check_pow_2(num): if num ==0: return 0 if(num & num-1) == 0: return 1 return 2 switch ={ 0 : "Number is 0", 1 : "Number is power of two", 2 : "Number is neither power of 2 nor 0" } number = int(input("Enter a Number")) ...
true
ff61137fb930d6a2b211d8eeb1577ca67ec64924
YammerStudio/Automate
/CollatzSequence.py
490
4.28125
4
import sys ''' Rules: if number is even, divide it by two if number is odd, triiple it and add one ''' def collatz(num): if(num % 2 == 0): print(int(num/2)) return int(num/2) else: print(int(num * 3 + 1)) return int(num*3 + 1) print('Please enter a number and the Collatz seque...
true
5ec608e2a356eb31b0095da2153cedb1e74152d3
oreo0701/openbigdata
/Review/integer_float.py
801
4.1875
4
num = 3 num1 = 3.14 print(type(num)) print(type(num1)) print(3 / 2) # 1.5 print(3 // 2) # floor division = 1 print(3**2) #exponnet print(3%2) #modulus - distinguish even and odd print(2 % 2) #even print(3 % 2) #odd print(4 % 2) print(5 % 2) print(3 * (2 + 1)) #incrementing values num = 1 num = num + 1 num1 *= 10 ...
true
f870ea6fa7baca5bb9c428128313c3a56ac80f4e
oreo0701/openbigdata
/Review/list_tuple_set.py
1,463
4.25
4
#list : sequential data courses = ['History', 'Math', 'Physic','CompSci'] print(len(courses)) #4 values in list print(courses[0]) print(courses[3]) print(courses[-1]) print(courses[-4]) print(courses[0:2]) print(courses[:2]) print(courses[2:]) #add values courses.append('Art') print(courses) #choose location to ...
true
852a1cbe7932d9065b29b6d11f81c3bdc8db6227
nadiabahrami/c_war_practice
/level_8/evenorodd.py
272
4.4375
4
"""Create a function that takes an integer as an argument and returns "Even" for even numbers or "Odd" for odd numbers.""" def even_or_odd(number): return "Even" if number % 2 == 0 else "Odd" def even_or_odd_bp(num): return 'Odd' if num % 2 else 'Even'
true
4464f45eaf50f90ef887757f56d9ecd02ed7330c
imvera/CityUCOM5507_2018A
/test.py
500
4.21875
4
#0917test #print("i will now count my chickens") #print ("hens", 25+30/6) #print("roosters",100-25*3%4) #print("now count the eggs") #print(3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6) #print("is it true that 3+2<5-7?") #print(3+2<5-7) #print("what is 3+2?",3+2) #print("what is 5-7?",5-7) #print("is it greater?",5 > -2) #print("...
true
1a6195375e49cdcf2c06f3fd89f38134bc0ab80e
yukan97/python_essential_mini_tasks
/005_Collections/Task1_3_and_additional.py
508
4.25
4
def avg_multiple(*args): return sum(args)/len(args) print(avg_multiple(1, 2, 4, 6)) print(avg_multiple(2, 2)) def sort_str(): s = input("Eneter your text ") print(' '.join(sorted(s.split(' ')))) sort_str() def sort_nums(): num_seq_str = input("Please, enter your sequence ").split() try: ...
true
67dfa55500af7f9c1e0e57bcd96cb01b30d2353c
murchie85/hackerrank_myway
/findaString.py
1,407
4.1875
4
""" https://www.hackerrank.com/challenges/find-a-string/problem?h_r=next-challenge&h_v=zen&h_r=next-challenge&h_v=zen&h_r=next-challenge&h_v=zen Sample Input ABCDCDC CDC Sample Output 2 Concept Some string processing examples, such as these, might be useful. There are a couple of new concepts: In Python, the lengt...
true
87e87abc6bcedda29a349fb945fd45541e8a681a
AirborneRON/Python-
/chatbot/chatBot.py
1,980
4.1875
4
file = open("stop_words") stopList = file.read().split("\n") file.close() # how to open up my plain text file, then create a variable to stuff the read file into #seperating each element of the list by the return key #then close # all responses should start with a space before typing print(" Hello ") response =...
true
c451f37b2016ec1ad6b073a5bae922a98c72e270
RiverEngineer2018/CSEE5590PythonSPring2018
/Source Code/Lab3 Q3.py
2,249
4.34375
4
#Don Baker #Comp-Sci 5590 #Lab 3, Question 3 #Take an Input file. Use the simple approach below to summarize a text file: #- Read the file #- Using Lemmatization, apply lemmatization on the words #- Apply the bigram on the text #- Calculate the word frequency (bi-gram frequency) of the words (bi-grams) #- Cho...
true
49007104a978b21ad305c9ae13413da0dccd7e77
noy20-meet/meet2018y1lab4
/sorter.py
228
4.375
4
bin1="apples" bin2="oranges" bin3="olives" new_fruit = input('What fruit am I sorting?') if new_fruit== bin1: print('bin 1') elif new_fruit== bin2: print('bin 2') else: print('Error! I do not recognise this fruit!')
true
ed6f6da350b48cde11a0e7952aad238c590cca74
mkoryor/Python
/coding patterns/dynamic programming/palindromic_subsequence/palindromic_partitioning_brute.py
1,329
4.15625
4
""" Given a string, we want to cut it into pieces such that each piece is a palindrome. Write a function to return the minimum number of cuts needed. Example 1: Input: "abdbca" Output: 3 Explanation: Palindrome pieces are "a", "bdb", "c", "a". Example 2: Input: = "cddpd" Output: 2 Explanation: Palindrome pieces ar...
true
d7830b9e24ae1feeff3e2e7fce5b3db531adab73
mkoryor/Python
/coding patterns/dynamic programming/palindromic_subsequence/longest_palin_substring_topDownMemo.py
1,591
4.15625
4
""" Given a string, find the length of its Longest Palindromic Substring (LPS). In a palindromic string, elements read the same backward and forward. Example 1: Input: "abdbca" Output: 3 Explanation: LPS is "bdb". Example 2: Input: = "cddpd" Output: 3 Explanation: LPS is "dpd". Example 3: Input: = "pqr" Out...
true
027f1de2e737fdc5556c86a83f0e7248c2812934
mkoryor/Python
/coding patterns/subsets/string_permutation.py
1,143
4.1875
4
""" [M] Given a string, find all of its permutations preserving the character sequence but changing case. Example 1: Input: "ad52" Output: "ad52", "Ad52", "aD52", "AD52" Example 2: Input: "ab7c" Output: "ab7c", "Ab7c", "aB7c", "AB7c", "ab7C", "Ab7C", "aB7C", "AB7C" """ # Time: O(N * 2^n) Space: O(N * 2^n) de...
true
2c713bda8945104526d6784acdced81ae0681ad4
mkoryor/Python
/coding patterns/modified binary search/bitonic_array_maximum.py
957
4.1875
4
""" [E] Find the maximum value in a given Bitonic array. An array is considered bitonic if it is monotonically increasing and then monotonically decreasing. Monotonically increasing or decreasing means that for any index i in the array arr[i] != arr[i+1]. Example 1: Input: [1, 3, 8, 12, 4, 2] Output: 12 Explan...
true
83407eac0a8aaa8a71aa1631bbd17f5818dc877c
mkoryor/Python
/coding patterns/dynamic programming/longest_common_substring/subsequence_pattern_match_bottomUpTabu.py
1,261
4.15625
4
""" Given a string and a pattern, write a method to count the number of times the pattern appears in the string as a subsequence. Example 1: Input: string: “baxmx”, pattern: “ax” Output: 2 Explanation: {baxmx, baxmx}. Example 2: Input: string: “tomorrow”, pattern: “tor” Output: 4 Explanation: Following are the fo...
true
b2ae19549528e82aaec418c4bb32868ac9272b73
mkoryor/Python
/binary trees/diameterBT.py
1,697
4.3125
4
# A binary tree Node class Node: # Constructor to create a new Node def __init__(self, data): self.data = data self.left = self.right = None # utility class to pass height object class Height: def __init(self): self.h = 0 # Optimised recursive function to find di...
true
b6c8c4750c8feca766f8d199428d11f6d5410ec6
mkoryor/Python
/binary trees/inorder_traversal_iterative.py
657
4.15625
4
# Iterative function to perform in-order traversal of the tree def inorderIterative(root): # create an empty stack stack = deque() # start from root node (set current node to root node) curr = root # if current node is None and stack is also empty, we're done while stack or curr: # if current node is not...
true
68db251c87295d02c092b7e521524f134b55d0a8
mkoryor/Python
/coding patterns/dynamic programming/palindromic_subsequence/palindromic_partitioning_bottomUpTabu.py
1,836
4.15625
4
""" Given a string, we want to cut it into pieces such that each piece is a palindrome. Write a function to return the minimum number of cuts needed. Example 1: Input: "abdbca" Output: 3 Explanation: Palindrome pieces are "a", "bdb", "c", "a". Example 2: Input: = "cddpd" Output: 2 Explanation: Palindrome pieces ar...
true
db3da546c26b6d3c430ca62e18a2fc2127d76e60
mkoryor/Python
/coding patterns/dynamic programming/knapsack_and_fib/count_subset_sum_bruteforce.py
1,325
4.15625
4
""" Given a set of positive numbers, find the total number of subsets whose sum is equal to a given number ‘S’. Example 1: # Input: {1, 1, 2, 3}, S=4 Output: 3 The given set has '3' subsets whose sum is '4': {1, 1, 2}, {1, 3}, {1, 3} Note that we have two similar sets {1, 3}, because we have two '1' in our input....
true
1f567c01031206e9cd45c02f0590a36a0affde12
mkoryor/Python
/coding patterns/dynamic programming/longest_common_substring/longest_common_substring_topDownMemo.py
1,204
4.125
4
""" Given two strings ‘s1’ and ‘s2’, find the length of the longest substring which is common in both the strings. Example 1: Input: s1 = "abdca" s2 = "cbda" Output: 2 Explanation: The longest common substring is "bd". Example 2: Input: s1 = "passport" s2 = "ppsspt" Output: 3 Explanation: The lon...
true
adf515163aad1d273839c8c6ed2ca2d8503dfb9b
adamomfg/lpthw
/ex15ec1.py
1,187
4.59375
5
#!/usr/bin/python # from the sys module, import the argv module from sys import argv # Assign the script and filename variables to argv. argv is a list of # command lne parameters passed to a python script, with argv[0] being the # script name. script, filename = argv # assign the txt variable to the instance of o...
true
92be2d072d41e740329b967749d113fb96a40882
amZotti/Python-challenges
/Python/12.2.py
993
4.15625
4
class Location: def __init__(self,row,column,maxValue): self.row = row self.column = column self.maxValue = float(maxValue) print("The location of the largest element is %d at (%d, %d)"%(self.maxValue,self.row,self.column)) def getValues(): row,column = [int(i) for i in input...
true
b3fbd14eb0439bbb1249fd30112f81f1c72f2d51
lglang/BIFX502-Python
/PA8.py
2,065
4.21875
4
# Write a program that prompts the user for a DNA sequence and translates the DNA into protein. def main(): seq = get_valid_sequence("Enter a DNA sequence: ") codons = get_codons(seq.upper()) new_codons = get_sets_three(codons) protein = get_protein_sequence(new_codons) print(protein) def get_va...
true
1efa65530ee7adfb87f28b485aa621d7bab157ca
nat-sharpe/Python-Exercises
/Day_1/loop2.py
264
4.125
4
start = input("Start from: ") end = input("End on: ") + 1 if end < start: print "Sorry, 2nd number must be greater than 1st." start end for i in range(start,end): if end < start: print "End must be greater than start" print i
true
fb971ad16bda2bb5b3b8bff76105a45510bcc24c
fyupanquia/idat001
/a.py
469
4.125
4
name = input("Enter your name: ") worked_hours = float(input("How many hours did you work?: ")) price_x_hour = float(input("Enter your price per hour (S./): ")) discount_perc = 0.15; gross_salary = worked_hours*price_x_hour discount = gross_salary*discount_perc salary=gross_salary-discount print("") print("*"*10) print...
true
fd66e0908166c686971c2164cb81331045a54f49
AniyaPayton/GWC-SIP
/gsw.py
1,714
4.375
4
import random # A list of words that word_bank = ["daisy", "rose", "lily", "sunflower", "lilac"] word = random.choice(word_bank) correct = word # Use to test your code: #print(word){key: value for key, value in variable} # Converts the word to lowercase word = word.lower() # Make it a list of letters for someone ...
true
f873c177b269ff834f3cb930f14b17d6295c4c1c
kronicle114/codewars
/python/emoji_translator.py
837
4.4375
4
# create a function that takes in a sentence with ASCII emoticons and converts them into emojis # input => output # :) => 😁 # :( => 🙁 # <3 => ❤ ascii_to_emoji = { ':)': '😁', ':(': '🙁', '<3': '❤️', ':mad:': '😡', ':fire:': '🔥', ':shrug:': '¯\_(ツ)_/¯' } def emoji_translator(input, mapper): ...
true
8cfc878be48ddbf6fc5a6a977075b1691b4c44c6
IcefoxCross/python-40-challenges
/CH2/ex6.py
778
4.28125
4
print("Welcome to the Grade Sorter App") grades = [] # Data Input grades.append(int(input("\nWhat is your first grade? (0-100): "))) grades.append(int(input("What is your second grade? (0-100): "))) grades.append(int(input("What is your third grade? (0-100): "))) grades.append(int(input("What is your fourth g...
true
b0be90fabd5a0ba727f3e8c36d79aead438e20b5
TheOneTAR/PDXDevCampKyle
/caish_money.py
2,961
4.375
4
"""An account file ofr our Simple bank.""" class Account: """An Account class that store account info""" def __init__(self, balance, person, account_type): self.balance = balance self.account_type = account_type self.owner = person def deposit(self, money): self.balance +=...
true
6e7622b6cc1de5399b05d7c52fe480f832c495ba
jacobkutcka/Python-Class
/Week03/hash_pattern.py
636
4.25
4
################################################################################ # Date: 02/17/2021 # Author: Jacob Kutcka # This program takes a number from the user # and produces a slant of '#' characters ################################################################################ # Ask user for Input INPUT = i...
true