blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
e8b6686ac6ecd5d490688ff33633ca530407f6c0
SHJoon/Algorithms
/arrays/9_rotate_array.py
705
4.15625
4
# Rotate Array # Implement rotateArr(arr, shiftBy) that # accepts array and offset. Shift arr’s values to the # right by that amount. ‘Wrap-around’ any values # that shift off array’s end to the other side, so that # no data is lost. Operate in-place: given # ([1,2,3],1), change the array to [3,1,2]. def rotate_arr(ar...
true
74bb0a85a677c94c0dd5fc5057d4cffb988f51a8
SHJoon/Algorithms
/hackerrank/warmup/2_counting_valleys.py
2,221
4.78125
5
# An avid hiker keeps meticulous records of their hikes. During the last # hike that took exactly steps steps, for every step it was noted if it was an uphill, U, # or a downhill, D step. Hikes always start and end at sea level, and each step up or # down represents a 1 unit change in altitude. We define the following ...
true
48245c91b2bcf9b78c3fc81c57bb447a85db5231
maladeveloper/algos-and-data-structures
/Sorting/heap_sort.py
482
4.21875
4
from heap import MinHeap def heap_sort(arr): sorted_arr = [] min_heap = MinHeap(array=arr) for i in range(len(arr)): sorted_arr.append(min_heap.extract_min()) for i in range(len(sorted_arr)): arr.append(sorted_arr[i]) if __name__ == "__main__": arr = [3, 21, 123, 2, ...
false
b14444421ce6c71b7ad8ba3e72fbc6558e0bcca9
maladeveloper/algos-and-data-structures
/StacksAndQueue/reversing_linked_list.py
1,495
4.25
4
from SingleLinkedList import Linked List ''' Code for reversing a list via both functions was written by me. ''' my_list = LinkedList() my_list.append("M") my_list.append("A") my_list.append("L") my_list.print_list() ##Implementation of reversing a linked list using recursion def reverse_list(prev_node, curr_nod...
true
4ad9e9a083c73a065cd9af7d8f00d56f01971f14
kantel/nodebox-pyobjc
/examples/Extended Application/sklearn/examples/linear_model/plot_ols.py
2,804
4.15625
4
""" ========================================================= Linear Regression Example ========================================================= This example uses the only the first feature of the `diabetes` dataset, in order to illustrate a two-dimensional plot of this regression technique. The straight line can be s...
true
f01c1a88928fec538ea44250e3f0d86eccfce234
erofes/python_learn
/CribLibrary/functions/function_arguments.py
606
4.25
4
def func(a, b, c = 2): # a, b is necessary! c is not necessary return a + b + c print(func(1, 2, 3), func(1, 2), func(a=2, b=3)) # There are ways to use arguments # 6 5 7 def many(*args): # Must take any number of elements, unnamed tuple '''Custom description: Return input arguments''' return args # ...
true
781821bec5003263baf4364df0f0d8d92ae3ce44
jorien-witjas/python-labs
/python_fundamentals-master/07_classes_objects_methods/07_00_planets.py
629
4.21875
4
''' Create a Planet class that models attributes and methods of a planet object. Use the appropriate dunder method to get informative output with print() ''' class Planet(): def __init__(self, name, size, colour): self.name = name self.size = size self.colour = colour Jupiter = Planet("j...
true
3fc8ee0756d2a19b62635047d0d24e0a6f662049
Aetrix27/CS-1.0-Custom-Calculator
/app.py
1,205
4.6875
5
import math def calculate_quadratic(coeff_1, coeff_2, coeff_3): #The formula to calculate the quadratic equation for the positive result given by the square #root is found below, the inputted into the appropriate variable. positive_root=(-coeff_2+math.sqrt((coeff_2**2)-(4*(coeff_1*coeff_3))))/(2*coeff_1) ...
true
644b6ce2a21fb0e390fedb77aef04f12c77cf603
Ben-Lapuhapo/ICS3U-Unit-4-02-Python
/multiplying.py
878
4.125
4
#!/usr/bin/env python3 # Created by: Ben Lapuhapo # Created on: October 2019 # This program shows the factorial of a number def main(): while True: # input sub_answer = 1 total_number = 1 number = input("Input A Positive (+) Number: ") print() try: num...
true
e1db5c5c64dc952b7f9fc40374ab220159b8f67a
X-R4Y-1/me
/week3/exercise3.py
1,323
4.28125
4
"""Week 3, Exercise 3. Steps on the way to making your own guessing game. """ import random def get_number(message): while True: try: answer = input(message) answer = int(answer) return answer except ValueError: pass def advancedGuessingGame(): ...
true
a0839d4e963ddf8b987366f7498c3f09f56df718
lewispark345/p3w
/p3w_01.2b.2.py
878
4.125
4
# A program to perform the following mathematical operations in Python """a. Addition""" """b. Subtraction""" """c. Multiplication""" """d. Division""" print ("# A program to perform the following mathematical operations in Python") print ("a. Addition") print ("b. Subtraction") print ("c. Multiplication") p...
true
520720ba773d6bf68bea065eefe96ce412d6ea6b
rahultc26/python
/stringtypes.py
661
4.15625
4
s0="awesome " print(s0) s="my name is rahul " #using string print(s) s1="""you are awesome because your learning python.. all the best""" #you can take single or double quotes instead print(s1) s2='i am learning python' #using single quotes print(s2) #indexing in strings print(s[0...
true
4391d982f51ae1f6638c866b87c6f6751b72fdd1
AshuHK/Sorting_Visualization
/text_based_sorts/SelectionSort.py
522
4.125
4
from Swap import _swap def selection_sort(unsorted): """ Does an selection sort on a Python list Expected Complexity: O(n^2) (time) and O(1) (space) :param unsorted: unsorted Python list to be sorted """ for i in range(len(unsorted)): # look at each of the remaining values and locate...
true
c11eb267e93ff7f97343c593468f6b346289c137
AshuHK/Sorting_Visualization
/text_based_sorts/Swap.py
541
4.25
4
def _swap(test_list, x, y): """ Conducts a Pythonic swap within a list between two indicies - Note: the order of x and y do not matter as long as both are in an acceptable range [0, len(test_list)] Expected Complexity: O(1) (time and space) :param some_list: Python list of integ...
true
28a416eb85a23c3ed0cb0e6a2fe207797f8f9f0b
92FelipeSantos/CursoEmVideoPython
/CursoEmVideoExercicios/ex005.py
205
4.1875
4
# Digite um número e mostre seu antecessor e seu sucessor n = int(input('Digite um número: ')) print('O número digitado foi: {}. Seu antecessor é {} e seu sucessor é {}.'.format(n, (n - 1), (n + 1)))
false
6e29a0b4eb5805051dafdaf5c6dba6501489c298
FE1979/Dragon
/Python_4/is_sorted.py
1,086
4.1875
4
""" check recursively if list is sorted """ def is_sorted(list): sorted = True items = len(list) medium = len(list) // 2 left_list = list[:medium] right_list = list[medium:] if items > 4: #end script when left and right lists have 1 or 2 items if left_list[0] <= left_list[-1] <= right_...
true
4c236ab912c9fac7847b567d0366657d02ed6d13
FE1979/Dragon
/Python_3/fibo_recurs.py
314
4.125
4
fibo_top = int(input('Type top of Fibonacci list>')) list = [0,1] def fibonacci(list, top): if list[-1] < top: list.append(list[-1] + list[-2]) list = fibonacci(list, top) if list[-1] > top: list.pop() return list print('Fibonacci list\n{}'.format(fibonacci(list,fibo_top)))
false
b636c8a39b3c5ef41011fea7f2290cd8f64daf1e
FE1979/Dragon
/Python_3/median.py
243
4.15625
4
first_list_len = int(input('Type a lenght of the first list\n')) second_list_len = int(input('Type a lenght of the second list\n')) median = (first_list_len + second_list_len)/2 print('A median of the two merged lists is {}'.format(median))
true
76c2e3674764893d0b35594fd0a52d69473e82f0
Aaronphilip2003/GUI_Tkinter
/18)Databases.py
2,562
4.125
4
from tkinter import * import sqlite3 root=Tk() #Create a table ''' c.execute("""CREATE TABLE addresses( first_name text, last_name text, addresses text, city text, state text, zipcode integer )""") ''' f_name=Entry(root,width=30) f_name.grid(row=0,column=1) l_name=Entry(root,width=...
false
d302c81aee46e0abaa5a7e075fef44fb44405410
Onimanta/pythonHardway
/ex39_drill.py
486
4.21875
4
# -*- coding: utf-8 -*- cantons = { 'NE': 'Neuchâtel', 'VD': 'Vaud', 'FR': 'Fribourg', 'BE': 'Berne', 'GE': 'Genève' } cities = { 'Chaux-de-fonds': 'NE', 'Lausanne': 'VD', 'Bulle': 'FR', 'Bienne': 'BE', 'Meyrin': 'GE' } print "The abbreviation of all of the canton: ", cantons....
false
3ec3b48304331486cac681892a9cfdd0974ae0fd
njones777/school_programs
/X&Y.py
2,533
4.25
4
###################################################################################################################### # Name: Noah Jones # Date: 9/13/2021 # Description: program to do simple X & Y coordinate calculations such as midpoint and distance between two points #############################################...
true
c74b685438df1dbae6fadbe9b39846944921b81a
kstack4074/daily_coding
/#9.py
1,212
4.28125
4
''' Given a list of integers, write a function that returns the largest sum of non-adjacent numbers. Numbers can be 0 or negative. For example, [2, 4, 6, 2, 5] should return 13, since we pick 2, 6, and 5. [5, 1, 1, 5] should return 10, since we pick 5 and 5. Follow-up: Can you do this in O(N) time and constant space?...
true
f872c22c73d77b2750d02092aaa396e97e38284b
KyLarson-Research/100Days-21
/day2.py
439
4.1875
4
#Authored by Kyle Larson 9-30 print('Welcome to the tip calculator.') bill =input("What was the total bill?") people = input("How many people to split the bill?") percentage = input("WHat percentatge tip would you like to give?") if int(percentage) < 0 or int(percentage) > 100: print("invalid percentage") else: ...
true
eca17996335c4fa8b1c2de5cc93e7ec170efcc9e
BenRauzi/159.171
/Workshop 3/13.py
255
4.15625
4
words = [] while True: word = input("Enter a word: ") if word.lower() == "end": #.lower() allows any casing from the input, prevents errors in real world scenarios break words.append(word) print("The resulting list is " + str(words))
true
53793985ba1d3bca5dd13c74ae15c1867145fc7d
LuisCastellanosOviedo/python3
/my-python-project/datetime/time-till-deadline.py
609
4.21875
4
from _datetime import datetime user_input =input("enter your goal with a deadline separated by colon \n") input_list = user_input.split(":") goal = input_list[0] deadline = input_list[1] print(input_list) deadline_date = datetime.strptime(deadline, "%d.%m.%Y") today_date = datetime.today() print(deadline_date) pri...
true
ad1f15c1dd06cf6db543de987c669e5b84a9ae8d
LuisCastellanosOviedo/python3
/my-python-project/day9_dictionaries_and_nesting/main.py
505
4.15625
4
first_dic = { "bug": "is a error", "Function": "A piece of code", "Loop": "some repetitive", } # retrieve all elements from the dic print(first_dic) print(f"bug values: {first_dic['bug']}") # Adding new elements to dictionary first_dic["Error"] = "A problem in the code" print(first_dic) # Create and emp...
true
1568cb71199c1ce51eee28205d95429df363a4c9
nishalpattan/DataStructures-Algorithms
/Arrays/twoSum.py
1,021
4.3125
4
def twoNumberSum(array, targetSum): """ Time Complexity : O(n) Space Complexity : O(n) :param array: :param targetSum: :return:[number1, number2] """ hash_map = dict() for num in array: if num in hash_map: return [num, targetSum - num] hash_map[targetSum - num] = num return [] def tw...
true
3f4ed5b3ea1a1c83fa58784590f92c1ca0b983d9
vuthanhdatt/MIT_6.0001
/ps1/ps1b.py
681
4.25
4
annual_salary = int(input('Enter your annual salary:')) portion_saved = float(input('Enter the percent of your salary to save:')) total_cost = int(input('Enter the cost of your house:')) semi_annual_raise = float(input('Enter the semi­annual raise, as a decimal:')) portion_down_payment = .25 current_savings = 0 r = .0...
true
8375c9db42e10ee289459c316ea6f4e33a0756a1
gocersensei/Recursion
/totalTheValues.py
963
4.25
4
## # Total a collection of numbers entered by the user. The user will enter a blank line to # indicate that no further numbers will be entered and the total should be displayed. # ## Total all of the numbers entered by the user until the user enters a blank line # @return the total of the entered values def readAndTota...
true
0a95d47a6764e6390bc7a0463ca0113d1673b2d0
nonamejx/python-design-patterns
/src/factory_method/factory_method.py
1,304
4.53125
5
""" Factory Method Design Pattern. Intent: Provide an interface for creating an object, but let subclasses decide which class to instantiate. """ from __future__ import annotations from abc import ABC, abstractmethod class Transport(ABC): @abstractmethod def deliver(self) -> str: pass class Truc...
true
26f9d146a24929bbf5f4469260754a3c8d377dfe
leilongquan/selfteaching-python-camp
/exercises/1901100231/1001S02E03_calculator.py
864
4.3125
4
#告知这是个计算机小程序 print("""请键入要进行运算的两个数字 并按: “+”代表加 “-”代表减 “*”代表乘 “/”代表除 “%”代表求余数 “**”代表求次方 的如上所示的规则键入你要进行的运算 本程序只可运行一次,重复计算请重复使用 请切换至英文输入模式进行数字和运算的键入""") #获取要算的数和运算 x = input() y = input() z = input() #计算器程序 if z == "+": print(x,"+",y,"=",int(x)+int(y))#加法 elif z== "-": print(x,"-",y,"=",int(x)-int(y))#减法 elif z==...
false
960bd9b4ab615c14b92f2b0f82f77118e1d3d668
EmAchieng/myPy
/employees.py
716
4.375
4
#creating an instanciated simple classes #classes allow us to logically group our data and functions making it easy to reuse class Employee: #means you just want to skip it pass #each of these will be their own unique instances of the employee class emp_1 = Employee() emp_2 = Employee() #both of these are ...
true
60bd4f6ad8853b44a62604f8ca56e798af1229c4
saikiranPadala/basic-projects
/basic projects/calculator.py
818
4.21875
4
# simple calculator def add(x,y): return x+y def subtract(x,y): return x-y def multiply(x,y): return x*y def divide(x,y): return x/y def power(x,y): return pow(x,y) print("select operation.") print("1.Add") print("2.Subtract") print("3.Multiply") print("4.Divide") print("5.Power") choice = input("...
false
45242b779548b11bdedea095e68ca9f97db33075
bcbc-group/PLSCi7202_2021
/first_python.py
1,660
4.53125
5
#!/usr/local/bin/python3 #testing out python print("Python is fun!") #using variables message = "Python is fun!" print(message) #using the title method name = "suzy strickler" print(name.title()) #using variables in strings first_name = "suzy" last_name = "strickler" full_name = f"{first_name} {last_name}" print(ful...
true
f70ecd164dd2177c16d34a2dd2c671a8a73d4169
sakshambhardwaj523/Python-OOP-Projects
/Assignments/Assignment 3/menu.py
1,649
4.15625
4
""" Stores Menu items for Pizza shop UI. """ import pizza class Menu: """ Stores items for menu creation. """ start_menu = { 1: "Build your own pizza", 2: "Quit" } cheese_menu = { 1: pizza.Ingredient("Parmigiano Reggiano", 4.99), 2: pizza.Ingredient("Fresh Moz...
true
4ee97294e3144d500b4045fcff47fa91599d864a
sakshambhardwaj523/Python-OOP-Projects
/Labs/Lab 2/item.py
2,079
4.15625
4
import abc class Item(abc.ABC): """ Represents an Item that is stored in a Catalogue at the Library. Any class that inherits from this class MUST implement all the @abstractmethods and @abstractclassmethods. """ def __init__(self, title, call_no, author, num_copies): """ Initia...
true
282885f934c239d86252c9f4503fa4174476dbe1
sakshambhardwaj523/Python-OOP-Projects
/Labs/Lab 0/calculator.py
1,565
4.15625
4
"""Demonstrates basics of Python functions.""" def sum(a, b): """ Return sum of two ints. :param a: int :param b: int :return: sum as an int """ return a + b def subtract(a, b): """ Return difference of two ints. :param a: int :param b: int :return: difference as an int...
true
e27c41f9b5045a9f45375f2c41d460a13d52a8de
mosest/11th-Python
/8 - Snowflake Fractal.py
1,054
4.21875
4
#Tara Moses #Assignment 8: Snowflake Fractal #February 4, 2013 #1. Program draws a snowflake fractal depending on the user-specified fractal order. #2. Program fills the snowflake with a certain user-specified color. import turtle,Tkinter order=int(raw_input("What order fractal would you like? ")) snowflake_color=ra...
true
99d5c42af89537c281fd365e644f76dc3938df39
mosest/11th-Python
/20 - TicTacToe 1.py
1,720
4.21875
4
#Tara Moses #Assignment 20: TicTacToe 1 #April 29, 2013 import random class Board: def __init__(self): self.nums=[[0,1,2],[3,4,5],[6,7,8]] def canPlace(self,pos): numbers=[0,1,2,3,4,5,6,7,8] row=pos/3 col=pos%3 spot=self....
false
1d4b314ca1f36c9e4b84125bbff659cd4fb014ff
mosest/11th-Python
/6.4 - Divisible by 1 to 16.py
1,895
4.15625
4
#Tara Moses #Assignment 6.4: First Number Divisible by 1, 2, ..., 16 #January 29, 2013 #1. Program tests whether a number is divisible by all numbers 1-16. #2. Program outputs first number that satisfies conditions. print("I'll print the first number that is divisible by every number") print("from 1 to 16.") num_to_...
true
0ed7acd5c63b9fce0245800345bcf6dfc292cd67
rabbit-jump/LPYHW
/exercise/e03.py
783
4.4375
4
#coding=utf-8 print("I will now count my chickens:") print ("Hens",25+30/6)#计算表达式的值,并输出。除法运算 (/) 永远返回浮点数类型。如果要做 floor division 得到一个整数结果(忽略小数部分)你可以使用 // 运算符 print("25+30/6的整数结果:",25+30//6) print ("Roosters",100-25*3%4) print("Now I will count the eggs:") print(3+2+1-5+4%2-1/4+6) print("Is it true that 3+2<5-7?") print(3...
false
9d0423cc0ba16147283f43a697a7a9d417467e9f
andprogrammer/crackingTheCodingInterview
/python/chapter3/3/solution.py
1,982
4.125
4
class Stack(object): def __init__(self, capacity): self.capacity = capacity self.stack = [] self.size = 0 def push(self, elem): if self.is_full(): raise Exception('Stack is full') self.size += 1 self.stack.append(elem) def pop(self): if s...
false
59b45ba95b8ad280816e2c6c21d151746c23de21
zhishixiang/python-learning
/012 列表类型的内置函数.py
604
4.1875
4
#count 检查一个数在列表里出现了几次 number = [1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2] print(number.count(1)) #index 检索数组中的某个值第一次出现在哪个位置 print(number.index(2)) #限定范围 number2 = [1,1,2,2,1,1,2,2,1,1,2,2,1,1,2,2] print(number2.index(2,4,8)) #reverse 来过倒组数把 number3 = [1,2,3,4,5,6,7,8,9] number3.reverse() print(number3) #sort 根据指定参...
false
5b4a835de7024a3f8ec9c09b2ead038a303e75e4
zhishixiang/python-learning
/033 异常处理.py
1,401
4.125
4
#打开一个不存在的文件时会出现FileNotFound的异常 #f = open("我是一个文件.txt") #print(f.read()) #f.close() #使用try语句时可以检测抛出的异常 try: f = open("这是个不存在的文件.txt") print(f.read) sum = 1 + '1' f.close() #使用except可以决定当某个异常出现时执行什么指令 #except还可以添加一个变量存放错误原因 #变量需要使用str()方法转换为字符 except OSError as error: print("出现错误!\n错误的原因是"+str(error))...
false
6a3fa81f303c29dbd65df18e20aaf8c89d2921f4
Edithwml/python
/grammar/内建函数(map、filter、reduce、sorted).py
2,603
4.28125
4
''' 1、range Python2中range返回列表,Python3中range返回一个迭代值。 如果想要一个列表可以通过list函数 ''' a = range(5) list(a) #创建列表的另一种方法 testlist = [x+2 for i in range(5)] #testlist=[2,3,4,5,6] ''' 2、map函数 map函数会根据提供的函数对指定序列做映射 map(...) map(function, sequence[, sequence, ...]) -> list function:是一个函数 sequence:是一个或多个序列,取决于function需要一个参数 返回值是一个li...
false
7e74ea4cce76fb0be74df39feb492966119031bf
Juan337492/PythonCalculator
/MyCalc.py
1,131
4.28125
4
#Program name: MyCalc #Lab no: 1 #Description: Input two numbers then select operator #Your name: Juan Rodriguez #Date: 06-13-2021 title = "My Calculator" choice = "y" while (choice == 'y'): num1 = int(input("Enter Number 1: ")) num2 = int(input("Enter Number 2: ")) print("Please select operation to be per...
true
889b5fd7a45c3666c29b8eda1efaec1f366fc960
harperpack/Harper-s-Practice-Repository
/list_practice_4.py
1,278
4.59375
5
# Still practicing with lists, from Python Crash Course locations = ["japan", "korea", "vietnam", "cambodia", "new zealand"] print (locations) print ("\n") # Adjust each item in the list to be capitalized for location in locations: locations.remove(location) location = location.title() locations.insert...
true
17308c5c65d56b64070822e1e7ae5e0c1594a5a9
harperpack/Harper-s-Practice-Repository
/number_work.py
670
4.15625
4
# This is a program built to help me practice representing numbers in Python # Explore different arithmetic in Python import time print(5 + 3) print(4.0 * 2) print(2 ** 3) print(24 / 3) print(9.0 - 1) favorite_number = 8.0 print("Can you guess which is my favorite number?") # Allow the user time to ...
true
2d489c85552512da120bcdbb1a6b84fdc0a16b15
malavikasrinivasan/D06
/HW06_ch09_ex06.py
1,478
4.625
5
#!/usr/bin/env python3 # HW06_ch09_ex05.py # (1) # Write a function called is_abecedarian that returns True if the letters in a # word appear in alphabetical order (double letters are ok). # - write is_abecedarian # (2) # How many abecedarian words are there? # - write additional function(s) to assist you # - nu...
true
cdfffc41e35a60ade6032f9b8522a8751e8e8821
malavikasrinivasan/D06
/HW06_ch09_ex02.py
1,157
4.40625
4
#!/usr/bin/env python3 # HW06_ch09_ex02.py # (1) # Write a function called has_no_e that returns True if the given word doesn't # have the letter "e" in it. # - write has_no_e # (2) # Modify your program from 9.1 to print only the words that have no "e" and # compute the percentage of the words in the list have no "...
true
d48b53882f5ef8b7fe23bd28fc407745b284ab7e
ianzapolsky/practice
/euler_problems/4.py
486
4.125
4
# 4.py # Description: Find the largest palindrome made from the product of two 3-digit # numbers. # Author: Ian Zapolsky (10/31/13) def biggest_p(): biggest_pal = 0 for x in range(100, 1000): for y in range(100, 1000): if is_pal(x*y) and (x*y) > biggest_pal: biggest_p...
false
81e3697052ce18a2c72e51ae8c8f06a6b812f8eb
pranavchandran/Automate-with-Python
/stopwatch.py
1,324
4.25
4
# My StopWatch """ Track the amount of time elapsed between presses of the ENTER key, with each key press starting a new “lap” on the timer. Print the lap number, total time, and lap time. This means your code will need to do the following: Find the current time by calling time.time() and store it as a timestamp ...
true
6193235aaa2f557e8e9c53d8b63ca819788be73a
ToMountainTops/MangoTest
/mango_programming_test_classes.py
1,847
4.25
4
""" Created on Sun Sep 29 For Mango Solutions Python test For any questions please contact Claire Blejean: claire.blejean@gmail.com The solution presented here relies on the random sampling function which is part of python.numpy. A numerical solution can be coded which relies on mapping the inverse cumulative di...
true
493f17f5e53b46fbccc4cb95b2ea1e9a4a5cc7a3
IshaBansal0408/HackerRank---Python-Programming
/Understanding Regular Expression/002. Groups in RE.py
531
4.34375
4
""" GROUPS IN REGULAR EXPRESSION groups() return tuple containing all the captured groups """ import re m=re.search('(\d+),(\d+),(\d+)','123,12763,773687') print(m) print(m.groups()) """ GROUPS IN REGULAR EXPRESSION group(n) return nth group """ print("Empty Group: ",m.group()) print("Group 0: ",m.group(0)) print("Gro...
false
66b500e3a58a5fccb6cfc7ff6d6363a798757dfa
ParitoshBarman/Python-Practice
/Chapter-06-Conditional Expression/10_pr05.py
218
4.21875
4
names = ["shubha","sasti","samir","bishu","bishadu"] name = input("Enter the name to check-->") if name in names: print("Your name is present in the list") else: print("Your name is not present in the list")
false
bdc98d70e73076855eedbe73247b27d05f4e2182
baileejbrown/Projects
/prac_03/password_entry.py
429
4.1875
4
"""Bailee Brown""" MIN_LENGTH = 6 def main(): password = get_password() print_asterisks(password) def print_asterisks(password): print('*' * len(password)) def get_password(): password = input("Please enter a password 6 digits or longer: ") while len(password) < MIN_LENGTH: print("Pa...
false
1ae0dd893d251b323e662d58dc6e49b62e29e018
brandon932/learnPython
/CtoF.py
610
4.1875
4
#simple program to convert a temerature to in celcius to fahrenheit def cel_to_fahr(c): if c < -273.15: print("how is that possible") else: f = c * 9/5 + 32 print(str(c) + " celcius is " + str(f) + " fahrenheit") return f def main(): c = float(input("enter a temperature in celcius: ")) cel_to...
false
da3044772c9b3d4cd03151d1b177e335973dea99
ChiranthakaJ/Google-Crash-Course-on-Python
/Python_OOP_Documenting_Functions_Classes_Methods.py
2,451
4.65625
5
#We can still use the Python function help to find documentation about classes and methods. #We can also do this on our own classes, methods, and functions. #Let's look at the below example. class Apple: def __init__(self, color, flavor): self.color = color self.flavor = flavor def __str__(se...
true
3473cb8474c1476efbaedd61785ada112665c321
ColinLafferty/python_tutorials_2013
/leap_year.py
1,238
4.65625
5
#!/usr/bin/env python '''\ Leap years occur according to the following formula: a leap year is divisible by four, but not by one hundred, unless it is divisible by four hundred. For example, 1992, 1996, and 2000 are leap years, but 1993 and 1900 are not. The next leap year that falls on a century will be 2400. sour...
true
5cd2a3acd1ef12389804180e51071ad660c84d46
IsmailFadeli/Python-for-Probability-statistics-and-ML
/Random_Variables.py
1,100
4.125
4
# What is the probability that the sum of the dice equals seven? # Step 1: associate all of the (a,b) pairs with their sum. d = {(i,j):i+j for i in range(1,7) for j in range(1,7)} # Step 2: collect all of the (a,b) pairs that sum each of the possible values from two to twelve. from collections import ...
true
1dd80cfb8fe81573fe4b5b6467ffd12feda38acb
shirishdhar/HW04
/HW04_ex00.py
1,270
4.21875
4
#!/usr/bin/env python # HW04_ex00 # Create a program that does the following: # - creates a random integer from 1 - 25 # - asks the user to guess what the number is # - validates input is a number # - tells the user if they guess correctly # - if not: tells them too high/low # - only lets t...
true
f77318b267a53148e75bf32c0d564a25c250db34
Zerl1990/python_essentials
/examples/module_1/06_inputs.py
211
4.40625
4
# Input will show a message in the console, and return what the used types # The return value can be store in a variable age = input("What is your age?") # Print the user input print("Your age is: " + age)
true
d2912a4091ba27c9be145f61b5a1ce2f51c3c60f
Zerl1990/python_essentials
/examples/module_1/03_variables.py
453
4.3125
4
# type function return the type of the variables. # for example, for number variable, it will return int number = 5 print("Number Type:") print(type(number)) decimal = 15.5 print("Decimal Type:") print(type(decimal)) char = 'A' print("Char Type:") print(type(char)) string = 'My String' print("String Type:") print(t...
true
72873dcfb1b9be8216663493368425738908b1ca
GuoXian88/15112_py
/fluent_py/ch08_obj_ref/ch8_obj_ref.py
1,852
4.3125
4
''' garbage collection, the del command, and how to use weak references to “remember” objects without keeping them alive. reference variables: label attached to objects 下面可以证明赋值是先evluate右边再绑定到左边(Gizmo实例创建成功但是y并没有赋值成功) To understand an assignment in Python, always read the right- hand side first: that’s where ...
true
55f6d217079a25a1bc92c94e6de29af502482c11
mirandarevans/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/5-text_indentation.py
474
4.15625
4
#!/usr/bin/python3 def text_indentation(text): if type(text) != str: raise TypeError('text must be a string') newline = True for char in text: if newline is True: if char == ' ': pass else: newline = False if newline is False:...
true
62c7bb6af2a4ed5fd481d5807f3f83d3ea87910a
vanithaasivakumar/Python---Hands-on
/Advanced Modules/FileIO.py
640
4.125
4
myfile=open('SampleText.txt') print(myfile.read()) #displays file content print(myfile.read()) #running it again will display empty string. Cursor is in end of the file myfile.seek(0) #brings the cursor to the beginning of the file print(myfile.read()) myfile.seek(0) print(myfile.readlines()) #['Hello Wor...
true
c6d1a211a7fefb816865d1a55aa40c82685cb6cc
Sergi-Simon/INTRODUCTION-TO-PYTHON-PROGRAMMING
/Solutions to Exercises in Lecture Notes, Sections 1-6/week 2 (section 2)/temperature.py
790
4.28125
4
""" temperature.py Prorgram that converts any temoerature from Fahrenheit to Celsius and from Celsius to Fahrenheit Author: Sergi Simon Last update: October 22, 2020 """ # conversion of Celsius to Fahrenheit def C_to_F ( c ): return c*1.8 + 32. # conversion of Fahrenheit to Celsius def F_to_C ( f ...
false
f9caaf9183591321cb40114dc1484fa8c27d8b6b
Sergi-Simon/INTRODUCTION-TO-PYTHON-PROGRAMMING
/Solutions to Exercises in Lecture Notes, Sections 1-6/week 3 (section 3)/vector_cosine.py
1,455
4.21875
4
""" vector_cosine.py Program returnning the cosine of two vectors with recursive functions Author: Sergi Simon Last update: October 26, 2020 """ import math def take_input( n, string, list0 ): list1=list0.copy() # you can also write list1=list0 and it will still work if len( list1 ) == n: return list1 x = flo...
true
ea2dc847f4175a358ebf78760f7da0537cb122a8
Sergi-Simon/INTRODUCTION-TO-PYTHON-PROGRAMMING
/Solutions to Exercises in Lecture Notes, Sections 1-6/week 6 (sections 5, 6)/6/function_graph.py
1,615
4.46875
4
""" function_graph.py Routine that checks the number of changes in sign in the graph provided in the lecture notes Author: Sergi Simon Last Update: November 18, 2020 """ import sys def verify_signs ( x0, x1 ): if x0 == -3 or x0 == 2 or x0 == 6 or x1 == -3 or x1 == 2 or x1 == 6: string = "you have chosen interva...
true
fe34b8e6d72e091a7dc01eeacc3d09e262c1ef31
Sergi-Simon/INTRODUCTION-TO-PYTHON-PROGRAMMING
/Solutions to Exercises in Lecture Notes, Sections 1-6/week 4 (section 4)/Solutions to Exercises/1/reverse_tuple_2.py
316
4.34375
4
""" reverse_tuple.py Function that reverses any tuple Author: Sergi Simon Last update: October 26, 2020 """ def reverse_tuple ( Tuple ): list1 = list( Tuple ) list1.reverse() return tuple( list1 ) print( reverse_tuple( (1,2,3) ) ) x= 1,2,3,"a","good morning", -1,-2 print( reverse_tuple( x ) )...
false
9e950dc6b0a0f7941d5d6d1fe1fcc2f354a7495f
Alena-Ryzhko/python_algorithms
/unit_test/reverse_string.py
478
4.125
4
""" Unit Test –> Reverse String """ import unittest class TestStringReversal(unittest.TestCase): def test_reverse_string(self): input = "Rosa are red and I am glad" expected_result = "glad am I and red are Rosa" output = self.reverse_string(input) self.assertEqual(expected_result,...
true
6cdb0e720062ef1b9f3751bd6b5c3d48184d276e
Alena-Ryzhko/python_algorithms
/algorithms_2_num/sum_of_natural_numbers_of_the_random_generated_num.py
1,012
4.1875
4
""" A function which finds the sum of num natural numbers: (sum of digits of a randomly generated number n) """ from random import randint # Approach 1 def sum_of_natural_numbers_of_num(number_of_digits): down = 10**(number_of_digits-1) up = (10**number_of_digits)-1 n = randint(down, up) ...
false
546b568c45ff86dfec09cf3ed4b2c4c8e6bce0b4
Alena-Ryzhko/python_algorithms
/algorithms_2_num/fibonacci_sequence.py
983
4.40625
4
""" The Fibonacci Sequence is the series of numbers: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34,... where F0 = 0 , F1 = 1 and Fn = Fn-1 + Fn-2 A function to Print the Fibonacci sequence: """ # Approach 1 n = int(input("How many numbers will be in the sequence? Enter please ")) def fibonacci(n): # First Fibonacci number is...
true
b83bdcfc0cee4c86dbcf94cf51d2f910acb3e959
daniglezmar/Python
/Codigos_De_Clase/Códigos-1/condicionalIF.py
431
4.125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # Comparacion entre varios numeros print ("Vamos a comparar dos números: ") numero1 = int (input("Escribe un primer numero: ")) numero2 = int (input("Escribir un segundo numero: ")) if (numero1 < numero2): print ("Menor: ", numero1, "Mayor: ", numero2) elif (numero1 >...
false
e5c3d33b4d20042bebdfc4ea3d637a0928948663
Maruthi18/Python_Projects
/Calculator/calculator.py
1,006
4.21875
4
from replit import clear from art import logo def add(n1, n2): return n1 + n2 def subtract(n1, n2): return n1 - n2 def multiply(n1, n2): return n1 * n2 def divide(n1, n2): return n1 / n2 operations = { "+": add, "-": subtract, "*": multiply, "/": divide } def calculator(): """ here we are taking n1...
true
f293f33656b14932f10e04482a51df8cf9ffd5b0
123zrf123/python-
/practice_7.py
766
4.21875
4
#栈的基本操作 class Stack(object): """模拟栈""" def __init__(self): self.items = [] def isEmpty(self): return len(self.items)==0 def push(self, item): self.items.append(item) def pop(self): return self.items.pop() def peek(self): if not self.is...
false
bcf75ce80a6eb0a2115056ae7172b981dbd047e4
xlistarer/recurse
/main.py
2,877
4.34375
4
# This is a sample Python script. # Press Shift+F10 to execute it or replace it with your code. # Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings. ''' ############################################# # All tasks should be solved using recursion ######################...
true
ba579d74b47eb7dc1a55a242e22701abdbb46997
roshansinghbisht/hello-python
/day-5-using-a-simple-loop.py
1,945
4.34375
4
# TASK: The provided code stub reads and integer, n, from STDIN. # For all non-negative integers i<n, print n^2 . if __name__ == '__main__': n = int(input("Enter a number between 1 and 20")) for i in range(n): print(i**2) # A module is a file containing Python definitions and statements. # T...
true
8f3e26501cd9a96e8b9f4677fe3586994afd0869
roshansinghbisht/hello-python
/day-17-data-structures.py
1,076
4.28125
4
print('Creating a Tuple...............................................') dimensions = 52, 40, 100 length, width, height = dimensions print("The dimensions are {} x {} x {}".format(length, width, height)) # Creating a set fro a list (to remove duplicates from a list). print('Creating a set................................
true
2e8540fb1fdbf26c5d19dee9e5855bf06ac3c484
Pittor052/SoftUni-Courses
/Python/Basics/0.2-Conditional-Statements/Exercises/converter.py
496
4.21875
4
num_to_convert = float(input()) unit_in = input() unit_out = input() if unit_in == "m": if unit_out == "cm": num_to_convert *= 100 elif unit_out == "mm": num_to_convert *= 1000 if unit_in == "cm": if unit_out == "m": num_to_convert /= 100 elif unit_out == "mm": num_to_c...
false
a9e469a52407aa1004562ab4b212bea5c471e71a
nick-fl/projecteuler
/5.py
480
4.25
4
#infinitely outputs multiples of 20. there is probably and easier way print("Finding the smallest number that has every number between 1 and 20 as a factor.") found = 0 a = 0 while found == 0: counter = 0 b = a + 20 for i in range(1,21): if b%i == 0: counter += 1 if counter ==...
true
b4513eb73cd6683c02ad1e0d1b413785bdeece4d
BernardWong97/Collatz
/collatz.py
399
4.46875
4
# The number to perform the Collatz operation. n = int(input("Enter a positive integer: ")) # Keep looping until n = 1 assuming Collatz conjecture is true. while n != 1: print(n) # print current value of n. if n % 2 == 0: # if even, divide by two. n //= 2 else: # if odd, multiply by three and ad...
true
6936684126b9a4d76c079d0b9638d4dddc8ae96d
Steantc/SENG3110_Lab2_Python_Unit_Testing_Project
/cube.py
886
4.125
4
import math def surfaceArea(ln): area = round((6 * ln**2), 2) return area def volume(ln): volume = round((ln**3), 2) return volume def lateral(ln): lateral = round((4* ln**2), 2) return lateral def prompt(): print() print("----------------------------------------------------------...
true
36ae7457a749d276c36e4e71bfeac919112168d7
ayumoesylv/draft-tic-tac-toe
/L2 Python Class 1 homework pt 2.py
260
4.125
4
#write a program to count the number of elements in a list. FruitIndex = ["apple", "orange", "banana", "kiwi", "blueberry", "grape"] fruitNum = len(FruitIndex) for i in range(0, len(FruitIndex)): print(FruitIndex[i], end = " ") print("total:", fruitNum)
true
da4b5f37095f003305bbda58c149b0afe8f255e7
sharma-arpit/cs50
/Random/stud.py
245
4.28125
4
from student import Student students = [] for i in range(3): name = input("name: ") dorm = input("dorm: ") students.append(Student(name, dorm)) for student in students: print("{} is in {}.".format(student.name, student.dorm))
true
13d3bc182e07027e3fef6dea8094e3976e55e7eb
paua-app/Python-Stuff
/functional programming/mylen.py
2,111
4.34375
4
""" Task: Write a function that calculates the length of a list. Example: #>>> print(len([1,2,3,4,5])) 5 """ from auxfuncs import cdr from auxfuncs import build_list as bl from auxfuncs import curry __author__ = 'Aurora' def my_len_imp(lst): temp = 0 i = 0 while lst[i] != None: ...
true
89fc0701e224e24bc764f31de5d01efbd59d633b
arsh771/assignment16
/MONGODB.py
857
4.3125
4
#Q.1- Write a python script to create a databse of students named Students. import pymongo client=pymongo.MongoClient() database=client['Students'] print('STUDENTS DATABASE CREATED') collection=database['Student Data'] print('STUDENTS DATA TABLE CREATED') #Q.2- Take students name and marks(between 0-100) as inpu...
true
861757dc22878e5535c974eb49104a1195beba6f
kshannoninnes/hyprfire
/hyprfire_app/utils/file.py
534
4.34375
4
from pathlib import Path def get_filename_list(path): """ get_filename_list Helper function to retrieve a list of non-hidden filenames from a directory Parameters path: a path to a directory containing files Return A list of non-hidden filenames in the directory """ file_list = ...
true
13365a83cff07ae5eab820f17d288d5f86bc4afc
ujaani/python
/max.py
373
4.125
4
first = input("give me a number") second = input("give me another number") first_int = int(first) second_int = int(second) if first_int > second_int: max = first_int elif first_int == second_int: print("both no. are equal. the equal no. is " + first) exit(0) else: max = second_int max_s...
true
6a8f1ff7ce2492d3c963e3d8d75a1162b5c4ccf5
huzefa53/python-learning
/python-learning/dict.py
779
4.21875
4
#!/usr/bin/python '''Python's dictionaries are kind of hash table type. They work like associative arrays or hashes found in Perl and consist of key-value pairs. A dictionary key can be almost any Python type, but are usually numbers or strings. Values, on the other hand, can be any arbitrary Python object. Dictionari...
true
5a6585d058c0dcf1f27f984fc6e436206bd3e90f
AfroHackology/OOP
/coreyS_classes/emp.py
1,379
4.15625
4
class Employee: num_of_emps = 0 raise_amount = 1.04 names = input([]) tardies = bool(False) def __init__(self, first, last, pay): self.first = first self.last = last self.pay = pay self.email = first + '.' + last + '@company.com' Employee.num_of_emps += 1 ...
true
0dac3948778f6524def5952f7112c5ca80303b63
w23023030/sc-projects
/stanCode-Projects/boggle_game_solver/anagram.py
2,363
4.1875
4
""" File: anagram.py Name: Jasmine Tsai ---------------------------------- This program recursively finds all the anagram(s) for the word input by user and terminates when the input string matches the EXIT constant defined at line 19 If you correctly implement this program, you should see the number of anagrams for ea...
true
dc9f2e3e4b34a603913683da5a0d79cc7944cfd0
nlkek/CodewarsProgs
/SimplePigLatin.py
475
4.1875
4
def pig_it(text): res = '' lst = text.split(' ') for word in lst: if word.isalnum(): res += word[1:] + word[0] + 'ay ' else: res += word return res.rstrip() """ Move the first letter of each word to the end of it, then add "ay" to the end of the word....
true
ec9d503e6ee3a5079ee9d71e4077ff9232a69ea3
Matthew-Barrett/rock_paper_scissors
/rpsv3.py
1,786
4.21875
4
import random hands = {"r":"Rock", "p": "Paper", "s": "Scissors","e": "exit"} ai_hands = {"r": "Rock", "p": "Paper", "s":"Scissors" } print( "Welcome to Rock, Paper, Scissors" ) print( "This is a game of wits, human vs machine." ) print( "You may also concede defeat by pressing e") game_on = True while gam...
false
2d86a3cacbf4ad14167d00f63d43ae7fccef594c
arwildo/hacker-rank
/30DaysOfCode/day3.py
383
4.15625
4
#!/bin/python3 def checks(N): odd = 1 if N%2 != odd and N > 20: print('Not Weird') elif N%2 != odd and N >= 2 and N <= 5: print('Not Weird') elif N%2 != odd and N >= 6 and N <= 20: print('Weird') elif N%2 == odd: print('Not Weird') else: print('Weird') ...
false
0eecdc646a3b101f41ddf1b4580f5cf571849d2a
gahakuzhang/PythonCrashCourse-LearningNotes
/6.dictionaries/6.4.1 a list of dictionaries.py
320
4.21875
4
# 6.4.1 a list of dictionaries 字典列表 aliens=[] # 创建30个绿色外星人 for alien_number in range(30): new_alien={'color':'green','points':5,'speed':'slow',} aliens.append(new_alien) for alien in aliens[:5]: print(alien) print('...') print("The total number of aliens: "+str(len(aliens)))
true
57cd761fc481808c38c9994b6eb73ac579a0fb77
gahakuzhang/PythonCrashCourse-LearningNotes
/9.classes/9.3.3 define attributes and methods for the child class.py
1,205
4.34375
4
# 9.3.3 define attributes and methods for the child class 为子类定义属性和方法 class Car(): def __init__(self,make,model,year): self.make=make self.model=model self.year=year self.odometer_reading=0 def get_descriptive_name(self): long_name=str(self.year)+' '+self.make+' '+...
true
2323d1575e0e3299b67bddaa9c88ac80332a23f3
YaYaChen827/Udacity_Intro_to_Computer_Science
/Quiz/Lesson5_Quiz_Empty_Hash_Table.py
1,186
4.1875
4
# Creating an Empty Hash Table # Define a procedure, make_hashtable, # that takes as input a number, nbuckets, # and returns an empty hash table with # nbuckets empty buckets. def make_hashtable(nbuckets): hashtable = [] for i in range(0, nbuckets): hashtable.append([]) return hashtable #Testing right make_hasht...
true
802e97f5333bb818ff099bcbbcfa7bc204b67dec
robgoyal/CodingChallenges
/CodeWars/7/complementaryDNA.py
437
4.125
4
# Name: complementaryDNA.py # Author: Robin Goyal # Last-Modified: March 15, 2018 # Purpose: Return the complement of a DNA string def DNA_strand(dna): """ (str) -> str Return the DNA complement of dna as a string. Examples: >>> DNA_strand("ACTGTAC") "TGACATG" """ complements = {"A"...
true
0d85a27d4679d367cf451ab98124bf3722701614
robgoyal/CodingChallenges
/HackerRank/Algorithms/Implementation/21-to-30/jumpingOnTheCloudsRevisited.py
884
4.375
4
# Name: jumpingOnTheCloudsRevisited.py # Author: Robin Goyal # Last-Modified: November 23, 2017 # Purpose: Calculate the remaining energy level after jumping over clouds def jumpingOnTheCloudsRevisited(n, k, clouds): ''' n -> int: number of clouds k -> int: jump size clouds -> list: clouds of value 0 ...
true