blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
c0849e4301054fd5484bb3dfd02ab40b7092901a | TesztLokhajtasosmokus/velox-syllabus | /week-05/1-tdd/grouptest/works/aliz_work.py | 1,272 | 4.28125 | 4 | # Write a function, that takes two strings and returns a boolean value based on if the two strings are Anagramms or not.
def anagramm(string1, string2):
if type(string1) == int:
return False
if string1 == '' or string2 == '':
return False
if len(string1) != len(string2):
... | true |
55438a72dad375d8a4d97997f34fc57fddc31837 | TesztLokhajtasosmokus/velox-syllabus | /week-05/1-tdd/grouptest/works/ddl_work.py | 1,101 | 4.28125 | 4 | # Write a function, that takes two strings and returns a boolean value based on if the two strings are Anagramms or not.
#
def anagramm(str1, str2):
a = sorted(str1)
b = sorted(str2)
if str1 or str2 != '':
pass
else:
return('Please type in valid strings')
try:
if int(str1) ... | true |
415d129291f2531a5f5867fedc30c45f47776210 | TesztLokhajtasosmokus/velox-syllabus | /week-03/2-functions-data-structures/solutions/37.py | 303 | 4.125 | 4 | numbers = [3, 4, 5, 6, 7]
# write a function that filters the odd numbers
# from a list and returns a new list consisting
# only the evens
def filter_odds(input):
evens = []
for item in input:
if item % 2 == 0:
evens += [item]
return evens
print(filter_odds(numbers))
| true |
9ed0b7f1ac77d9271995eb562d9b19dc4e37e80c | anuabey/Event_Management | /eventlist.py | 647 | 4.15625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Jan 21 20:38:11 2018
This program uses the pandas dataframe to read from a CSV file
containing event and participant details, sort the values
event-wise & writes the data to multiple CSV files based
on the event
@author: Anu Mary Abey
"""
import pandas as pd
de... | true |
751ebf359318f8e81e0ae5c6a327ed990413f55a | notdiego1/Palindrone | /palindrone.py | 512 | 4.125 | 4 | def palindrone(phrase):
x = -1
y = 0
noSpaces = []
makeList = list(phrase)
for i in makeList:
if i == " ":
del i
else:
noSpaces.append(i)
for i in noSpaces:
if i != noSpaces[x]:
y = 1
break
x = x - 1
if y == 1:
... | true |
5f390487c7a24b856147147609ea0f76e1c4fe18 | justingabrielreid/Python2019AndON | /DogClass.py | 964 | 4.25 | 4 | #!/usr/bin/env python3
#Author: Justin Reid
#Purpose: Practice classes and object oriented programming
def main():
class Dog:
species = 'mammal'
#instance attributes
#these can be different for each instance
def __init__(self, name, age, gender):
self.name = name
... | true |
a5ecd5b8f9188bf41e66ffd14b935886dbae57c5 | PierceAndy/rpc-taxi-booking-sim | /booking/trip.py | 1,246 | 4.21875 | 4 | from .point import Point, manhattan_dist
class Trip:
"""Contains the starting and ending locations of a trip.
Attributes:
src: A Point instance of the starting location of a trip.
dst: A Point instance of the ending location of a trip.
"""
def __init__(self, booking):
"""Init... | true |
feafb858caa38a45d5ed7070eb063ed3c1f36c48 | quento/660-Automated | /odd-or-even.py | 663 | 4.28125 | 4 |
def number_checker(num, check):
"Function checks if a number is a multiple of 4 and is odd or even. "
if num % 4 == 0:
print(num, "Is a multiple of 4")
elif num % 2 == 0:
print(num, "Is an even number")
else:
print(num,"You picked an odd number.")
if num % check == 0:
print(num, "... | true |
80424cf18c0f9d67b8479d8e0c265a658ca143b4 | Skinshifting/lpthw | /ex6.py | 808 | 4.21875 | 4 | # variable x assigned to a string %d means decimal value
x = "There are %d types of people." % 10
# variable assigned to strings
binary = "binary"
do_not = "don't"
# variable assigned to string with %s variables as strings
y = "Those who know %s and those who %s." % (binary, do_not)
# code begins - print the values
pr... | true |
627671aece9a7b8c6969dacbf36b9589bf16e5d4 | Ashton-Sidhu/Daily-Coding-Problems | /Solutions/Problem 3.py | 2,202 | 4.28125 | 4 | #QUESTION
# Given the root to a binary tree, implement serialize(root), which serializes the tree into a string,
# and deserialize(s), which deserializes the string back into the tree.
# For example, given the following Node class
# class Node:
# def __init__(self, val, left=None, right=None):
# self.val = ... | true |
e5b6371ed9f4f8077a55aba8b0556b695308aa24 | Ashton-Sidhu/Daily-Coding-Problems | /Solutions/Problem 5.py | 617 | 4.125 | 4 | #QUESTION
#cons(a, b) constructs a pair, and car(pair) and cdr(pair) returns the first and last element of that pair. For example, car(cons(3, 4)) returns 3, and cdr(cons(3, 4)) returns 4.
#Given this implementation of cons:
#def cons(a, b):
# def pair(f):
# return f(a, b)
# return pair
def cons(a, b):
... | true |
47b9d78eaeb94d0bdef33466c1f86642e8eb4551 | ssamanthamichelle/Sam-Codes-Python | /python08-code.py | 741 | 4.34375 | 4 | """
hey guys, it's me SAM~
here is the code for the two programs in my youtube video python 08
feel free to download & run this!
;)
"""
# first program
# only works for 1 string- my_string = '123 GO!'
# ... if you want to use a different string, have to modify function...
# not ideal :/
#####################... | true |
8219c6056ea0113993bdaa15d456d56f3483afff | gaya38/devpy | /Python/assignment/pes-python-assignments-2x.git/22.py | 686 | 4.125 | 4 | import math
print "perform all the trignomatric operations on given numbers"
x=input("Enter the x value in radians:")
y=input("Enter the x value radians:")
print "acos value of x:",math.acos(x)
print "asin value of x:",math.asin(x)
print "atan value of x:",math.atan(x)
print "atan values of x and y:",math.atan2(y,x)
pr... | true |
93ce9584577775999be0def15e982d515eb6925d | gaya38/devpy | /Python/TVS/27.py | 225 | 4.375 | 4 | import string
a=raw_input("Enter the string to check whether it is palindrome or not:")
b=''.join(reversed(a))
if (a==b):
print "The given string is palindrome"
else:
print "The given string is not a palindrome"
| true |
e534e73d57e92556421e78a70302f613fbb4237a | gaya38/devpy | /Python/assignment/pes-python-assignments-2x.git/45.py | 267 | 4.3125 | 4 | def palindrome(n):
i=''.join(reversed(n))
if (i==n):
return 1
else:
return 0
n=raw_input("Enter the n value:")
k=palindrome(n)
if (k==1):
print "The given string is a palindrome"
else:
print "The given string is not a palindrome"
| true |
1a10267b248eebb8e6aa081ca01f8078c776b1d1 | Neethu-Ignacious/Python-Programs | /ceaser_cypher.py | 1,032 | 4.375 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[9]:
def ceaser_cypher(my_string,shift_num):
"""This function will find the ceaser cypher encrypted value"""
#initializing the string
cypher = ''
#traversing through the input string
for string in my_string:
if string == '... | true |
dda53b487106190adbfe2961af80c8355d66dee0 | awarnes/twitter_maze | /twitter_maze/char_freq.py | 1,420 | 4.21875 | 4 | """
Use letter frequency tables to generate a list of letters as they are likely to appear in English.
"""
from math import ceil
def get_data(filename):
with open(filename, 'r') as file:
text = file.read()
return text
def letter_frequency(filename):
"""
Build a list of each letter accord... | true |
df8f240ade94a547e42d831e7f55b878bd525999 | pjchavarria/algorithms | /leetcode/graph-valid-tree.py | 2,109 | 4.125 | 4 | # https://leetcode.com/problems/graph-valid-tree/
# Given n nodes labeled from 0 to n - 1 and a list of undirected edges
# (each edge is a pair of nodes), write a function to check whether these
# edges make up a valid tree.
# For example:
# Given n = 5 and edges = [[0, 1], [0, 2], [0, 3], [1, 4]], return true.
# ... | true |
ecacc381c96c0e1b9814ad74caa2e3d058e10abd | jackandrea54/C4T39-NDN | /Lesson4/Ex1.py | 339 | 4.25 | 4 | month = int(input("What month of year: "))
if month <= 0 or month >= 13:
print("Không hợp lệ")
if month >= 2 and month <= 4:
print("It's Xuân")
elif month >= 5 and month <= 7:
print("It's Hạ")
elif month >= 8 and month <= 10:
print("It's Thu")
elif month == 11 or month == 12 or month ==1:
print("It... | true |
a2f8e0db1c4fd12702b81f469f7272a1043d21ec | azonmarina/AdventOfCode | /d1p2.py | 1,067 | 4.125 | 4 | # --- Part Two ---
# Now, given the same instructions, find the position of the first character that causes him to enter the basement (floor -1). The first character in the instructions has position 1, the second character has position 2, and so on.
# For example:
# ) causes him to enter the basement at character po... | true |
6a775f67b5afe8b2332024c0dc1fb598b8b4b476 | ethanmatthews/KCC-Intro-Mon-Night | /tanner.py | 721 | 4.125 | 4 | # input
weight = float(input("How much does your package weigh?"))
#processes and outputs
if weight > 0 and weight <= 2 :
print("Your shipment will cost $" + str(1.5 * weight) + " at a rate of $1.50 per pound.")
elif weight > 2 and weight <= 6 :
print("Your shipment will cost $" + str(3 * weight) + " at a rate ... | true |
5edbfd47f420b83d8f9978f31010e0b345cb1ede | siddiqmo10/Python | /user_input.py | 427 | 4.125 | 4 | # Ask a user their weight (in pounds), convert it to kilograms and print on the terminal
weight = input("What is your weight ? ")
# weight_kilo = float(weight) / 2.20462
weight_kilo = int(weight) * 0.45
print("Your weight in kilograms is :", weight_kilo)
# Solution by mosh
weight_lbs = input("Weight (lbs): ")
weigh... | true |
68cdba8e2e287307d4bc9c39352126a7ddfdb813 | siddiqmo10/Python | /if_else.py | 1,209 | 4.25 | 4 | is_hot = False
is_cold = False
if is_hot:
print("It's a hot day")
print("Drink plenty of water")
elif is_cold:
print("It's a cool day")
print("Wear warm clothes")
else:
print("It's a lovely day")
print("Enjoy your day")
# Exercise
price = 1000000
is_credit_good = True
if is_credit_good:
down... | true |
28b434b6172f276e49129f781f9634f62cd2af18 | EstephaniaCalvoC/holbertonschool-higher_level_programming | /0x04-python-more_data_structures/1-search_replace.py | 234 | 4.21875 | 4 | #!/usr/bin/python3
def search_replace(my_list, search, replace):
"""Replace all occurrences of an element by another in a new list"""
new_list = list(map(lambda x: replace if x == search else x, my_list))
return new_list
| true |
8dbf72c25aa71284d593cfce89ef2180fee0e848 | and-he/Python-Fun | /goldbach.py | 2,623 | 4.375 | 4 | #the goal of this program is to piggy back off of goldbach's conjecture which is:
#is every even number the sum of 2 prime numbers?
#this program will ask for input an even number, and return the two prime numbers that sum up to it
#ex: 6 returns 3 + 3
user_input = int(input("Please enter an even number: "))
#we coul... | true |
564846c5d1349f5a38acc4b4e1bea7842fb77f5d | gevertoninc/python101 | /general/for_loops.py | 291 | 4.125 | 4 | for letter in 'Giraffe attack':
print(letter)
friends = ['Joey', 'Chandler', 'Ross']
for friend in friends:
print(friend)
range_variable = range(10)
print(range_variable)
for index in range_variable:
print(index)
for index in range(1, 9):
print(index)
| true |
59e4b29ef8f608a19178e32bd0cefa8fa0387f8c | pasang2044/mycode | /class_project/multfunc.py | 409 | 4.15625 | 4 | #!/usr/bin/env python3
total = 1
number_list =[]
n = int(input("Enter the desired list size "))
print("\n")
for i in range(0,n):
print("Enter the number at index", i)
item = int(input())
number_list.append(item)
print("Here is your list ", number_list)
for elements in range (0, len(number_list)):
total... | true |
aea9c31852b64b641983b815a9a3605912cc05b6 | nsylv/PrisonersDilemma | /printtable.py | 1,255 | 4.4375 | 4 | ''' Basic table-printing function
Given a list of the headers and a list of lists of row values,
it will print a human-readable table.
Toggle extra_padding to true to add an extra row of the spacer
character between table entries in order to improve readability
'''
def print_table(headers,rows,extra_padding=F... | true |
2585278282d8a452124efbcf32c61a2998398b7f | NguyenVanThanhHust/Python_Learning | /RealPython/Automatic Docs with MkDocs/calculator/calculations.py | 1,310 | 4.53125 | 5 | """Provide several sample math calculations.
This module allows the user to make mathematical calculations.
Examples:
>>> from calculator import calculations
>>> calculations.add(2, 4)
6.0
>>> calculations.multiply(2.0, 4.0)
8.0
>>> from calculator.calculations import divide
>>> divide(4.0... | true |
a56fbd07ba5b17e6aa13ed7efb3601ee17fc6195 | Pengux1/Pengux1.github.io | /Notes/Python/FIT1045/ech.py | 251 | 4.15625 | 4 | #Selection
if 5 < 7:
print("Maths!")
else:
print("What the heck?")
#Iteration
#Both will print 0-4 in order.
for i in range(0, 5):
print(i)
Num = 0
while Num < 5:
print(Num)
Num += 1 | true |
7a2c881a73df253ed483d24d9ccfa8ff6cf20152 | anatulea/Educative_challenges | /Arrays/08_right_rotate.py | 679 | 4.21875 | 4 | '''Given a list, can you rotate its elements by one index from right to left'''
# Solution #1: Manual Rotation #
def right_rotate(lst, k):
k = k % len(lst)
rotatedList = []
# get the elements from the end
for item in range(len(lst) - k, len(lst)):
rotatedList.append(lst[item])
# get the rema... | true |
330cfb9e1f991f85362a4a521898ace96eb050a4 | anatulea/Educative_challenges | /Linked Lists/09_union&intersection.py | 2,794 | 4.25 | 4 | '''
The union function will take two linked lists and return their union.
The intersection function will return all the elements that are common between two linked lists.
Input #
Two linked lists.
Output #
A list containing the union of the two lists.
A list containing the intersection of the two lists.
Sample Input... | true |
10d00777aa19db0147bad5f4b72b1b473e51b20e | Daniel-Choiniere/python-sequences | /number_lists.py | 440 | 4.375 | 4 | even = [2, 4, 6, 8]
odd = [1, 3, 5, 7, 9]
print(min(even))
print(max(even))
print(min(odd))
print(max(odd))
print()
print(len(even))
print(len(odd))
print()
print("mississippi".count("s"))
print("mississippi".count("iss"))
# combines the odd list to the even list
print()
even.extend(odd)
print(even)
# sorting does... | true |
2376ba55fc9ae154d9030b6c8d4e60345b1c259c | Scotth72/codePractice | /code/practice.py | 617 | 4.34375 | 4 | # print("Hello world")
# Find all the pairs of two integers in an unsorted array that sum up to a given S. For example, if the array is [3, 5, 2, -4, 8, 11] and the sum is 7, your program should return [[11, -4], [2, 5]] because 11 + -4 = 7 and 2 + 5 = 7.
# Given
# have an array of unsorted
# - the sum
# plan
# for... | true |
93c68c98109dea9dc261130dd6a3d7e70f199300 | malikmubeen1/codingground | /Python exercises/BMI.py | 346 | 4.3125 | 4 | # BMI program
print "What is your weight, in pounds?",
weight = 0.453592*int(raw_input())
print "What is your height, in inches?",
height = 0.0254 * int(raw_input())
BMI = weight / (height*height)
print "Your BMI is %r" % BMI
if BMI >= 30:
print "Wow, you are obese. lose some weight plz."
elif BMI >= 25:
p... | true |
f831823fe70f4be4084c66950a77037c1915cce9 | kotalbert/poc1 | /hw1.py | 2,881 | 4.15625 | 4 | print type(3.14)
def clock_helper(total_seconds):
"""
Helper function for a clock
"""
seconds_in_minute = total_seconds % 60
print clock_helper(90)
val1 = [1, 2, 3]
val2 = val1[1:]
val1[2] = 4
print val2[1]
def appendsums(lst):
"""
Repeatedly append the sum of the current last three e... | true |
5c598337966f1c32ade87d174bce38b1c1243973 | paladugul/assignments | /samba/assignmt15.py | 614 | 4.28125 | 4 | #! user/dell/python
#15. take a string from the user and check contains atleast one small letter or not?
input1= raw_input("Enter a string to check it contains atleast one lowercase letters or not: ")
for i in input1:
if i==i.lower() and i.isalpha():
print "String contains lowercase letters"
break
else:
print ... | true |
59350092748d02241dd354c3b325cf9752ac614f | shuvabiswas12/Python-Basic | /Strings/string.py | 2,301 | 4.34375 | 4 |
# string in python
# Note: In python there is no character type. Instead of this there has string type
str = "Bangladesh"
print(str)
str = 'Bangladesh'
print(str)
# str = 'Bangladesh's' # here is show an error because of apostropi(')
str = "Bangladesh's" # now its ok
print(str)
str = 'Bangladesh\'s' # an apostropi... | true |
8c61d82abc97b735788109c1eec2acf6bf3bef1e | kiranpjclement/Playground_Python | /square_root.py | 300 | 4.40625 | 4 | """11. Write a Python program to compute and return the square root of a given 'integer'.
Input : 16
Output : 4
Note : The returned value will be an 'integer' """
inputno=int(input("What number you want to compute square root for: > "))
output=inputno**(1/2)
outputint=int(output)
print(outputint) | true |
779091c1b5101f3a546fbb1c4fb32dde383e60ad | cmaxcy/project-euler | /Euler25.py | 715 | 4.125 | 4 | '''
Gets the fibonacci number at 'index'
Assumes 0th term is 0, 1st is 1, 2nd is 1, etc...
'''
def get_fib(index):
# used to traverse fibonacci sequence
a = 0
b = 1
# a becomes b, b becomes sum of a and b
for i in range(index):
a, b = b, a + b
return a
'''
... | true |
60d9ecb7448bcb8f5b1a0008bd1c82c95b5ccf8e | mivalov/HackerRank-py | /src/validate_postal_codes.py | 2,433 | 4.5 | 4 | """ Validate postal codes
A valid postal code P have to fulfill both requirements:
1. P must be a number in range from 100000 to 999999 inclusive.
2. P must not contain more than one alternating repetitive digit pair.
Alternating repetitive digits are digits which repeat immediately after
the next digit. In o... | true |
f829a0d8e21315ac40f0471fc066b9c95d144f39 | Brother-Blue/Coding-Challenges | /project_euler/2.py | 554 | 4.15625 | 4 | """"
Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:
1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms."""... | true |
e11478d6d576d63de76c27cc52c959abfb11c8d2 | alchemistake/random-code-challenges | /maximize_the_product/find_maximum_product.py | 1,916 | 4.15625 | 4 | from functools import reduce
from operator import mul
def find_maximum_product(sequence: list):
if not all([type(x) == int for x in sequence]):
raise TypeError("Every elements must be integer.")
# I am assuming that you want 0 if there is no elements, alternatively It can throw an error here.
if ... | true |
8afe594b1a6cce3fae41b4c950337628059db87d | xerifeazeitona/PCC_Data_Visualization | /chapter_15/examples/rw_visual_2_multiple_walks.py | 545 | 4.15625 | 4 | """
One way to use the preceding code to make multiple walks without having
to run the program several times is to wrap it in a while loop
"""
import matplotlib.pyplot as plt
from random_walk import RandomWalk
while True:
# Make a random walk.
rw = RandomWalk()
rw.fill_walk()
# Plot the points in the... | true |
96874a5866ccf2b650fa299c74570eb14b82f31e | mpkrass7/Practice-Python | /ex2.py | 1,486 | 4.4375 | 4 | #Ask the user for a number.
#Depending on whether the number is even or odd,
#print out an appropriate message to the user.
#Hint: how does an even / odd number react differently when divided by 2?
#Extra 1: If number is a multiple of 4, print another message
#Extra 2: Ask the user for two numbers, one to check (num) a... | true |
8099d8d00d74d6ffcc1f8076ba517002650ff6e9 | manas3789/Hacktoberfest | /Beginner/03. Python/SalsShipping.py | 2,086 | 4.53125 | 5 | """
Sal runs the biggest shipping company in the tri-county area, Sal’s Shippers.
Sal wants to make sure that every single one of his customers has the best, and most affordable experience shipping their packages.
In this project, you’ll build a program that will take the weight of a package and determine the cheapest... | true |
15ab0dd5426b2fc750c5236a0cd92623ee95559d | manas3789/Hacktoberfest | /Beginner/03. Python/InsSort.py | 729 | 4.34375 | 4 | #Insertion Sort
def insertionSort(ar):
#the outer loop starts from 1st index as it will have at least 1 element to compare itself with
for i in range(1, len(ar)):
#making elements as key while iterating each element of i
key = ar[i]
#j is the element left to i
j = i - 1
... | true |
4d659d9295f6f2a2d03bac745bb710d799624848 | sarahfig824/AutomobileClass- | /ITS320_CTA2_OPTION2.py | 2,487 | 4.3125 | 4 | #------------------------------------------------------------------------
# Program Name:Vehicle Data
# Author:Sarah Figueroa
# Date:10/19/19
#------------------------------------------------------------------------
# Pseudocode: This program will allow the User to type the Brand, Make, Model, Odometer Readings, ... | true |
03779db4fc85a214f25fef8d4bfcdf20af746dec | 224apps/Leetcode | /1400-1500/1496.py | 1,216 | 4.125 | 4 | '''
Given a string path, where path[i] = 'N', 'S', 'E' or 'W', each representing moving one unit north, south, east, or west, respectively. You start at the origin (0, 0) on a 2D plane and walk on the path specified by path.
Return True if the path crosses itself at any point, that is, if at any time you are on a loca... | true |
1687a783543e00e9307f3c501526b3b094cd2919 | jasonkwong11/ultimate-python | /ultimatepython/data_structures/tuple.py | 562 | 4.4375 | 4 | def main():
# This is a tuple of integers
immutable = (1, 2, 3, 4)
print(immutable)
# It can be indexed like a list
assert immutable[0] == 1
# It can be iterated over like a list
for number in immutable:
print("Immutable", number)
# But its contents cannot be changed. As an al... | true |
bc999276aa750f609d826efac98166e5034e5256 | ganeshzilpe/Guess_the_number | /GuessTheNumber.py | 2,945 | 4.40625 | 4 | #-------------------------------------------------------------------------------
# Name: Guess the Number
# Purpose:
#
# Author: Ganesh
#
# Created: 11/06/2015
# Copyright: (c) Ganesh 2015
# Licence: <your licence>
#Description:
# There are two ranges 0-100 and 0-1000. Computer randomely select o... | true |
501a66ab24c0213e3ddabadb2937f104f684b593 | raberin/hackerrank-questions | /PY/price_check.py | 1,251 | 4.15625 | 4 | """
Given product list and their prices, check if the products being sold have price discrepencies
Example:
products = [egg, milk, cheese]
productPrices = [2.89, 3.29, 5.79]
productSold = [egg, egg, milk, cheese]
productSoldPrices = [2.89, 2.99, 3.29, 5.79]
Answer => The 2nd batch of eggs sold were sold for 0.10 cents ... | true |
ca0576358a06e4a040e2fd4b47118d8e841e3b77 | floryken/Ch.07_Graphics | /7.2_Picasso.py | 1,670 | 4.4375 | 4 | '''
PICASSO PROJECT
---------------
Your job is to make a cool picture.
You must use multiple colors.
You must have a coherent picture. No abstract art with random shapes.
You must use multiple types of graphic functions (e.g. circles, rectangles, lines, etc.)
Somewhere you must include a WHILE or FOR loop to create a ... | true |
3708119728b42de1c8cbb2dd36d7578db2bacb6f | coder-hello2019/Stanford-Algorithms | /Week 1/mergesort.py | 1,431 | 4.40625 | 4 | # Merge sort implementation, done for practice
def mergesort(unsorted):
# base case - if the list has only 1 element, it is sorted
if len(unsorted) <= 1:
return unsorted
# recursive case
else:
# use // so that we can deal with uneven numbers of lists
midpoint = len(unsorted) //... | true |
c119ebb9d32790c530d2e3ae67e283ac2ee2fba2 | zhcheng1/CodingCampusExercise | /Exercises/Exercise3.py | 866 | 4.1875 | 4 |
def converter_2():
user_input = raw_input("Please enter a speed in miles/hour: ")
while not user_input.isdigit():
user_input = raw_input("Please enter an integer as a speed in miles/hour: ")
return user_input
inmile = int(converter_2())
#convert to meter
inmeter = inmile * 1609.34
#convert to ba... | true |
d73d52a7f6dd3afa09857234454f83a202f73ff4 | jgarmendia/Intro-Python | /files/2-guess_the_number.py | 2,058 | 4.21875 | 4 | # template for "Guess the number" mini-project
# input will come from buttons and an input field
# all output for the game will be printed in the console
import simplegui
import random
# initialize global variables used in your code
secret_number = 0
remaining = 7
# define event handlers for control panel
... | true |
fa58535a49a03759048aff85582fbce5c5d38c44 | EddieAzzi/me | /week2/exercise1.py | 1,494 | 4.75 | 5 | """
Commenting skills:
TODO: above every line of code comment what you THINK the line below does.
TODO: execute that line and write what actually happened next to it.
See example for first print statement
"""
import platform
# I think this will print "hello! Let's get started" by calling the print function.
print("h... | true |
cb5431d51aa8df52f2d5b83c429bfa841220381e | GregoryMNeal/Digital-Crafts-Class-Exercises | /Python/List_Exercises/smallest_number.py | 428 | 4.15625 | 4 | # Imports
# Functions
def find_smallest():
numbers = [1,2,5,4,3]
# Find the largest number first
largest = 0
for i in numbers:
if i > largest:
largest = i
# Find the smallest number
smallest = largest
for i in numbers:
if i < smallest:
smallest = i
... | true |
7b3291e14ea6273e216bae60d43fa8344497e4c8 | cyyrusli/hr30dayschallenge | /day17.py | 862 | 4.3125 | 4 | # Day 17 coding challenge - More exceptions
# Write a Calculator class with a single method: int power(int,int). The power method takes two integers, n and
# p, as parameters and returns the integer result of n**p. If either n or p is negative, then the method must throw
# an exception with the message: n and p should... | true |
8c6a656cec052ed2c3ae2498bd07a54cde601512 | meghakailas/Sayone-Training | /SAYONETASKS/PythonTasks/AssignmentSet1/pgm2.py | 217 | 4.3125 | 4 | #program to generate list and tuple
L=[]
T=()
data=input("Enter elemnts separated by comma:")
elements=data.split(",")
for i in elements:
L.append(i)
print("The list is:",L)
T=tuple(L)
print("The tuple is:",T)
| true |
b904a7242e9d05c0298a6cc6ec133d09f346df4c | Evrgreen/Data-Structures | /stack/stack.py | 1,149 | 4.25 | 4 |
import sys
sys.path.append("../singly_linked_list")
from singly_linked_list import LinkedList
"""
A stack is a data structure whose primary purpose is to store and
return elements in Last In First Out order.
1. Implement the Stack class using an array as the underlying storage structure.
Make sure the Stack tes... | true |
78c2d0bf8b1f7d98616666fa111fb23cb01251f2 | pushp360/CCC | /Python/Sorting/SelectionSort.py | 605 | 4.25 | 4 | """
Contributed by: Anushree Khanna
Email-ID: anushreek@ieee.org
"""
#Selection Sort uses the concept of finding the minimum element in the unsorted part of the list and adding it to the end of the already sorted subarray.
def SelectionSort(arr):
for i in range(len(arr)):
currentmin=i
... | true |
1c8620b52f2d2675100cccd5aee9b68d5c13d90c | snehilk1312/Python-Progress | /day_on_date.py | 202 | 4.34375 | 4 | #You are given a date. Your task is to find what the day is on that date.
import datetime as dt
my_date=input()
my_date=dt.datetime.strptime(my_date,'%m %d %Y')
print((my_date.strftime('%A')).upper())
| true |
154d27a9124bebd38888bd10201e6b6c638c91eb | dineshhnaik/python | /PythonSamples/RemoveDuplicates.py | 371 | 4.125 | 4 | # Remove duplicates in list
numbers = [2,6, 4, 5, 6, 5, 8]
duplicate_numbers = []
for num in numbers:
if numbers.count(num) > 1 and num not in duplicate_numbers:
duplicate_numbers.append(num)
print(f'Numbers before removing duplicates: {numbers}')
for num in duplicate_numbers:
numbers.remove(num)
prin... | true |
26246efe4044ffc3b014bb3268e3fec04fdd5d40 | hanssenamanda/Chatbot | /n.py | 1,345 | 4.25 | 4 | user_name = input("Hello, Human. What's your name? ")
print(user_name)
while True:
original_user_response = input("My name is cas. What kind of movie would you like to hear about? ")
user_response = original_user_response.lower()
print(user_response)
if "romcom" in user_response:
p... | true |
a0803e18a4ca89904abfbd89e575e7de1a69c3fd | llgeek/leetcode | /628_MaximumProductofThreeNumbers/solution.py | 380 | 4.1875 | 4 | """
sorted based
key point is to find three largest numbers, and two smallest numbers
time complexity: O(nlgn)
"""
class Solution:
def maximumProduct(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
nums.sort()
left = nums[0]*nums[1]*nums[-1]
right =... | true |
fb86cc6af7306d64d8b433a8388113c9aaaf8199 | RPMeyer/intro-to-python | /Intro to Python/Homework/CSC110_2 Ch03/hw_03_ex_05.py | 1,612 | 4.34375 | 4 | # Assume you have the assignment xs = [12, 10, 32, 3, 66, 17, 42, 99, 20]
# (a) Write a loop that prints each of the numbers on a new line.
# (b) Write a loop that prints each number and its square on a new line.
# (c) Write a loop that adds all the numbers from the list into a variable called total.
# You should set... | true |
2514e006315c3b31b7c989ed486807216918772a | RPMeyer/intro-to-python | /Intro to Python/In Class WS/Chapter_4/WS_Ch04-08.py | 1,151 | 4.25 | 4 | # **********************************************
# WS ch4_8
#
# Write a function, trngl_perim(x1,y1,x2,y2,x3,y3), which takes the
# coordinates of the 3 vertices of a triangle as parameters and
# which returns the perimeter of the triangle. Write a helper
# function, distance(x1,y1,x2,y2), which returns the distance
# ... | true |
745246db47ad2549111992f447622e7449722c73 | RPMeyer/intro-to-python | /Intro to Python/Homework/CSC110_2_Ch08/hw_08_ex_07.py | 706 | 4.125 | 4 | # HW:7,8,10
#
#Write a function that reverses its string argument, and satisfies these tests:
# test(reverse("happy") == "yppah")
# test(reverse("Python") == "nohtyP")
# test(reverse("") == "")
# test(reverse("a") == "a")
import sys
def test(did_pass):
''' print result of a test '''
linenum = sys._getframe(1).... | true |
0d92b0d863287499008ab5be8993e4c280ce5937 | renukrishnan/pythondjangoluminar | /flowcontrols/decisionmaking/assessment1.py | 260 | 4.125 | 4 | #read two numbers
# print true if sum of two numbers is equal to 100 or anyone num is 100
#else print false
num1=int(input("Enter num1:"))
num2=int(input("enter num2:"))
if((num1+num2==100)|(num1==100)|(num2==100)):
print(" True")
else:
print("false") | true |
7a3347411ce42377266da5cf58186b8a6b0fb13f | Yeshitha/AMI-Course-Material | /Lab1/Lab1 Ex3.py | 1,062 | 4.125 | 4 | todo = []
def print_list():
tasks = ['1. insert a new task', '2. remove a task', '3. show all existing tasks', '4. close the program']
for i in tasks:
print(i)
def insert():
print('The name of the task you would like to enter into the list?')
new_task = input()
todo.append(new_task)
def r... | true |
06c489de7776f92c90b4d37e14c49ea562a31161 | Aaradhyaa717/Palindrome-Finder | /Palindrome_finder.py | 737 | 4.59375 | 5 | def palindrome_finder(string):
'''
This function checks if a given string is a palindrome or not.
Example:
Word
Radar Palindrome
Bat Not a palindrome
'''
string_lowercase = string.lower()
#this will makesure there... | true |
2d3a0a13ba6fe9a4a6e9dd1e95d492685838c1a5 | juju515/2nd_year | /2. Code Examples/1- Python review/Python Basic Syntax/ex10_functions_call_stack.py | 2,046 | 4.375 | 4 |
#--------------------------------------------------------
# PYTHON PROGRAM
# Here is where we are going to define our set of...
# - Imports
# - Global Variables
# - Functions
# ...to achieve the functionality required.
# When executing > python 'this_file'.py in a terminal,
# the Python interpreter ... | true |
bec1d1a7e86a85fb1db4d97a1bda12b24617849a | juju515/2nd_year | /2. Code Examples-2/2. Code Examples/1- Python review/Python Basic Syntax/ex13_function_return.py | 2,365 | 4.5 | 4 |
#--------------------------------------------------------
# PYTHON PROGRAM
# Here is where we are going to define our set of...
# - Imports
# - Global Variables
# - Functions
# ...to achieve the functionality required.
# When executing > python 'this_file'.py in a terminal,
# the Python interpreter ... | true |
646705a55145ed4a54d44212827d5afc1296530b | juju515/2nd_year | /2. Code Examples-2/2. Code Examples/1- Python review/Python Compound Types/1. Lists/ex05_lists_remove.py | 1,910 | 4.4375 | 4 |
#--------------------------------------------------------
# PYTHON PROGRAM
# Here is where we are going to define our set of...
# - Imports
# - Global Variables
# - Functions
# ...to achieve the functionality required.
# When executing > python 'this_file'.py in a terminal,
# the Python interpreter ... | true |
90fa7123fc275425e47e009a5739be9b973330b0 | juju515/2nd_year | /2. Code Examples-2/2. Code Examples/1- Python review/Python Compound Types/3. Strings/ex01_strings.py | 2,322 | 4.71875 | 5 |
#--------------------------------------------------------
# PYTHON PROGRAM
# Here is where we are going to define our set of...
# - Imports
# - Global Variables
# - Functions
# ...to achieve the functionality required.
# When executing > python 'this_file'.py in a terminal,
# the Python interpreter ... | true |
2734b3f4d4d517988076c52e3f293c89893d34d3 | stldraxvii/code | /prime.py | 341 | 4.15625 | 4 | from factors import list_factors
def find_primes(num):
factors = list_factors(num)
primes = []
for j in factors:
if factors[j] == 'Prime':
primes.append(j)
return primes
def main():
num = input("Enter a number:")
num = int(num)
print(find_primes(num))
if __name__ == '_... | true |
6e20aea0cc4e8f6fc50e006d7f12e92a294e47ba | sirejik/software-design-patterns | /behavioral_patterns/visitor/visitor.py | 1,837 | 4.125 | 4 | """
Describes the operation performed on each object from some structure. The visitor pattern allows you to define a new
operation without changing the classes of these objects.
"""
from __future__ import annotations
from abc import ABCMeta, abstractmethod
class Element(metaclass=ABCMeta):
@abstractmethod
def... | true |
a13c99cd13cf9add0a87b290dd1ab8d9749608a8 | kreechan123/Python-Basics | /decision_making.py | 308 | 4.125 | 4 | def decision_making():
x = input("Please enter a number between 1,4 and 3:")
if x == 1:
print('You type "I"')
elif x == 4:
print('You type "LIKE"')
elif x == 3:
print('You type "YOU"')
else:
print("Oops! pick number from 1,4 and 3 only!")
decision_making() | true |
5d1ee65e84a15418f9d9739d224223277ee2be8e | LynnePLex/100-days-of-python | /day _two_ bmi-cal.py | 475 | 4.3125 | 4 | height = input("enter your height in m: ")
weight = input("enter your weight in kg: ")
#We can check what type the above variables are
#print(type(height))
#print(type(weight))
#converting the str() into float() and int()
a_height = float(height)
b_weight = int(weight)
#calculating the both data types
result = b_wei... | true |
a0fe4e2348f8b0495cf62dccdc11a6aa8da351fb | bongsang/coding | /binary_gap.py | 1,978 | 4.21875 | 4 | # 1. BinaryGap
# Find longest sequence of zeros in binary representation of an integer.
"""
A binary gap within a positive integer N is any maximal sequence of consecutive zeros that is surrounded by ones at both ends in the binary representation of N.
For example, number 9 has binary representation 1001 and contains ... | true |
2c6e2755e7a21558288a4fc545e5bddea0396deb | SandipanGhosh/Data-Structures-and-Algorithms | /bubble_sort.py | 552 | 4.125 | 4 | def bubble_sort(ar_list):
# Outer range will be n for first pass, (n-1) for second pass etc.
for outer_indx in range(len(ar_list)-1, 0, -1):
# Compare within the set range
for inner_indx in range(outer_indx):
if ar_list[inner_indx] > ar_list[inner_indx+1]:
temp = ar_list[inner_indx]
ar_list[inner_indx... | true |
cfe0ef46e5776a4f9e1b0148ce21d2d9b16b252f | henrylin2008/local_project | /Implementation_Queue.py | 1,071 | 4.375 | 4 | # Queue Methods and Attributes
# Before we begin implementing our own queue, let's review the attribute and methods it will have:
# Queue() creates a new queue that is empty. It needs no parameters and returns an empty queue.
# enqueue(item) adds a new item to the rear of the queue. It needs the item and returns nothi... | true |
3d7246b11e71d8f07f3c90c0b3b28df88ed1cf93 | krhicks221/Trio | /menu.py | 677 | 4.1875 | 4 | menu = """
1. Reverse a string
2. Reverse a sentence
3. Find the minimum value in a list
4. Find the maximum value in a list
5. Calculate the remainder of a given numerator and denominator
6. Return distinct values from a list including duplicates
8. Exit menu
"""
while(True):
print(menu)
choice = input()
if c... | true |
03cfac8179d65005d9426c7d9262be977d1dbf7f | digizeph/code | /reference/Python/lang/number_choice.py | 416 | 4.15625 | 4 | import random
secret_number = random.randint(1, 20)
print("Computer is making a number between 1 and 20")
for t in range(1, 7):
print("choose a number.")
choice = int(input())
if choice < secret_number:
print("should be larget")
elif choice > secret_number:
print("should be smaller")
... | true |
ffc4d88d75a0a16f60a7f69742b1f8b8ce6ca4fb | glen-s-abraham/data-structures-and-algorithms-python | /linkedList.py | 2,691 | 4.34375 | 4 | """
Each node is composed of data and a reference to the next node
Can be used to implement several other comon data types:stacks,queues
Indexing:O(n)
Insert At begining:O(1)
Insert at end:O(n)
Delete at begining:O(1)
Delete at end:O(n)
Waste space:O(n)
Use linked list if you want to insert/remove elements at begining
... | true |
c22939da0cab46dee3d3da7c56453396531ad776 | silent-developer/ml_practice | /udemy/linreg/one.py | 1,086 | 4.3125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Dec 9 19:52:04 2017
@author: Tan
"""
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
x = 10 * np.random.rand(100)
y = 3 * x + np.random.randn(100)
plt.scatter(x,y)
from sklearn.linear_model import LinearRegression
model = LinearR... | true |
61b665b20e386b40e53b86e47aafb285b267fa85 | miloknowles/coding-practice | /hashing/hashtable.py | 1,373 | 4.21875 | 4 | """ Implement a hash table using lists in python. """
class HashTable(object):
def __init__(self, size):
self.size = size
self.table = [None] * self.size
def hash(self, key):
return hash(key) % self.size
def __setitem__(self, key, val):
""" Uses open addressing to resolve collisions. """
idx = self.hash... | true |
94ffd250faaf4357cca3c5409185bf204051a9eb | Jreema/Kloudone_Assignments | /Python/python2/armstrongNumber.py | 300 | 4.15625 | 4 | #to check if a number is armstrong number or not
x=input("Enter a number: ")
x= x.lstrip('0')
order = len(x)
number = list(x)
out = [int(num)**order for num in number]
total =sum(out)
if total== int(x):
print(x," is an armstrong number")
else:
print(x," is not an armstrong number") | true |
d37732755b7ae9dca2a86bf2930f842f3041cfbf | pawarspeaks/Hacktoberfest-2021 | /Python/reverse_digit.py | 208 | 4.21875 | 4 | //simply program to reverse the digits of any number
a=int(input("enter the number:"))
b=0
c=0
while a!=0:
b=int(b*10)
c=int(a%10)
b=b+c
a=int(a/10)
print(b)
| true |
3c197fa76bd299afdc477d500259e3f5dc7846f0 | pawarspeaks/Hacktoberfest-2021 | /Python/palindrom.py | 352 | 4.5 | 4 | print('CODE TO CHECK WHETHER THE WORD IS PALINDROM OR NOT')
print("--------------------------------->>>>>>>>><<<<<<<<<<<<<<<<<<<<----------------------------------------------")
words=input('Enter a word to check if it\'s palindrom:')
new_word=words[::-1]
if new_word==words:
print('It\'s palindrome')
else:
... | true |
fda6466a067f7fce6f15b3a7ecfd17713d76833e | Dillon1john/Turtle-Race | /main.py | 2,065 | 4.3125 | 4 | from turtle import Turtle, Screen
import turtle as t
import random
# Etch Sketch project
# w = forwards
# S = backwards
# A = counter-clockwise(left)
# D = Cloclkwise(right)
# C = clear drawing
is_race_on = False
screen = Screen()
# Resizes screen
screen.setup(width=500, height=400)
user_bet = screen.textinput(title="... | true |
8efcc43403d9bf544beb87226a5d0614ed7c3f4e | nathan-lau/ProjectEuler | /problem_3.py | 553 | 4.1875 | 4 | print('Problem 3:');
#Prime Factors
number = int(input('What is the number you want to find its prime factors ? '))
count = 0;
largest_prime = 1;
x = 1;
for x in range(1, number):
if number % x == 0: #iterate to find the factors of the input
for i in range(1, x):
if x % i == 0:
... | true |
c29d78b2f373f1ad2e182f0ee1eb2f9b5c9b7f9c | Shirley0210/MachineLearning | /MachineLearning/LinearRegresssion.py | 1,721 | 4.15625 | 4 | import numpy as np
import math
#This program is not optimal just understanding of linear regresssion.
Xtrain = [1,2,3,4] #Stores the training inputs
Ytrain = [3,5,7,9] #Stores the training labels
#Hyperparameters
learningRate = .01
numEpochs =1000
#In this case, our hypothesis is in the form of a model representi... | true |
e32e69fd84394bc8ec1ebcea10e0991f4c1805ac | ajh1143/ClassicQuickSort | /QuickSorter.py | 762 | 4.1875 | 4 | def quicksort(arr):
#Initialize Lists
pivoter = []
highVal = []
lowVal = []
#Check size of list, if 1 or less, no need to sort, just return
if len(arr) <= 1:
return arr
#Else, array contains items that must be sorted
else:
#Set pivot = first index
pivot = arr[0]
... | true |
ab80b4e087159b923df0761b706363cff08d9e72 | ivkumar2004/Python | /sample/tablemultiplication.py | 576 | 4.125 | 4 |
def mathstable():
"""Function to generate table from sequence 1 to 12, Number get from user"""
tableInt = int(input("Enter the number to generate its multiples: "))
for sequence in range(1,13):
print ("%s x %s = %s"%(tableInt,sequence,tableInt*sequence))
return
if __name__ == "__main__":
exitOperation = False
... | true |
7debdc1b988769380b99662e44ad84ffaf4fbb79 | Adarsh-shakya/python_lab | /element_in_tuple_or_not.py | 277 | 4.28125 | 4 | #check whether an element exists within a tuple.
n=int(input("Enter any number: "))
t=(3,4,7,6,0,10,5,11,97,34)
for i in t:
if n==i:
print('Entered element is exist in the tuple')
break
else:
print('Entered element is not exist in the tuple')
| true |
8789d03d8451f2e9ddae2852a71bd69ff17630ab | Rachel-Hill/100daysofcode-with-python-course | /days/13-15-text-games/RockPaperScissors/RockPaperScissors.py | 1,982 | 4.1875 | 4 | from player import Player
from roll import Roll
import random
def main():
print_header()
rolls = build_the_three_rolls()
name = get_players_name()
player1 = Player(name)
player2 = Player("computer")
game_loop(player1, player2, rolls)
def get_players_name():
player_name = input("What i... | true |
b259a5d59f37e6c5dd17c5088dea475a2dce1704 | 93akshaykumar/GeneralPractice | /PYTHON/factorial_recursive.py | 309 | 4.28125 | 4 | def factorial(factValue):
if factValue<=1: return 1
else: return factValue * factorial(factValue-1)
try:
factValue=int(input("Please Enter The Number To Find Factorial=="))
except:
print("ERROR - Please Enter The Interger value")
else:
print("The Factorial of ",factValue," is== ",factorial(factValue))
| true |
35c856534fb4a91868572bf2c17caa167c7e0633 | Waka-Entertain/Let-code-everyday | /Python/valid-sudoku.py | 1,892 | 4.125 | 4 | """
Determine if a 9x9 Sudoku board is valid. Only the filled cells need to be validated according to the following rules:
Each row must contain the digits 1-9 without repetition.
Each column must contain the digits 1-9 without repetition.
Each of the 9 3x3 sub-boxes of the grid must contain the digits 1-9 without rep... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.