blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
83323c1163bd366d418957a6542e97e0ccaa72a8
dkurchigin/gb_algorythm
/lesson2/task5.py
684
4.125
4
# 5. Вывести на экран коды и символы таблицы ASCII, начиная с символа под номером 32 и заканчивая 127-м включительно. # Вывод выполнить в табличной форме: по десять пар "код-символ" в каждой строке. FIRST_SYMBOL = 32 LAST_SYMBOL = 127 letter_code = FIRST_SYMBOL result_string = '' while letter_code <= LAST_SYMBOL: ...
false
cfa20cc0ce19e7f0a0ea13a8e52ccc365814b5e5
renzon/Estrutura_Dados
/bubble.py
1,825
4.15625
4
''' ***Adicionei teste de lista ordenada e o teste de lista desordenada com vinte elementos; ***Havia dois testes com o nome def teste_lista_binaria(self), mudei um deles para def teste_lista_desordenada; >>Complexidade: O bubbleSort roda em o de n ao quadrado em tempo de execução no pior caso e o(1) em memória, Mas no...
false
687e8141335fe7d529dc850585f29ad5e50c4cbb
spacecoffin/OOPproj2
/buildDict.py
1,677
4.1875
4
# Assignment does not specify that this program should use classes. # This program is meant to be used in the __init__ method of the # "Dictionary" class in the "spellCheck" program. import re def main(): # The program buildDict should begin by asking the user for a # list of text files to read ...
true
7a7ab6085f25abdc688ab65ebe6373cdc9e05530
Anonsurfer/Simple_Word_List_Creator
/Word_List_Creator.py
835
4.28125
4
# This simple script allows you to create a wordlist and automatically saves it as .txt # if the final value of wordlist is 100 - it will create the wordlist from 0,1,2,3,4.... so on to 100. import os # Importing the Os Module keys_ = open("keys.txt",'w') # Creating a new txt file keys_range = int(input("Enter the fin...
true
7f12c500ecd0bac47473615ddf95185f7bc23993
josterpi/python
/python1.py
2,734
4.21875
4
#!/usr/bin/env python # initialized at 1, I have two actions I can do on the number # line. I can jump forward and jump backwards. # The jump forward is 2*current position + 1 # The jump back is the current position - 3 # Can you hit all of the integers? # If not, what can't you hit? What can you? Any patterns? # When...
true
a9cc2ffc28ec15381aab9e4026b05337ee8deb8e
code-guide/python
/_5_data_structure/c_dict.py
448
4.15625
4
#!/usr/bin/env python3.5 ''' 字典 ''' # 声明 name = {key: value} dic = {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5} # 修改 name[key] = value result = dic['a'] dic['a'] = 2 # dic['asdas'] 访问不存在的key会报错 # 判断key是否存在 result = 'c' in dic result = dic.get('q', 'empty return value') # 删除 del dic['b'] dic.pop('c') # del dic # ...
false
2b8a5961e68d32283401892eec11dbfade6c80d2
HarrisonHelms/helms
/randomRoll/roll2.py
350
4.25
4
from random import random R = random() sides = input("Enter the number of sides on the die: ") ''' rolled = (sides - 1) * R rolled = round(rolled) rolled += 1 ''' def roll(sides): rolled = (sides - 1) * R rolled = round(rolled) rolled += 1 return rolled num = roll(int(sides)) num = str(num) print("Y...
true
1d3b8c0502397f907e965adfd6535b58765c8c7a
shuhailshuvo/Learning-Python
/15.Date.py
727
4.1875
4
from datetime import datetime, date, time from time import sleep now = datetime.now() print("Current Datetime", now) today = date.today() print("Current Date", today) print("Current Day", today.day) print("Current Month", today.month) print("Current Year", today.year) # difference between two dates t1 = date(1971, 1...
false
e4a71284092ec0a1cc7a9e2a29eaf719e51a6ca4
denglert/python-sandbox
/corey_schafer/sorting/sort.py
2,775
4.4375
4
# - Original list lst = [9,1,8,2,7,3,6,4,5] print('Original list:\t', lst ) # - Sort list with sorted() function s_lst = sorted(lst) print('Sorted list: {0}'.format(s_lst) ) # - Sort lits Using subfunction .sort() lst.sort() print('Sorted list:\t', lst ) # - Sort list in reverse order with sorted() function s_l...
true
3dbfd602383d5791f2f5a4bcfc4c5e54b07e9ce7
denglert/python-sandbox
/corey_schafer/namedtuples/namedtuples.py
932
4.40625
4
############################ ### --- Named tuples --- ### ############################ from collections import namedtuple ### --- Tuple --- ### # Advantage: # - Immutable, can't change the values color_tuple = (55, 155, 255) print( color_tuple[0] ) ### --- Dictionaries --- ### # Disadvantage: # - Requires more ty...
true
fe7dad7782ed143451c1c48fe9b82333393a41e3
mmarotta/interactivepython-005
/guess-the-number.py
2,540
4.15625
4
import simplegui import random import math # int that the player just guessed player_guess = 0 # the number that the player is trying to guess secret_number = 0 # the maximum number in the guessing range (default 100) max_range = 100 # the number of attempt remaining (default 7) attempts_remaining = 7 # helper functi...
true
c439df82328da0dac0f03bfce15558cd274fb636
effedib/the-python-workbook-2
/Chap_01/Ex_28.py
358
4.1875
4
# Body Mass Index # Read height ed weight from user height, weight = input("Inserisci l'altezza in metri ed il peso in kg: ").split() # Convert the variables from string to float height, weight = [float(height), float(weight)] # Compute the BMI bmi = weight / (height * height) # Display the result print("Il tuo ind...
false
0fabb98b1c2a86dc202f5eecb58b9a5d3011019e
effedib/the-python-workbook-2
/Chap_06/Ex_142.py
463
4.4375
4
# Unique Characters # Determine which is the number of unique characters that composes a string. unique = dict() string = input('Enter a string to determine how many are its unique characters and to find them: ') for c in string: if c not in unique: unique[c] = 1 num_char = sum(unique.values()) print(...
true
f3a3d5e579092cfe05d7dd072336f7bb1336aafc
effedib/the-python-workbook-2
/Chap_04/Ex_87.py
536
4.28125
4
# Shipping Calculator # This function takes the number of items in an orger for an online retailer and returns the shipping charge def ShippingCharge(items: int) -> float: FIRST_ORDER = 10.95 SUBSEQ_ORDER = 2.95 ship_charge = FIRST_ORDER + (SUBSEQ_ORDER * (items - 1)) return ship_charge def main(...
true
182bf7a4858162954223f42c72bae8ff258c9ef0
effedib/the-python-workbook-2
/Chap_04/Ex_96.py
816
4.125
4
# Does a String Represent an Integer? def isInteger(string: str) -> bool: string = string.strip() string = string.replace(' ', '') if string == "": return False elif string[0] == '+' or string[0] == '-': if len(string) == 1: return False for i in string[1...
true
0050797557855d27088eed9dbf73027031d5de12
effedib/the-python-workbook-2
/Chap_01/Ex_14.py
390
4.46875
4
# Height Units # Conversion rate FOOT = 12 # 1 foot = 12 inches INCH = 2.54 # 1 inch = 2.54 centimeters # Read height in feet and inches from user feet = int(input("Height in feet: ")) inches = int(input("Add the number of inches: ")) # Compute the conversion in centimeters cm = (((feet * FOOT) + inches) *...
true
d2d56139ba9962a8faa87c358b5de4081255570e
effedib/the-python-workbook-2
/Chap_01/Ex_21.py
326
4.40625
4
# Area of a Triangle (3 sides) import math # Read the sides from user s1, s2, s3 = input("Inserisci i 3 lati: ").split() s1,s2,s3 = [float(s1), float(s2), float(s3)] # Compute the area s = (s1 + s2 + s3) / 2 area = math.sqrt(s * (s - s1) * (s - s2) * (s - s3)) # Display the result print("Area del triangolo: %.2f" %...
false
9b15b4f104947f8fd306784d22c0d4f12c574c55
effedib/the-python-workbook-2
/Chap_02/Ex_48.py
1,934
4.46875
4
# Birth Date to Astrological Sign # Convert a birth date into its zodiac sign # Read the date from user birth_month = input("Enter your month of birth: ").lower() birth_day = int(input("Enter your day of birth: ")) # Find the zodiac sign if (birth_month == 'december' and birth_day >= 22) or (birth_month == 'january'...
true
cc33896b761eba91b55e31d018a0b90fcfc46321
effedib/the-python-workbook-2
/Chap_05/Ex_113.py
504
4.28125
4
# Avoiding Duplicates # Read words from the user and display each word entered exactly once # Read the first word from the user word = input("Enter a word (blank to quit): ") # Create an empty list list_words = [] # Loop to append words into the list until blank is entered and if is not a duplicate while word != ''...
true
2acaac01a17a6d6f066b5f0a07cd1d59c8edccf1
effedib/the-python-workbook-2
/Chap_03/Ex_69.py
708
4.1875
4
# Admission Price # Compute the admission cost for a group of people according to their ages # Read the fist age first_age = input("Enter the age of the first person: ") # Set up the total total_cost = 0 age = first_age while age != "": # Cast age to int type age = int(age) # Check the cost if age ...
true
74a039d010118274d5d437cf34c016713a4cc210
effedib/the-python-workbook-2
/Chap_08/Ex_177.py
672
4.125
4
# Roman Numerals # This function converts a Roman numeral to an integer using recursion. def roman2int(roman: str) -> int: romans_table = {'M': 1000, 'D': 500, 'C': 100, 'L': 50, 'X': 10, 'I': 1} roman = roman.upper() if roman == '': return 0 if len(roman) > 1: if romans_table[rom...
false
dcbcbadbe3b33e0e50b792d7dafb00039f7ac41a
effedib/the-python-workbook-2
/Chap_08/Ex_183.py
1,706
4.21875
4
# Element Sequences # This program reads the name of an element from the user and uses a recursive function to find the longest # sequence of elements that begins with that value # @param element is the element entered by the user # @param elem_list is the list of elements to check to create the sequence # @return t...
true
95cffa4e93b281b5534b209ec831400b7c320de7
effedib/the-python-workbook-2
/Chap_04/Ex_99.py
463
4.21875
4
# Next Prime # This function finds and returns the first prime number larger than some integer, n. def nextPrime(num: int): from Ex_98 import isPrime prime_num = num + 1 while isPrime(prime_num) is False: prime_num += 1 return prime_num def main(): number = int(input("Enter a non negati...
true
4b25aa4c98e34db99f3fd8654477ce4c3a2cebad
effedib/the-python-workbook-2
/Chap_01/Ex_17.py
675
4.15625
4
# Heat Capacity # Read the mass of water and the temperature change mass_water = float(input("Inserisci la quantità d'acqua in ml: ")) temperature = float(input("Inserisci il cambio di temperatura desiderato in gradi Celsius: ")) # Define constants for heat capacity and electricity costs HEAT_CAPACITY = 4.186 ELEC_CO...
false
aaa01b2ce41701e351067b0ea953db842e7a391f
effedib/the-python-workbook-2
/Chap_03/Ex_84.py
784
4.3125
4
# Coin Flip Simulation # Flip simulated coins until either 3 consecutive faces occur, display the number of flips needed each time and the average number of flips needed from random import choices coins = ('H', 'T') counter_tot = 0 for i in range(10): prev_flip = choices(coins) print(prev_flip[0], end=" ") ...
true
ecc22e65773bcc269fbd5fcc18abff21ab301162
effedib/the-python-workbook-2
/Chap_04/Ex_95.py
734
4.1875
4
# Capitalize It # This function takes a string as its only parameter and returns a new copy of the string that has been correctly capitalized. def Capital(string: str) -> str: marks = (".", "!", "?") new_string = "" first = True for i, c in enumerate(string): if c != " " and first is True: ...
true
c0e3387fb01e402d647e3c7954a4d8ccba653f6f
effedib/the-python-workbook-2
/Chap_01/Ex_22.py
325
4.34375
4
import math s1 = float(input('Enter the length of the first side of the triangle:')) s2 = float(input('Enter the length of the second side of the triangle:')) s3 = float(input('Enter the length of the third side of the triangle:')) s = (s1+s2+s3)/2 A = math.sqrt(s*(s-s1)*(s-s2)*(s-s3)) print('The area of the triangle i...
true
d41046ceabddad69bcbf57fdf7cad495c3a2b6d0
effedib/the-python-workbook-2
/Chap_03/Ex_76.py
908
4.1875
4
# Multiple Word Palindromes # Extend the solution to EX 75 to ignore spacing, punctuation marks and treats uppercase and lowercase as equivalent # in a phrase # Make a tuple to recognize only the letters letters = ( "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", ...
true
4259b2e9d383daf2f189f50f7e40923b3354b1ae
effedib/the-python-workbook-2
/Chap_08/Ex_182.py
2,174
4.21875
4
# Spelling with Element Symbols # This function determines whether or not a word can be spelled using only element symbols. # @param word is the word to check # @param sym is the list of symbols to combine to create the word # @param result is the string to return at the end, it was initialized as empty string # @pa...
true
edbe35d0172d1c78007e551e10f97d53ac12cee4
axelniklasson/adventofcode
/2017/day4/part2.py
1,640
4.34375
4
# --- Part Two --- # For added security, yet another system policy has been put in place. Now, a valid passphrase must contain no two words that are anagrams of each other - that is, a passphrase is invalid if any word's letters can be rearranged to form any other word in the passphrase. # For example: # abcde fghij...
true
bcd5658e96365509fc455058cdb7d7a7fc7109c2
couchjd/School_Projects
/Python/EXTRA CREDIT/6PX_12.py
2,279
4.25
4
#12 Rock, Paper, Scissors Game import random import time def numberGen(): #generates a random value to be used as the computer's choice random.seed(time.localtime()) return random.randrange(1,3) def compare(compChoice, userChoice): #compares user choice vs computer choice compDict = {1:'rock', 2:'pa...
true
dee422c3e12ec0314c0e72fe187454934fd3104e
couchjd/School_Projects
/Python/EXTRA CREDIT/6PX_5.py
394
4.15625
4
#5 Kinetic Energy def kinetic_energy(mass, velocity): kEnergy = ((1/2)*mass*velocity**2) #calculates kinetic energy, given a return kEnergy #mass and velocity def main(): print("The kinetic energy is %.2f joules." % kinetic_energy(float(input("Enter mass of object: ")), ...
true
0cb19f7f08eafd81fcffed36d46a2a7ac42eda3a
MandipGurung233/Decimal-to-Binary-and-vice-versa-conversion-and-adding
/validatingData.py
2,976
4.25
4
## This file is for validating the entered number from the user. When user are asked to enter certain int number then they may enter string data type ## so if such cases are not handled then their may occur run-time error, hence this is the file to handle such error where there is four different function..:) de...
true
73ef198d2a47801f75df1a48393244febed9e85a
daneven/Python-programming-exercises
/Exersise_4.py
1,034
4.34375
4
#!/usr/bin/python3 #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ''' @Filename : Exersises @Date : 2020-10-28-20-31 @Project: Python-programming-exercises @AUTHOR : Dan Even ''' #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ''' Question 4 Level 1 Question: Write ...
true
e1bf679159088e4653f0c21ebac8311e63b6b304
daneven/Python-programming-exercises
/Exersise_5.py
1,104
4.375
4
#!/usr/bin/python3 #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ''' @Filename : Exersises @Date : 2020-10-28-20-31 @Project: Python-programming-exercises @AUTHOR : Dan Even ''' #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ''' Question 5 Level 1 Question: Define...
true
386a08d884f31869297b8579cd3e2742bfe796a7
dragomir-parvanov/VUTP-Python-Exercises
/03/2-simple-calculator.py
1,049
4.375
4
# Python Program to Make a Simple Calculator def applyOperator(number1, operator,number2): if currentOperator == "+": number1 += float(number2) elif currentOperator == "-": number1 -= float(number2) elif currentOperator == "*": number1 *= float(number2) elif currentO...
true
e937a40b941f9599bcd2ecf407d8cc03376403b4
dragomir-parvanov/VUTP-Python-Exercises
/02/8-negative-positive-or-zero.py
237
4.40625
4
# Check if a Number is Positive, Negative or 0 numberInput = int(input("Enter a number: ")) if numberInput > 0: print("Number is Positive") elif numberInput < 0: print("Number is negative") else: print("Number is 0(ZERO)")
true
79ccbbac541b5bbac6dcb0a60aba12948e5f246e
cchvuth/acss-grp-5-git-python
/mazes.py
1,862
4.125
4
# Mazes # by Yuzhi_Chen def Mazes(): print(" ") print("The width and height should be more than 5 and the height should be an odd number.") print(" ") input_str = input("Enter the width of the maze: ") w = int(input_str) input_str = input("Enter the height of the maze: ") h = ...
false
88ff525e751b4e21af01de0d2aa9cc52d988ed40
da1dude/Python
/OddOrEven.py
301
4.28125
4
num1 = int(input('Please enter a number: ')) #only allows intigers for input: int() check = num1 % 2 # Mudelo % checks if there is a remainder based on the number dividing it. In this case 2 to check if even or odd if check == 0: print('The number is even!') else: print('The number is odd!')
true
b9bd153886194726840fa940231afed161399585
andrew5205/Python_cheatsheet
/string_formatting.py
712
4.15625
4
name = "Doe" print("my name is John %s !" %name) age = 23 print("my name is %s, and I am %d years old" %(name, age)) data = ["Jonh", "Doe", 23] format_string = "Hello {} {}. Your are now {} years old" print(format_string.format(data[0], data[1], data[2])) # tuple is a collection of objects which ordered and i...
true
5113d129124225dba7c10a0b4cde1016f6ea8af6
krenevych/programming
/P_08/ex_2.py
488
4.28125
4
""" Приклад 8.2. За допомогою розкладу функції e^x в ряд Тейлора """ # Описуємо функцію exp def exp(x, eps = 0.0001): S = a = 1 n = 0 while abs(a) >= eps: n += 1 a *= x / float(n) S += a return S # головна програма x = float(input("x = ")) y = exp(x) # використовуємо типове з...
false
0edbe19fc1c3b187309f943ad7c1c1c18383c733
ersmindia/accion-sf-qe
/workshop_ex1.py
697
4.25
4
'''Exercise 1: A) Create a program that asks the user to enter their name and their age. Print out a message that tells them the year that they will turn 50 and 100 years old. B)Add on to the previous program by asking the user for another number and printing out that many copies of the previous message. ''' from date...
true
d08c53ba5fe5c06c84b199b253554cfb6cecdc80
standrewscollege2018/2019-year-13-classwork-ostory5098
/Object orientation Oscar.py
1,608
4.6875
5
# This is an intro to Object orientation class Enemy: """ This class contains all the enemies that we will fight. It has attributes for life and name, as well as functions that decrease its health and check its life. """ def __init__(self, name, life): """ the init function runs automat...
true
a3d457ff813c70b7e43e6903222308eaae6ff7ae
FreeTymeKiyan/DAA
/ClosestPair/ClosestPair.py
2,642
4.4375
4
# python # implement a divide and conquer closest pair algorithm # 1. check read and parse .txt file # 2. use the parsed result as the input # 3. find the closest pair in these input points # 4. output the closest pair and the distance between the pair # output format # The closest pair is (x1, x2) and (y1, y2). # The ...
true
7e5f9155c0e22abb671c826d940da51c3ba46294
danmaher067/week4
/LinearRegression.py
985
4.1875
4
# manual function to predict the y or f(x) value power of the input value speed of a wind turbine. # Import linear_model from sklearn. import matplotlib.pyplot as plt import numpy as np # Let's use pandas to read a csv file and organise our data. import pandas as pd import sklearn.linear_model as lm # read the datase...
true
80b6dfde38ee834f6ef0ef55b558b36e33b77faa
Gopi30k/DataStructures_and_Algorithms_in_Python
/04_Sorting_Algorithms/03_Insertion_sort.py
562
4.125
4
def insertion_sort(arr: list): # O(N)in best case O(N2) in worst case for i in range(1, len(arr)): currentVal = arr[i] j = i-1 while j >= 0 and currentVal < arr[j]: arr[j+1] = arr[j] j -= 1 arr[j+1] = currentVal return arr if __name__ == '__main__': ...
false
eb7045f3d5b9f3a02d7b3fc26f90bf795a5ebfbf
Gopi30k/DataStructures_and_Algorithms_in_Python
/02_RecursionProblems/01_powerOfNumber.py
480
4.15625
4
def naivePower(base: int, exponent: int): power = 1 for _ in range(0, exponent): power = power*base return power def recursivePower(base: int, exponent: int): if exponent == 0: return 1 return base * recursivePower(base, exponent-1) if __name__ == "__main__": print(naivePower...
false
56635b0819e7cdbc8b96ec68bb4de313ca0da587
Woobs8/data_structures_and_algorithms
/Python/Sorting/bubble_sort.py
2,850
4.1875
4
import argparse import timeit from functools import partial import random from sorting import BaseSort class BubbleSort(BaseSort): """ A class used to encapsulate the Bubble Sort algorithm Attributes ---------- - Methods ------- sort(arr, in_place=False) Sorts an array using ...
true
2e6ebd01b1e1e5b508501d5a2536d5b85883af23
lbray/Python-3-Examples
/file-analyzer.py
370
4.28125
4
# Program returns the number of times a user-specified character # appears in a user-specified file def char_count(text, char): count = 0 for c in text: if c == char: count += 1 return count filename = input("Enter file name: ") charname = input ("Enter character to analyze: ") with open(filename) as f: da...
true
f66bdd92134a81252316b519e4f92b0b950a025a
SingleHe/LearningPython
/condition.py
1,104
4.3125
4
# age = 20 # if age >= 18: # print("your age is ",age) # print("adult") # age = 3 # if age >= 18: # print("your age is",age) # print("adult") # else: # print("your age is",age) # print("teanager") # age_str = input("请输入您的年龄:") # age = int(age_str) # if age >= 18: # print("adult") # elif age >=6: # print("teen...
false
281085709d44facc168cbb6324aa7429bc36f9ce
macoopman/Python_DataStructures_Algorithms
/Recursion/Projects/find.py
1,934
4.15625
4
""" Implement a recrsive function with the signature find(path, name) that reports all entries of the file system rooted at the given path having the given file name """ import os, sys def find(path, name): """ find and return list of all matches in the given path """ found = [] ...
true
83046855b03c830defd9e840123d8a6abe0d44f5
macoopman/Python_DataStructures_Algorithms
/Recursion/Examples/Linear_Recursion/recursive_binary_search.py
968
4.25
4
""" Recursive Binary Search: locate a target value within a "sorted" sequence of n elements Three Cases: - target == data[mid] - found - target < data[mid] - recur the first half of the sequence - target > data[mid] - recur the last half of the sequence Runtime => O(log n) """ def binary_search(data, targ...
true
a1176c834491e81013d6bc3bb6a4a341c99bf954
fucking-algorithm/algo-py
/algo/two_sum.py
1,429
4.15625
4
"""两数之和""" def two_sum_double_pointer(sorted_nums: tuple, target: int) -> tuple: """ 返回两个下标, 元素和为 target 对于有序的数组, 首选双指针 """ left = 0 right = len(sorted_nums) - 1 while left < right: left_plus_right = sorted_nums[left] + sorted_nums[right] if left_plus_right == target: ...
false
008317fe6ca28ef600fc024c049a39c6bf7db163
myszunimpossibru/shapes
/rectangles.py
1,843
4.25
4
# coding: utf8 from shape import Shape import pygame class Rectangle(Shape): """ Class for creating the rectangular shape Parameters: pos: tuple Tuple of form (x, y) describing the position of the rectangle on the screen. Reminder: PyGame sets point (0, 0) as the upper lef...
true
13567cd51d5b39eb0f2229961789ede446516033
qqmy/python_study
/python_test/test_savefurnishings.py
1,503
4.1875
4
''' 需求 1、房子有户型,总面积和家具名称列表 新房子没有任何的家具 2、家具有名字和占地面积,其中 席梦思占地4平米 衣柜占地2平米 餐桌占地1.5平米 3、将以上三件家具添加到房中 1、打印房子是,要求输出:户型,总面积,剩余面积,家具名称列表 剩余面积 1、在创建房子对象是,定义一个剩余面积的属性,初始值和总面积相等 1、当调用add_item方法的时候,想房间添加家具是,让剩余面积>=家具面积类 属性:house_type,house_area,item_list,free_area 方法:_init_, _str_,add_item 类:houseItem 属性:name,area 方法:_init_ ''' # ...
false
fe0d6c09f4eacfc2d14944e9a7661ad7d1658a3a
rufi91/sw800-Coursework
/ML-14/ex.py
1,442
4.21875
4
""" 1) Implement MLPClassifier for iris dataset in sklearn. a. Print confusion matrix for different activation functions b. Study the reduction in loss based on the number of iterations. 2) Implement MLPRegressor for boston dataset in sklearn . Print performance metrics like RMSE, MAE , etc. """ from sklearn.neural_ne...
true
6049135043f6aa6b446c2856ee89cee66e7f706f
rufi91/sw800-Coursework
/Python/py-24/ex.py
2,164
4.375
4
""" Open python interpreter/ipython and do the following. 0.import pandas 1.create a dataframe object from a (10,4)2D array consisting of random integers between 10 and 20 by making c1,c2,c3,c4 as column indices. 2.Sort the above oject based on the key 'c1' in ascending and then by 'c3' in descending order. """...
true
2310417c508e94b2e2d1709f5a884c80bace0e5b
yveslym/cs-diagnostic-yves-songolo
/fuzzbuzz1.py
943
4.1875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Sep 9 12:33:02 2017 @author: yveslym """ #problem 5 An algorithm is a way to solve a problem with simple solution #problem 6 #pseudocode: #start: function to check weither the first # is divisible by 5 or 3 # end: function to check weither the l...
false
e7b8ac86e23d9ddd1a03dba8f75789e4b3288b57
nshoa99/Leetcode
/List/1324.py
1,268
4.1875
4
''' Medium Given a string s. Return all the words vertically in the same order in which they appear in s. Words are returned as a list of strings, complete with spaces when is necessary. (Trailing spaces are not allowed). Each word would be put on only one column and that in one column there will be only one word. ...
true
076ac8dcc7af8424b0e1b5fb4da98a8b9a9478c3
nshoa99/Leetcode
/String/524.py
1,338
4.1875
4
''' Given a string and a string dictionary, find the longest string in the dictionary that can be formed by deleting some characters of the given string. If there are more than one possible results, return the longest word with the smallest lexicographical order. If there is no possible result, return the empty string....
true
ee64bbec7eee7449b7d526f5147d749b07942740
haroldhyun/Algorithm
/Sorting/Mergesort.py
1,998
4.3125
4
# -*- coding: utf-8 -*- """ Created on Tue Sep 7 20:04:26 2021 @author: Harold """ def Mergesort(number): """ Parameters ---------- number : list or array of numbers to be sorted Returns ------- sorted list or array of number """ # First divide the...
true
a985d1439e1f07522b6d141260b8e299278e045b
Kritika05802/DataStructures
/area of circle.py
235
4.21875
4
#!/usr/bin/env python # coding: utf-8 # In[3]: radius = float(input("Enter the radius of the circle: ")) area = 3.14 * (radius) * (radius) print("The area of the circle with radius "+ str(radius) +" is " + str(area)) # In[ ]:
true
f066e25dd7044e0a2e7fb37a9f0729e6190c38e7
prd-dahal/sem4_lab_work
/toc/lab7.py
684
4.5625
5
#Write a program for DFA that accepts all the string ending with 3 a's over {a,b}\#Write a program for DFA that accepts the strings over (a,b) having even number of a's and b's def q0(x): if(x=='a'): return q1 else: return q0 def q1(x): if(x=='a'): return q2 else: return q0 d...
true
0b7c2b351c39fa1b718a156eb41ffc9e19b9382e
felixguerrero12/operationPython
/learnPython/ex12_Prompting_asking.py
397
4.1875
4
# -*- coding: utf-8 -*- # Created on July 27th # Felix Guerrero # Exercise 12 - Prompting - Learn python the hard way. #Creating Variables with Direct Raw_Input age = raw_input("How old are you? \n") height = raw_input("How tall are you? \n") weight = raw_input("How much do you weight? \n") # Print Variables print "...
true
3a069734693a40536828bdaf82eb3db7188d5e2e
felixguerrero12/operationPython
/learnPython/ex03_Numbers_And_Variable_01.py
703
4.34375
4
# Created on July 26th # Felix Guerrero # Exercise 3 - Numbers and math - Learn python the hard way. #Counting the chickens print "I will now count my chickens:" print "Hens", 25 + 30 / 6 print "Roosters", 100 - 25 * 3 % 4 #Counting the eggs print "Now I will count the eggs:" print 3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6 ...
true
840747d89d7f2d84c7b819b5d26aa4ac1ea93254
felixguerrero12/operationPython
/learnPython/ex15_Reading_Files.py
739
4.25
4
# Felix Guerrero # Example 15 - Reading Files # June 28th, 2016 # Import the sys package and import the arguement module from sys import argv # The first two command line arguements in the variable will be # these variables script, filename = argv # 1. Open up variable filename # 2. Give the content of the file to t...
true
451700ee74f47681206b30f81e7c61b80c798f8c
ChiefTripodBear/PythonCourse
/Section7/utils/database.py
1,803
4.1875
4
import sqlite3 """ Concerned with storing and retrieving books from a list. Format of the csv file: [ { 'name': 'Clean Code', 'author': 'Robert', 'read': True } ] """ def create_book_table(): connection = sqlite3.connect('Section7/da...
true
625707a1917c8f1e91e3fd9f2ee4a51102f27af5
golddiamonds/LinkedList
/LinkedList.py
2,790
4.28125
4
##simple linked list and node class written in python #create the "Node" structure class Node: def __init__(self, data, next_node=None): self.data = data self.next_node = next_node def getData(self): return self.data #create the structure to hold information about the list #including ...
true
34518198d4445856607dd480a3e81e492508bedd
olegborzov/otus_algo_1218
/hw3/eratosfen.py
2,131
4.15625
4
""" Алгоритм решета Эратосфена с улучшениями: - Битовые операции - каждый элемент массива представляет собой true/false для определенного числа. Используя этот алгоритм можно уменьшить потребности в памяти в 8 раз. - Откидываются четные числа - Сегментация - вычисления выполняются блоками определенного размера. ""...
false
3d289735bca17f15a1e100fdaa01b4a86b871a25
emuyuu/design_pattern
/3_behavioral_design_patterns/iterator_pattern.py
1,704
4.59375
5
# iterate = 繰り返す # Iterator: # > Anything that is iterable can be iterated, # > including dictionaries, lists, tuples, strings, streams, generators, and classes # > for which you implement iterator syntax. # 引用:http://ginstrom.com/scribbles/2007/10/08/design-patterns-python-style/ # ----------------------------------...
true
99a214e31f4f1251f04f6f66fb4c96ef57049873
crashley1992/Alarm-Clock
/alarm.py
2,189
4.28125
4
import time from datetime import datetime import winsound # gets current time result = time.localtime() # setting varable for hour, minute, seconds so it can be added to user input current_hour = result.tm_hour current_min = result.tm_min current_sec = result.tm_sec # test to make sure format is correct print(f'{cur...
true
23983cbb84f1b375a5c668fb0cb9f75aef9a67e9
steve-thousand/advent_of_code_2018
/5.py
1,076
4.125
4
input = "OoibdgGDEesYySsSMmlLIKkkVvKvViERxXVvrfmMsSFeaAvnNVdMmJjDBmMXbBJjWwPZzpHhLlCsSfFpPcKVvxlLXbBkxUIJjfFoOigEeGHhdDJjdDAazTtrRCotTFfOoOcZPDejJEdpTzsSYzZMmyMmZtshHJzZkKYyJjnAaNjpflLFPUuNndnPpNxAiIMbBCcgLlGPrRpmaHnNhXDoOzZxXUdjJWwilLIDutWwTjwMmWcCJvVxXthHfFkKdDWwmMHjbBKkRrXxlLJhOoTYytKZzrGvVgabbBBjJpPAKMmsSktwWfFTWoO...
false
cf823ebcf1c564bef2ed6103588b2ff8ed1e86da
donrax/point-manipulation
/point_side_line.py
623
4.34375
4
import numpy as np def point_side_line(p1, p2, p): """ Computes on which side of the line the point lies. :param p1: [numpy ndarray] start of line segment :param p2: [numpy ndarray] end of line segment :param p: [numpy ndarray] point :return: 1 = LEFT side, 0 = ON the line, -1 = RIGHT side ...
true
84d6ee056bb099be066eaad41b5db90c95fa5936
tomasroy2015/pythoncrash-study
/fibonacci.py
297
4.25
4
def fibonacci(n): if(n <= 1): return n else: return fibonacci(n-1)+fibonacci(n-2) nterms = int(input("How many terms? ")) if(nterms < 0): print("Enter valid input") else: print("Print fibonacci sequence:") for i in range(nterms): print(fibonacci(i))
false
e562b59876199bf03b6aa533afe98f5f8d385fd5
Meethlaksh/Python
/again.py
1,899
4.1875
4
#Write a python function to find the max of three numbers. def m1(l): d = max(l) return d l = [1,2,3,4,5] print(m1(l)) #Write a python function to sum up all the items in a list def s1(s): e = sum(s) return e s = [1,2,3,4,5] print(s1(s)) #multiply all the items in a list import math def mul1(x): ...
true
baff5161fd319ce26fd9d5de0e68078885b9983e
Meethlaksh/Python
/studentclass.py
985
4.125
4
"""Create a Student class and initialize it with name and roll number. Make methods to : 1. Display - It should display all informations of the student. 2. setAge - It should assign age to student 3. setMarks - It should assign marks to the student. """ """ keywords: parameter methods difference between functions and m...
true
d20c3b7e09d7a003f03bbd45ab38f9ac06aa9ff5
roque-brito/ICC-USP-Coursera
/icc_pt2/week1/cria_matriz_aula/cria_matriz_elemento_unico.py
847
4.25
4
def cria_matriz(num_linhas, num_colunas, valor): ''' (int, int, valor) -> matriz(lista de listas) Cria e retorna uma matriz com num_linhas linhas e num_colunas colunas em que cada elemento é igual ao valor dado (valores iguais) ''' # Criar uma lista vazia: matriz = [] for i in...
false
d9be0d047ffd5a0664d47e49e8fe96f0d6c20823
Mehedi-Hasan-NSL/Python
/fibonacci_hr.py
977
4.34375
4
# -*- coding: utf-8 -*- """ Created on Thu Jul 8 17:06:09 2021 @author: DELL """ #!/bin/python3 import math import os import random import re import sys # # Complete the 'fibonacciModified' function below. # # The function is expected to return an INTEGER. # The function accepts following parame...
false
51fe7b41819c567a3814c24263a5b6e47131d5e8
AlexandrKhabarov/csc_python
/5 lection/tuple.py
658
4.21875
4
person = ('George', "Carlin", "May", 12, 1937) LAST_NAME = 1 BIRTHDAY = slice(2, None) print(f"Last name: {person[LAST_NAME]}") print(f"Birthday: {person[BIRTHDAY]}") # Part 2 from collections import namedtuple Person = namedtuple('Person', ['first_name', 'last_name', 'age']) p = Person('Terrence', 'Gilliam', 7...
false
58a96988ee925d1c65148817e500a3dee2e0216d
kylastyles/Python1000-Practice-Activities
/PR1000_03/PR03_HexReaderWriter.py
970
4.40625
4
#!usr/bin/env python3 # Problem Domain: Integral Conversion # Mission Summary: Convert String / Integral Formats user_string = input("Please enter a string to encode in hexadecimal notation: ") def hex_writer(user_string): hex_string = "" if user_string == "": return None for char in user_stri...
true
2e8fb160337f084912b9ed384f11891ab01fe63e
AwjTay/Python-book-practice
/ex4.py
1,207
4.25
4
# define the variable cars cars = 100 # define the variable space_in_a_car space_in_a_car = 4.0 # define the variable drivers drivers = 30 # define the variable passengers passengers = 90 # define the variable cars_not_driven cars_not_driven = cars - drivers # define the variable cars_driven as equal to drivers ca...
true
f04ebf307b78d87f0579d1b5d10e8781b761ff7e
menghaoshen/python
/11.面向对象/20.面向对象相关的方法.py
755
4.125
4
class Person(object): def __init__(self,name,age): self.name = name self.age = age class X(object): pass class Student(Person,X): pass p1 = Person('张三',18) p2 = Person('张三',18) s = Student('jack',19) print(p1 is p2) #is 身份运算符是用来比较是否是同一个对象 print(type(s) == Student) #True print(type(s) == ...
false
9110d37b4f6c4b7e75bba20fe41bdf7ea71904d2
menghaoshen/python
/03-进制转换,数据类型详解、类型转换、预算符/15.逻辑运算的短路.py
752
4.1875
4
#逻辑与运算,只有所有的运算符都是True,结果才是True #只有有一个运算数是False,结果就是False 4 > 3 and print('hello') 4 < 3 and print('您好世界') #逻辑或运算,只有所有的运算符都是False,结果测试False #只要有一个运算符是True,结果就是True 4 > 3 or print('哈哈哈') 4 < 3 or print('嘿嘿') #短路: 只要遇到False,就停止了,不在继续执行了 #逻辑运算的结果,不一定是布尔值 #逻辑与运算取值时,取得是第一个为False的值,如果所有的运算数都是True,取最后一个 print(3 and 5 and 0 a...
false
72cb7e9d73041025ecd0e17490fb4cf1dcf1b508
jw0711qt/Lab4camelcase
/Lab4_camelCase.py
641
4.3125
4
def camel_case(sentence): if sentence.isnumeric(): #if statment handling empty and numeric number return 'enter only words' elif sentence=="": return 'please enter your input' else: split_sentence=sentence.split() #for loop handling the camel case. cap_sentence=[split_senten...
true
6c272fbdedd87251c8d4033b649aa1bcd56093c8
tmflleowow/Python
/16_字串|迭代運算(Iteration).py
346
4.53125
5
#迭代運算 #用for 理由:簡單 ''' for c in "abcdefg": print(c, end = " ") ''' #用iter() 理由:可自定迭代順序 iterator = iter("abcdefg") # ==> ['a' , ''b' , 'c', ... , 'g'] for i in iterator: print(i) #用enumerate() 理由:有索引值與內容 iterator = enumerate("abcdefg") for i , j in iterator: print(i , j)
false
2f5eeabbad6d9f7cc4a53e85da174af7ab891002
tushushu/pads
/pads/sort/select_sort.py
1,315
4.21875
4
# -*- coding: utf-8 -*- """ @Author: tushushu @Date: 2018-09-10 22:23:11 @Last Modified by: tushushu @Last Modified time: 2018-09-10 22:23:11 """ def _select_sort_asc(nums): """Ascending select sort. Arguments: nums {list} -- 1d list with int or float. Returns: list -- List in ascendin...
true
7fd24f06f3e47581d35635e1767bc230da26b20b
NortheastState/CITC1301
/chapter10/Course1301.py
1,507
4.1875
4
# =============================================================== # # Name: David Blair # Date: 04/14/2018 # Course: CITC 1301 # Section: A70 # Description: You can think of this Python file as a "driver" # that tests the Student class. It can also be # thought of as a...
true
475cee6f9b8424e9028087a90c96fc1c6c69a2e8
NortheastState/CITC1301
/chapter1/foobar.py
964
4.21875
4
# =============================================================== # # Name: David Blair # Date: 01/01/2018 # Course: CITC 1301 # Section: A70 # Description: In the program we will examine simple output # using a function definition with no parameters # and a print statem...
true
9bc5bf07fbc4a04940394c23bfd0d0116422749e
sahilg50/Python_DSA
/Array/reverse_array.py
782
4.3125
4
#Function to reverse the array def reverse(array): if(len(array)==0): return ("The array is empty!") L = 0 R = len(array)-1 while(L!=R and L<R): array[R], array[L] = array[L], array[R] L+=1 R-=1 return array #Ma...
true
8a962ec652a3d239af3a3b860cf7663ab173c070
sahilg50/Python_DSA
/Array/Max_Min_in_Array.py
1,463
4.28125
4
# Find the maximum and minimum element in an array def get_min_max(low, high, array): """ (Tournament Method) Recursive method to get min max. Divide the array into two parts and compare the maximums and minimums of the two parts to get the maximum and the minimum of the whole array. """ # If arr...
true
7b62197a3a0395b563b62d68bc34066d8fa2643f
Libbybacon/Python_Projects
/myDB.db.py
1,068
4.125
4
# This script creates a new database and adds certain files from a given list into it. import sqlite3 conn = sqlite3.connect('filesDB.db') fileList = ('information.docx','Hello.txt','myImage.png', \ 'myMovie.mpg','World.txt','data.pdf','myPhoto.jpg') # Create a new table with two fields in filesDB datab...
true
8f1507a5140d329d2234f13fe0987291a7ff4df5
Libbybacon/Python_Projects
/buildingClass2.py
2,665
4.25
4
# Parent class Building class Building: # Define attributes: numberSides = 4 numberLevels = 1 architectureType = 'unknown' primaryUse = 'unknown' energyEfficient = True def getBuildingDetails(self): numberSides = input("How many sides does the building have?\n>>> ") number...
true
3f2884d5da68f9fc7f684e63ed5a8a2144f0f39f
agrepravin/algorithms
/Sorting/MergeSort.py
1,193
4.15625
4
# Merge sort follows divide-conquer method to achieve sorting # As it divides array into half until one item is left these is done in O(log n) time complexity # While merging it linear compare items and merge in order which is achieved in O(n) time complexity # Total time complexity for MergeSort is O(n log n) in all t...
true
612e527762f60567874da66187cdaecf1063874e
khch1997/hw-python
/timing.py
462
4.125
4
import time def calculate_time(func): """ Calculate and print the time to run a function in seconds. Parameters ---------- func : function The function to run Examples -------- def func(): time.sleep(2) >>> calculate_time(func) 2.0001738937 """ def wra...
true
6c0d5375fda176642668a007e65f8ae9f4c21e4a
josgard94/CaesarCipher
/CesarEncryption.py
1,915
4.53125
5
""" Author: Edgard Diaz Date: 18th March 2020 In this class, the methods of encrypting and decrypting the plain text file using modular arithmetic are implemented to move the original message n times and thus make it unreadable in the case of encryption, the same process is performed for decryption usi...
true
f9b109cc9d356431ae79bf53b635889cd56465f3
Kertich/Linked-List
/linkedList.py
777
4.15625
4
# Node class class Node: def __init__(self, value): self.value = value self.next = None class LinkedList: def __init__(self): self.start = None # Inserting in the Linked List def insert(self, value): if self.start == None: self.start = Node(value) ...
true
47321ae0df841cdc0c790d1692b65d9411aa8f7d
Croxy/The-Modern-Python-Bootcamp
/Section 10: Loops/examples/whileExample1.py
332
4.28125
4
# Use a while loop to check user input matches a specific value. msg = input("what is the secret password?") while msg != "bananas": print("WRONG!") msg = input("what is the secret password?") print("CORRECT!") # Use a while loop to create for loop functionality. num = 1 while num < 11: print(num) n...
true
ba30a449793ff270e61284e1d4598629647f5681
pradeepraja2097/Python
/python basic programs/arguments.py
543
4.1875
4
''' create a function for adding two variables. It will be needed to calculate p=y+z ''' def calculateP( y , z ) : return int( y ) + int( z ) ''' create a function for multiplying two variables. It will be needed to calculate p=y+z ''' def calculateResult( x, p ) : return int( x ) * int( p ) #Now this...
true
23f95e08d2678366d97400ade96b85453ce265e5
EdwinaWilliams/MachineLearningCourseScripts
/Python/Dice Game.py
484
4.28125
4
# -*- coding: utf-8 -*- """ Created on Thu Jan 10 22:18:01 2019 @author: edwinaw """ import random #variable declaration min = 1 max = 6 roll = "yes" while roll == "yes" or roll == "y": print("Rolling the dices...") dice = random.randint(min, max) #Printing the random number generated print("Yo...
true
69237dabe784446234868c8f59c6e1b0173c8df5
hfu3/codingbat
/logic-1/date_fashion.py
719
4.28125
4
""" You and your date are trying to get a table at a restaurant. The parameter "you" is the stylishness of your clothes, in the range 0..10, and "date" is the stylishness of your date's clothes. The result getting the table is encoded as an int value with 0=no, 1=maybe, 2=yes. If either of you is very styli...
true