blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
77f5fe9c0172c1eecc723b682a3d2c82eda2918d
charliepoker/pythonJourney
/lists.py
2,340
4.40625
4
#list is a value that contains multiple values in an ordered sequence. number = [23, 67, 2, 5, 69, 30] #list of values assigned to number name = ['mike', 'jake', 'charlie', 'tim', 'dave', 'jane'] #list of values assigned to name print(name[2] + ' is ' + str(number[5]) + ' years old.') #lis...
true
0211c3fa0ff36391c2394f1ea8973d07d4555c87
bodawalan/HackerRank-python-solution
/cdk.py
2,845
4.3125
4
# Q.1 # # Write a function that takes as input a minimum and maximum integer and returns # all multiples of 3 between those integers. For instance, if min=0 and max=9, # the program should return (0, 3, 6, 9) # # A # you can type here def func(min, max): for in xrange(min, max): if (i % 3 == 0) ...
true
07969f835c57729793df401fc7e367e4e6d399a6
dodieboy/Np_class
/PROG1_python/coursemology/Mission32-CaesarCipher.py
1,288
4.71875
5
#Programming I #################################### # Mission 3.2 # # Caesar Cipher # #################################### #Background #========== #The encryption of a plaintext by Caesar Cipher is: #En(Mi) = (Mi + n) mod 26 #Write a Python program that prompts user to enter ...
true
03396cc7b38b7a779ca33d376a6ccb33720289b0
dodieboy/Np_class
/PROG1_python/coursemology/Mission72-Matrix.py
1,081
4.25
4
#Programming I ####################### # Mission 7.1 # # MartrixMultiply # ####################### #Background #========== #Tom has studied about creating 3D games and wanted #to write a function to multiply 2 matrices. #Define a function MaxtrixMulti() function with 2 parameters. #Both parameters are in ...
true
c3ba57ea7ad83b5819851bafb7e88d62cd267c8d
jason-neal/Euler
/Completed Problems/Problem 5-smallest_multiple.py
641
4.15625
4
"""Smallest multiple Problem 5 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20? """ import numpy as np def smallest_multiple(n): """Smallest multiple of numbe...
true
cbc97978dbafa655d385b6741d6c046cb648cff4
stevalang/Coding-Lessons
/SoftUni/Python Developmen/Python-Basics/4_Conditional_Statements/fruit_or_vegitable.py
386
4.34375
4
product_name = input() if product_name == 'banana' or product_name == 'apple' or product_name == 'kiwi' or product_name == 'cherry' or \ product_name == 'lemon' or product_name == 'grapes': print('fruit') elif product_name == 'tomato' or product_name == 'cucumber' or product_name == 'pepper' or product_nam...
true
0569f8f4243c3694a236fd8daf00171893d8666c
stevalang/Coding-Lessons
/SoftUni/Python Developmen/Python-Fundamentals/03_Basic_Syntax_Conditions_Loops/maximum_multiple.py
397
4.1875
4
''' Given a Divisor and a Bound, find the largest integer N, such that: N is divisible by divisor N is less than or equal to bound N is greater than 0. Notes: The divisor and bound are only positive values. It's guaranteed that a divisor is found ''' divisor = int(input()) bound = int(input()) max_num = 0 for i in ra...
true
5b3145219fbf8802f747d84079e0c4ca2099a4a8
stevalang/Coding-Lessons
/SoftUni/Python Developmen/Python-Basics/4_Conditional_Statements/number_100_200.py
587
4.15625
4
""" Conditional Statements - Lab Check: https://judge.softuni.bg/Contests/Practice/Index/1012#0 06. Number 100 ... 200 Condition: Write a program that reads an integer entered by the user and checks if it is below 100, between 100 and 200 or over 200. Print messages accordingly, as in the examples below: Sample input a...
true
fc8c286f691360c9b96b4c91fa3fabeccade2aac
stevalang/Coding-Lessons
/SoftUni/Python Developmen/Python-Fundamentals/04_Lists/bread_factory.py
2,805
4.3125
4
""" As a young baker, you are baking the bread out of the bakery. You have initial energy 100 and initial coins 100. You will be given a string, representing the working day events. Each event is separated with '|' (vertical bar): "event1|event2|event3…" Each event contains event name or item and a number, separated b...
true
b4bb635ae844e30f8fd58d64eeab5adda17726b2
stevalang/Coding-Lessons
/SoftUni/Python Developmen/Python-Fundamentals/04_Lists/04.Search.py
1,153
4.3125
4
""" Lists Basics - Lab Check your code: https://judge.softuni.bg/Contests/Practice/Index/1724#3 SUPyF2 Lists Basics Lab - 04. Search Problem: You will receive a number n and a word. On the next n lines you will be given some strings. You have to add them in a list and print them. After that you have to filter out only ...
true
5fc56d9d02475b497d20988fbe8a244faec680e9
stevalang/Coding-Lessons
/SoftUni/Python Developmen/Python-Basics/2_simple_calculations/Projects_Creation.py
762
4.3125
4
""" Simple Operations and Calculations - Lab 05. Creation Projects Check: https://judge.softuni.bg/Contests/Compete/Index/1011#2 Write a program that calculates how many hours it will take an architect to design several construction sites. The preparation of a project takes approximately three hours. Entrance 2 lines a...
true
b0e20c859c4c65478d955ee75ec04bbf2c0a370a
stevalang/Coding-Lessons
/SoftUni/Python Developmen/Python-Fundamentals/04_Lists/number_filter.py
1,173
4.1875
4
""" Lists Basics - Lab Check your code: https://judge.softuni.bg/Contests/Practice/Index/1724#4 SUPyF2 Lists Basics Lab - 05. Numbers Filter Problem: You will receive a single number n. On the next n lines you will receive integers. After that you will be given one of the following commands: • even • odd • negative • p...
true
eec96339c928ff8c2148957172c237c2cb015a2f
stevalang/Coding-Lessons
/SoftUni/Python Developmen/Python-Basics/2_simple_calculations/Fish_Tank.py
582
4.1875
4
# 1. Read input data and convert data types lenght = int(input()) width = int(input()) height = int(input()) percent_stuff = float(input()) # 2. Calculating aquarium volume acquarium_volume = lenght * width * height #3. Convert volume (cm3) -> liters volume_liters= acquarium_volume * 0.001 #4. Calculating litter tak...
true
73ca29ffb697d7e08b72cbc825a7a7672d989dd4
happyandy2017/LeetCode
/Rotate Array.py
2,287
4.1875
4
# Rotate Array # Go to Discuss # Given an array, rotate the array to the right by k steps, where k is non-negative. # Example 1: # Input: [1,2,3,4,5,6,7] and k = 3 # Output: [5,6,7,1,2,3,4] # Explanation: # rotate 1 steps to the right: [7,1,2,3,4,5,6] # rotate 2 steps to the right: [6,7,1,2,3,4,5] # rotate 3 steps ...
true
ab4b0424777999fbe22abb732279e9f3de3efeb3
happyandy2017/LeetCode
/Target Sum.py
2,048
4.125
4
''' Target Sum Go to Discuss You are given a list of non-negative integers, a1, a2, ..., an, and a target, S. Now you have 2 symbols + and -. For each integer, you should choose one from + and - as its new symbol. Find out how many ways to assign symbols to make sum of integers equal to target S. Example 1: Input: ...
true
1e458d8bbd986b4b838f784b15ed9f6aaf5eccfc
mblue9/melb
/factorial.py
928
4.1875
4
import doctest def factorial(n): '''Given a number returns it's factorial e.g. factorial of 5 is 5*4*3*2*1 >>> factorial(0) 1 >>> factorial(1) 1 >>> factorial(3) 6 ''' if not type(n) == int: raise Exception("Input to factorial() function must be an integer") if n <...
true
a000ab576b9eefeb3be6565177102dea660a1b74
TrafalgarSX/graduation_thesis_picture-
/lineChart.py
678
4.4375
4
import matplotlib.pyplot as pyplot # x axis values x = [1,2,3,4,5,6] # corresponding y axis values y = [2,4,1,5,2,6] # plotting the points pyplot.plot(x, y, color='green',linestyle='dashed', linewidth=3, marker='*',markerfacecolor='blue',markersize=12, label = "line 1") x1 = [1,2,3] y1 = [4,1,3] # plotting the line ...
true
992e6ee0179e66863f052dce347c35e0d09b9138
rowaxl/WAMD102
/assignment/0525/factorial.py
316
4.25
4
def fact(number): if number == 0: return 1 if number == 1 or number == -1: return number if number > 0: nextNum = number - 1 else: nextNum = number + 1 return number * fact(nextNum) number = int(input("Enter a number for calculate factorial: ")) print(f"{number}! = ", fact(number))
true
4b52d601646ac88a58de8e75d09481e65d758fa5
seriousbee/ProgrammingCoursework
/src/main.py
2,452
4.125
4
def print_welcome_message(): print('Welcome to Split-it') def print_menu_options(): menu_dict = {'About\t\t': '(A)', 'CreateProject\t': '(C)', 'Enter Votes\t': '(V)', 'Show Project\t': '(S)', 'Quit\t\t': '(Q)'} for k, v in menu_dict.items(): print(f'{k} {v}') # not 100% w...
true
be4579851af7ea20e3ed8cfeeeb0e493426273c4
mayankkuthar/GCI2018_Practice_1
/name.py
239
4.28125
4
y = str(input(" Name ")) print("Hello {}, please to meet you!".format(y)) def reverse(s): str = "" for i in s: str = i + str return str s = y print ("Did you know that your name backwards is {}?".format(reverse(s)))
true
72bbfab5a298cda46d02758aae824188c0703f8c
josan5193/CyberSecurityCapstone
/CapstoneMain.py
859
4.1875
4
def main(): while True: Test1Word = input("What's your name?: ") try: Test1Num = int(input("Please choose one of three presidential candidates: \n 1. Donald Trump \n 2. Joe Biden \n 3. Bernie Sanders \n")) if Test1Num >= 1 and Test1Num <= 3: print("Congratulations," , Test1Word, ", you have voted!") ...
true
49d2f9a2183b3fc93c29d450ae3e84923ceefea8
python-packages/decs
/decs/testing.py
907
4.4375
4
import functools def repeat(times): """ Decorated function will be executed `times` times. Warnings: Can be applied only for function with no return value. Otherwise the return value will be lost. Examples: This decorator primary purpose is to repeat execution of some test fu...
true
9279ba88a2f2fd3f7f3a5e908362cb0b0449c97d
KendallWeihe/Artificial-Intelligence
/prog1/main[Conflict].py
1,477
4.15625
4
#Psuedocode: #take user input of number of moves #call moves () #recursively call moves() until defined number is reached #call main function import pdb import numpy as np #specifications: #a 0 means end of tube #1 means empty red_tube = np.empty(6) red_tube[:] = 2 green_tube = np.empty(5) gre...
true
cc315e7aa80c04128721d665deb4c1eadf081d8f
YaqoobAslam/Python3
/Assignment/Count and display the number of lines not starting with alphabet 'A' present in a text file STORY2.TXT.py
863
4.53125
5
Write a function in to count and display the number of lines not starting with alphabet 'A' present in a text file "STORY.TXT". Example: If the file "STORY.TXT" contains the following lines, The rose is red. A girl is playing there. There is a playground. An aeroplane is in the sky. Numbers are not allowed in the pass...
true
2e54f9ee0938beb93b9caa2c5417bf60a8870e2d
pasinducmb/Python-Learning-Material
/Genarator Expressions.py
811
4.1875
4
# Generator Expressions from sys import getsizeof # Comprehension for Lists and Tuples value = [(x + 1)**2 for x in range(10)] print("List: ", value) value = ((x + 1)**2 for x in range(10)) print("Tuple: ", value) # (reason for error is due to tuples are not coprehendible objects as Lists, sets and dictionaries, th...
true
f15f1cc97586bb5fc23b23499328542f93204ea5
wobedi/algorithms-and-data-structures
/src/implementations/sorting/quicksort.py
1,074
4.15625
4
from random import shuffle from src.implementations.sorting.basic_sorts import insertion_sort from src.implementations.helpers.partition import three_way_partition def quicksort(arr: list) -> list: """Sorts arr in-place by implementing https://en.wikipedia.org/wiki/Quicksort """ shuffle(arr) # shuff...
true
55e3ac37f644ea67052a1c21aea38dac9b2e7b52
EcoFiendly/CMEECourseWork
/Week2/Code/test_control_flow.py
1,387
4.15625
4
#!/usr/bin/env python3 """ Some functions exemplifying the use of control statements """ __appname__ = '[test_control_flow.py]' __author__ = 'Yewshen Lim (y.lim20@imperial.ac.uk)' __version__ = '0.0.1' __license__ = "License for this code/program" ## Imports ## import sys # module to interface our program with the o...
true
5c96975d02b72a1519f58eb440f497c617f64b9f
hebertmello/pythonWhizlabs
/project1.py
581
4.15625
4
import random print ("Number guessing game") number = random.randint(1, 20) chances = 0 print("Guess a number between 1 and 20") while(chances < 5): guess = int(input()) if (guess == number): print("Congratulations you won!!!") break elif guess < number: print(...
true
8383a43b540f04be1f3e20a85017c9f42fe4e13c
ugant2/python-snippate
/pract/string.py
1,664
4.3125
4
# Write a Python function to get a string made of the first 2 # and the last 2 chars from a given a string. If the string # length is less than 2, return instead of the empty string. def string_end(s): if len(s)<2: return ' ' return len(s[0:2]) + len(s[-2:]) print(string_end('laugh out')) # Write ...
true
75a068175dd23bd786319ab2df60e61aee8dbfa1
ugant2/python-snippate
/oop/inheritance Animal.py
651
4.34375
4
# Inheritance provides a way to share functionality between classes. # Imagine several classes, Cat, Dog, Rabbit and so on. Although they may # differ in some ways (only Dog might have the method bark), # they are likely to be similar in others (all having the attributes color and name). class Animal: def __init...
true
a8af418b9cff8cb6ee6da6dea287fbd6b8e9034c
mikhael-oo/honey-production-codecademy-project
/honey_production.py
1,525
4.1875
4
# analyze the honey production rate of the country # import all necessary libraries import pandas as pd import matplotlib.pyplot as plt import numpy as np from sklearn import linear_model # import file into a dataframe df = pd.read_csv("https://s3.amazonaws.com/codecademy-content/programs/data-science-path/l...
true
7cabb3d44067c67d5ed50700fa3120ad2277053c
vgates/python_programs
/p010_fibonacci_series.py
940
4.46875
4
# Python program to print first n Fibonacci Numbers. # The Fibonacci numbers are 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, ... # The sequence is characterized by the fact that every number after the # first two is the sum of the two preceding ones. # get the user input and store it in the variable n # int function...
true
4b2b1f3eb6ebadc10e0737b8affbfc0351d0e87d
vgates/python_programs
/p015_factorial.py
1,015
4.34375
4
# Python program to find factorial of a number # Factorial of a number n is the multiplication of all # integers smaller than or equal to n. # Example: Factorial of 5 is 5x4x3x2x1 which is 120. # Here we define a function for calculating the factorial. # Note: Functions are the re-usable pieces of code which ...
true
fd73120ca7a5ac32608d0aec17003c45fb9198a0
JazzyServices/jazzy
/built_ins/slices.py
1,850
4.25
4
# encoding=ascii """Demonstrate the use of a slice object in __getitem__. If the `start` or `stop` members of a slice are strings, then look for those strings within the phrase and make a substring using the offsets. If `stop` is a string, include it in the returned substring. This code is for demonstration purposes ...
true
12a5c1259f669055442de8ddfb7dfd6245e2bcbf
chagaleti332/HackerRank
/Practice/Python/Collections/namedtuple.py
2,990
4.59375
5
""" Question: Basically, namedtuples are easy to create, lightweight object types. They turn tuples into convenient containers for simple tasks. With namedtuples, you don’t have to use integer indices for accessing members of a tuple. Example: Code 01 >>> from collections import namedtuple >>> Point = na...
true
24a0e80c3f81577f00b5b2096e4b32992914db5e
chagaleti332/HackerRank
/Practice/Python/Math/integers_come_in_all_sizes.py
960
4.4375
4
""" Question: Integers in Python can be as big as the bytes in your machine's memory. There is no limit in size as there is: 2^31 - 1(c++ int) or 2^63 - 1(C++ long long int). As we know, the result of a^b grows really fast with increasing b. Let's do some calculations on very large integers. Task: Read four num...
true
56049a2b6eaef72e1d4381a7f76a1d4cb9800912
chagaleti332/HackerRank
/Practice/Python/Introduction/python_print.py
441
4.4375
4
""" Question: Read an integer N. Without using any string methods, try to print the following: 123....N Note that "" represents the values in between. Input Format: The first line contains an integer N. Output Format: Output the answer as explained in the task. Sample Input: 3 Sample Output: 123 ...
true
08605343a771a0837e3383972c370a03516db4aa
chagaleti332/HackerRank
/Practice/Python/Sets/set_add.py
1,440
4.5625
5
""" Question: If we want to add a single element to an existing set, we can use the .add() operation. It adds the element to the set and returns 'None'. Example >>> s = set('HackerRank') >>> s.add('H') >>> print s set(['a', 'c', 'e', 'H', 'k', 'n', 'r', 'R']) >>> print s.add('HackerRank') Non...
true
59e25fa8a6649f0d23deaa9fe33e4df78f674c03
chagaleti332/HackerRank
/Practice/Python/Introduction/python_loops.py
458
4.1875
4
""" Question: Task Read an integer N. For all non-negative integers i < N, print i^2. See the sample for details. Input Format: The first and only line contains the integer, N. Constraints: * 1 <= N <= 20 Output Format: Print N lines, one corresponding to each . Sample Input: 5 Sample Output: ...
true
2d0beaf86a1f65715dbdacdcf07aec623856b6cb
chagaleti332/HackerRank
/Practice/Python/Sets/the_captains_room.py
1,570
4.15625
4
""" Question: Mr. Anant Asankhya is the manager at the INFINITE hotel. The hotel has an infinite amount of rooms. One fine day, a finite number of tourists come to stay at the hotel. The tourists consist of: → A Captain. → An unknown group of families consisting of K members per group where K ≠ 1. The Captain was gi...
true
4735407294bd47ed69477087a1f628d3426d0cfb
chagaleti332/HackerRank
/Practice/Python/RegexAndParsing/group_groups_groupdict.py
2,019
4.4375
4
""" Question: * group() A group() expression returns one or more subgroups of the match. Code >>> import re >>> m = re.match(r'(\w+)@(\w+)\.(\w+)','username@hackerrank.com') >>> m.group(0) # The entire match 'username@hackerrank.com' >>> m.group(1) # The first parenthesized sub...
true
6ab8e6e334434326b8d52145366e35ac535e8dd9
chagaleti332/HackerRank
/Practice/Python/BasicDataTypes/lists.py
1,968
4.34375
4
""" Question: Consider a list (list = []). You can perform the following commands: * insert i e: Insert integer e at position i. * print: Print the list. * remove e: Delete the first occurrence of integer e. * append e: Insert integer e at the end of the list. * sort: Sort the list. * pop: Pop ...
true
162cd5c5c636f39d116bb3b928b70ce60f1bf25c
khidmike/learning
/Python/caesar.py
849
4.21875
4
# Simple program using a Caesar Cipher to encode / decode text strings import sys def main(): print("Welcome to the Caesar Cipher Encoder / Decoder") print() coding = str(input("What would you like to do? Type 'e' to encode / 'd' to decode: ")) if (coding != "e") and (coding != "d"): print("...
true
bf45447e0c258970584c89c445b40d7d84193812
kmenon89/python-practice
/whileloopchallenge.py
613
4.53125
5
#get the line length ,angle,pen color from user and keep drawing until they give length as 0 #import turtle to draw import turtle # declare variables len=1 angle=0 pcolour="black" #use while loop while len != 0 : #get input from user about length angle and pen colour len=int(input("welcome to sketch...
true
679a164e1ffe6086681b2ec1c990633cadb673ba
kmenon89/python-practice
/fibonacci.py
929
4.1875
4
#fibinacci series a=0 b=1 #n=int(input("please give the number of fibonacci sequence to be generated:")) n=int(input("please give the maximum number for fibonacci sequence to be generated:")) series=[] series.append(a) series.append(b) length=len(series)-1 print(length,series[length]) while len(series)<...
true
d2015bc58d2c72e4d91ea716ba2cc6cf05f064ec
bartkim0426/deliberate-practice
/exercises4programmers/ch03_operations/python/07_rectangle.py
1,462
4.375
4
''' pseudocode get_length_and_width length: int = int(input("What is the length of the room in feet? ")) width: int = int(input("What is the width of the room in feet? ")) end calculate_feet_to_meter squre_meter: float = round(square_feet * 0.09290304, 3) end calculate_squre_feet squre_feet = length ...
true
beadb79ce6c4df356833bf50da1c989b1f18bbb0
hanyunxuan/leetcode
/766. Toeplitz Matrix.py
884
4.5
4
""" A matrix is Toeplitz if every diagonal from top-left to bottom-right has the same element. Now given an M x N matrix, return True if and only if the matrix is Toeplitz. Example 1: Input: matrix = [ [1,2,3,4], [5,1,2,3], [9,5,1,2] ] Output: True Explanation: In the above grid, the diagonals are: "[9]", "[5...
true
e77bbe516fc274f1e9cd3c8614f614ccfd4ab490
Raushan117/Python
/014_Append_Mode.py
827
4.5
4
# Reference: https://automatetheboringstuff.com/chapter8/ # Writing in plaintext mode and appending in plaintext mode # Passing a 'w' or 'a' in the second arugment of open() # If the file does not exist, both argument will create a new file # But remember to close them before reading the file again. # About: # Creati...
true
6beca592164142ea3b6381ec9185b4791ca208ad
sagsh018/Python_project
/18_Tuple_unpacking_with_python_function.py
2,410
4.625
5
# in this lecture we are going to learn more about function, and returning multiple items from function using tuple # unpacking # Suppose we want to write a function, which takes in a list of tuples having name of employee and number of hrs worked # We have to decide who is the employee of the month based number of hou...
true
4b31604397b17724d8a249c691a7828d0c07719c
sagsh018/Python_project
/9_Logical_Operators.py
1,242
4.78125
5
# In This lecture we are going to learn how to chain the comparison operators we have learnt in the previous lecture # We can chain the comparison operator with the help of below listed logical operators # and # or # not # Suppose we want to do two comparisons print(1 < 2) # True print(2 < 3) # True # another way of d...
true
acb345bad9c7a7be1c51586ca0587931d864b99b
sagsh018/Python_project
/14_List_comprehensions_in_python.py
2,803
4.84375
5
# List comprehensions are unique way of quickly creating list in python # if you find yourself creating the list with for loop and append(). list comprehensions are better choice my_list = [] print(my_list) # [], so we have an empty list for item in range(1, 10): my_list.append(item) print(my_list) # [1, 2, 3, 4, 5...
true
2e97e48539eaae2d4a43533487c5d263baa1e587
sagsh018/Python_project
/12_While_loop_in_python.py
1,948
4.4375
4
# While loop will continue to execute a block of code while some condition remains true # Syntax # =============================== # while some_boolean_condition: # do something # =============================== # We can also combine while statement with the else statement # =============================== # ...
true
b67420e180277e8abd7908d95a410427a30373ea
homanate/python-projects
/fibonacci.py
711
4.21875
4
'''Function to return the first 1000 values of the fibonacci sequence using memoization''' fibonacci_cache = {} def fibonacci(n): # check input is a positive int if type(n) != int: raise TypeError("n must be a positive int") if n < 1: raise ValueError("n must be a positive int") # che...
true
a1c4e25c5608a1097f71d22db51a3b51aabcafaa
RadchenkoVlada/tasks_book
/python_for_everybody/task9_2.py
1,098
4.3125
4
""" Exercise 2: Write a program that categorizes each mail message by which day of the week the commit was done. To do this look for lines that start with “From”, then look for the third word and keep a running count of each of the days of the week. At the end of the program print out the contents of your dictionary (o...
true
804ec370c29b1d0cafdae1cf1a2615abf4b3f766
RadchenkoVlada/tasks_book
/python_for_everybody/task10_2.py
1,521
4.3125
4
""" Exercise 2: This program counts the distribution of the hour of the day for each of the messages. You can pull the hour from the “From” line by finding the time string and then splitting that string into parts using the colon character. Once you have accumulated the counts for each hour, print out the counts, one ...
true
86de60fccaa7393daa94e67f1e0e8c25e59f8e30
RadchenkoVlada/tasks_book
/python_for_everybody/task7_2.py
2,907
4.46875
4
""" Exercise 2: Write a program to prompt for a file name, and then read through the file and look for lines of the form: X-DSPAM-Confidence:0.8475 When you encounter a line that starts with “X-DSPAM-Confidence:” pull apart the line to extract the floating-point number on the line. Count these lines and then compute ...
true
342ec86d210a77162b489c42d788703070c8a694
nd955/CodingPractice
/HighestProductOfThree.py
858
4.15625
4
import math def get_highest_product_of_three(input_integers): highest_product_of_3 = 0 highest_product_of_2 = 0 highest_number = 0 lowest_product_of_2 = 0 lowest_number = 0 for i in range(len(input_integers)): highest_product_of_3 = max(highest_product_of_3, highest_product_o...
true
486501ac24a31929fb1f621562a4f610de01c13c
green-fox-academy/fehersanyi
/python/dataStructures/l3.py
533
4.125
4
# Create a function called 'create_new_verbs()' which takes a list of verbs and a string as parameters # The string shouldf be a preverb # The function appends every verb to the preverb and returns the list of the new verbs verbs = ["megy", "ver", "kapcsol", "rak", "nez"] preverb = "be" def create_new_verbs(preverb, ...
true
5ec90b5061479057ab0be74166f7662897056973
KyeCook/PythonStudyMaterials
/LyndaStudy/LearningPython/Chapter 3/time_delta_objects.py
1,347
4.34375
4
###### # # # Introduction to time delta objects and how to use them # # ###### from datetime import date from datetime import datetime from datetime import time from datetime import timedelta def main(): # Constructs basic time delta and prints print(timedelta(days=365, hours=5, minutes=1)) # print date...
true
c73bbcb19f8fefe0c8ac9a03af30f84878398d34
rafianathallah/modularizationsforum
/modnumber10.py
395
4.125
4
def pangramchecker(str): alphabet = "abcdefghijklmnopqrstuvwxyz" for characters in alphabet: if characters not in str.lower(): return False return True sentence = str(input("Enter a sentence: ")) if(pangramchecker(sentence) == True): print("This sent...
true
e9c023d8afffb2b4d28954c7bc2ff4311c3e1a94
Ryan149/Bioinformatics-Repository
/bioinformatics/coding/month.py
705
4.15625
4
name={} name[0]="January" name[1]="February" name[2]="March" name[3]="April" name[4]="May" name[5]="June" name[6]="July" name[7]="August" name[8]="September" name[9]="October" name[10]="November" name[11]="December" def daysInMonth(month): days = 30 if (month < 7): if (month % 2 == 0): ...
true
87e82f31d1624d627eed4c122307fc3762165e75
EdBali/Python-Datetime-module
/dates.py
1,626
4.3125
4
import datetime import pytz #-----------------SUMMARRY OF DATETIME module------------ #-------------The datetime module has 4 classes: # datetime.date ---(year,month,date) # datetime.time ---(hour,minute,second,microsecond) # datetime.datetime ---(year,month,date,hour,minute,second,microsecond) # datetime.timedelta ---...
true
a1d69d9a43163882862a5460605a20086fc8f334
marcemq/csdrill
/strings/substrInStr.py
665
4.125
4
# Check if a substring characters are contained in another string # Example # INPUT: T = ABCa, S = BDAECAa # OUTPUT: ABCa IN BDAECAa import sys from utils import _setArgs def checkSubstrInStr(substr, mystr): frec = {key:0 for key in substr} for key in substr: frec[key] += 1 counter = len(frec) ...
true
2a3c4c11d5fbcb16d69d2c18ebc3c0ef30d0b352
PsychoPizzaFromMars/exercises
/intparser/intparser.py
1,951
4.40625
4
'''In this kata we want to convert a string into an integer. The strings simply represent the numbers in words. Examples: - "one" => 1 - "twenty" => 20 - "two hundred forty-six" => 246 - "seven hundred eighty-three thousand nine hundred and nineteen" => 783919 Additional Notes: - The minimum numbe...
true
80d2008455dc937de197802177241472e75c8f1a
Afnaan-Ahmed/GuessingGame-Python
/guessingGame.py
1,036
4.4375
4
import random #Generate a random number and store it in a variable. secret_number = random.randint(1,10) #Initially, set the guess counter to zero, we can add to it later! guess_count = 0 #set a limit on how many guesses the user can make. guess_limit = 3 print('Guess a number between 1 and 10.') #Do this so the p...
true
5dbb4db96d384b13f027ca6adba424dae8f8b7a0
vishnupsingh523/python-learning-programs
/gratestofThree.py
543
4.375
4
# this program is to find the greatest of three numbers: def maxofThree(): # taking the input of three numbers x = int(input("A : ")); y = int(input("B : ")); z = int(input("C : ")); #performing the conditions here for finding the greatest if x>y: if x>z: print(x," is the g...
true
3349311b8347f6eac17c3dfb9b87da5816f57e0c
eestey/PRG105-16.4-Using-a-function-instead-of-a-modifier
/16.4 Using a function instead of a modifier.py
945
4.1875
4
import copy class Time(object): """ represents the time of day. attributes: hour, minute, second""" time = Time() time.hour = 8 time.minute = 25 time.second = 30 def increment(time, seconds): print ("Original time was: %.2d:%.2d:%.2d" % (time.hour, time.minute, time.second)) ...
true
302bee99dec0d511bda305ec8ba4bdc6fa028138
Rossnkama/AdaLesson
/linear-regression.py
1,181
4.25
4
# Importing our libraries import numpy as np import matplotlib.pyplot as plt # Our datasets x_data = [1.0, 2.0, 3.0] y_data = [2.0, 4.0, 6.0] # Forward propagation in our computational graph def feed_forward(x): return x * w # Loss function def calculate_loss(x, y): return (feed_forward(x) - y)**2 # To plot...
true
9621fb0236eaf16068f246c7bc199679c51c24d2
Snakanter/FunStuff
/rps.py
1,832
4.1875
4
#!/usr/bin/env python3 """ File: rps.py Name: A rock-paper-scissors game against the CPU Concepts covered: Random, IO, if/else, printing """ import random import sys import os def main(): # Code here print("READY FOR A GAME OF ROCK, PAPER, SCISSORS!?") PlayerChoice = input("Choose between optio...
true
52a19ec7a20ac94d87dd8d26a9492df110792804
hsqStephenZhang/Fluent-python
/对象引用-可变性-垃圾回收/8.4函数的参数作为引用时2.py
2,010
4.375
4
""" 不要使用可变类型作为函数的参数的默认值 """ class HauntedBus(object): def __init__(self, passengers=[]): # python会提醒,不要使用mutable value self.passengers = passengers def pick(self, name): self.passengers.append(name) def drop(self, name): try: self.passengers.remove(name) exce...
true
7cc3efabd755c0aba8f2e650dfcf5a043b89b5c1
baki6983/Python-Basics-to-Advanced
/Collections/Tuple.py
328
4.46875
4
#tuples are ordered and unchangable fruitsTuples=("apple","banana","cherry") print(fruitsTuples) print(fruitsTuples[1]) # if you try to assign value to fruitsTuples[1] , it will change because its Unchangeable # With DEL method you can completely List , but you cant item in the list for i in fruitsTuples: pr...
true
6705d4095c282200d0c3f2ca1c7edfb15cdc7009
akshayreddy/yahtzee
/yahtzee.py
2,427
4.25
4
''' .) Programs creats a list of dices .) ProbailityInfo is used to keep track of the positions of dices which will be used to re rolled in future .) probability contais the list of probanilities ''' from decimal import Decimal from random import randint import sys j,k=0,0 dices,ProbabilityInfo,probaility=[],[],[...
true
09fd2d4e77c3bb2ce2401f583a567c6351aaf2d7
veryobinna/assessment
/D2_assessment/SOLID/good example/liskov_substitution.py
1,345
4.125
4
''' Objects in a program should be replaceable with instances of their base types without altering the correctness of that program. I.e, subclass should be replaceable with its parent class As we can see in the bad example, where a violation of LSP may lead to an unexpected behaviour of sub-types. In our example, "i...
true
eeb4417e9f419a311fb639aeada768728c113f28
tekichan/teach_kids_python
/lesson5/circle_pattern.py
897
4.34375
4
from turtle import * bgcolor("green") # Define Background Color pencolor("red") # Define the color of Pen, i.e our pattern's color pensize(10) # Define the size of Pen, i.e. the width of our pattern's line radius = 100 # Define the radius of each circle turning_angle = 36 # Define how much the ...
true
15e49688c27e8237138889efa46963ffa4775c91
kenifranz/pylab
/popped.py
309
4.28125
4
# Imagine that the motorcycles in the list are stored in chronological order according to when we owned them. # Write a pythonic program to simulate such a situation. motorcycles = ['honda', 'yamaha','suzuki'] last_owned = motorcycles.pop() print("The last motorcycle I last owned was "+ last_owned.title())
true
17f39a18c96ac3f6a3bb1646da4d01875b1889e6
JaredColon-Rivera/The-Self-Taught-Programmer
/.Chapter-3/Challenge_4.py
233
4.375
4
x = 10 if x <= 10: print("The number is less than or equal to 10!") elif x > 10 and x <= 25: print("The number is greater than equal to 10 but it is less than or equal to 25!") elif x > 25: print("The number is greater than 25!")
true
d6bd643d0da7cfb11fd22a0d0b346171fba82b24
sureshbvn/leetcode
/recursion/subset_sum.py
952
4.25
4
# Count number of subsets the will sum up to given target sum. def subsets(subset, targetSum): # The helper recursive function. Instead of passing a slate(subset), we are # passing the remaining sum that we are interested in. This will reduce the # overall complexity of problem from (2^n)*n to (2^n). ...
true
5d0d3522cee1193cb0765c366e7d5d73a583aab2
pravinv1998/python_codeWithH
/newpac/read write file.py
339
4.15625
4
def read_file(filename): ''' 'This function use only for read content from file and display on command line' ''' file_content = open(filename) read_data = file_content.read() file_content.close() return read_data n=read_file("name.txt") print(n) print(read_file.__doc__) # read the ...
true
bc4906e63fbb7278109151edfd73f7d06cc38630
abalulu9/Sorting-Algorithms
/SelectionSort.py
701
4.125
4
# Implementation of the selection sorting algorithm # Selection sort takes the smallest element of the vector, removes it and adds it to the end of the sorted vector # Takes in a list of numbers and return a sorted list def selectionSort(vector, ascending = True): sortedVector = [] # While there are still elements...
true
2f28f3c4f6c93913345c688e688662eb228879ed
stanislav-shulha/Python-Automate-the-Boring-Stuff
/Chapter 6/printTable.py
997
4.46875
4
#! python3 # printTable.py - Displays the contents of a list of lists of strings in a table format right justified #List containing list of strings #rows are downward #columns are upward tableData = [['apples', 'oranges', 'cherries', 'banana'], ['Alice', 'Bob', 'Carol', 'David'], ['dogs', 'cats', 'moose', 'goo...
true
96a3ec7334436703a69c3d4bd396eb3f99ca5bf2
stanislav-shulha/Python-Automate-the-Boring-Stuff
/Chapter 4/CommaList.py
733
4.59375
5
#Sample program to display a list of values in comma separated format #Function to print a given list in a comma separated format #Takes a list to be printed in a comma separated format def comma_List(passedList): #Message to be printed to the console message = '' if len(passedList) == 0: print('Empty List') ...
true
2b7df14561403960fe975298193f7863d79d2987
charlesumesi/ComplexNumbers
/ComplexNumbers_Multiply.py
1,049
4.3125
4
# -*- coding: utf-8 -*- """ Created on 16 Feb 2020 Name: ComplexNumbers_Multiply.py Purpose: Can multiply an infinite number of complex numbers @author: Charles Umesi (charlesumesi) """ import cmath def multiply_complex(): # Compile one list of all numbers and complex numbers to be multiplied ...
true
007f176e9d38b1d07543cda8113ae468d31daa28
andresjjn/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/4-print_square.py
779
4.375
4
#!/usr/bin/python3 """ Module Print square This document have one module that prints a square with the character #. Example: >>> print_square(4) #### #### #### #### """ def print_square(size): """Add module. Args: size (int): The size length of the square. Reises: TypeE...
true
e23a809a3a920c566aa857d70f684fc787381bbb
GbemiAyejuni/BubbleSort
/bubble sort.py
828
4.28125
4
sort_list = [] # empty list to store numbers to be sorted list_size = int(input("Enter the size of list: ")) # variable to store size of list indicated by the user for i in range(0, list_size): number = int(input("Enter digit: ")) sort_list.append(number) # adds each number the user gives to sort_list ...
true
d9a69fbda9ed1346f9475dd255278948ae5038de
arifams/py_coursera_basic_
/for_test2.py
352
4.40625
4
print("before, this is the total number") numbers = 3,41,15,73,9,12,7,81,2,16 for number in numbers: print(number) print("now python try to find the largest number") largest_so_far = 0 for number in numbers: if number > largest_so_far: largest_so_far = number print(largest_so_far, number) print("Now the curre...
true
7b9e12083faf0278926f41cc4c60562e24332697
lasupernova/book_inventory
/kg_to_PoundsOrOunces.py
1,806
4.125
4
from tkinter import * #create window-object window = Tk() #create and add 1st-row widgets #create label Label(window, text="Kg").grid(row=0, column=0, columnspan=2) #create function to pass to button as command def kg_calculator(): # get kg value from e1 kg = e1_value.get() # convert kg into desired un...
true
6e8d17c385229344a5ba7cfddfdc9679de7e09eb
jelaiadriell16/PythonProjects
/pset2-1.py
736
4.1875
4
print("Paying the Minimum\n") balance = int(raw_input("Balance: ")) annualInterestRate = float(raw_input("Annual Interest Rate: ")) monthlyPaymentRate = float(raw_input("Monthly Payment Rate: ")) monIntRate = annualInterestRate/12.0 month = 1 totalPaid = 0 while month <= 12: minPayment = monthlyPaymentRate ...
true
ba3b85ec95dc22ecb4c91ada9c2f61512e5359ea
Gabe-flomo/Filtr
/GUI/test/tutorial_1.py
1,950
4.34375
4
from PyQt5 import QtWidgets from PyQt5.QtWidgets import QApplication, QMainWindow import sys ''' tutorial 1: Basic gui setup''' # when working with PyQt, the first thing we need to do when creating an app # or a GUI is to define an application. # we'll define a function named window that does this for us def window...
true
75f4e3cd2ccfe294c9940f3cc7332c3626dcb139
Muhammad-Yousef/Data-Structures-and-Algorithms
/Stack/LinkedList-Based/Stack.py
1,303
4.21875
4
#Establishing Node class Node: def __init__(self): self.data = None self.Next = None #Establishing The Stack class Stack: #Initialization def __init__(self): self.head = None self.size = 0 #Check whether the Stack is Empty or not def isEmpty(self): retur...
true
43f674a715ad3f044bc2a5b406dc3b5edabe1323
DoozyX/AI2016-2017
/labs/lab1/p3/TableThirdRoot.py
838
4.4375
4
# -*- coding: utf-8 -*- """ Table of third root Problem 3 Create a table with third root so that the solution is a dictionary where the key is the integer and the value is the third root of the integer. The keys should be numbers whose third root is also an integer between two values m and n. or a given input, print ou...
true
dcdbd68cea46053d4c116d19d5ed64f0d26eca1f
obaodelana/cs50x
/pset6/mario/more/mario.py
581
4.21875
4
height = input("Height: ") # Make sure height is a number ranging from 1 to 8 while (not height.isdigit() or int(height) not in range(1, 9)): height = input("Height: ") # Make range a number height = int(height) def PrintHashLine(num): # Print height - num spaces print(" " * int(height - num), end="") ...
true
014130aa0b43faecfbb0737cb47bf66bbf6bd318
carriekuhlman/calculator-2
/calculator.py
2,425
4.25
4
"""CLI application for a prefix-notation calculator.""" from arithmetic import (add, subtract, multiply, divide, square, cube, power, mod, ) # loop for an input string # if q --> quit # otherwise: tokenize it # look at first token # do equation/math for whatever it corresponds to # return as a...
true
61d8cb65ed02a9dbd905897290709080c49ba886
benjiaming/leetcode
/validate_binary_search_tree.py
1,596
4.15625
4
""" Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: The left subtree of a node contains only nodes with keys less than the node's key. The right subtree of a node contains only nodes with keys greater than the node's key. Both the left and righ...
true
f7c50862b43c8c0386195cd4b01419c0ac6f7b21
benjiaming/leetcode
/find_duplicate_subtrees.py
1,636
4.125
4
""" Given a binary tree, return all duplicate subtrees. For each kind of duplicate subtrees, you only need to return the root node of any one of them. Two trees are duplicate if they have the same structure with same node values. Example 1: 1 / \ 2 3 / / \ 4 2 4 / 4...
true
f2d07b36bb42c0d8b1ec205cb3fa338d18719363
benjiaming/leetcode
/rotate_image.py
1,571
4.1875
4
#!/bin/env python3 """ You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Note: You have to rotate the image in-place, which means you have to modify the input 2D matrix directly. DO NOT allocate another 2D matrix and do the rotation. Example 1: Given input matrix =...
true
b048988bbaa1a55c3010042e642d232d7e1e4698
SDSS-Computing-Studies/004c-while-loops-hungrybeagle-2
/task2.py
520
4.21875
4
#! python3 """ Have the user enter a username and password. Repeat this until both the username and password match the following: Remember to use input().strip() to input str type variables username: admin password: 12345 (2 marks) inputs: str (username) str (password) outputs: Access granted Access denied example:...
true
7779633f0c8bf9a73c3eafcc06e21beed0200332
Nivedita01/Learning-Python-
/swapTwoInputs.py
967
4.28125
4
def swap_with_addsub_operators(x,y): # Note: This method does not work with float or strings x = x + y y = x - y x = x - y print("After: " +str(x)+ " " +str(y)) def swap_with_muldiv_operators(x,y): # N...
true
43927a3adcc76846309985c0e460d64849de0fa7
Nivedita01/Learning-Python-
/guess_game.py
560
4.21875
4
guess_word = "hello" guess = "" out_of_attempts = False guess_count = 0 guess_limit = 3 #checking if user entered word is equal to actual word and is not out of guesses number while(guess != guess_word and not(out_of_attempts)): #checking if guess count is less than guess limit if(guess_count < guess_lim...
true
12f9dbff51caec4d245d00d5d6cc71d0c3c88b5f
rdumaguin/CodingDojoCompilation
/Python-Oct-2017/PythonFundamentals/Lists_to_Dict.py
1,020
4.21875
4
name = ["Anna", "Eli", "Pariece", "Brendan", "Amy", "Shane", "Oscar"] favorite_animal = ["horse", "cat", "spider", "giraffe", "ticks", "dolphins", "llamas"] def zipLists(x, y): zipped = zip(x, y) # print zipped newDict = dict(zipped) print newDict return newDict zipLists(name, favorite_animal) # C...
true
503355cdd49fa7399ed1062a112b8de55f1c0654
tme5/PythonCodes
/Daily Coding Problem/PyScripts/Program_0033.py
926
4.25
4
''' This problem was asked by Microsoft. Compute the running median of a sequence of numbers. That is, given a stream of numbers, print out the median of the list so far on each new element. Recall that the median of an even-numbered list is the average of the two middle numbers. For example, given the sequence [2, 1, ...
true