blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
8c999f21b38fd1147e85a451ad278e2664a06a3b
midnightkali/w3resource.com-python-exercises
/Excercise Solutions/question-2.py
617
4.40625
4
''' 2. Write a Python program to create a function that takes one argument, and that argument will be multiplied with an unknown given number. Sample Output: Double the number of 15 = 30 Triple the number of 15 = 45 Quadruple the number of 15 = 60 Quintuple the number 15 = 75 ''' def compute(num): return lambda nu...
true
6787185c9fcaeacccc3cac1e620f4d64cfbe6927
wchamber01/Algorithms
/stock_prices/stock_prices.py
970
4.125
4
#!/usr/bin/python import argparse def find_max_profit(prices): #find highest_value in list highest_value = max(prices[1:]) # print(highest_value) #find lowest_value in list that occurs before the highest value for i in prices: temp_arr = prices.index(highest_value) # print(temp_arr) lowes...
true
b2cf3c5d25e600356f1340baf4724f39bef92a8f
365cent/calculate_pi_with_turtle_py
/calculatePi.py
2,845
4.5625
5
""" References: https://stackoverflow.com/questions/37472761/filling-rectangles-with-colors-in-python-using-turtle https://www.blog.pythonlibrary.org/2012/08/06/python-using-turtles-for-drawing/ https://docs.python.org/3/library/turtle.html https://developer.apple.com/design/human-interface-guidelines/ios/visual-design...
true
f9f764c303cca5872cea4f868abcc073a979e9e5
tberhanu/all_trainings
/9_training/transpose*_matrix.py
1,502
4.75
5
""" Given a matrix A, return the transpose of A. The transpose of a matrix is the matrix flipped over it's main diagonal, switching the row and column indices of the matrix. Example 1: Input: [[1,2,3],[4,5,6],[7,8,9]] Output: [[1,4,7],[2,5,8],[3,6,9]] Example 2: Input: [[1,2,3],[4,5,6]] Output: [[1,4],[2,5],[3,6]] ...
true
d49312d3275d7af730b00dd4eff0844b9f8c9e7a
tberhanu/all_trainings
/revision_1_to_7/15_largest_prime_factor.py
358
4.125
4
""" 15. Given an int, what is the largest prime factor? """ def largest_prime_factor(num): i = 2 while i * i <= num: while num % i == 0: num = num // i i = i + 1 return max(2, num) print(largest_prime_factor(12)) print(largest_prime_factor(15)) print(largest_prime_factor(21)...
false
d1ca4df1ebd74bf0e64444d1ede451425d783520
tberhanu/all_trainings
/9_training/921_add-parenthesis.py
1,607
4.34375
4
""" Given a string S of '(' and ')' parentheses, we add the minimum number of parentheses ( '(' or ')', and in any positions ) so that the resulting parentheses string is valid. Formally, a parentheses string is valid if and only if: It is the empty string, or It can be written as AB (A concatenated with B), where A ...
true
ccef15befdc8373f187d0be2b6fd3e205057e65b
tberhanu/all_trainings
/8_training/monotonic_array.py
1,193
4.1875
4
""" An array is monotonic if it is either monotone increasing or monotone decreasing. An array A is monotone increasing if for all i <= j, A[i] <= A[j]. An array A is monotone decreasing if for all i <= j, A[i] >= A[j]. Return true if and only if the given array A is monotonic. Example 1: Input: [1,2,2,3] Output...
true
98976e9dbd53034092cdad20f46cec9573ed5769
tberhanu/all_trainings
/revision_1_to_7/13_array_flattening.py
352
4.1875
4
""" 13. Given a nested array, return a flattened version of it. Ex. [1, 2, [3, [4, 5], 6]] ---> [1, 2, 3, 4, 5, 6] """ from collections.abc import Iterable def flatten(arr): for a in arr: if isinstance(a, Iterable): yield from flatten(a) else: yield a print(list(f...
true
1531e733cc5859b5be70b6b606c2c75488411c77
tberhanu/all_trainings
/9_training/73_set_matrix_zeroes.py
997
4.28125
4
""" Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in-place. Example 1: Input: [ [1,1,1], [1,0,1], [1,1,1] ] Output: [ [1,0,1], [0,0,0], [1,0,1] ] Example 2: Input: [ [0,1,2,0], [3,4,5,2], [1,3,1,5] ] Output: [ [0,0,0,0], [0,4,5,0], [0,3,1,0] ] Follow up: ...
true
4ced710feb067c8c912875511f7af2294b529e03
tberhanu/all_trainings
/revision_1_to_7/8_reverse_array_inplace.py
294
4.15625
4
""" 8. Inplace reverse an array of characters """ def inplace_reverse(arr): i = 0 j = len(arr)-1 while i < j: arr[i], arr[j] = arr[j], arr[i] i = i + 1 j = j - 1 return arr print(inplace_reverse([1, 2, 3, 4])) print(inplace_reverse([1, 2, 3, 4, 5]))
false
7c6c0c78a813ec102b63072b31057cd5e909bbc6
tberhanu/all_trainings
/3_training/qn3_shortest_route.py
1,658
4.1875
4
#!/usr/bin/env python3 import networkx as nx import matplotlib.pyplot as plt def shortest_path(network, name1, name2): """shortest_path(network, name1, name2) --> a function taking a NETWORK and output and array of Strings as a shortest path from name1 to name2 --> Need to install networkx, and inbuilt py...
true
a42a1b8a508f5dad31c13eac7d6f4d605896155e
Marist-CMPT120-FA19/-Kathryn-McCullough--Project-10-
/censor.py
1,494
4.28125
4
#name: Kathryn McCullough #email: kathryn.mccullough1@marist.edu #description: This program references a file with words and a separate #file with a phrase and censors those words from the first into a third file. #goes through characters and replaces all letters with * #plus censores word with comma will still have ...
true
71a4d5d390639160838813bc0ff468853b248ddd
jjmaldonis/Data-Structures-Code
/pythoncrashcourse/intsertion.py
869
4.25
4
#if you import this module you can type help(insertion) and it will give you the help info below """ insertion sort script that demonstrates implementation of insertion sort. """ import random def insertion(l): """ implements insertion sort pass it a list, list will be modified in plase """ pri...
true
8ff7e379b9a79d6c8094165e0ab6a9fb089d753a
jtwray/Intro-Python-I
/src/07_slices.py
1,789
4.625
5
""" Python exposes a terse and intuitive syntax for performing slicing on lists and strings. This makes it easy to reference only a portion of a list or string. This Stack Overflow answer provides a brief but thorough overview: https://stackoverflow.com/a/509295 Use Python's slice syntax to achieve the following: "...
true
7a6b08c52a1f57f07dc3c6be620b3df74620fa64
wsullivan17/Cashier
/Cashier.py
1,678
4.125
4
#Automated cashier program #Willard Sullivan, 2020 #total cost of items total = 0 done = "" from users import users_dict, pwds_dict from items import items_dict, cost_dict print("Welcome to the Automated Cashier Program. ") go = input("Type the Enter key to continue. ") while go != "": go = input("Type the E...
true
1e2b7e6f44c7fba2e1aa916481a50a4dc86e5195
maianhtrnguyen/Assignment-2
/Assignment/PythonLearningProject1-master/helloWorld.py
1,675
4.1875
4
# Install the package Pillow: pip install pillow from PIL import Image # The documentation is here, # https://pillow.readthedocs.io/en/stable/reference/Image.html# # please just look at the Image Module and Image Class section # Read about this module/class and its relevant information, but dont worry about other cl...
true
21939208c9d75a5e10e77f874041e111051d7be2
AtieDag/Project-Euler
/Problem14.py
572
4.125
4
# The following iterative sequence is defined for the set of positive integers: from functools import lru_cache @lru_cache(maxsize=100) def collatz_sequence(n, terms=0): terms += 1 if n == 1: return terms # n is even if n % 2 == 0: return collatz_sequence(n / 2, terms) # n is odd ...
true
18f31e559b7c838ff226b6dad3bc0f25665930cc
KostadinovShalon/curso-de-python-2020
/dia 1/ejercicios/ejercicio_15.py
683
4.1875
4
# 15. Pidele al usuario que ingrese una lista de palabras y le digas cual fue la mas larga. Recuerda que deben de ser # palabras, por lo que frases no cuentan! palabra_mas_larga = "" while True: palabra = input("Introduzca una palabra [O introduzca * para salir]: ") if palabra == "*": break palabr...
false
e2e3884345256a114aa8fe57fd10fd8ce388e679
RisingLight/Python_Practice
/Challenge questions/TejaSreeChand/wordscramb challenge3 .py
1,349
4.25
4
import random import os def shuf(string): ltemp=string[1:len(string)-1] # taking only the mid part { change it into string[0:len(string)] for a full words shuffle ltemp=list(ltemp) # convert the word into alphabet list eg: "hey" -> ["h","e","y"] random.shuffle(ltemp) # ...
true
b4839a749136a1cace5be79885b0e72098fab39f
vansh1999/Python_core_and_advanced
/functions/decorators.py
2,034
4.59375
5
''' Decorators in Python A decorator is a design pattern in Python that allows a user to add new functionality to an existing object without modifying its structure. Decorators are usually called before the definition of a function you want to decorate. Functions in Python are first class citizens. This means that t...
true
35435a318e2262d5b7fce50deae1fd3fa82aad48
vansh1999/Python_core_and_advanced
/sequencedatatype/tuples/tuple.py
715
4.125
4
# declare a tuple colors = ("r" , "b" , "g") print(colors) # tuple packaging - # Python Tuple packing is the term for packing a sequence of values into a tuple without using parentheses. crl = 1,2,3 print(crl) # tuble unpackaging - a,b,c = crl print(a,b,c) # Crete tuple with single elements tupl1 = ('n') #< --...
true
02f42d9c69c3ab2b7dec8c56333af234ae75da7a
chenPerach/Open-Vision
/libs/geometry/point.py
755
4.21875
4
import math class vector: """ a simple class representing a vector """ def __init__(self,x:float,y:float): self.x = x self.y = y def __add__(self,vec): return vector(self.x - vec.x,self.y - vec.y) def size(self): return math.sqrt(math.pow(self.x,2) + mat...
false
8b22fc6b4b4f6b3cf28f7c2b3dfc1f03ac301fb4
evroandrew/python_tasks
/task8.py
2,322
4.21875
4
import argparse MSG_INFO = 'To output Fibonacci numbers within the specified range, enter range: ' MSG_ERROR = 'Use any numbers, instead of you entered.' MSG_FIRST_ELEMENT = 'Enter first argument of range: ' MSG_SECOND_ELEMENT = 'Enter second argument of range: ' ERRORS = (argparse.ArgumentError, TypeError, argparse.A...
true
9c9c562ac2a07f66c4d4202ea003f9ed308c0d5a
Praveen-Kumar-Bairagi/Python_Logical_Quetions
/ifelse_python/char.py
413
4.25
4
char=str(input("enter the char")) if char>="a" and char<="z" or char<"A" and char<="Z": print("it is char") number=float(input("enter the number")) if number>=0 and number<=200: print("it is digit") specialchar=input("enter the specialchar") if specialchar!=char and specialchar!=number: ...
true
aad6088e046f4b4f333441f26ed6a65d50f260a3
Praveen-Kumar-Bairagi/Python_Logical_Quetions
/ifelse_python/prime.py
883
4.15625
4
# num=int(input("enter the num")) # if num==1: # print("it is not prime number") # if num%2!=0: # print("it is prime number") # if num%5!=0: # print("it is prime number") # else: # print("it is prime number") Sex = input("enter sex M\F") material_s...
false
c0a95dfdf5d086724bbb96875598facac45618fd
eliseoarivera/cs50transfer
/intro-python/day-one/ageCheck.py
485
4.28125
4
age = input("How old are you?") """if age >= "18": print("You're old enough to vote!") else: print("You're not old enough to vote.")""" age = input("How old are you?") # Read this as "Set age equal to whatever string the user types." age = int(age) # We reassign the variable information here. # In essence, "Set...
true
56bd713a364a7abd0657341e45f71b57e2a611ef
eliseoarivera/cs50transfer
/intro-python/day-one/functions.py
1,551
4.4375
4
"""def shout(name): name = name.upper() return "HELLO " + name + "!" print(shout("Britney"))""" """def costForDisney(adults, children, days): adult_cost = adults * 100 print("Calculated adult cost at " + str(adult_cost)) child_cost = children * 90 print("Calculated child cost at " + str(child_cost)) dail...
true
a8803c9a755d33efa0a111eae2b80cc2573803de
tcraven96/Cracking-the-Coding-Interview
/Cracking the Coding Interview/Question1-1.py
798
4.1875
4
# Implement an algorithm to determine if each string has all unique characters. # What if you cannot use additional data structures? import unittest # Goes through string, replaces element found once with "" so that duplicates are not replaced. # Will return if duplicate characters are found in the string. def unique...
true
7d9982d39a2f8a6937dfded0ddc2a03f00a6017d
jeanggabriel/jean-scripts
/curso em video/programaresolucaoporcramer3x3empython.py
1,761
4.21875
4
print ("\n Programa em Python para resolver um sistema de equa��es com tr�s inc�gnitas") print ("\n Estou definindo um sistema de tr�s equa��es com tr�s inc�gnitas desta forma:") print ("\n \n ax + by + cz = R1 \n dx + ey + fz = R2 \n gx + hy + iz = R3 \n") print ("\n Digite os valores para: \n") # O usu�rio d� valore...
false
f5bc910e44639ae828c56017c5f659e8c02c370c
LizaShengelia/100-Days-of-Code--Python
/Day10.Project.py
1,278
4.3125
4
from art import logo #add def add(n1, n2): return n1 + n2 #subtract def subtract(n1, n2): return n1 - n2 #multiply def multiply(n1, n2): return n1 * n2 #divide def divide(n1, n2): return n1 / n2 operations = { "+": add, "-": subtract, "*": multiply, "/": divide } def calculator(): print(log...
true
df6c4c6355a62b8545bb50779b624a3ad6ce8a3c
ermanh/dailycoding
/20200715_inversion_count.py
2,116
4.1875
4
''' 2020-07-15 [from dailycodingproblems.com #44] We can determine how "out of order" an array A is by counting the number of inversions it has. Two elements A[i] and A[j] form an inversion if A[i] > A[j] but i < j. That is, a smaller element appears after a larger element. Given an array, count the number of inver...
true
89a63d37c1520e8a2e2adeb42a92fbf0214cf72a
ermanh/dailycoding
/20200706_balanced_brackets.py
1,509
4.25
4
''' 2020-07-06 [from dailycodingproblem.com #27] Given a string of round, curly, and square open and closing brackets, return whether the brackets are balanced (well-formed). For example, given the string "([])[]({})", you should return true. Given the string "([)]" or "((()", you should return false. ''' def balan...
true
f06e6cb2349160b53b3897dee89b9a8620b47a4a
ermanh/dailycoding
/20200727_line_breaks.py
1,604
4.25
4
''' 2020-07-27 [from dailycodingproblem.com #57] Given a string s and an integer k, break up the string into multiple lines such that each line has a length of k or less. You must break it up so that words don't break across lines. Each line has to have the maximum possible amount of words. If there's no way to bre...
true
d6a249c5f49bae6495eeaaf2fe118286fe9f55e5
cartoonshow57/SmallPythonPrograms
/multiples_of_num.py
386
4.46875
4
"""This program takes a positive integer and returns a list that contains first five multiples of that number""" def list_of_multiples(num1): lst = [] for i in range(1, 6): multiple = num1 * i lst.append(multiple) return lst num = int(input("Enter a positive number: ")) print("The first...
true
de55a87bc414dc26a65f9b12d350550779446579
cartoonshow57/SmallPythonPrograms
/nested_loop.py
252
4.25
4
# A dummy program for how a nested loop works print("Nested loop example") print("-------------------------------") for i in range(1, 4, 1): for j in range(1, 1001, 999): print(format(i * j, "8d"), end="") print() print("EOP") input()
true
5cf128f4cb83571f291b8d6981914cb0106c372a
cartoonshow57/SmallPythonPrograms
/sum_of_array.py
392
4.21875
4
# This program prints the sum of all the elements in an array def sum_of_array(arr1): total = sum(list(arr1)) return total arr = [] n = int(input("Enter the number of elements in the array: ")) for i in range(n): arr.append(int(input("Enter no. in array: "))) print("The given array is,", arr) print("...
true
89a4b8735d13a7a2536d3fa18c80cda5c8b46b68
cartoonshow57/SmallPythonPrograms
/array_replacement.py
661
4.21875
4
"""Given an array of n terms and an integer m, this program modifies the given array as arr[i] = (arr[i-1]+1) % m and return that array""" def array_modification(arr1, m1): test_arr = [] index = 0 for _ in arr1: s = (arr1[index - 1] + 1) % m1 test_arr.append(s) index += 1 retur...
true
40247c58ddd68593214c719ac84db9252174b69c
cartoonshow57/SmallPythonPrograms
/first_and_last.py
431
4.1875
4
"""This program takes an array and deletes the first and last element of the array""" def remove_element(arr1): del arr1[0] del arr1[-1] return arr1 arr = [] n = int(input("Enter number of elements in the list: ")) for i in range(n): arr.append(int(input("Enter array element: "))) print("The give...
true
8c841eabc2a03af875f2b7286a86c2e5ac14eae4
motirase/holbertonschool-higher_level_programming-1
/0x07-python-test_driven_development/0-add_integer.py~
472
4.21875
4
#!/usr/bin/python3 """ function 0-add_integer adds two integers """ def add_integer(a, b=98): """adds two numbers >>> add_integer(4, 3) 7 >>> add_integer(5, 5) 10 """ fnum = 0 if type(a) is int or type(a) is float: fnum += int(a) else: raise TypeError("a must be a...
true
bf094483c1d4fcc049e9fcb3aab8c57e8429badf
hly189/hw
/lab3.py
1,585
4.1875
4
def factorial(n): if n == 0: return 1 else: return n*factorial(n-1) def sum(n): if n==0: return 0 else: return n + sum(n-1) def ab_plus_c(a,b,c): if b==0: return c else: return a + ab_plus_c(a, b-1,c) def square(x): return x*x def summation(n, term): """ >>> summation(3, square) 14...
false
fb7d4013fd9394072a043c958e1e35b1ff8f3b63
Dyke-F/Udacity_DSA_Project1
/Task4.py
1,441
4.125
4
""" Read file into texts and calls. It's ok if you don't understand how to read files. """ import csv with open('texts.csv', 'r') as f: reader = csv.reader(f) texts = list(reader) with open('calls.csv', 'r') as f: reader = csv.reader(f) calls = list(reader) """ TASK 4: The telephone company want to i...
true
d6396e1980649d9fcfbe3e5a50f3fb6f37016731
aditya-sengupta/misc
/ProjectEuler/Q19.py
1,067
4.21875
4
"""You are given the following information, but you may prefer to do some research for yourself. 1 Jan 1900 was a Monday. Thirty days has September, April, June and November. All the rest have thirty-one, Saving February alone, Which has twenty-eight, rain or shine. And on leap years, twenty-nine. A leap year occurs o...
true
5d393e90f23624f1a27ca7af73fa9606e08beaf4
B3rtje/dataV2-labs
/module-1/Code-Simplicity-Efficiency/your-code/challenge-2_test.py
1,678
4.25
4
import string import random def new_string(length): letters = string.ascii_lowercase+string.digits str = ''.join(random.choice(letters) for num in range(length)) return str #print(get_random_string(10)) def string_gen (): strings = [] number_of_strings = input("How many strings do you want...
true
486440929bfc62b5fc48823002c695afeacd67bb
sailesh190/pyclass
/mycode/add_book.py
252
4.375
4
address_book = [] for item in range(3): name = input("Enter your name:") email = input("Enter your email:") phone = input("Enter your phone number:") address_book.append(dict(name=name, email=email, phone=phone)) print(address_book)
true
405fbc0f2d07a41d15ff248af2e429e45de498e7
AhmUgEk/tictactoe
/tictactoe_functions.py
1,974
4.125
4
""" TicTacToe game supporting functions. """ # Imports: import random def display_board(board): print(f' {board[1]} | {board[2]} | {board[3]} \n-----------\n {board[4]} | {board[5]} | {board[6]}\ \n-----------\n {board[7]} | {board[8]} | {board[9]} \n') def player_input(): marker = 0 ...
true
8c988bf453d8f1c5bb69272e69e254df77c1b874
shreeji0312/learning-python
/python-Bootcamp/assignment1/assignment1notes/basicEx2.py
2,924
4.5625
5
# WPCC # basicEx2.py # Let's take a look at some different types of data that Python # knows about: print(10) print(3.14) print("Python is awesome!") print(True) # There are 4 fundamental types of data in Python: # integers, floating point numbers, strings, and booleans # You can create more types of data, but we'll...
true
46004672cd99417c2bc0027e364ecb4441f1c8f9
shreeji0312/learning-python
/python-Bootcamp/assignment1/assignment1notes/basicEx6.py
1,907
4.84375
5
# WPCC # basicEx6.py # So far we've made our own variables that store # data that we have defined. Let's look at how we can # ask the user to enter in data that we can manipulate # in our program # We will use the `input` function to ask the user to enter # some data user_input = input("Please enter a number: ") # ...
true
6c4c8561cb46045307cf14a1481f97b3e63c1af8
shreeji0312/learning-python
/python-Bootcamp/assignment5/assignment5notes/2dlistEx1.py
2,000
4.71875
5
# WPCC # 2dlistEx1.py # We're going to look at what a 2D list is. # A 2D list is a list that contains other lists. # For example: marks = [ [90, 85, 88], [68, 73, 79] ] # The list `marks` contains 2 other lists, each containing # integers. We would say that this list is of size 2x3: # two lists, each containing 3 ele...
true
291d09272a542e9b24fab373d154466f9d1b0c30
shreeji0312/learning-python
/python-Bootcamp/assignment4/assignment4notes/functionEx2.py
1,611
4.84375
5
# WPCC # functionEx2.py # When we call some Python standard functions, it gives us back # a value that we can assign to a variable and use later in our programs. # For example: import random randomNumber = random.randint(0, 10) # This function will return the value it generates so we can assign its # value to `rand...
true
20656a0b0704de6339feab22f2a2a4d539cda92f
fantasylsc/LeetCode
/Algorithm/Python/75/0056_Merge_Intervals.py
977
4.15625
4
''' Given a collection of intervals, merge all overlapping intervals. Example 1: Input: [[1,3],[2,6],[8,10],[15,18]] Output: [[1,6],[8,10],[15,18]] Explanation: Since intervals [1,3] and [2,6] overlaps, merge them into [1,6]. Example 2: Input: [[1,4],[4,5]] Output: [[1,5]] Explanation: Intervals [1,4] ...
true
a312e0acb76d0747602ccf4c39d799a3c814c30c
fantasylsc/LeetCode
/Algorithm/Python/1025/1007_Minimum_Domino_Rotations_For_Equal_Row.py
2,473
4.1875
4
''' In a row of dominoes, A[i] and B[i] represent the top and bottom halves of the i-th domino. (A domino is a tile with two numbers from 1 to 6 - one on each half of the tile.) We may rotate the i-th domino, so that A[i] and B[i] swap values. Return the minimum number of rotations so that all the values in A...
true
a18260a2c70db8afa8c17a910f0ea09a4d1802b1
fantasylsc/LeetCode
/Algorithm/Python/100/0079_Word_Search.py
2,907
4.15625
4
''' Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or vertically neighboring. The same letter cell may not be used more than once. Example: board = [ ['A','B','C','E']...
true
8f3f5394b435a3b706388f72f98d14ac42e5ed10
fantasylsc/LeetCode
/Algorithm/Python/75/0065_Valid_Number.py
2,383
4.125
4
''' Validate if a given string can be interpreted as a decimal number. Some examples: "0" => true " 0.1 " => true "abc" => false "1 a" => false "2e10" => true " -90e3 " => true " 1e" => false "e3" => false " 6e-1" => true " 99e2.5 " => false "53.5e93" => true " --6 " => false "-+3" => false "95a54...
false
955c1c68bdd8c6c869585f98009b603eb3938d28
amirhosseinghdv/python-class
/Ex4_Amirhossein Ghadiri.py
1,617
4.1875
4
"""#Ex12 num1=int(input("addad avval?")) num2=int(input("addad dovvom?")) if num1 >= num2: print(num2) print(num1) else: print(num1) print(num2) """ """#13: num=int(input("please enter a number lower than 20: ")) if num >= 20: print("Too high") else: print("Thank you") """ ...
true
07d431c2473e33a00b597bc6412af322f116abab
AnumaThakuri/pythonassignment
/assignment4/question 1.py
310
4.28125
4
#average marks of five inputted marks: marks1=int(input("enter the marks 1:")) marks2=int(input("enter the marks 2:")) marks3=int(input("enter the marks 3:")) marks4=int(input("enter the marks 4:")) marks5=int(input("enter the marks 5:")) sum=marks1+marks2+marks3+marks4+marks5 avg=sum/5 print("average=",avg)
true
86ed441f6d4ab832a0087ed1b6b5adac3085ebcf
AnumaThakuri/pythonassignment
/Python test1/question 1.py
264
4.34375
4
#convert tempersture clesius to farenhuet and vice versa farenheit=float(input("Enter the temperature : ")) celsius=(farenheit-32)*5/9 print(farenheit ," Farenheit is",celsius,"Celsius") farenheit=(celsius*9/5)+32 print(celsius," Celsius is",farenheit,"Farenheit")
false
e343ff42820c7d794248635ec646eb8d4b184181
lxiong515/Module13
/GuessGame/topic1.py
2,385
4.15625
4
""" Program: number_guess.py Author: Luke Xiong Date: 07/18/2020 This program will have a set of buttons for users to select a number guess """ import tkinter as tk from random import randrange from tkinter import messagebox window = tk.Tk() window.title("Guessing Game") label_intro = tk.Label(window, text = "Guess...
true
a970f1be719d68082548cf222aeff5beaea5da64
cyan33/leetcode
/677-map-sum-pairs/map-sum-pairs.py
1,235
4.15625
4
# -*- coding:utf-8 -*- # # Implement a MapSum class with insert, and sum methods. # # # # For the method insert, you'll be given a pair of (string, integer). The string represents the key and the integer represents the value. If the key already existed, then the original key-value pair will be overridden to the new ...
true
f7eb0bfd643b4d386350d8a220d768d734e2041b
vaibhavranjith/Heraizen_Training
/Assignment1/Q8.py
354
4.25
4
#registration problem (register only people above the age 18) name=input("Enter the name: \n") mbno=int(input("Enter the mobile number:\n")) age=int(input("Enter the age:\n")) if age<=18: print("Sorry! You need to be at least 18 years old to get membership.") else : print(f"Congratulations {name} for...
true
e563732e0c4613d96718dbe04f094fb26a4823da
Dionisiohenriq/Python-Learning
/alura_python/Filmes/playlist.py
1,182
4.1875
4
# herança é usada tanto para o reuso, quanto para absorver o polimorfismo(ducktyping), # herança pelo polimorfismo - atributos, métodos # herança pelo reuso de código e remoção de duplicação # herança = extensão # composição = conceito de 'tem um' ao invés de 'é um' # Classes abstract based classes - abc - obrigam a im...
false
bb3b04baf74550ea0cc12ff62e717d90fc2ceca7
hack-e-d/Rainfall_precipitation
/Script/prediction_analysis.py
1,567
4.5
4
# importing libraries import pandas as pd import numpy as np import sklearn as sk from sklearn.linear_model import LinearRegression import matplotlib.pyplot as plt # read the cleaned data data = pd.read_csv("austin_final.csv") # the features or the 'x' values of the data # these columns are used t...
true
e3187b055b6db5a497b94602820ac86b8671e637
rajagoah/Tableua_rep
/EmployeeAttritionDataExploration.py
2,105
4.125
4
import pandas as pd df = pd.read_csv("/Users/aakarsh.rajagopalan/Personal documents/Datasets for tableau/Tableau project dataset/WA_Fn-UseC_-HR-Employee-Attrition.csv") #printing the names of the columns print("names of the columns are:") print(df[:0]) #checking if there are nulls in the data #note that in pandas do...
true
2c25567847813a6b87ab0952612e89fad3123b66
EGleason217/python_stack
/_python/python_fundamentals/course_work.py
1,988
4.25
4
print("Hello World!") x = "Hello Python" print(x) y = 42 print(y) print("this is a sample string") name = "Zen" print("My name is", name) name = "Zen" print("My name is " + name) first_name = "Zen" last_name = "Coder" age = 27 print(f"My name is {first_name} {last_name} and I am {age} years old.") first_name = "Zen" la...
true
2a585f085a104e399c0a623e278a25642d8c0166
anthonytrevino/Monday
/objectsandclasses.py
1,870
4.15625
4
class Person(object): def __init__(self, name, email, phone): self.name = name self.email = email self.phone = phone self.friends =[] self.greeting_count = 0 def greet(self, other_person): self.greeting_count += 1 print("Hello {0}, I am {1}!".format (oth...
false
cdf54f108bf8e4d7b26613b3d6ac3dcac3083157
ColorfulCodes/ATM
/ATM .py
1,073
4.15625
4
# We will be creating a bank account class BankAccount(object): balance = 0 def __init__(self, name): self.name = name def __repr__(self): return "This account belongs to %s and has a balance of %.2f dollars." % (self.name, self.balance) def show_balance(self): print "Y...
true
dde5c4982b3a03e1c44d086a5a86924d91e83b1b
kylejablonski/Python-Learning
/conditionals.py
786
4.46875
4
print("Hello, World! This is a conditionals program test.") # prompts for a value and checks if its more or less than 100 maxValue = int(input("Please enter a value: ")) if maxValue > 100: print("The max value of {0} is greater than 100!".format(maxValue)) elif maxValue < 100: print("The max value of {0} is l...
true
ae8ee65d9527b2edfd5b393bb69d70016ddabede
Gafan154/MichaelGafan
/FactGood.py
483
4.1875
4
print("Factorial") def FactInput(): global num num=0 num = input("enter interger number: ") if not num.isdigit(): FactInput() def Fact(num): f=1 while num > 1: f=f*num num-=1 return(f) more='y' while more == 'y': FactInput() ...
false
33de7e691ca65a230c76d269d1ae6f5a9e6647eb
Lonabean98/pands-problem-sheet
/es.py
812
4.40625
4
#This program reads in a text #file and outputs the number of e's it contains. #It can also take the filename from an argument on the command line. #Author: Lonan Keane #The sys module provides functions and variables used to # manipulate different parts of the Python runtime environment. import sys # sys.argv retur...
true
028ef354ab87048c660f7c74c1d117f43b23b757
elimbaum/euler
/002/002.py
411
4.21875
4
#! /usr/bin/env python3.3 """ Project Euler problem 002 Even Fibonacci Numbers by Eli Baum 14 April 2013 """ print("Project Euler problem 002") print("Even Fibonacci Numbers") n = int(input("Upper Limit: ")) # Brute-Force calculate all of the fibonacci numbers a, b = 0, 1 sum = 0 while True: a, b = a + b, a i...
true
1f341dec6a19daad68ae3cd636a1d395d1c539dd
elimbaum/euler
/003/003.py
687
4.25
4
#! /usr/bin/env python3.3 """ Project Euler problem 003 Largest Prime Factor by Eli Baum 14 April 2013 """ from math import * print("Project Euler problem 003") print("Largest Prime Factor") n = float(input("n = ")) """ We only need to find ONE prime factor. Then we can divide, and factor that smaller number. ...
true
2aa4a954d83a4e6773947d6fef64ff41cc2f1986
keivanipchihagh/AUTHUB
/03/Data Structures and Algorithms/notes/codes/Merge Sort.py
1,045
4.28125
4
import random def merge_sort(array): # Return condition if len(array) <= 1: return # Find middle middle = len(array) // 2 # Find left hand left_side = array[:middle] # Find right hand right_side = array[middle:] # Sort first half merge_sort(left_side) # Sort se...
false
e05d23b8f68f0fcf422ce4a91f5aed4fdfa7630c
samiatunivr/NLPMLprojects
/linearRegression.py
1,821
4.53125
5
__author__ = 'samipc' from numpy import loadtxt def linearRegression(x_samples, y_labels): length = len(x_samples) sum_x = sum(x_samples) sum_y = sum(y_labels) sum_x_squared = sum(map(lambda a: a * a, x_samples)) sum_of_products = sum([x_samples[i] * y_labels[i] for i in range(length)]) a...
true
91f974b6597229fe3904f31e9ebc98b52e966a5d
timfornell/PythonTricksDigitalToolkit
/Lesson4.py
514
4.25
4
""" Lesson 4: Implicit returns """ # Python will automatically return None, all following functions will return the same value def foo1(value): if value: return value else: return None def foo2(value): """ Bare return statement implies 'return None'""" if value: return value ...
true
3f3ce30522dc34b97d1db423092598cf0d56ed80
ArnyWorld/Intro_Python
/8.-Condicionales.py
1,735
4.125
4
#Las condicionales nos permiten realizar una acción cuando se cumple cierta condición edad = 15 if edad >= 18: print('Eres mayor de edad') else: print('Eres menor de edad') experiencia = 3 if experiencia == 3: print('Tienes experiencia de 3 años') else: print('No tienes la experiencia solicitada') ...
false
5d54fac367fd107da96dbebc34f99ffa55188742
geeta-kriselva/python_excercise
/Prime_number.py
599
4.125
4
# Checking, if user input number is prime a number. if not printing all the facors. n= input("Enter the number: ") try: num = int(n) except: print("Enter only integer number") quit() if num > 1: factor = [] a = 0 for i in range(2,num+1): if (num % i) == 0: factor.insert(a,i) ...
true
38cebc4b8358782b77b27e9f46c0b76a17b24b17
JoseBalbuena181096/python_course
/lesson_10/adivina.py
1,699
4.125
4
from utilidades import logo from utilidades import limpiar_consola from random import randint from time import sleep VIDAS_FACIL = 10 VIDAS_DIFICIL = 5 def elegir_dificultad(): dificultad = input('¿Qué dificultad deseas?, F para fácil y D para difícil.\n').upper() if dificultad == 'F': return VIDAS_FA...
false
684a461578aa7a89a5d314b87c8ae225787e79ce
o8oo8o/Py_Design_Patterns
/factory.py
896
4.21875
4
#!/usr/bin/env python """ 抽象工厂模式 """ class PetShop: def __init__(self, animal_factory=None): self.pet_factory = animal_factory def show_pet(self): pet = self.pet_factory.get_pet() print("动物类型:", str(pet)) print("动物叫声:", pet.speak()) print("吃的东西:", self.pet_factory.ge...
false
9c33904e4f7aa5755bdc68499645da20d9c86902
MatiasToniolopy/condicionales_python
/profundizacion_2.py
1,990
4.1875
4
# Tipos de variables [Python] # Ejercicios de profundización # Autor: Inove Coding School # Version: 2.0 # NOTA: # Estos ejercicios son de mayor dificultad que los de clase y práctica. # Están pensados para aquellos con conocimientos previo o que dispongan # de mucho más tiempo para abordar estos temas por su cuenta...
false
bee70d6fa16e25998f08830db5669e8b260e93d7
DriesDD/python-workshop
/Examples/guess.py
1,237
4.21875
4
""" This uses the random module: https://www.w3schools.com/python/module_random.asp Exercises: 1. Can you make it a number between one and 100? Give more hints depending on whether the player is close or not? And change the number of guesses that the player can make? 2. Can you make the game into a function called sta...
true
554f0ccf1ca0bd3bd7da513e690f74fa1f170f4e
Rockforge/python_training
/exercise17.py
321
4.15625
4
# exercise17.py # Data type: tuple denominations = ('pesos', 'centavos') # denominations = ('pesos',) # this should be the syntax for one element tuples print(denominations) print(type(denominations)) print(denominations[1]) print('--- Entering loop ---') for denomination in denominations: print(denomination) ...
true
6c6341cf4989c57c420cf661aa26836f35a2f4f4
Leownhart/My_Course_of_python
/Geek University/Seção 5/Exercicios/EX21.py
1,121
4.25
4
''' 21 - Escreva o menu de opções abaixo. Leia a opção do usuário e execute a operação escolhida. Escreva uma mesagem de erro se a opção for inválida. Escolha a opção: 1 - Soma de 2 números. 2 - Diferença entre 2 números (maior pelo menor) 3 - Produto entre 2 números. 4 - Divisão ente 2 números (o denominador não pod...
false
ec9b8fac5dd0be6f60102c2eaebe615fbfb9a430
Leownhart/My_Course_of_python
/Geek University/Seção 4/tipo_float.py
390
4.125
4
""" Tipo Float -> Váriaveis com ponto flutuante """ # Errado valor = 1, 44 print(valor) # Certo so ponto de viata float valor = 1.44 print(valor) print(type(valor)) # É possivel realizar dupla atribuição valor1, valor2 = 1, 44 print(valor1) print(valor2) print(type(valor1)) print(type(valor2)) # Podemos converter u...
false
8ad662296e95222506e01a903b694aaddbde2b15
Leownhart/My_Course_of_python
/Geek University/Seção 6/entendendo_ranges.py
744
4.375
4
""" - Precisamos conhecer o loop for para utilizar o range. Ranges são utilizados para gerar sequências numéricas, não de forma aleatória, mas sim de maneira especifica. Formas gerais: # Forma 01 range(valor_de_parada) OBS: valor_de_parada não inclusive (inicio padrão 0, e passo de 1 em 1) # Forma 1 for num in ...
false
8e5c4b8fbcf49eb02931a653bbbba9d49be94611
tazi337/smartninjacourse
/Class2_Python3/example_00630_secret_number_exercise_1.py
771
4.21875
4
# Modify the secret number game code below such # that it shows the number of attempts # after each failed attempt # Modify the secret number game code below such # that it shows the number of attempts # after each failed attempt secret = "1" counter = 5 while counter > 0: counter -= 1 guess = input("guess ...
true
2f056da07759ce4b904eeb8fb3410261289aa87a
tazi337/smartninjacourse
/Class1_Python3/example_00300_operations_strings.py
962
4.40625
4
greeting = "Hello World!" name = "Smartninja!" # ADDING STRINGS (CONCAT) print(greeting) print(greeting + " - AI ") # MULTIPLYING STRINGS - das Beispiel hier erzeugt einen String mit 20 Sternchen print("*" * 20) # PRINTING THEM BY INSERTING print("Greeting: {}, Name: {}".format(greeting, name)) # new in Python 3: pr...
false
dae58627d930502a1a950949637285e6a1275921
mjftw/design-patterns
/example-design-patterns/iterator/iterator_example.py
240
4.40625
4
'''Trivially simple iterator example - python makes this very easy!''' def main(): a = 'a' b = 'b' c = 'c' iterable = [a, b, c] for element in iterable: print(element) if __name__ == '__main__': main()
true
a0f6ba8f4571e7eb2fa3db91f82fae617f8e7093
CC3688/studycode
/Python/lxf-paython/004pythonBasic.py
1,287
4.5
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @ CC3688 # email:442677028@qq.com #条件判断 #if age = 20 if age >= 18 : print('your age is',age) print('adult') #if else age = 10 if age >= 18 : print('your age is',age) print('adult') else: print('your age is',age) print('adult') #elif ---->else if py...
false
d0a2a502929ec839607ab88eb4fa6eca97141342
jkoppel/QuixBugs
/python_programs/sqrt.py
420
4.3125
4
def sqrt(x, epsilon): approx = x / 2 while abs(x - approx) > epsilon: approx = 0.5 * (approx + x / approx) return approx """ Square Root Newton-Raphson method implementation. Input: x: A float epsilon: A float Precondition: x >= 1 and epsilon > 0 Output: A float in the interva...
true
14857cf1f6d3397403c422ebad8994bc33848216
jkoppel/QuixBugs
/correct_python_programs/mergesort.py
2,389
4.15625
4
def mergesort(arr): def merge(left, right): result = [] i = 0 j = 0 while i < len(left) and j < len(right): if left[i] <= right[j]: result.append(left[i]) i += 1 else: result.append(right[j]) j +...
true
23bf4b2a12455334e5fb0ffa4fce75a11cdb2378
jkoppel/QuixBugs
/python_programs/hanoi.py
1,138
4.40625
4
def hanoi(height, start=1, end=3): steps = [] if height > 0: helper = ({1, 2, 3} - {start} - {end}).pop() steps.extend(hanoi(height - 1, start, helper)) steps.append((start, helper)) steps.extend(hanoi(height - 1, helper, end)) return steps """ Towers of Hanoi hanoi An a...
true
2069cdf48656121df91bcc30ffe95be6a01d0392
ksharonkamal/workshop
/day3/2.py
236
4.125
4
#program to sum all items in dictionary dict1 = {"tony" : 100 , "thor" : 200 , "peter" : 300 ,"strange" : 400} sum = 0 # for i in dict1.values(): # sum+=i for i in dict1: sum+=dict1[i] print("sum of items in dict1 is ",sum)
false
c0421854953fd6080d9eefc56fade47695ffa823
Raghumk/TestRepository
/Functions.py
1,076
4.46875
4
# Parameter functions is always pass by reference in Python def fun1( Name ): Name = "Mr." + Name return Name def fun2(Name = "Raghu"): Name = "Mr." + Name return Name print (fun1("Raghu")) print (fun1(Name="Kiran")) # Named argument print (fun2()) # Default argument #### Variable l...
true
661fe981ec3b27d9b9d4f5d36e30634bf642d196
Raghumk/TestRepository
/Tuples.py
310
4.40625
4
#Tuples are sequence of Immutable (unchangable) objects tup1= ('physics', 'chemistry', 1997, 2000) tup2 = (1, 2, 3, 4, 5 ) tup3 = "a", "b", "c", "d" print (tup1, "\n", tup2 , "\n" , tup3 ) # accessing tuple elements is same as accessing list element print (tup1[1]) # chemistry. del tup1
false
24851e56fd5704a5693657d13cee92004aa81d7c
kneesham/cmp_sci_4250
/Main.py
2,458
4.25
4
### # Name: Theodore Nesham # Project: 4 # Date: 11/02/2019 # Description: This project was used to show inheritance, polymorphism, and encapsulation. The parent class is Product # and the two children classes are Book and Movie. The two subclasses override the print_description # function sho...
true
c269df6a9e5ab28181e7073991e7fcd6756e1c6d
ahermassi/Spell-Checker
/src/trie/trie.py
1,712
4.125
4
from src.node.trie_node import TrieNode class Trie: def __init__(self): self.root = TrieNode() def __contains__(self, word): """ Returns if the word is in the trie. :type word: str :rtype: bool """ word = word.strip() root = self.root f...
true
580d41a8f9f430feaac5bdfbd8126afffa481d00
Tochi-kazi/Unit3-10
/calculate_average .py
358
4.15625
4
# Created by : Tochukwu Iroakazi # Created on : oct-2017 # Created for : ICS3UR-1 # Daily Assignment - Unit3-10 # This program displays average print('type in your score') userinput = input() counter = 0 numtotal = 0 for userinput in range (0,100): numtotal = numtotal + userinput counter = counter + 1 ...
true
70277b5371bcdb5190de68567903b4ed8aade82f
thomasdephuoc/bootcamp_python
/day_00/ex_03/count.py
651
4.4375
4
def text_analyzer(text=None): """This function counts the number of upper characters, lower characters, punctuation and spaces in a given text.""" if text is None: text = input("What is the text to analyse?") nb_char = sum(1 for c in text if c.isalpha()) nb_upper = sum(1 for c in text if c.isu...
true
c696337cda0492a06385ab26fdff89cf8de0aa8f
irene-yi/Classwork
/Music.py
2,108
4.28125
4
class Music: # if you pass in artists while calling your class # you need to add it to init def __init__(self, name, artists): self.name = name self.artists = artists self.friends = {} # Pushing information to the array def display(self): print() print ("Your artists:") for artists in self.artists: ...
true
c4a1f0448e9ce013071569c6e3710bec01261f46
paralaexperimentacion/experiment1
/red_day16.py
2,003
4.25
4
import turtle import random #setting up variables t = turtle #to make writing code easier t.speed(10) while True: #assigning random numbers to variables for number and color num = random.randint(10,40) r = random.randint(1,255) b = 0 g = 0 t.pd() #assigns color of turtle t.color(r, b, g) #keeps...
false
7c78cdd9a7c791a82adfe6e19f2f9e1a63f3a953
IronManCool001/Python
/Guess The Number/main.py
590
4.125
4
import random chances = 5 print("Welcome To Guess The Number Game") no = random.randint(0,256) run = True while run: guess = int(input("Enter your guess")) if guess == no: print("You Got It") run = False break elif guess > no: ...
true