blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
e79b3bee9714ca2a548311b7e78fd203503d70e1
ShifaZaman/IntroToPython
/Pyramid.py
215
4.34375
4
print("Input a number to make a pyramid!") number=input() for a in range(2,13): #I started at 2 because when you start at 1, it repeats. it'll be like #3 #3 #33 #333 print(number*a) '''c="5" print(3*c)'''
true
fc0c9b2102f094a2f6b79dd97e276ed6eb0f0679
ShifaZaman/IntroToPython
/24hourto12hour.py
1,283
4.5
4
print("Type hours in 24-hour mode") hours=int(input()) hoursnew=hours%12 #% - gives you the remainder. Modulus of something that is smaller will be itself e.g 11 is smaller than 12 so it will be 11 if((hours>24)|(hours<1)): # If comparing two things, put brackets around both so it does bedmas and evaluates brackets fi...
true
bb66288e230ed522491b095ba3e344221bd27ba1
CodeSeven-7/password_generator
/password_generator.py
670
4.25
4
# password_generator.py import random import string print('Welcome to PASSWORD GENERATOR!') # input the length of password length = int(input('Enter the length of the password you would like to create: ')) # define data num = string.digits symbols = string.punctuation lower = stri...
true
df43194f5d82d5808925736e24351938641ac355
Juanjo-M/Primero
/Lab31112.py
360
4.125
4
year = int(input("Enter a year: ")) if year >= 1582: if year % 4 != 0: print("This is a common year.") elif year % 100 != 0: print("This is a leap year.") elif year % 400 != 0: print("This is a common year.") else: print("This is a leap year.") else: print("Not within...
true
473e2eff54f1ee5faa5151c8968fab0f705b73c1
unclebae/python_tutorials
/DataStructures/DictionariesTest.py
2,154
4.34375
4
# Dictionaries are sometimes found in other languages as "associative memories" or "associative arrays" # Unlike sequences, which are indexed by a range of numbers, dictionaries are indexed by keys, # which can be any immutable type; # strings and numbers can always be keys tel = {'jack':4098, 'sape':4139} tel['guido'...
true
4598d2e50265da88fab8cfe116c5581a57816524
nshagam/Python_Practice
/Divisors.py
463
4.28125
4
# Create a program that asks the user for a number and then prints out a list of all # the divisors of that number. (If you don’t know what a divisor is, it is a number that # divides evenly into another number. For example, 13 is a divisor of 26 because 26 / 13 has no remainder.) num = int(input("Enter a number: ...
true
ed105b7cf0dbaee6468a2c8a298708a344894b08
shanekelly/SoftDesSp15
/toolbox/word_frequency_analysis/frequency.py
1,568
4.5625
5
""" Analyzes the word frequencies in a book downloaded from Project Gutenberg """ import string def get_word_list(file_name): """ Reads the specified project Gutenberg book. Header comments, punctuation, and whitespace are stripped away. The function returns a list of the words used in the book as a list. A...
true
ddc7d4172e1200bef9ffa01f9b5682eab34e8be1
bearddan2000/python-cli-pydoc-ugly-num-functional-prog
/bin/main.py
1,323
4.1875
4
""" Given a number find the next number that is divides by 2, 3, or 5. """ def max_divide(a, b): """ This function divides a by greatest divisible power of b :param a: const number 2, 3, 5 :param b: current number iteration :return: max number 2, 3, 5 """ if a % b != 0: return a; ...
true
4bb59227eb63e743e7bd58732cbe7fcc07ae0af9
Sarah1108/HW070172
/hw_5/ch_7_5.py
422
4.15625
4
# exersice 5, chapter 7 # def main(): weight = float(input("Enter your weight in pounds: ")) height = float(input("Enter your height in inches: ")) BMI = (weight*720)// (height**2) if BMI < 19: print("Your BMI", BMI, "is underweight!") elif 19 < BMI<= 25: print("Your BMI", BMI, "...
false
aa124bfe70359c8c48a3e43d12949bc2ec18c8d0
Sarah1108/HW070172
/hw_5/ch_6_3.py
475
4.21875
4
#exercise 3 # import math def sphereArea(radius): area = 4* math.pi * radius**2 return area def sphereVolume(radius): volume = 4/3 * math.pi* radius**3 return volume def main(): print("This programm calculates the Volume and surface area of a sphere.") print() radius = int(input("Ente...
true
b362f102f6792584eb2846684668dbd4fb85fd05
Jyoti-27/Python-4
/Python 4.1 string.py
1,362
4.3125
4
#!/usr/bin/env python # coding: utf-8 # In[2]: string1 = "My name is Jyoti and I am working a Data Scientist" # In[4]: print(string1) # In[5]: # Converting from a string to list list1 = string1.split() # In[7]: print(list1) # In[9]: len(list1) # In[15]: list1.append('DL','AI') # In[13]: list1...
false
a56255215d64a8f5e8481ec0ab04c7132510bf0c
AayushmanJung/pythonProjectlab1
/lab1/lab6.py
371
4.34375
4
''' Solve each of the problem using Python Scripts. Make sure you use appropriate variable names and comments. When there is a final answer have Python print it to the screen. A person's body mass index (BMI) is defined as: BMI = mass in kg / (height in m)**2 ''' mass= int(input('Enter the mass')) height= int(input('E...
true
8b4f79396bc2048b247139c8b3ced9dba4183a07
Renan-S/How-I-Program
/Python/Curso de Python/Escopo de variaveis.py
708
4.25
4
""" Escopo pode ser entendido como as limitações Dois casos de escopos de variáveis: 1- Variáveis globais <> Seu escopo compreende todo o programa 2- Variáveis locais <> Seu escopo compreende apenas no bloco onde foram declaradas Python é de tipagem dinâmica. A linguagem infere um tipo específico de acordo...
false
4b6d2d8a1ac75450d33d15a8c93bd68e652e792b
Renan-S/How-I-Program
/Python/Curso de Python/For - Loop.py
1,605
4.21875
4
""" for item in interavel: (exemplo) Os loops são para iterar sobre sequências ou valores iteráveis Iteráveis: 1- Strings: "Renan" 2 - Lista: [1,3,5,7] 3 - Range: numeros = range [1, 10] """ nome = "Renan Cavalcante" lista = [1, 3, 5, 7, 9] numeros = range(1, 10) #É necessário transforma em lista f...
false
dfcf70c0ecbb6bc19cec52deee8c5483ecce962f
divyatejakotteti/100DaysOfCode
/Day 62/Collections.deque().py
753
4.125
4
''' Task Perform append, pop, popleft and appendleft methods on an empty deque . Input Format The first line contains an integer , the number of operations. The next lines contains the space separated names of methods and their values. Constraints Output Format Print the space separated eleme...
true
edc95514a21b81e5ed7c36399fb35a1b5ba666a4
divyatejakotteti/100DaysOfCode
/Day 23/SherlockAndAnagrams.py
1,512
4.21875
4
''' Two strings are anagrams of each other if the letters of one string can be rearranged to form the other string. Given a string, find the number of pairs of substrings of the string that are anagrams of each other. For example s= mom, the list of all anagrammatic pairs is [m,m],[mo,om]at positions [[0],[2]],[[0,...
true
d0dab6a753a2682e9a5f4a898ca72cef7908d9b5
divyatejakotteti/100DaysOfCode
/Day 38/FairRations.py
2,329
4.15625
4
''' You are the benevolent ruler of Rankhacker Castle, and today you're distributing bread. Your subjects are in a line, and some of them already have some loaves. Times are hard and your castle's food stocks are dwindling, so you must distribute as few loaves as possible according to the following rules: Every...
true
dc1b524bca8b58ea8c13d461eda010e45d759ba4
divyatejakotteti/100DaysOfCode
/Day 74/CheckStrictSuperset.py
1,057
4.15625
4
''' You are given a set and other sets. Your job is to find whether set is a strict superset of each of the sets. Print True, if is a strict superset of each of the sets. Otherwise, print False. A strict superset has at least one element that does not exist in its subset. Example Set is a strict sup...
true
2f8d24b3f1bea47e316b56a6484a82888b9c80ab
divyatejakotteti/100DaysOfCode
/Day 60/WordOrder.py
1,079
4.125
4
''' You are given words. Some words may repeat. For each word, output its number of occurrences. The output order should correspond with the input order of appearance of the word. See the sample input/output for clarification. Note: Each input line ends with a "\n" character. Constraints: The sum of the le...
true
f574490c0c3e9924c031d262b6d43440d5ad5552
divyatejakotteti/100DaysOfCode
/Day 25/SequenceEquation.py
917
4.15625
4
''' Given a sequence of integers, where each element is distinct and satisfies . For each x where 1<=x<n, find any integer y such that p(p(y))=x and print the value of y on a new line. Function Description Complete the permutationEquation function in the editor below. It should return an array of integers that r...
true
2a88f0aa503ceb61fcd07144fdd10e2562c32b62
divyatejakotteti/100DaysOfCode
/Day 37/FlatlandSpaceStations.py
1,718
4.5
4
''' Flatland is a country with a number of cities, some of which have space stations. Cities are numbered consecutively and each has a road of length connecting it to the next city. It is not a circular route, so the first city doesn't connect with the last city. Determine the maximum distance from any city to it's...
true
b6be72984e340456b8f87b4ddd8ec845a21fc938
divyatejakotteti/100DaysOfCode
/Day 27/SherlockAndSquares.py
1,206
4.46875
4
''' Watson likes to challenge Sherlock's math ability. He will provide a starting and ending value describing a range of integers. Sherlock must determine the number of square integers within that range, inclusive of the endpoints. Function Description Complete the squares function in the editor below. It should r...
true
3a054171a05293d817336dc7b56af7ab7421fcb3
divyatejakotteti/100DaysOfCode
/Day 25/BeautifulDays_at_theMovies.py
1,733
4.4375
4
''' Lily likes to play games with integers. She has created a new game where she determines the difference between a number and its reverse. For instance, given the number 12, its reverse is 21. Their difference is 9. The number 120reversed is 21, and their difference is 99. She decides to apply her game to decisio...
true
339c11950657fd59e71804f3a54b0f548642c627
divyatejakotteti/100DaysOfCode
/Day 48/StrongPassword.py
2,194
4.15625
4
''' Louise joined a social networking site to stay in touch with her friends. The signup page required her to input a name and a password. However, the password must be strong. The website considers a password to be strong if it satisfies the following criteria: Its length is at least . It contains...
true
eb5770b15ba0e06dbff9cb5e9f4ac1b4aaca1453
divyatejakotteti/100DaysOfCode
/Day 06/SocksMerchant.py
1,064
4.5625
5
''' John works at a clothing store. He has a large pile of socks that he must pair by color for sale. Given an array of integers representing the color of each sock, determine how many pairs of socks with matching colors there are. For example, there are n=7 socks with colors ar=[1,2,1,2,1,3,2]. There is one pair o...
true
fa6737f47bf7733838a05784d3da6a97ff8835ff
Saltyn1/tasks_db
/OOP.Encapsulation.py
2,376
4.1875
4
""" 1)Создайте класс и объявите в нём 3 метода: публичный, защищённый и приватный. Затем создайте экземпляр данного класса и вызовите по очереди каждый из методов. """ class Website: def to_open(self): return 'www.google.com' def _get_email (self): return "Limited access" def __get_...
false
606334ca145a342d401e35dc271d7d0ee5080fab
joehammahz808/CS50
/pset6/mario/mario.py
789
4.125
4
# Ruchella Kock # 12460796 # this program will take a given height and print a pyramid with two spaces in between from cs50 import get_int # prompt user for positive integer while True: height = get_int("height: ") if height > 23 or height < 0: continue else: break # do this height times ...
true
110737c9958d67282c27f00c82543f97723bbf06
bpatgithub/hacker
/python/objectPlay/Inheritance.py
1,495
4.53125
5
# Understanding inheritance. # class PartyAnimal: # this class has two local data store x and name. x = 0 name = "" # now lets define constructor. # Constructor is optional. Complier will perform that operation by itself if you don't. # all methods with __ are special. # self is just the ...
true
3c6ee85b82e2410032e6f5be4c6d9750b59977e4
bpatgithub/hacker
/machineLearning/mapReduce/asymmetricFriends/mr_asymmetric_friends.py
1,780
4.21875
4
''' Find all Asymmetric relationship in a friend circle. The relationship "friend" is often symmetric, meaning that if I am your friend, you are my friend. MapReduce algorithm to check whether this property holds. It will generate a list of all non-symmetric friend relationships. Map Input Each input record is a 2 ele...
true
e6d33a819da979fb63e086bbad1d7309e71f9954
gcpdeepesh/harshis-python-code
/Can You Drive Now !.py
303
4.15625
4
driving_age = eval(input("What is the legal driving age in your area ? ")) your_age = eval(input("What is your age ? ")) if your_age >= driving_age : print ("You are old enough to drive legally") if your_age < driving_age : print ("Sorry you can drive" , driving_age - your_age, "years later.")
false
d22875a8da5a677f6008db9705f6ae097a1abafc
joker2013/education
/Python/Lesson-7-List1.py
1,003
4.21875
4
cities = ['New York', 'Moscow', 'new dehli', 'Simferopol', 'Toronto'] print(cities) # Колличество в массиве print(len(cities)) # Выбор из массива print(cities[0]) # Первый с канца print(cities[-1]) print(cities[2].upper()) # замена в массиве cities[2] = 'Tula' print(cities) # Добавление в массив cities.append('Ku...
false
a8bd48aeefb58ed69fd609ffa55c27bb32aa048f
borko81/SU_OOP_2021
/Iterators_generators/fibo_gen.py
256
4.21875
4
def fibonacci(): previous = 0 current = 1 while True: yield previous previous, current = current, current + previous if __name__ == '__main__': generator = fibonacci() for i in range(5): print(next(generator))
true
b3080e1275ecd99a94af2492bfe5ed5894b48fc8
likair/python-programming-course-assignments
/Assignment3_4.py
773
4.15625
4
''' Created on 15.5.2015 A program, which finds all the indexes of word 'flower' in the following text: "A flower is a beautiful plant, which can be planted in the garden or used to decorate home. One might like a flower for its colors and the other might like a flower for its smell. A flower t...
true
b6184226d54b6c62649165d0c0cfec0eec104e2a
TimJJTing/test-for-gilacloud
/part1_multiples.py
703
4.3125
4
# part1_multiples.py # If we list all the natural numbers below 10 that # are multiples of 3 or 5, we get 3, 5, 6 and 9. # The sum of these multiples is 23. # Find the sum of all the multiples of 3 or 5 below 1000. def find_multiples_of_3_or_5(below): # ans = [] # multiples of 3 # n = 0 # while 3...
true
5b7d0e84fc7c0aa52dc3717ec492fab1f5772bee
aarthymurugappan101/if-else-elif-python1
/L3_2_elif.py
308
4.125
4
mark = input("Enter your mark in the test -> ") print ("\nYou have entered" , mark , "marks") marks = int(mark) grade = "F" if marks >= 80: grade = "A" elif marks >= 70: grade = "B" elif marks >= 60: grade = "C" elif marks >= 50: grade = "D" # else # grade = "F" print ("Your grade is " + grade)
false
6b42ee24ea21731d01da1b487f3f5374671a766d
xiangchan/python_study
/2.list_dict_tuple_set/1.tuple.py
485
4.15625
4
# filename: tuple.py tuple01 = (1, 2, 3, 4, 5, 6, 7, 8) print(tuple01, type(tuple01)) tuple02 = (1, 2, 3, [], 9, 6) print(tuple02) tuple02[3].append(1) print(tuple02) # tuple02[3] = [1, 2, 3, 4, 5, 6] # print(tuple02) for i in range(2,11): tuple02[3].append(i) print(tuple02) # get list[index=4]. # a = tuple02[...
false
16374e3c97e3fee9c378a3e2ba0ab955b2fc9188
implse/Code_Challenges
/Random/flatten_nested_dictionary.py
922
4.375
4
# Write a function to flatten a nested dictionary. Namespace the keys with a period. # # For example, given the following dictionary: # # { # "key": 3, # "foo": { # "a": 5, # "bar": { # "baz": 8 # } # } # } # # it should become: # # { # "key": 3, # "foo.a": 5, # ...
false
f9db575371ab34db729a931c0db269a8ae17e041
wildflower-42/FLVS-Foundations-of-Programing
/FavoriteColoursProgram.py
1,710
4.375
4
#Alaska Miller #6/23/2020 #The Perpouse of this program is to prompt the human end user to input a series of questions that will have them rank their favorite colours, then the program will match them against MY previously listed into the program, favorite colours! def favoritesCompare(): #This section of code creates...
true
ea3ee2d7d504aa666b0c6823f27359135482ec0e
jeffdeng1314/CS16x
/cs160_series/python_cs1/labs/lab2/again.py
261
4.28125
4
x = input("Give me a positive number that is less than 256\n") try: x = int() if x > 256 or x <0: print('error') else: while (x > 0): print(int(x%2)) x=x//2 except ValueError: print('bad input')
true
f3ebdc3e84c3eaf396fccbe1d32eef39b1eb97e0
sarcasm-lgtm/Python-Learning
/Printing Arrays Homework Assignment.py
616
4.3125
4
#I tried doing it, but it said this: #['Ahana', 'is', 'my', 'sister'] #Traceback (most recent call last): #File "/Users/aarohi/Documents/Printing Arrays Homework Assignment.py", line 4, in <module> #v=ahana #NameError: name 'ahana' is not defined array1=["Ahana","is","my","sister"] print(array1) v="Ahana " q="i...
true
2d16bb6cf202fdccdee2c8e1b679173b652fb48c
armstrong019/coding_n_project
/Jiuzhang_practice/implement_trie.py
2,083
4.25
4
class TrieNode(): def __init__(self): self.children = {} self.is_word = False class Trie(object): def __init__(self): """ Initialize your data structure here. """ self.root = TrieNode() def insert(self, word): """ Inserts a word into the trie...
true
5ebd4360a8efde45eb3803b5e0adffea32030691
Abhishek19009/Algorithms_and_Data_structures
/Common_Algorithms/String_splitting.py
649
4.5
4
# String splitting algorithm is basic but will be used multiple times so know how to create it # String splitter will split the string into list based on the special character def string_splitter(string, replace): string_temp = "" string_list = [] for char in string: if char != replace: ...
true
981f67ed61c882fff9322d9538615cbde8a99a68
Abhishek19009/Algorithms_and_Data_structures
/Miscellaneous/Swap_quickly.py
320
4.25
4
''' Python has a very cool and short codeline to swap elements without using any temporary variable. ''' arr = [3,4,5,6,9,1] arr[2],arr[3] = arr[3],arr[2] # swap element at 3 index with element at 2 index ''' This is much shorter than creating temp variable to store 3 element and then assigning it to 2 element. '''
true
ce648722f6691b0801d22da61026fe3b8f1e04d3
Abhishek19009/Algorithms_and_Data_structures
/Data Structures/Hashing/Hashing_with_chaining.py
419
4.125
4
''' Usually hashing creates problem of multiple elements belonging to same hash. To accommodate this we can store such elements in some data structure like list. ''' # Consider the hash function f(n) = n mod 7 where n is the element of the list. arr = [15, 47, 23, 34, 85, 97, 56, 89, 70] # Creating 7 empty buckets ...
true
4e293ceb648bf422376f5deb5386b8923ef5ad57
Abhishek19009/Algorithms_and_Data_structures
/Common_Algorithms/Graph/Dijkstra_shortest_path.py
1,956
4.1875
4
# Implementing Dijkstra # Not working, fix the bug import heapq as hp class Node: def __init__(self, index, distance): # We can also add extra properties of the node. self.index = index self.distance = distance class Graph: def __init__(self, n): # n == no of nodes self.n = n self.adj = [...
true
a06859bddd8042dcc1e5775a9ae0406b62c70ad6
NikolaosPanagiotopoulos/PythonLab
/lectures/source/lecture_04/lecture_04_exercise_2a.py
1,125
4.1875
4
"""Άσκηση 2 – Lectures 4 Ένας φοιτητής ζήτησε από τους γονείς του να αγοράσει έναν H/Y αξίας 3000€. Οι γονείς του συµφώνησαν να του δώσουν τα χρήµατα µε τον εξής τρόπο: Την πρώτη εβδοµάδα θα του δώσουν 20€. Στο τέλος κάθε εβδοµάδας θα του δίνουνε τα διπλάσια από αυτά που του δώσανε την προηγούµενη εβδοµάδα µέχρι να συγ...
false
880ad96ee77a46f04c81562aa4b415f56841ce5a
harshitakumbar/pythonlabprogramme
/put.py
216
4.25
4
num1=3 num2=4 num3=5 if (num1>=num2) and (num2>=num3): largest=num1 elif (num2>=num1) and (num2>=num3): largest=num2 else: largest=num3 print("the largest number between",num1,",",num2,"and",num3,"is",largest)
false
c8e4f3f3e64aa94661dd075f670798a7121ad2b4
andrewhml/dev-sprint2
/chap6.py
2,024
4.1875
4
# Enter your answrs for chapter 6 here # Name:Andrew Lee import math # Ex. 6.3 def area (radius): temp = math.pi * pow(int(radius), 2) return temp def distance(x1, y1, x2, y2): dx = x2-x1 dy = y2-y1 dsquared = pow(dx, 2) + pow(dy, 2) d = math.sqrt(dsquared) return d def circle_area(xc, yc, xp...
false
584652ea2632671d89e0d6228c44b05518cc1856
antoniotorresz/python
/py/Logical/reverse_string.py
285
4.28125
4
def get_reverse(base_string): base_list = list(base_string) reverse = "" for i in range(len(base_list)): reverse += base_list[(len(base_list) - 1) - i] return reverse word = input("Enter a word to get its reverse: ") print(word + " -> " + get_reverse(word))
false
0bf431af9180d8e61c6d6ef1bd95d453d72d9a82
antoniotorresz/python
/py/Logical/factorial_number.py
324
4.375
4
#Recursive function to calculate factorial froma given number def get_factorial(number): if not number == 0 or number == 1: return (get_factorial(number - 1) * number) else: return 1 x = int(input("Please, type a number to calculate its factorial: ")) print(str(x) + "! = " + str(get_factorial(x...
true
dff935b5eff8e09fac2d299613963670a8eb8511
BenjiYang/python-foundation
/day4/4-2-oop2.py
924
4.1875
4
# 类 模板 class People: # 对象可以强行增加类没有的属性 - 非常容易被增加属性对象,灵活性,但涉及安全问题 # __slots__: 限制属性,对象不可另外增加其他属性 __slots__ = {"name", "age", "weight"} # __init__: __特殊方法__,用于对象初始化: # self 相当于自身,java的this def __init__(self, name, age, weight): self.name = name self.age = age self.weigh...
false
5a7b7cfe9cef4d67c8942b549b604ce77f2b7dd0
rusalinastaneva/Python-Advanced
/07. Error handling/01. Numbers Dictionary.py
1,039
4.3125
4
numbers_dictionary = {} line = input() class IsNotNumberStringError(Exception): """Raised when the value is a digit""" pass while line != "Search": try: number_as_string = line if number_as_string.isdigit(): raise IsNotNumberStringError("Input must be a string") numb...
true
36ba2d301680a56b5d556eef7a3cd7865a9aee4f
rusalinastaneva/Python-Advanced
/05. Functions advanced/Lab_ 07. Operate.py
807
4.15625
4
def operate(operator, *args): result = 0 if operator == '*' or operator == '/': result = 1 for num in args: if operator == '+': result += num elif operator == '-': result -= num elif operator == '*': result *= num elif operator == '...
false
50d80a5a2e60d98d760fe151f6a7772e8446069e
imarkofu/PythonDemo
/Demo/day04.py
2,870
4.3125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # 可变参数 # 但是调用的时候,需要先组装出一个list或tuple: def calc(numbers): sum = 0 for n in numbers: sum += n * n return sum print(calc([1, 2, 3])) print(calc((1, 3, 5, 7))) # 在参数前面加了一个*号 def calc(*numbers): sum = 0 for n in numbers: sum += n * n ...
false
71013446d528f0dce9a7439ee4c84b364a5ea2c6
hancoro/Python_Learn_Project
/PythonFile_RPH7_If_Statements.py
1,036
4.4375
4
# set a boolean variable as true boolean_for_if_statement = False second_boolean_for_if_statement = False # If statement with one condition if boolean_for_if_statement: print("One condition if statement HAS been met") else: print("One condition if statement was NOT met") # If statement with multip...
true
3b31c41338a759b313b8195f4765aebca106c17c
hancoro/Python_Learn_Project
/PythonFile_RPH13_Exponent_Function.py
266
4.15625
4
# this is a function that accepts 2 parameters def raise_to_the_power_of(base_num, pow_num): result = 1 for num in range(pow_num): result = result * base_num # print(num) return result print(raise_to_the_power_of(3, 3))
true
aeaf4ad44859525a4845e9a178e66bc3173c137f
hancoro/Python_Learn_Project
/PythonFile_RPH14_2d_lists_nested_loops.py
661
4.5
4
# 2d lists are essentially lists of lists # for example number_grid = [ [1, 2, 3], [4, 5, 6], [7, 8, 9], [0] ] # the example now has 4 rows with three columns # to access a specific element in the list by reference to the row and column print(number_grid[1][2]) # This will print row 1, co...
true
518392eae8e2127061b15b1a75927899001537d1
egroshev/old
/pyfolder/old/python3/learn/decorators.py
1,356
4.28125
4
''' # BEFORE USING A DECORATOR def some_function(number): print ("{}".format(number+1)) ''' """ >>> some_function(11) 12 >>> some_function(8) 9 >>> some_function(1) 2 """ # AFTER USING A DECORATOR def history_decorator(my_function): history = [] # list def wrapper(my_argument): # creates a function wr...
false
fba98d5bc7c45544c8dbc47aa6ca5b75c4ae7762
anuraga2/Coding-Problem-Solving
/Sorting/BubbleSort.py
404
4.1875
4
#Function to sort the array using bubble sort algorithm. def bubbleSort(self,arr, n): # code here # running the outer loop for i in range(n-1): swapped = True for j in range(n-i-1): if arr[j] > arr[j+1]: arr[j], arr[j+1] = arr[j+1], arr[j] swa...
true
386583b7139d1ffa01daaf3f430e2972e9dd821e
SravaniDash/Coursera-Python-For-Everyone
/exercises/chapter13/extractXML.py
696
4.125
4
# In this assignment you will write a Python program somewhat similar to http://www.py4e.com/code3/geoxml.py. The program will # prompt for a URL, read the XML data from that URL using urllib and then parse and extract the comment counts from the XML data, # compute the sum of the numbers in the file. # Actual Data: ht...
true
143b32c0cbf692e4072c707d9e9de0bf77fb077f
HohShenYien/Harvard-CS50
/Week6/credit.py
1,954
4.125
4
def main(): # Putting in all the return strings into a list # so that the function just return an int return_type = ["INVALID", "AMEX", "MASTERCARD", "VISA"] nums = all_nums(get_nums()) # Print invalid if failed Luhn algorithm if not luhn_check(nums): print(return_type[0]) # Prev...
true
b84126a63bac595977f08afcfe84130d80bd6f64
Jahir575/Python3.8OOP
/EmployeeAssaignment.py
1,342
4.4375
4
""" Create an Employee class with following attributes and methods: - constructor, which will create an instance of Employee class based on provided arguments: first name, last name, email address and monthly salary - get_annual_salary method, which will calculate and return employee annual salary - show_employe...
true
a34dc0a076d26372679924c80bafee594878891b
gocommitz/PyLearn
/pydict.py
732
4.15625
4
#Import library import json #Loading the json data as python dictionary #Try typing "type(data)" in terminal after executing first two line of this snippet data = json.load(open("data.json")) #Function for retriving definition def retrive_definition(word): if word in data: return data[word] elif word.t...
true
941223ed6e1f2897992eb7b0db86c7918305110a
Bshock817/basic-python
/basic2.py
1,709
4.1875
4
""" # Countdown - Create a function that accepts a number as an input. # Return a new list that counts down by one, from the number (as the 0th element) down to 0 (as the last element). def countdown(num): nums = [] for val in range(num,-1,-1): nums.append(val) return nums print(countdown(1...
true
1111183e8cd379b298acbc3535787508395ba06b
Ajay-Puthiyath/Luminar_Django
/Luminar_Project/Flow_Controls/Decesion_Making_Statement/Maximum_Of_Three_Numbers.py
985
4.25
4
num1 = int(input("Enter the first number")) num2 = int(input("Enter the second number")) num3 = int(input("Enter the third number")) if(num1>=num2) and (num1>=num3): largest = num1 print("The largest number is",largest) elif(num2>=num1) and (num2>=num3): largest = num2 print("The largest number is",larg...
true
0783801f9fc57d08bf0552c5935c4fed801628aa
SergioKulyk/Stepic
/Математика и Python для анализа данных/1 Неделя 1 - Основы Python/1.8 Функции/1.8.5.py
597
4.1875
4
# Напишите функцию convert(L), принимающую на вход список, состоящий из чисел и строк вида: # # [1, 2, '3', '4', '5', 6] # и возвращающую список целых чисел (в том же порядке): # # [1, 2, 3, 4, 5, 6] # Примечание. В этой задаче не нужно ничего считывать и ничего выводить на печать. Только реализовать функцию. def conv...
false
e8a759ffe437a57b693b79f6d3eb7dcff18f921e
addinkevin/programmingchallenges
/MedalliaChallenges/2017Challenge/problema2.py
1,382
4.1875
4
import unittest """ Given an integer n, we want you to find the amount of four digit numbers divisible by n that are not palindromes. A palindromic number is a number that remains the same when its digits are reversed. Like 1661, for example, it is "symmetrical". For example, if n equals 4000, the only four digit numb...
true
0cf95999f495b6e72ae69acef4eb2cc28ed21c88
Aniket-99/Python-programs
/Python/Age.py
291
4.3125
4
age = int(input("Enter your age: ")); if(age <= 1): print("You are infant") elif(age >1 and age<13): print("You are a child") elif(age >13 and age<20): print("You are a Teenager") elif(age >=20 and age<=110): print("You are an adult!!") else: print("Enter valid input")
false
d7e38ea8166127fd9b1d403d88094a0cc0f17b0a
commGom/pythonStudy
/sparta_algorithim/week_1/1_2_최빈값찾기02.py
624
4.125
4
input = "hello my name is sparta" def find_max_occurred_alphabet(string): alphabet_occurence_array = ["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'] max_occurrence=0 max_alphabet=alphabet_occurence_array[0] for alphabet in alphabet_occurence_a...
false
04caeadc2469e4bca2256b0731e62ee1d93c13a1
SreeramSP/Python-Data-Collection-and-Processing
/#Below, we have provided a list of tuuple.py
399
4.34375
4
#Below, we have provided a list of tuples that contain students’ names and their final grades in PYTHON 101. Using list comprehension, create a new list passed that contains the names of students who passed the class (had a final grade of 70 or greater). l1 = ['left', 'up', 'front'] l2 = ['right', 'down', 'back']...
true
fc72535954544203ce0c60b5dbdfa23c608bf7f3
JustinKnueppel/CSE-1223-ClosedLab-py
/ClosedLab07a.py
374
4.25
4
def getWordCount(input): numWords = 1 while " " in input: numWords += 1 input = input[input.index(' ') + 1: len(input)] return numWords string = input('Enter a string: ') while not string: print('ERROR - string must not be empty\n') string = input('Enter a string: ') print(getWordCount(string)) print('Your s...
true
6f4de077c0f535f5a6e635ce86e95e13542508fa
JustinKnueppel/CSE-1223-ClosedLab-py
/ClosedLab04a.py
663
4.15625
4
grade = float(input('Enter a grade value between 0 and 100: ')) while (grade < 0 or grade > 100): grade = float(input('ERROR: Grade must be between 0 and 100: ')) if (grade > 93): print('You received an A') elif (grade > 90): print('You received an A-') elif (grade > 87): print('You received a B+') elif (grade > 83...
false
e68cf7c5c99d97df4dc021ba20c7a0fd01ae791b
UF-CompLing/Word-Normalization
/FromLecture.py
1,010
4.21875
4
import re TextName = 'King-James-Bible' ## ~~~~~~~~~~~~~~~~~~~~ ## START OF FUNCTIONS print('opening file\n') input_file = open('Original-Texts/' + TextName + '.txt', 'r') # the second parameter of both of these open functions is # the permission. 'r' means read-only. # # The 'Original-Texts/' part is so that i...
true
0473322373aa0f9d9989f69cb221b7eb88fa176f
OmChaurasia/Python-modules-I-worked
/garbage python/lists.py
1,052
4.28125
4
things=["apple","mango","banana",56] print(things)#to print pura print(things[1])#to print specific num=[2,3,2,5,6] num.sort()#sort karne ke liye num.reverse()#reverse karne ke liye print(num) """ list me slice usi tarah hota hai jaise string me hota tha slice karne par original change nahi hota keval print ho jata hai...
false
2aa0ea0761121f1eeb626b17e3c04c97282c9bd1
amcclintock/Breakfast_Programming_Guild
/broken_1_6.py
1,217
4.46875
4
Take user input, and tell me stuff about the data user_input = input('Enter something:') #Check if the data contains alpha if (user_input.isalpha()): print (user_input, " contains alpha characters") #Do some math on characters three_user_input = user_input * 3 print (user_input, " three...
true
abad7aaa10a6918b8eb3b763e179178eeb677253
driscoll42/leetcode
/0876-Middle_of_the_Linked_List.py
1,381
4.15625
4
''' Difficulty: Easy Given a non-empty, singly linked list with head node head, return a middle node of linked list. If there are two middle nodes, return the second middle node. Example 1: Input: [1,2,3,4,5] Output: Node 3 from this list (Serialization: [3,4,5]) The returned node has value 3. (The judge's seria...
true
016b4c71006d62f4ca5857c8d3eb52c46a109c74
saisatwikmeda/Personal-Programs
/find_short.py
471
4.15625
4
#Sai Satwik Reddy Meda # Returning the length of the smallest word in a given string def find_short(s): L = s.split(' ') #split list final = "" final = L[0] for i in range(len(L)): if len(final) > len(L[i]): final = L[i] # Assign smallest word everytime it changes i += 1 ...
true
36ad03ca7141958e68f7429d438c9f0f7a51834e
clintmod/aiden
/2023.05.06/Worldcount.py
451
4.15625
4
# Ask the user to enter a sentence sentence = input("Enter a sentence: ") # Initialize a variable to count vowels vowel_count = 0 # Loop over each character in the sentence for char in sentence: # Check if the character is a vowel if char.lower() in "aeiou": # If it is, increment the vowel count ...
true
98c9974136879a86fbc53fcc7ec65c4ee81b9864
Davin-Rousseau/ICS3U-Assignment-6-Python
/assignment_6.py
1,198
4.25
4
#!/usr/bin/env python3 # Created by: Davin Rousseau # Created on: November 2019 # This program uses user defined functions # To calculate surface area of a cube import math def surface_area_cube(l_c): # calculate surface area # process surface_area = (l_c ** 2) * 6 # output return surface_area...
true
83376880f7ac1c33a8b35d4b00b6b703891a1d32
jkim23/python-code-samples-1
/radius JTKIM (1).py
445
4.34375
4
#jt kim #2.29.2019 #compute radius of circle #radius = int(input("Enter radius for your circle: ")) #area_of_circle = (radius * 3.14) * radius #print ("Your circle is: ", area_of_circle) def areaOfCircle(radius): area = (radius ** 2) * 3.14 return area print("the area of the circle is ", areaOfCir...
true
600afdcf40cba9a2efacde240c6a71a669e4fbfa
kenigandrey/python
/Lesson-2/Task3.py
837
4.15625
4
#3. Пользователь вводит месяц в виде целого числа от 1 до 12. Сообщить к какому времени года относится месяц (зима, весна, лето, осень). # Напишите решения через list и через dict. # list n = int(input("Укажите номер месяца (целое число от 1 до 12) = ")) lst = "зима,зима,весна,весна,весна,лето,лето,лето,осень,осень,ос...
false
bde9ebc19081fed03780da6564698d9f5d1b8c06
kenigandrey/python
/Lesson-3/Task1.py
797
4.34375
4
# Реализовать функцию, принимающую два числа (позиционные аргументы) и выполняющую их деление. # Числа запрашивать у пользователя, предусмотреть обработку ситуации деления на ноль. def my_div(arg_1, arg_2): """Возвращает результат деления arg_1 на arg_2""" try: return arg_1 / arg_2 except ZeroDivis...
false
4cbdb9a15e97a8bc1158cc1db2588d095bfc6003
carlos-carlos/different-solutions
/solution_03.py
1,535
4.46875
4
''' Write a script that sorts a list of tuples based on the number value in the tuple. For example: unsorted_list = [('first_element', 4), ('second_element', 2), ('third_element', 6)] sorted_list = [('second_element', 2), ('first_element', 4), ('third_element', 6)] ''' #driver code and empty list for the desired resu...
true
34dc764b76b229373cda809ddde5a0372170ef6b
outoftune2000/Python
/strings/substringcount.py
508
4.5
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- #program to count the number of times a given substring has been repeated in a given string def countingSubstrings(string,substring): count=0 for i in range(0,len(string)): if string[i:i+len(substring)]==substring: count=count+1 return count...
true
accd5bfd406cab61113d642643f2bed1307bd865
danieltshibangu/Mini-projects
/kilometer.py
598
4.34375
4
# This program will prmpt for distance in km # then convert distace to miles by formula # miles = kilometers * 0.6214 # define variables miles = 0.0 kilometers = 0.0 # define miles constant K_FACTOR = 0.6214 # main will prompt for kilometers, # use km to miles funtion # print result def main(): kilometers = floa...
true
1cdb8009743880959b3f7b17feecfec0a3e64031
danieltshibangu/Mini-projects
/PYTHON PRACT.py
598
4.21875
4
# This program displays property taxes TAX_FACTOR = 0.0065 #Represents tax factor # Get the first lot number print( 'Enter the property lot number' ) print( 'or rnter 0 to end.' ) lot = int( input( 'Lot number: ' ) ) # continue processing as long as the user # does not enter lot number 0 while lot != 0: #Get...
true
a2b2651ad516b9d159954d37d301cda056dcced4
danieltshibangu/Mini-projects
/initials.py
932
4.1875
4
# this program gets title data from user and # prints the data # the main function gets a first, middle and # last name from user, passing them as arguments # for get_initials functions. Initial name # entered and the initials of name printed def main(): first = input( "Enter first name: " ) middle = input( "...
true
e6710b0744d0703493aa2434f4a7a171cda70c28
danieltshibangu/Mini-projects
/total_sales.py
709
4.34375
4
# this program will display the total sales for # the days of the week # DAYS_OF_WEEK is used as a constant for the # size of the list DAYS_OF_WEEK = 7 def main(): # create the list for days of the week sales = [0] * DAYS_OF_WEEK # define the accumulator total = 0.0 # get the sales for each day ...
true
ba2de7234a0c6c4ad0c467db583dd97bd6721be2
danieltshibangu/Mini-projects
/kinetic_energy.py
732
4.3125
4
# program calculates kinetic energy of object # define variables mass = 0.0 velocity = 0.0 k_energy = 0.0 # main function will prompt for # mass and velocity, call the kinetic_energy # function and display the kinetic energy def main(): mass = float( input( "Enter mass in kilograms: " ) ) velocity = float( i...
true
02467d255c9184e51c2fd62edd052e5a9dd1a5dd
danieltshibangu/Mini-projects
/rand_file_writer.py
793
4.3125
4
# this program will print a user specified amount # of random numbers to the random_numbers.txt file # import the random module import random # state the variables used num_of_rand = 0 random_num = 0 # state the constants RAND_MAX = 500 def main(): # create variable for user input num_of_rand = int( input( ...
true
9c4aea9dd5ed5b7f1ebc7f69cc058032e0582d4d
subash-sunar-0/python3
/Assignment1.py
815
4.25
4
#WAP that ask user to enter their name and their age.print out a message address to them that tells them the year they will turn 100 years old try: name = str(input("please enter your name:" )) age = int(input("Please enter your age: ")) num = 100-age if age >=100: print(name, "...
true
ca327674cf6069bd0628d2ffb013bc021e5b2b5b
Tulip2MF/100_Days_Challenge
/day_010/number_of_days.py
716
4.125
4
def divisionFunction(year): if (year % 4) == 0: if (year % 400) == 0: return True elif (year % 100) == 0: return False else: return True else: return False def days_in_month(year, month): leap_year = divisionFunction(year) month_days ...
true
b0d6a2da26dbb9753984c4e809ecd416bda12714
defaults/algorithms
/Python/Geometry/orientation_of_3_ordered_points.py
1,858
4.15625
4
# coding=utf-8 from __future__ import print_function """ Orientation of an ordered triplet of points in the plane can be 1. counterclockwise 2. clockwise 3. collinear If orientation of (p1, p2, p3) is collinear, then orientation of (p3, p2, p1) is also collinear. If orientation of (p1, p2, p3) is clockwise, then orie...
true
1b6a6723c48abfd90938356ffd29f520c346c55f
thevolts/PythonSnippets
/Day_of_the_week.py
319
4.25
4
# Python program to Find day of # the week for a given date import datetime import calendar def findDay(date): born = datetime.datetime.strptime(date, '%d %m %Y').weekday() return (calendar.day_name[born]) # Driver program date = '03 02 2019' date = str(input("Enter Date :")) print(type(date)) print(findDay(date))
true
f43ab77e2049e5525b260811534d8e925a66b45b
ViRaL95/HackerRank
/strings/find_maximum_consecutive_repeating.py
1,211
4.3125
4
def find_max_consecutive(string): """ This method finds the largest consecutive characters in a string. It does this by having a previous and a current 'pointer' which checks if they are equal. If they are equal we can increase a count and check if its value is greater than max_. If it is we update...
true
4f9d9ba09b4835ccef2fd4aac4a76296be2250bc
dmitchell28/Other-People-s-Code
/quessing a number.py
815
4.28125
4
from random import randint print ("In this program you will enter a number between 1 - 100." "\nAfter the computer will try to guess your number!") number = 0 while number < 1 or number >100: number = int(input("\n\nEnter a number for the computer to guess: ")) if number > 100: print...
true
131534c10785852aad6b7b75f442f7b2d3708e37
amnaamirr/python-beginners
/volume-of-sphere.py
246
4.3125
4
"""Write a python program to get the volume of a sphere, take the radius as input from user. V = 4/3 πr3""" import math radius = float(input("ENTER RADIUS: ")) pi = math.pi volume = 4/3*(pi)*(radius**3) print("THE VOLUME OF SPHERE IS",volume)
true
79e4531c7cddbe0819ed8f25f947271b43a0a7fe
amnaamirr/python-beginners
/checking-palindrome.py
461
4.1875
4
"""Write a program to check whether given input is palindrome or not """ # palindrome is a number which reads the same forward or backward num = (input("ENTER A NUMBER: ")) reverse_num = num[::-1] while int(num) > 9: if num == reverse_num: print(f"THE NUMBER {num} IS A PALINDROME!") break ...
true
83d52ed13f38fe1a7a8a56676fbdd2df539ebb42
16030IT028/Daily_coding_challenge
/SmartInterviews/SmartInterviews - Basic/044_Half_Diamond_pattern.py
654
4.21875
4
# https://www.hackerrank.com/contests/smart-interviews-basic/challenges/si-basic-print-half-diamond-pattern/problem """ Print half diamond pattern using '*'. See example for more details. Input Format Input contains a single integer N. Constraints 1 <= N <= 50 Output Format For the given integer, print the half ...
true
857582fbc152c5f27e6203ff838284f458161dba
16030IT028/Daily_coding_challenge
/SmartInterviews/047_Swap_Bits.py
1,551
4.15625
4
# https://www.hackerrank.com/contests/smart-interviews/challenges/si-swap-bits/problem """ Given a number, swap the adjacent bits in the binary representation of the number, and print the new number formed after swapping. Input Format First line of input contains T - number of test cases. Each of the next T lines c...
true