blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
2ae130d5f467c00cd8c54b05409bbf4839b8579a
shaunn/projecteuler
/Problem1/py/p1.py
1,730
4.21875
4
# divisors of 3 and 5 # # Problem 1 # If we list all the natural numbers below 10 that are divisors of 3 or 5, we get 3, 5, 6 and 9. # The sum of these divisors is 23. # # Find the sum of all the divisors of 3 or 5 below 1000. # Strategies # # 1. `remainder = dividend - divisor * quotient` and `remainder=0` # 2. Using...
true
ab403bbb4698cc504ca55c83af4067710a785ae6
ziyadalvi/PythonBook
/6The Dynamic Typing Interlude/3GarbageCollection.py
1,251
4.28125
4
#when we reassign a variable, what happens to the value it was #previously referencing? For example, after the following statements, what happens to #the object 3? """The answer is that in Python, whenever a name is assigned to a new object, the space held by the prior object is reclaimed if it is not referenced by an...
true
655c7e3810af8e5c502f65f2a95892598a45e1b9
anila-a/CEN-206-Data-Structures
/lab04/mainPolygon.py
1,306
4.5625
5
''' Program: mainPolygon.py Author: Anila Hoxha Last date modified: 03/21/2020 Design a class named Polygon to represent a regular polygon. In regular polygon, all the sides have the same length. The class contains: Constructor: Instance Variable: n – number of sides with default value 3, side – length of th...
true
84f6fd7694a4f63abc9c445f7a2d0a6c13ab57a8
anila-a/CEN-206-Data-Structures
/hw01/hw1_2.py
868
4.125
4
''' Program: hw1_2.py Author: Anila Hoxha Last date modified: 04/2/2020 Consider the Fibonacci function, F(n), which I defined such that 𝐹(1) = 1, 𝐹(2) = 2, 𝑎𝑛𝑑 𝐹(𝑛) = 𝐹(𝑛 − 2) + 𝐹(𝑛 − 1) 𝑓𝑜𝑟 𝑛 > 2. Describe an efficient algorithm for determining first n Fibonacci numbers. What is the running tim...
true
500e415d59727e99428a28bb85835e81a35eb836
anila-a/CEN-206-Data-Structures
/midterm/Q1/main_Q1.py
439
4.25
4
''' Program: main_Q1.py Author: Anila Hoxha Last date modified: 05/14/2020 Implement a program that can input an expression in postfix notation (see Exercise C-6.22) and output its value. ''' from postfix import * ''' Test the program with sample input: 52+83-*4/ ''' exp = str(input("Enter the expressi...
true
ac14eab101249ad1f9e19f01f9add32ad7e01e7a
anila-a/CEN-206-Data-Structures
/lab04/mainFlight.py
1,761
4.5
4
''' Program: mainFlight.py Author: Anila Hoxha Last date modified: 03/21/2020 Design then implement a class to represent a Flight. A Flight has a flight number, a source, a destination and a number of available seats. The class should have: • A constructor to initialize the 4 instance variables. You must shorte...
true
3d4cbfbfc5da19abbc3fd2b8c9e99d4192f48e4c
anila-a/CEN-206-Data-Structures
/midterm/Q2/B/singlyQueue.py
2,276
4.1875
4
''' Program: singlyQueue.py Author: Anila Hoxha Last date modified: 05/16/2020 Write a singlyQueue class, using a singly linked list as storage. Test your class in testing.py by adding, removing several elements. Submit, singlyQueue.py and testing.py. ''' class SinglyQueue: # FIFO queue implementation u...
true
fd59412ce8e23b59d93543166848d4c9ff9f25b6
urmidedhia/Unicode
/Task1Bonus.py
1,543
4.28125
4
number = int(input("Enter number of words : ")) words = [] print("Enter the words : ") for i in range(number): # Taking input in a list words element = input() words.append(element) dist = [] for word in words: # Adding distinct words to a list dist ...
true
d161e2a732a5c0c15610d8145b428419b87bcd9a
Yaasirmb/Alarm-Clock
/alarm.py
602
4.125
4
from datetime import datetime import time from playsound import playsound #Program that will act as an alarm clock. print("Please enter your time in the following format: '07:30:PM \n") def alarm (user = input("When would you like your alarm to ring? ")): when_to_ring = datetime.strptime(user, '%I:%M:%p').tim...
true
e0aa2e46821854211eac3041ec4fee381da8d516
BeAgarwal/Palindrome
/Python/Different Types/palindrome_type1.py
642
4.15625
4
''' Code by Shubham Agarwal Link: https://github.com/BeAgarwal/Palindrome ''' '''Program to check the sum of a digit is a palindrome or not.''' def check_palindrome(n): r = 0 t = n while n > 0: rem = n % 10 r = (r * 10) + rem n = n // 10 if r == t: return True ...
false
5c4d4fd464c0fa9bbb58f4f34125cff05b1a3d57
PauloHARocha/accentureChallenge
/classification_naiveBayes.py
2,036
4.125
4
import pandas as pd from sklearn.naive_bayes import MultinomialNB from sklearn.model_selection import train_test_split from sklearn import metrics # Naive Bayes # The objective of this module is to classify the data from the pre-processed dataset, # based on the alignment of each hero (good or bad), using the Naive B...
true
b8557d880d175569782682709d7055f2e219b994
kabitakumari20/if_else_py
/calculator.py
408
4.3125
4
num=int(input("enter the num:-")) num1=int(input("enter the num1:-")) symbol=input("enter the symbol:-") if symbol=="+": print(num+num1) elif symbol=="-": print(num-num1) elif symbol=="*": print(num*num1) elif symbol=="%": print(num%num1) elif symbol=="//": print(num//num1) elif symbol=="/": pri...
false
770dc7e863343aabae12f23a99b7da024c5827d1
ZakOpry/digital-crafts
/week1/day3/introToPython4.py
271
4.15625
4
# Conditionals print("Welcome to this program") firstName = input("What is your first name?") length_of_first_name = len(firstName) print(firstName) if length_of_first_name <= 0: print("Please enter at least one character") else: print(f"Hello {firstName}")
true
07b213e5a72caa2ce55966adfcdeb5ddf8b05362
HughesSvynnr/prg1_homework
/hw4.py
1,891
4.125
4
''' problem 1 Ask a user for a number. Depending on the number, respond with how many factors exist within that number for example: Enter a number >15 15 has 4 factors, which are 1 3 5 15 ''' ''' problem 2 Write a program that will ask a user for a word. For that word, replace each letter with the appropr...
true
7f3c7e24569cd0d3e070018bc26bf9946c83bf24
Pragya1407/sdet
/python/Activity11.py
327
4.1875
4
dict_fruit = { "apple" : 50, "banana" : 10, "watermelon" : 40, "orange" : 25, "kiwi" : 30 } check_fruit = input("What fruit you want?? ").lower() if (check_fruit in dict_fruit) : print("yes.. " + check_fruit + " is available") else : print("no.. " + check_fruit + " is not avai...
false
71f42f050b38abbc8e9bb1824c52c5195a4783fa
ImBadnick/CryptographyAlgorithms
/Algorithms/SuccessiveQuadratures/sq.py
1,437
4.125
4
def printList(l,listname): print(listname + " values:", end=' ') for j in range(len(l)): print(l[j], end=' ') print("") def decomposeZ(x): powers = [] i = 1 while i <= x: if i & x: powers.append(i) i <<= 1 return powers def calculateY_2_J(y,max,S): l...
false
d1d822f3c1b76c2c4953efa1b43f5fe7f8d8c0c1
ImBadnick/CryptographyAlgorithms
/Algorithms/EllipticCurves/kobritz.py
1,063
4.15625
4
class point: def __init__(self, x, y): self.x = x self.y = y def quadraticResidues(module): quadraticresidues = [] for i in range(module): quadraticresidues.append(point(i,(i**2) % module)) return quadraticresidues if __name__ == '__main__': print("Transform m into a point ...
false
be0d9eb645a4aeadd0f5dc9e5c78336aba9d7527
IvanKelber/plattsburgh-local-search
/Circles/circle.py
2,119
4.15625
4
# Created by Ivan Kelber, March 2017 import sys import random import math def circles(points): ''' - points is a list of n tuples (x,y) representing locations of n circles. The point (x,y) at points[i] represents a circle whose center is at (x,y) and whose radius is i. This function retu...
true
743606a3c25a96d1e7addb7ac6294bc04319f527
NaughtyJim/learning-python
/2019-09-16/trees.py
898
4.34375
4
def main(): width = input('How wide should the tree be? ') height = input('How tall should the tree be? ') print("Here's your tree:") print() width = int(width) height = int(height) # this is the call if we omit the height # print_tree(width, width // 2 + width % 2) print_tree(widt...
true
a32ecf010adc0c1fde48a03a73def9282c101def
Pallavi2000/heraizen_internship
/internship/M_1/digit.py
388
4.21875
4
"""program to accept a number from the user and determine the sum of digits of that number. Repeat the operation until the sum gets to be a single digit number.""" n=int(input("Enter the value of n: ")) temp=n digit=n while digit>=10: digit=0 while not n==0 : r=n%10 digit+=r n=n//10 ...
true
82b7d80de1f353d744906bbe3203149cad2299e2
Pallavi2000/heraizen_internship
/internship/armstrong.py
291
4.375
4
"""Program to check whether a given number is armstrong number or not""" n=int(input("Enter the value of n: ")) temp=n sum=0 while not temp==0: r=temp%10 sum+=r**3 temp=temp//10 if n==sum: print(f"{n} is a armstrong number") else: print(f"{n} is not a armstrong number")
true
40ac93b72c9244b3b4fe2dd07601dd2afd9a1324
Pallavi2000/heraizen_internship
/internship/mod2/labqns/qns1.py
313
4.1875
4
"""Program to calculate Simple interest""" principle = float(input("Enter the principle value: ")) rate_of_interest = float(input("Enter the rate of interest: ")) time = float(input("Enter the time: ")) simple_interest = (principle * rate_of_interest * time) / 100 print(f"Simple interest = {simple_interest}")
false
d6d13883deaedf3f3db0d95dda7a77fda53d5712
CRaNkXD/PyMoneyOrga
/PyMoneyOrga/PyMoneyOrga/domain/account.py
2,184
4.3125
4
from dataclasses import dataclass import datetime @dataclass class Transaction(object): """ Data class for transactions made from and to an account. Used in Account class. """ amount: int new_balance: int description: str time_stamp: datetime.datetime account_id: int = None # foreign...
true
47c8166a0ae2e8c9ef5d2b38fefe83d2983e18d4
as0113-dev/Python-Data-Structure
/mergeSort.py
1,078
4.1875
4
def mergeSort(array): #base case if len(array) <= 1: return array #midpoint of "array" mid = len(array)//2 #split array in half leftSplit = array[:mid] rightSplit = array[mid:] #recursively call the splitting of array leftSplit = mergeSort(leftSplit) rightSplit = mergeS...
true
32e8cbc32de0f0520b196d38feb18cd4000cd71c
trafo41/Hackerrank-python-domain-solutions
/class1_.py
1,508
4.3125
4
""" class Student: message = "hello there" def __init__(self,n,a,m=0): self.name = n self.age = a self.marks = m def display(self): print("-----------------------------") print("Your name : ", self.name) print("Your age : ", self.age) ...
false
2b93732d35dbee22032b49dc9968e6f07ad8ee89
stavernatalia95/Lesson-5.2-Assignment
/Exercise #1.py
781
4.34375
4
# Assume you have the list xs = [12, 10, 32, 3, 66, 17, 42, 99, 20] xs = [12, 10, 32, 3, 66, 17, 42, 99, 20] # Write a loop that prints each of the numbers on a new line for i in xs: print(i) # Write a loop that prints each number and its square on a new line. for i in xs: print(i,i**2) # Wr...
true
c2beb9e3beeb12a3e91f5189ea70fde4e4a07c87
SHETU-GUHA/1st
/1st chapter.py
1,128
4.375
4
print('Hellow World!') print ('What is your name?') myName = input() print ('it is good to meet you ' + myName) print('The length of our name is :') print (len(myName)) print ('what is your age?') myAge = input () print ('You will be ' + str (int(myAge)+1) + 'in a year.') #1. operator (*, -, / , +) values ...
true
6c24097e7f79f64552a51b7ee99e712f6f94e438
HristoMohamed/PythonStuff
/python-retrospective-hw/task1/solution.py
1,535
4.28125
4
#!/usr/bin/env python def what_is_my_sign(day, month): if (month == 3 and day >= 21) or (month == 4 and day <= 20): print('Овен') return 'Овен' if (month == 4 and day >= 21) or (month == 5 and day <= 20): print('Телец') return 'Телец' if (month == 5 and day >= 21) or (month...
false
99765350a6e38f6d6d9b46b2fdf0ae956f4d204f
Anna-Dvoskina/basic_exercises
/string_challenges.py
1,199
4.15625
4
# Вывести последнюю букву в слове from typing import Counter word = 'Архангельск' # ??? print(word[-1]) # Вывести количество букв "а" в слове word = 'Архангельск' # ??? print(f'{Counter(word.lower())}') # Вывести количество гласных букв в слове word = 'Arkhangelsk' count = 0 for letter in word: if letter.low...
false
f204312c8a2bd68d75b89db21b8334c3d7d9191d
Anurag-12/learning-python
/Coroutines_Example/main.py
2,464
4.3125
4
''' Both generator and coroutine operate over the data; the main differences are: Generators produce data Coroutines consume data Coroutines are mostly used in cases of time-consuming programs, such as tasks related to machine learning or deep learning algorithms or in cases where the program has to re...
true
d181bf517a3d745068e1e2de3af4d91abaf18b6b
Anurag-12/learning-python
/seek-tell-file/main.py
861
4.4375
4
#This code will change the current file position to 5, and print the rest of the line. # Note: not all file objects are seekable. f = open("myfile.txt", "r") f.seek(5) print( f.readline() ) f.close() f = open("myfile.txt") f.seek(11) print(f.tell()) print(f.readline()) # print(f.tell()) print(f.readlin...
true
5111dee03f6cdcc8dc76ffe3409b809fefaf4ffd
vijaypalmanit/daily_coding_problem
/daily_coding_problem_2.py
649
4.125
4
# This problem was asked by Uber. # Given an array of integers, return a new array such that each element at index i of the new array is the product of all the numbers in the original array except the one at i. # For example, if our input was [1, 2, 3, 4, 5], the expected output would be [120, 60, 40, 30, 24]. If our...
true
36829d8f6439f71ab6bca0fcf2b99617a611101a
Smile-Bonchichi/Library_Lab_PIPITEH
/4 семестр/Питон/Задание практика 5.py
1,238
4.1875
4
===1=== class Mercedes(object): def __init__(self, colors, type, model): self.colors = colors self.type = type self.mode = model def drive(self): """ Drive """ return "Я за рулем машины" def brake(self): """ Brake ...
false
54ad1438359c861d10e728bea6baadc29fb4f997
RafaelLua13/URI
/1002.py
435
4.1875
4
## Código ## r = float(input()) a = (r * r) * 3.14159 print("A=%0.4f" %a) ## Código comentado ## # r = float(input()) # Definição da variável 'r' como um valor float (Não necessáriamente inteiro). # a = (r * r) * 3.14159 # Cálculo da área do circulo multiplicando r^2 (r**2) pelo valor de Pi (3...
false
1f848e8400a6ecfc1342116e24906206c8745fd2
GDMane/Santubhau
/collectionsArrays/listOperations.py
921
4.15625
4
print("Shree Swami Samarth") print("Collections (array)") gmList = ['ganesh', 'ganesh', 'gmList']#duplicate allowed print(gmList[0])#single object print using index print("--------------") ''' gmList.reverse() print(gmList)#reverce elements in original refrance print("--------------") ''' gmList[0]="myChange" prin...
false
c4051d5b29c21c23b545cee418d14da0e11b29a0
shaunakchitare/PythonLearnings
/function_programs.py
2,152
4.40625
4
#------------------------------------------------------------------------------- #Exercise 1 - Creat a function that accepts 3 ardument and return their sum print('\nExercise 1') def add_numbers(x,y,z): total = x + y + z return total total = add_numbers(5,1,9) print(total) #------------------------------------...
true
1cd0a2fc2283355d1398aafb3fea2e57a50b5312
kovokilla/python
/namedTuple.py
684
4.375
4
# Import the 'namedtuple' function from the 'collections' module from collections import namedtuple # Set the tuple #tuple je v podstate object individual = namedtuple("Nazov_identifikacia", "name age height") user = individual(name="Homer", age=37, height=178) user2 = individual(name="Peter", age=33, height=175) # Pri...
true
75f90baadc03152562d4ef37d19a8b050130664c
carlan/dailyprogrammer
/easy/2/python/app.py
1,003
4.21875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """app.py: challenge #2""" __author__ = "Carlan Calazans" __copyright__ = "Copyright 2016, Carlan Calazans" __credits__ = ["Carlan Calazans"] __license__ = "MIT" __version__ = "1.0.0" __maintainer__ = "Carlan Calazans" __email__ = "carlancalazans at gmail dot com" __status...
false
8433b4e7cd6dd75a94344d8a5eb9d75f37a41ca3
udoy382/PyCode15h
/chapter_005.py
1,657
4.25
4
# Chapter -5 Dictionary & Sets # mydict = { # "Fast": "In a quick manner", # "Udoy": "Coder", # "Marks":[1,2,3,4], # "anatherdict": {'Udoy':'Player'} # } # print(mydict['Fast']) # print(mydict['Udoy']) # mydict['Marks'] = [22, 99, 436] # print(mydict['Marks']) # print(mydict['anatherdict']['Udoy']) #...
false
0161d8a35ce81625815121d56e93b56162a62b95
sabirul-islam/Python-Practice
/ANISUL ISLAM/list.py
1,125
4.34375
4
subjects = ['javascript', 'python', 'php', 'java', 'flutter', 'kotlin'] print(subjects) print(subjects[1]) print(subjects[2:]) # print from 2 number index print(subjects[-1]) print('python' in subjects) # check is this subject in here?(case sensitive) print('golang' not in subjects) # it returns true print(subjects + [...
true
a2ebbe7a95c56145f67b5e46208e3bbced0c44d2
Bokomoko/classes-and-operations-in-data-model-python
/main.py
744
4.375
4
class Polynomial: # method to initialize the object with some values def __init__(self, *coefs): self.coefs = coefs # function to represent the object (print) # similar to __str__ but for debuging purposes # it will be used if no __str__ method def __repr__(self): return 'Polynomial(*{!r})'.forma...
true
3ca81cce7fcf16010bd88b5fc94d932dd5834db0
rodrigodata/learning
/pyhton/arithmetic_operations/arithmetic_operations.py
434
4.1875
4
# add print(10 + 3) # 13 # subtract print(10 - 4) # 6 #float print(2.22 * 3) # 6.66 # multiplication print(2 * 8) # 16 # division print(10 / 3) # 3.3333333333333335 print(10 // 3) # 3 => Returns an integer from division # modules print(10 % 3) # 1 Returns the remaining # exponation print(10 ** 3) # 1000 #### #i...
true
f69b922883c61272175ca5b0a538106b2941a81a
esencgr/Programming_Contest_Solutions
/HackerRank/PYTHON/swap_case.py
342
4.15625
4
def swap_case(s): temp = list() st = "" for i in s: if i.islower(): temp.append(i.upper()) elif i.isupper(): temp.append(i.lower()) else: temp.append(i) return st.join(temp) if __name__ == '__main__': s = input() result = swap_cas...
false
23af8376aab114dd358d6d40903882886c800d88
ryankchang/DataClass
/Python Codes/Week3-1/Exercise 5.py
1,093
4.1875
4
import random possible = ['rock','paper','scissors'] continue_code = 'y' while continue_code == 'y': user = input('Pick one - [rock | paper | scissors]: ') computer = random.choice(possible) if user not in possible: print('Please select a valid choice. {user} is not valid.') print(f'You pic...
false
3c9c29480c72a6e8082cd18297d94773ab531e4f
gedo147/Python
/ConvertClassToDictionary/BinaryTree.py
719
4.1875
4
class BinaryTree: def __init__(self,value=None, left=None, right=None): self.value = value self.left = left self.right = right tree = BinaryTree(10,left=BinaryTree(7,left=3, right=8), right=BinaryTree(15,left=11,right=17)) print(tree.__dict__) print("So as we can see only ...
true
05efea7cc368a98561a771dbc17927731fcf81f9
gedo147/Python
/Comprehension/dict_comprehensions.py
1,078
4.4375
4
d = { 'hello': 1, 'hi': 2, 'namaste': 3} print("Current Dictionary") print(d) print("when we iterate over a dictionary, every item becomes a tuple") for item in d.items(): print(item) a,b,c = ("abc", 12, 14) # and this is how a tuple can be extracted print(a) print(b) print(c) #so for a, b in...
false
70ded69c41a75a06894364a029d28f77f54cad9c
ariannasg/python3-training
/standard_library/json_ops.py
1,356
4.1875
4
#!usr/bin/env python3 # working with JSON data import json import urllib.request # use urllib to retrieve some sample JSON data req = urllib.request.urlopen("http://httpbin.org/json") data = req.read().decode('utf-8') print(data) # use the JSON module to parse the returned data obj = json.loads(data) # when the data...
true
9835578b347135a0a3be9da82c7f1538b64843d1
ariannasg/python3-training
/advanced/lambdas.py
1,336
4.8125
5
#!usr/bin/env python3 # lambdas are simple and small anonymous functions that are used in situations # where defining a whole separate function would unnecessarily increase the # complexity of the code and reduce readability. # Lambdas can be used as in-place functions when using built-ins conversion # functions like...
true
45287696df3e49cbf7899d074edcdc0ae31e35a4
ariannasg/python3-training
/standard_library/random_sequence.py
1,788
4.8125
5
#!usr/bin/env python3 import random import string # A common use case for random number generation is to use the generated # random number along with a sequence of other values. # So for example, you might want to select a random element from a list or # a set of other elements. # Use the choice function to randomly ...
true
4e1dec27165ae11de26af08675f180aaaba8f2d9
ariannasg/python3-training
/standard_library/urls_parsing.py
1,349
4.15625
4
#!usr/bin/env python3 # Using the URL parsing functions to deconstruct and parse URLs import urllib.parse sample_url = "https://example.com:8080/test.html?val1=1&val2=Hello+World" # parse a URL with urlparse() result = urllib.parse.urlparse(sample_url) print(result) print('scheme:', result.scheme) print('hostname:', ...
true
bec0dc0a1418dc6eaddb447325395115ed8dddb4
ariannasg/python3-training
/standard_library/string_search.py
897
4.46875
4
#!usr/bin/env python3 # Use standard library functions to search strings for content sample_str = "The quick brown fox jumps over the lazy dog" # startsWith and endsWith functions print(sample_str.startswith("The")) print(sample_str.startswith("the")) print(sample_str.endswith("dog")) # the find function starts sea...
true
e5acc44ad8a023261a1818cce025e33ea782e299
vijonly/100_Days_of_Code
/Day2/tip_calculator.py
357
4.1875
4
# Tip Calculator project print("Welcome to the tip calculator.") bill = float(input("What was the total bill? $")) partition = int(input("How many people to split the bill? ")) tip_percentage = int(input("What percentage tip would you like to give? 10, 12, or 15? ")) print(f"Each person should pay: ${(bill / partition...
true
b3c75e95a54ef8a1ddaf19b83b4595a94df35cd7
vijonly/100_Days_of_Code
/Day15/coffee_machine.py
2,702
4.25
4
# Coffee Machine Program MENU = { "espresso": { "ingredients": { "water": 50, "coffee": 18, }, "cost": 1.5, }, "latte": { "ingredients": { "water": 200, "milk": 150, "coffee": 24, }, "cost": 2.5, ...
true
5db1788519d32d194b83d998344193c9cc8044d9
vijonly/100_Days_of_Code
/Day8/area_calc.py
654
4.3125
4
# Area Calc """ You are painting a wall. The instructions on the paint can says that 1 can of paint can cover 5 square meters of wall. Given a random height and width of wall, calculate how many cans of paint you'll need to buy. Formula to caclculate number of cans: (wall_height x wall_width) / coverage per can """ ...
true
591489c8f26efdd66c23665fce80a3d5ea3096dd
malmhaug/Py_AbsBegin
/Ch4E2_egasseM/main.py
353
4.34375
4
# Project Name: Ch4E2_egasseM # Name: Jim-Kristian Malmhaug # Date: 11 Des 2015 # Description: This program take an input message from the user and prints it backwards message = str(input("Hey! Please enter a message: ")) print("\nThe message is backwards:\n") for letter_nr in range(len(message), 0, -1): print(...
true
ab6a519ff67fba192d60c3fc45b4833034676a9a
malmhaug/Py_AbsBegin
/Ch3E4_GuessMyNumber_V1.02/main.py
2,503
4.21875
4
# Project Name: Ch3E4_GuessMyNumber_V1.02 # Name: Jim-Kristian Malmhaug # Date: 25 Oct 2015 # Description: This program is a modified version of the # Guess My Number program from the book, with computer versus player # Guess My Number - Computer guesser # # The user picks a random number between 1 and 100 # The comp...
true
cefb4ec8bf58af1859c49337d9cd7ca70df5ef77
pohrebniak/Python-base-Online-March
/pogrebnyak_yuriy/03/Task_3_2_Custom map.py
1,779
4.34375
4
''' Implement custom_map function, which will behave like the original Python map() function. Add docstring. ''' def custom_map(func, *args): """ Custom_map function, which will behave like the original Python map() function. :param arg1: func, function name to which custom_map passes each element of giv...
true
4674b82a4afad64d74fe1973eb1c83566b3c6aab
pohrebniak/Python-base-Online-March
/kirill_kravchenko/02/task_2.3.py
1,580
4.25
4
# Given an array, find the int that appears an odd number of times. There will always be only one integer that appears an odd number of times. # # Examples: # # list: [1, 2, 3, 1, 3, 2, 1] # output: 1 str = [1, 2, 3, 1, 3, 2, 1] # ====== # 1 variant # ====== equiv = 0 for i in str: for j in str: if i ...
true
d03e936eb276d78f90572ad39a31e14ff76a32e5
MuskanKhandelwal/Coding-problem-prep
/Operator overloading.py
456
4.125
4
class Student: def __init__(self,x,y): self.x=x self.y=y def __add__(self, other): ans1=self.x+other.x ans2=self.y+other.y return ans1,ans2 S1=Student(10,20) S2=Student(5,6) S3=S1+S2 #This will give error as we are trying to add 2 objects, so we will override ad...
true
4c92cfc6d9f3709ab208e4fec1d2bc1970cccea2
agladman/python-exercises
/small-exercises/readtime.py
1,087
4.15625
4
#!/usr/bin/env python3 """ Calculates reading time based on average pace of 130 words per minute. """ import sys, time def mpace(p): if type(p) == int and p > 0: return p else: match p: case "slow": return 100 case "average": return 130...
true
25dce67e505a17f3c7b71eb4a397539c956fa72d
agladman/python-exercises
/small-exercises/alphabetbob.py
406
4.34375
4
#!/usr/bin/env Python3 """ Write a program that asks the user for their name, and then prints out their name with the first letter replaced by each letter of the alphabet in turn, e.g. for 'Bob' it prints 'Aob', 'Bob', 'Cob', 'Dob' etc. """ alpha = 'A B C D E F G H I J K L M N O P Q R S T U V W X Y Z'.split() name =...
true
3a82c8e9821e237a17e5ffe44aa806518de59433
agladman/python-exercises
/small-exercises/benny.py
650
4.21875
4
#!/usr/bin/env python3 while True: name = input('What is your name? ') if name.replace(' ', '').isalpha(): print(f'Hello, {name}.') break else: print('That\'s not a name!') print('Here are the letters in your name: ', end='') letters = [] for c in name: if c not in letters: ...
false
827baf8718a70c90c62f702f817824a47d6ac068
dtom90/Algorithms
/Arrays/nearly-sorted-algorithm.py
1,490
4.125
4
""" Nearly Sorted Algorithm https://practice.geeksforgeeks.org/problems/nearly-sorted-algorithm/0 Given an array of n elements, where each element is at most k away from its target position. The task is to print array in sorted form. Input: First line consists of T test cases. First line of every test case consists o...
true
0a67103e7ad9ba72106c840ed1dfcd7e07c2869c
dtom90/Algorithms
/Encoding/url-shortener.py
2,067
4.5
4
""" https://practice.geeksforgeeks.org/problems/design-a-tiny-url-or-url-shortener/0 Design a system that takes big URLs like “http://www.geeksforgeeks.org/count-sum-of-digits-in-numbers-from-1-to-n/” and converts them into a short 6 character URL. It is given that URLs are stored in database and every URL has an asso...
true
834de094ea09b3e3a66ea6b7222a8ad905f9d790
nurawat/learning_python
/list_range_introduction.py
641
4.15625
4
## # Basic Learner type # ## # ip_address = input("Please Enter IP address : ") # print(ip_address.count(".")) ip_address = ["127.0.0.1", "192.168.0.1", "192.168.1.1"] for single_IP in ip_address: print("IP given is {}".format(single_IP)) ### List even = [2, 4, 6, 8] odd = [1, 3, 5, 7] numbers = even + odd l_num...
true
34b4df534b19bc416dffdb4f35a63681d9c6fa16
anant-creator/Other_sources
/Area_perimeter_of_Triangle.py
404
4.125
4
''' Area and perimeter of a right angle triangle ''' base = int(input("Enter the base of triangle:- ")) height = int(input("Enter the height of triangle:- ")) print("If you want to know the area then use '0' as hypotenuse") hypotenuse = int(input("Enter the hypotenuse:- ")) area = base * height / 2 perimeter = base +...
true
66a5d533a37ba0df7d85bba6df765a903e5679d3
KakE-TURTL3/PythonPractice
/Login System/loginSystem.py
1,509
4.15625
4
import time #Introduces user to program they are using print("Welcome to *insert name here*") #Asks the user to either register or log in opt = int(input ("To continue you must login or register. Please pick an option.\n1)Log In\n2)Register\n")) #Defines login function def login(): accountName = input(...
true
704eeb3197f4bfd65121dcb7bed54dc5113014b5
simrit1/scrabble-word-score-calculator
/scrabble_word_score.py
1,837
4.25
4
''' Habitica Challenge October 2019 Challenge Description In the game Scrabble each letter has a value. One completed word gives you a score. Write a program that takes a word as an imput and outputs the calculated scrabble score. Values and Letters: 1 - A, E, I, O, U, L, N, R, S, T 2 - D, G 3 - B, C, M, ...
true
f1bee033404e488367764c89353caa5798015b37
PaulCardoos/pythonBasics
/ListComprehensions/Examples/concatLists.py
214
4.21875
4
#concatenting lists in python is like combing them x = [1, 2, 3] y = [4, 5] z = x + y print(z) #z = [1, 2, 3, 4, 5] #if you multiple 3 * x it is similar to x + x + x print(3 * x) #[1, 2, 3, 1, 2, 3, 1, 2, 3]
false
08f9a8c7e174acc88b18811e4b2b6ee2b6bc0c4f
Liquid-sun/MIT-6.00.1x
/week-4/fruits.py
1,665
4.21875
4
""" Code Grader: Python Loves Fruits (10 points possible) Python is an MIT student who loves fruits. He carries different types of fruits (represented by capital letters) daily from his house to the MIT campus to eat on the way. But the way he eats fruits is unique. After each fruit he eats (except the last one wh...
true
d43a9d3ba885470d292cb3d377913f7257862571
Liquid-sun/MIT-6.00.1x
/week-1-2/payments3.py
731
4.125
4
#!/usr/bin/env python balance = 320000 annualInterestRate = 0.2 monthlyInterestRate = annualInterestRate / 12.0 min_pay = balance / 12 max_pay = (balance * (1 + monthlyInterestRate)**12) / 12.0 ans = (min_pay + max_pay) / 2 while(balance <= 0): print('pay: ', ans) for month in range(1, 13): balance -= a...
true
2dfc365283d74732559002389ca6b526ec4d0891
Liquid-sun/MIT-6.00.1x
/quiz/flatten.py
616
4.46875
4
#!/usr/bin/env python """ Problem 6 (15 points possible) Write a function to flatten a list. The list contains other lists, strings, or ints. For example, [[1,'a',['cat'],2],[[[3]],'dog'],4,5] is flattened into [1,'a','cat',2,3,'dog',4,5] """ def flatten(aList): ''' aList: a list Returns a copy of a...
true
96f5e490d0d0e216bc13b8ac4b6fced2a3888e86
Liquid-sun/MIT-6.00.1x
/week-6/queue.py
1,694
4.46875
4
#!/usr/bin/env python """ For this exercise, you will be coding your very first class, a Queue class. Queues are a fundamental computer science data structure. A queue is basically like a line at Disneyland - you can add elements to a queue, and they maintain a specific order. When you want to get something off the en...
true
d34b5d4f791efb03822cd6841ba5f7636cf635f1
prajaktasangore/coding-challenge-2015
/PythogorousTriplets.py
787
4.3125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # Author: Prajakta Sangore # Date: 30th September 2015 # Problem: A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, # a2 + b2 = c2 # For example, 32 + 42 = 9 + 16 = 25 = 52. # There exists exactly one Pythagorean triplet for which a + b...
true
c8a6d7caef5c558d448908ba2f764f4adbfab1d8
chunkify/Course_Materials
/CMPT 830_Bioinformatics_and_Computational_Biology/Assignment_1/Solution/Exercise 2.py
2,098
4.21875
4
#!/usr/bin/env python3 # This script will open the file "Glycoprotein.fasta" and read each line of the # file within a for-loop. That means that each iteration through the for-loop # will be performed with a new (the next) line of the input file. The # number of characters in each line is printed. # Open the file #f...
true
b87ab17b096cb7c1eed8dd619788156da0ce6047
ashrafuzzaman1973/python-basic
/logical.py
424
4.1875
4
''' num1 = 30 num2 = 50 num3 = 40 if num1 > num2 and num1 > num3 : print(num1) elif num2 > num1 and num2 > num3 : print(num2) else: print(num3) ''' #vowel - a,e,i,o,u ''' ch = 'b' if ch == 'a' or ch == 'e' or ch == 'i' and ch == 'o' or ch == 'u' : print("Vowel") else: print("Consonant") ''' marks...
false
d3db0e57da66e3105e022c17ee7567a2358b9541
chriscross00/cci
/data_structures/linked_lists.py
2,176
4.15625
4
# https://www.codefellows.org/blog/implementing-a-singly-linked-list-in-python/ # READ THIS https://www.greenteapress.com/thinkpython/thinkCSpy/html/chap17 # .html # creating the class Node class Node: def __init__(self, data, next=None): self.data = data self.next = next def get_data(self)...
true
4f4b1f8d07e12ede2fc210ab563bd6ece33feeab
BlackTimber-Labs/DemoPullRequest
/Python/ashi77.py
1,785
4.28125
4
from random import randint EASY_LEVEL_TURNS = 10 HARD_LEVEL_TURNS = 5 #Function to check user's guess against actual answer. def check_answer(guess, answer, turns): """checks answer against guess. Returns the number of turns remaining.""" if guess > answer: print("Too high.") return turns - 1 elif guess...
false
13300283d829e0a97591566f852896cbf30e2a00
BlackTimber-Labs/DemoPullRequest
/Python/tripur1.py
303
4.15625
4
# to find sum # of elements in given array def _sum(arr): sum=0 for i in arr: sum = sum + i return(sum) # driver function arr=[] # input values to list arr = [12, 3, 4, 15] # calculating length of array n = len(arr) ans = _sum(arr) # display sum print ('Sum of the array is ', ans)
true
ae33b423103085042b0b0084035f20108689778e
fizzahwaseem/Assignments
/31_gcd.py
394
4.21875
4
#Python program to compute the greatest common divisor (GCD) of two positive integers. print('To find GCD enter ') num1 = int(input('number 1 : ')) num2 = int(input('number 2 : ')) if num1 > num2: greater = num1 else: greater = num2 for i in range(1, greater+1): if((num1 % i == 0) and (num2 % i == 0...
true
37bd3a47aacd1402a5e1a2dd9bc3d828b0222027
fizzahwaseem/Assignments
/26_digit_to_etc.py
257
4.53125
5
#Python program to convert an integer to Binary, Octal and Hexadecimal numbers decimal = int(input("Enter an integer: ")) print(decimal, "to binary: ", bin(decimal)) print(decimal, "to octal: ", oct(decimal)) print(decimal, "to hexadecimal: ", hex(decimal))
false
bd671af590ae1ec9251afc96487aa2e1f95db6cb
fizzahwaseem/Assignments
/20_time_to_seconds.py
224
4.28125
4
#Python program to convert all units of time into seconds. hour = int(input("Enter time in hours: ")) minute = int(input("Enter time in minutes: ")) t = (hour * 60 * 60) + (minute * 60) print("Total time in seconds is: ", t)
true
26a3b257f2a1797e32773e653195450f68e83729
AnneOkk/Alien_Game
/bullet.py
1,561
4.125
4
import pygame from pygame.sprite import Sprite class Bullet(Sprite): """A class to manage bullets fired from the ship""" def __init__(self, ai_game): """Create a bullet object at the ship's current position.""" super().__init__() self.screen = ai_game.screen self.settings = ai_...
true
343cd7567341f94b32b70ac9b1089734aa79aaaf
trev3rd/gogo
/guess1.py
1,622
4.46875
4
import random guessesTaken = 0 #this represents how many times the user has tried guessing the right number starting from zero number = random.randint(1, 10) print(number) #this shows the random number the computer picked good for seeing if code works properly print(' I am thinking of a number between 1 and 10.') ...
true
e40c1a1235616b50f4eee5211d52146eb15d2234
rugved-mahamune/interview-practice
/fibo.py
273
4.1875
4
'''def fibonacci(n): if(n == 1 or n == 2): return 1 else: return fibonacci(n-1) + fibonacci(n-2) num = 8 print(fibonacci(num))''' list1 = [0,1] n = 8 curr = 2 while(curr < n): list1.append(list1[curr-1] + list1[curr-2]) curr+=1 print(list1)
false
0b5ce13bcb253816f93f40949150a0fc47b2dddd
faliona6/PythonWork
/letter.py
404
4.125
4
word = input("What is the magical word?") def Dictionary(word): dictionary = {} a = 0 for letter in word: if letter in dictionary: dictionary[letter] = dictionary[letter] + 1 else: dictionary[letter] = 1 return dictionary dictionary = Dictionary(word) for let, ...
true
7b14801d22dc3b8aedb276b27d5e636634fc25c7
Darshan1917/Data_analysis
/titanic.py
1,330
4.28125
4
# -*- coding: utf-8 -*- import pandas as pd import numpy as np titanic = pd.read_csv('train.csv', delimiter = ',') ''' ## checking the datatypes #print (titanic.info()) ## or #print (titanic.dtypes) ## Describe gives mean total number , median etc #print (titanic.describe()) ''' # print (type(titanic)) ''' ...
false
1b536c7de215a6511df46e606f059fef64529533
j33mk/PythonSandboxProdVersion
/pythonsandbox/sandbox/newpython/dopamine.py
872
4.1875
4
#i was thinking how can i link my dopamine with programming, get back to programming and learn datascience, machine learning, and make myself expert in everything that i come across # what is stopping me? What are the things that are stopping me # this is the question that i am searching the answer print('dopamine re...
true
eff5e1ac079573feb1d0cf78aacd4f2088e8c845
turalss/Python
/day_2_a.py
1,299
4.40625
4
# Write a string that returns just the letter ‘r’ from ‘Hello World’ # For example, ‘Hello World’[0] returns ‘H’.You should write one line of code. Don’t assign a variable name to the string. hello_world = 'Hello World' print(hello_world[8]) # 2. String slicing to grab the word ‘ink’ from the word ‘thinker’ # S=’hel...
true
8c4f0158e801cb77e85555ac6283c78f44c99ce9
AISWARYAK99/Python
/tuples.py
952
4.65625
5
#tuples #they are not mutable my_tuple=() my_tuple1=tuple() print(my_tuple) print(my_tuple1) my_tuple=my_tuple+(1,2,3) print(my_tuple) my_tuple2=(1,2,3) my_tupple4=tuple(('Python','Java','Php',1)) print(my_tuple2) print(my_tupple4) my_tuple5='example', #add comma if we want tuple with single elements pri...
true
b3fd5e9b71657eeb1333aa465f429d511ba27a2f
AISWARYAK99/Python
/start1.py
1,685
4.28125
4
#python beginning ''' There are 6 data types in python. 1.Numeric(not mutable) 2.List(mutable) 3.Tuples 4.Dictionary 5.Set 6.String ''' print('hello users welcome to the basics') a=int(input('Enter num a:'))#input is read as a string so converting it to int. b=int(input('Enter num s:'))#type conversion of s...
true
eadc78f6241176af767fed72ac5fbf14b5440c4f
Ivasuissa/python1
/isEven.py
246
4.1875
4
def is_even(n): if (n % 1) == 0: if (n % 2) == 0: print("True") return True else: print("False") return False else: print(f"{n} is not an integer") is_even(-4)
true
eb0146449cf4c1038ba3107983fbed12bb9db675
mdmcconville/Solutions
/validPalindrome.py
683
4.15625
4
import string """ This determines whether a given string is a palindrome regardless of case, punctuation, or whitespace. """ class Solution: """ Precondition: s is a string Postcondition: returns a boolean """ def isPalindrome(self, s): # Case: string is empty if not s: ...
true
9c86124bc1733189f8edab9712a4d79e3e074345
mlesigues/Python
/everyday challenge/day_19.py
1,916
4.125
4
#Task: Vertical Order Traversal of a Binary Tree from Leetcode #src:https://www.geeksforgeeks.org/print-binary-tree-vertical-order-set-2/ #src:https://leetcode.com/problems/vertical-order-traversal-of-a-binary-tree/discuss/253965/Python-8-lines-array-and-hashmap-solutions # Definition for a binary tree node. # class T...
true
551824b92a522ebbaa8d8efb5b2a790953662133
mlesigues/Python
/everyday challenge/day_13.py
1,713
4.125
4
#TASK: Given a full name, your task is to capitalize the name appropriately. #input: s is the full name # Complete the solve function below. def solve(s): #s[0] = s.capitalize() #cap = s.capitalize() # for i in len(range(s)): # if s[i] == " ": # s[i+1] = s.capitalize() # for i in ra...
true
bc4bbe31282a164f7490f19f8809323a04e551c7
mangel2500/Programacion
/Práctica 7 Python/Exer-2.py
603
4.1875
4
'''MIGUEL ANGEL MENA ALCALDE - PRACTICA 7 EJERCICIO 2 Escribe un programa que lea el nombre y los dos apellidos de una persona (en tres cadenas de caracteres diferentes), los pase como parmetros a una funcin, y sta debe unirlos y devolver una nica cadena. La cadena final la imprimir el pr...
false
ece505a202ad37c9ca990f3b84f121cc076f5a02
amrishparmar/countdown-solver
/countdown.py
2,941
4.25
4
import argparse import sys def load_words(filename): """Load all words (9 letters or less) from dictionary into memory :param filename: A string, the filename to load :return: A set, all relevant words in the file """ valid_words = set() with open(filename, 'r') as word_file: for...
true
c77766a42c2ad2c69e0dbb57ae284d8aa04f5a64
robinyms78/My-Portfolio
/Exercises/Python/Learning Python_5th Edition/Chapter 4_Introducing Python Object Types/Examples/Dictionaries/Nesting Revisited/Example1/Example1/Example1.py
375
4.46875
4
rec = {"name": {"first": "Bob", "last": "Smith"}, "jobs": ["dev","mgr"], "age": 40.5} # "name" is a nested dictionary print(rec["name"]) # Index the nested dictionary print(rec["name"]["last"]) # "jobs" is a nested list print(rec["jobs"]) # Index the nested list print(rec["jobs"][-1]) # Expand Bob's job descripti...
true
461fdf8ec3a0c44f068c802e51eff664a205dc27
dineshkumarkummara/my-basic-programs-in-java-and-python
/folders/python/instagram/45while_else.py
295
4.53125
5
#In Python, you can add the "else" block after a "while" loop. # It will be executed after the loop is over. x=3 while x<=5: #change the condition to check different outputs print(x) x+=1 #if the condition is false then else statement will be executed else: print("done")
true
131fea2d621c3a61c365d6794793cd4ba30ba951
dineshkumarkummara/my-basic-programs-in-java-and-python
/folders/python/others/fun2.py
605
4.4375
4
def fun(*args): for i in args: print(i) args=1,2,3,4,5,6 fun(*args) #or print("----------") fun(7,8,9) #You can't provide a default for args, for example func(*args=[1,2,3]) will raise a syntax error (won't evencompile). # You can't provide these by name when calling the function, for example func(*args=...
true