blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
637260eab712b7cca3c5f0f9e058fcd3639ffa96
bqr407/PyIQ
/bubble.py
1,671
4.15625
4
class Bubble(): """Class for bubble objects""" def __init__(self, id, x, y, x2, y2, value): """each bubble object has these values associated with it""" self.x = x self.y = y self.x2 = x2 self.y2 = y2 self.id = id self.value = value def getX(self): ...
true
a72b8412d9b2ca109436ac39d7dc3dcc021a8d75
jsvn91/example_python
/eg/getting_max_from_str_eg.py
350
4.15625
4
# Q.24. In one line, show us how you’ll get the max alphabetical character from a string. # # For this, we’ll simply use the max function. # print (max('flyiNg')) # ‘y’ # # The following are the ASCII values for all the letters of this string- # # f- 102 # # l- 108 # # because y is greater amongst all y- 121 # # i- 105...
true
5935356da274001c362f979a7405c61f71cdef0b
Zhaokun1997/2020T1
/comp9321/labs/week2/activity_2.py
1,596
4.4375
4
import sqlite3 import pandas as pd from pandas.io import sql def read_csv(csv_file): """ :param csv_file: the path of csv file :return: a dataframe out of the csv file """ return pd.read_csv(csv_file) def write_in_sqlite(data_frame, database_file, table_name): """ :param data_frame: the ...
true
dc903ba5999763753228f8d9c2942718ddd3fe69
magicmitra/obsidian
/discrete.py
1,190
4.46875
4
#---------------------------------------------------------------------------------- # This is a function that will calculate the interest rate in a discrete manner. # Wirh this, interest is compounded k times a year and the bank will only add # interest to the pricipal k times a year. # The balance will then be return...
true
097a63c09d55dc17208b953b948229ccc960c751
Onyiee/DeitelExercisesInPython
/circle_area.py
486
4.4375
4
# 6.20 (Circle Area) Write an application that prompts the user for the radius of a circle and uses # a method called circleArea to calculate the area of the circle. def circle_area(r): pi = 3.142 area_of_circle = pi * r * r return area_of_circle if __name__ == '__main__': try: r = int(input...
true
bccd0d8074473316cc7eb69671929cf14ea5c1ac
Onyiee/DeitelExercisesInPython
/Modified_guess_number.py
1,472
4.1875
4
# 6.31 (Guess the Number Modification) Modify the program of Exercise 6.30 to count the number of guesses # the player makes. If the number is 10 or fewer, display Either you know the secret # or you got lucky! If the player guesses the number in 10 tries, display Aha! You know the secret! # If the player makes more th...
true
3b26b40c9619c6b0eee0a36096688aeb57819f10
Subharanjan-Sahoo/Practice-Questions
/Problem_34.py
810
4.15625
4
''' Single File Programming Question Your little brother has a math assignment to find whether the given number is a power of 2. If it is a power of 2 then he has to find the sum of the digits. If it is not a power of 2, then he has to find the next number which is a power of 2. He asks for your help to validate his w...
true
0bbb5802a3cfb9cd06a9a458bc77403689dad0ca
Subharanjan-Sahoo/Practice-Questions
/Problem_33.py
1,040
4.375
4
''' Write a program to calculate and return the sum of distances between the adjacent numbers in an array of positive integers Note: You are expected to write code in the find TotalDistance function only which will receive the first parameter as the number of items in the array and second parameter as the array itsel...
true
97c1bac183bf1c744eb4d1f05b6e0253b1455f10
Subharanjan-Sahoo/Practice-Questions
/Problem_13.py
733
4.21875
4
''' Write a function to find all the words in a string which are palindrome Note: A string is said to be a palindrome if the reverse of the string is the same as string. For example, "abba" is a palindrome, but "abbe" is not a palindrome. Input Specification: input1: string input2: Length of the String Output Spe...
true
d30504a329fd5bcb59a284b5e28b89b6d21107e3
lada8sztole/Bulochka-s-makom
/1_5_1.py
479
4.1875
4
# Task 1 # # Make a program that has some sentence (a string) on input and returns a dict containing # all unique words as keys and the number of occurrences as values. # a = 'Apple was sweet as apple' # b = a.split() a = input('enter the string ') def word_count(str): counts = dict() words = str.split() ...
true
cdc0c71ee2fd47586fca5c145f2c38905919cff5
lada8sztole/Bulochka-s-makom
/1_6_3.py
613
4.25
4
# Task 3 # # Words combination # # Create a program that reads an input string and then creates and prints 5 random strings from characters of the input string. # # For example, the program obtained the word ‘hello’, so it should print 5 random strings(words) # that combine characters ‘h’, ‘e’, ‘l’, ‘l’, ‘o’ -> ‘hlelo’...
true
5438b1928dc780927363d3d7622ca0d00247a5c2
malay190/Assignment_Solutions
/assignment9/ass9_5.py
599
4.28125
4
# Q.5- Create a class Expenditure and initialize it with expenditure,savings.Make the following methods. # 1. Display expenditure and savings # 2. Calculate total salary # 3. Display salary class expenditure: def __init__(self,expenditure,savings): self.expenditure=expenditure self.savings=savings def total_s...
true
72a8086b765c8036b7f30853e440550a020d7602
bradger68/daily_coding_problems
/dailycodingprob66.py
1,182
4.375
4
"""Assume you have access to a function toss_biased() which returns 0 or 1 with a probability that's not 50-50 (but also not 0-100 or 100-0). You do not know the bias of the coin. Write a function to simulate an unbiased coin toss. """ import random unknown_ratio_heads = random.randint(1,100) unknown_rati...
true
68c281e253778c4c3640a5c67d2e7948ca8e150a
farahhhag/Python-Projects
/Grade & Attendance Calculator (+Data Validation).py
2,363
4.21875
4
data_valid = False while data_valid == False: grade1 = input("Enter the first grade: ") try: grade1 = float(grade1) except: print("Invalid input. Only numbers are accepted. Decimals should be separated with a dot.") continue if grade1 <0 or grade1 > 10: print("...
true
c68084826badc09dd3f037098bfcfbccb712ee15
kayazdan/exercises
/chapter-5.2/ex-5-15.py
2,923
4.40625
4
# Programming Exercise 5-15 # # Program to find the average of five scores and output the scores and average with letter grade equivalents. # This program prompts a user for five numerical scores, # calculates their average, and assigns letter grades to each, # and outputs the list and average as a table on the sc...
true
ed61c43c7ab9b7ea26b890a00a08d2ed52ba3e47
kayazdan/exercises
/chapter-3/exercise-3-1.py
1,209
4.65625
5
# Programming Exercise 3-1 # # Program to display the name of a week day from its number. # This program prompts a user for the number (1 to 7) # and uses it to choose the name of a weekday # to display on the screen. # Variables to hold the day of the week and the name of the day. # Be sure to initialize the ...
true
77f27e01be7161901f28d68801d67c3d1e1e8c83
Nikola011s/portfolio
/work_with_menus.py
2,539
4.6875
5
#User enters n, and then n elements of the list #After entering elements of the list, show him options #1) Print the entire list #2) Add a new one to the list #3) Average odd from the whole list #4) The product of all elements that is divisible by 3 or by 4 #5) The largest element in the list #6) The sum...
true
ba564bd38231baac9bec825f4eaac669c00ff6a5
desingh9/PythonForBeginnersIntoCoding
/Day6_Only_Answers/Answer_Q2_If_Else.py
353
4.21875
4
#1.) Write a program to check whether a entered character is lowercase ( a to z ) or uppercase ( A to Z ). chr=(input("Enter Charactor:")) #A=chr(65,90) #for i in range(65,90) if (ord(chr) >=65) and (ord(chr)<=90): print("its a CAPITAL Letter") elif (ord(chr>=97) and ord(chr<=122)): print ("its a Small charect...
true
dea948a20c0c3e4ad252eb28988f2ae935e79046
desingh9/PythonForBeginnersIntoCoding
/Q4Mix_A1.py
776
4.28125
4
#1) Write a program to find All the missing numbers in a given integer array ? arr = [1, 2,5,,9,3,11,15] occurranceOfDigit=[] # finding max no so that , will create list will index till max no . max=arr[0] for no in arr: if no>max: max=no # adding all zeros [0] at all indexes till the maximum no in arra...
true
be06a70e1eef93540bb5837ae43220ae29d7d7fa
veetarag/Data-Structures-and-Algorithms-in-Python
/Interview Questions/Rotate Image.py
592
4.125
4
def rotate(matrix): l = len(matrix) for row in matrix: print(row) print() # Transpose the Matrix for i in range(l): for j in range(i, l): matrix[i][j], matrix[j][i] = matrix[j][i], matrix[i][j] for row in matrix: print(row) print() # Row Reverse ...
true
219d0100864e2e8b1777cb935a9b5e61ca52ef8a
osalpekar/RSA-Encrypter
/rsa.py
620
4.15625
4
''' Main function instantiates the Receiver class Calls encrypt and decrypt on user-inputted message ''' from receiver import Receiver def main(): message = raw_input("Enter a message you would like to encrypt/decrypt: ") receiver = Receiver() encrypted_message = receiver.encrypt(message) decrypted_me...
true
db6b22e0d6c051b508dbdff4cab4babcbd867c6e
ua-ants/webacad_python
/lesson01_old/hw/script3.py
485
4.15625
4
while True: print('To quit program enter "q"') val1 = input('Enter a first number: ') if val1 == 'q': break val2 = input('Enter a second number: ') if val2 == 'q': break try: val1 = int(val1) val2 = int(val2) except ValueError: print('one of entere...
true
96b4061196c3dc36646c9f3b88a004890db47edf
KostaSav/Tic-Tac-Toe
/console.py
1,231
4.1875
4
########## Imports ########## import config # Initialize the Game Board and print it in console board = [ [" ", "|", " ", "|", " "], ["-", "+", "-", "+", "-"], [" ", "|", " ", "|", " "], ["-", "+", "-", "+", "-"], [" ", "|", " ", "|", " "], ] ## Print the Game Board in console def print_board(): ...
true
c03e3f76b690c87b8939f726faeac5c0d6107b93
Anwar91-TechKnow/PythonPratice-Set2
/Swipe two numbers.py
1,648
4.4375
4
# ANWAR SHAIKH # Python program set2/001 # Title: Swipe two Numbers '''This is python progaramm where i am doing swapping of two number using two approches. 1. with hardcorded values 2. Values taken from user also in this i have added how to use temporary variable as well as without ...
true
981c2e7984813e752f26a37f85ca2bec74470b40
mon0theist/Automate-The-Boring-Stuff
/Chapter 04/commaCode2.py
1,183
4.375
4
# Ch 4 Practice Project - Comma Code # second attempt # # Say you have a list value like this: # spam = ['apples', 'bananas', 'tofu', 'cats'] # # Write a function that takes a list value as an argument and returns a string # with all the items separated by a comma and a space, with and inserted before # the last item. ...
true
3c2f7e0a16640fdb7e72795f10824fcce5370199
mon0theist/Automate-The-Boring-Stuff
/Chapter 07/strongPassword.py
1,249
4.375
4
#! /usr/bin/python3 # ATBS Chapter 7 Practice Project # Strong Password Detection # Write a function that uses regular expressions to make sure the password # string it is passed is strong. # A strong password has: # at least 8 chars - .{8,} # both uppercase and lowercase chars - [a-zA-Z] # test that BOTH exist, no...
true
cf1e3aa630ec34233b352168bd4b0818565883cb
sofianguy/skills-dictionaries
/test-find-common-items.py
1,040
4.5
4
def find_common_items(list1, list2): """Produce the set of common items in two lists. Given two lists, return a list of the common items shared between the lists. IMPORTANT: you may not not 'if ___ in ___' or the method 'index'. For example: >>> sorted(find_common_items([1, 2, 3, 4], [1,...
true
fbb4ce33a955eec2036211a7421950f027330a0b
l3ouu4n9/LeetCode
/algorithms/7. Reverse Integer.py
860
4.125
4
''' Given a 32-bit signed integer, reverse digits of an integer. E.g. Input: 123 Output: 321 Input: -123 Output: -321 Input: 120 Output: 21 Note: Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [−231, 231 − 1]. For the purpose of t...
true
4f85b8be417d4253520781c0f99e31af282d60b7
sjtrimble/pythonCardGame
/cardgame.py
2,811
4.21875
4
# basic card game for Coding Dojo Python OOP module # San Jose, CA # 2016-12-06 import random # to be used below in the Deck class function # Creating Card Class class Card(object): def __init__(self, value, suit): self.value = value self.suit = suit def show(self): print self.value +...
true
6e2fd2cc56821e6aeb9ac0beb5173a9d57c03f67
ericd9799/PythonPractice
/year100.py
421
4.125
4
#! /usr/bin/python3 import datetime now = datetime.datetime.now() year = now.year name = input("Please enter your name: ") age = int(input("Please enter your age: ")) yearsToHundred = 100 - age turnHundred = int(year) + yearsToHundred message = name + " will turn 100 in the year "+ str(turnHundred) print(message)...
true
1b6d711b5078871fca2de4fcf0a12fc0989f96e4
ericd9799/PythonPractice
/modCheck.py
497
4.125
4
#! /usr/bin/python3 modCheck = int(input("Please enter an integer: ")) if (modCheck % 4) == 0: print(str(modCheck) + " is a multiple of 4") elif (modCheck % 2) == 0: print(str(modCheck) + " is even") elif (modCheck % 2) != 0: print(str(modCheck) + " is odd") num, check = input("Enter 2 numbers:").split() num =...
true
4e8737d284c7cf01dea8dd82917e1fc787216219
EraSilv/day2
/day5_6_7/day7.py
879
4.125
4
# password = (input('Enter ur password:')) # if len(password) >= 8 and 8 > 0: # print('Correct! ') # print('Next----->:') # else: # print('Password must be more than 8!:') # print('Try again!') # print('Create a new account ') # login = input('login:') # email = input('Your e-mail:') # print('Choos...
true
3253b6843f4edd1047c567edc5a1d1973ead4b00
watson1227/Python-Beginner-Tutorials-YouTube-
/Funtions In Python.py
567
4.21875
4
# Functions In Python # Like in mathematics, where a function takes an argument and produces a result, it # does so in Python as well # The general form of a Python function is: # def function_name(arguments): # {lines telling the function what to do to produce the result} # return result # lets consid...
true
de12c3cb06a024c01510f0cf70e76721a80d506e
ytlty/coding_problems
/fibonacci_modified.py
1,049
4.125
4
''' A series is defined in the following manner: Given the nth and (n+1)th terms, the (n+2)th can be computed by the following relation Tn+2 = (Tn+1)2 + Tn So, if the first two terms of the series are 0 and 1: the third term = 12 + 0 = 1 fourth term = 12 + 1 = 2 fifth term = 22 + 1 = 5 ... And so on. Given thre...
true
f69783e7a620ca692a6b6213f16ef06b491b35e5
lily-liu-17/ICS3U-Assignment-7-Python-Concatenates
/concatenates.py
883
4.3125
4
#!/usr/bin/env python3 # Created by: Lily Liu # Created on: Oct 2021 # This program concatenates def concatenate(first_things, second_things): # this function concatenate two lists concatenated_list = [] # process for element in first_things: concatenated_list.append(element) for elemen...
true
2015152c0424d7b45235cefa678ea2cb90523132
ChiselD/guess-my-number
/app.py
401
4.125
4
import random secret_number = random.randint(1,101) guess = int(input("Guess what number I'm thinking of (between 1 and 100): ")) while guess != secret_number: if guess > secret_number: guess = int(input("Too high! Guess again: ")) if guess < secret_number: guess = int(input("Too low! Guess again: ")) if gues...
true
ae9e8ccfee70ada5d6f60a9e8a16f3c2204078ca
OmarSamehMahmoud/Python_Projects
/Pyramids/pyramids.py
381
4.15625
4
height = input("Please enter pyramid Hieght: ") height = int(height) row = 0 while row < height: NumOfSpace = height - row - 1 NumOfStars = ((row + 1) * 2) - 1 string = "" #Step 1: Get the spaces i = 0 while i < NumOfSpace: string = string + " " i += 1 #step 2: Get the stars i = 0 while i < NumOfStars...
true
b746c7e3d271187b42765b9bf9e748e79ba29eca
fortunesd/PYTHON-TUTORIAL
/loops.py
792
4.40625
4
# A for loop is used for iterating over a sequence (that is either a list, a tuple, a set, or a string). students = ['fortunes', 'abdul', 'obinaka', 'amos', 'ibrahim', 'zaniab'] # simple for loop for student in students: print(f'i am: {student}') #break for student in students: if student == 'odinaka': ...
true
6d3f673aad4128477625d3823e3cf8688fc89f2f
CollinNatterstad/RandomPasswordGenerator
/PasswordGenerator.py
814
4.15625
4
def main(): #importing necessary libraries. import random, string #getting user criteria for password length password_length = int(input("How many characters would you like your password to have? ")) #creating an empty list to store the password inside. password = [] ...
true
2b33a5ed96a8a8c320432581d71f2c46b2a3998a
laufzeitfehlernet/Learning_Python
/math/collatz.py
305
4.21875
4
### To calculate the Collatz conjecture start = int(input("Enter a integer to start the madness: ")) loop = 1 print(start) while start > 1: if (start % 2) == 0: start = int(start / 2) else: start = start * 3 + 1 loop+=1 print(start) print("It was in total", loop, "loops it it ends!")
true
dfa330f673a2b85151b1a06ca63c3c78214c722e
joq0033/ass_3_python
/with_design_pattern/abstract_factory.py
2,239
4.25
4
from abc import ABC, abstractmethod from PickleMaker import * from shelve import * class AbstractSerializerFactory(ABC): """ The Abstract Factory interface declares a set of methods that return different abstract products. These products are called a family and are related by a hi...
true
1af1818dfe2bfb1bab321c87786ab356f7cff2d4
rahulrsr/pythonStringManipulation
/reverse_sentence.py
241
4.25
4
def reverse_sentence(statement): stm=statement.split() rev_stm=stm[::-1] rev_stm=' '.join(rev_stm) return rev_stm if __name__ == '__main__': m=input("Enter the sentence to be reversed: ") print(reverse_sentence(m))
true
590419d3a0fa5cbf2b1d907359a22a0aa7fe92b5
kopelek/pycalc
/pycalc/stack.py
837
4.1875
4
#!/usr/bin/python3 class Stack(object): """ Implementation of the stack structure. """ def __init__(self): self._items = [] def clean(self): """ Removes all items. """ self._items = [] def push(self, item): """ Adds given item at the t...
true
289d459d9e0dda101f443edaa9bf65d2985b4949
YaraBader/python-applecation
/Ryans+Notes+Coding+Exercise+16+Calculate+a+Factorial.py
604
4.1875
4
''' Create a Factorial To solve this problem: 1. Create a function that will find the factorial for a value using a recursive function. Factorials are calculated as such 3! = 3 * 2 * 1 2. Expected Output Factorial of 4 = 24 Factorial at its recursive form is: X! = X * (X-1)! ''' # define the factorial function def fac...
true
84e848c7b3f7cd20142ce6326a8a5131b1ecacad
YaraBader/python-applecation
/Ryans+Notes+Coding+Exercise+8+Print+a+Christmas+Tree.py
1,956
4.34375
4
''' To solve this problem: Don't use the input function in this code 1. Assign a value of 5 to the variable tree_height 2. Print a tree like you saw in the video with 4 rows and a stump on the bottom TIP 1 You should use a while loop and 3 for loops. TIP 2 I know that this is the number of spaces and hashes for the tre...
true
20d2c16838f90918e89bfcf67d7c1f9210d6d39a
vaishu8747/Practise-Ass1
/1.py
231
4.34375
4
def longestWordLength(string): length=0 for word in string.split(): if(len(word)>length): length=len(word) return length string="I am an intern at geeksforgeeks" print(longestWordLength(string))
true
894abe59b869794b4a35903f04a750b1f9ee5788
brianbrake/Python
/ComputePay.py
834
4.3125
4
# Write a program to prompt the user for hours and rate per hour using raw_input to compute gross pay # Award time-and-a-half for the hourly rate for all hours worked above 40 hours # Put the logic to do the computation of time-and-a-half in a function called computepay() # Use 45 hours and a rate of 10.50 per hour to ...
true
6168ffa995d236e3882954d9057582a5c130763a
ghinks/epl-py-data-wrangler
/src/parsers/reader/reader.py
2,129
4.15625
4
import re import datetime class Reader: fileName = "" def __init__(self, fileName): self.fileName = fileName def convertTeamName(self, name): """convert string to upper case and strip spaces Take the given team name remove whitespace and convert to uppercase """ ...
true
3e0567d81aa20bf04a43d2959ae3fff8b71501ec
biam05/FPRO_MIEIC
/exercicios/RE05 Functions/sumNumbers.py
955
4.34375
4
# -*- coding: utf-8 -*- """ Created on Wed Oct 24 11:47:09 2018 @author: biam05 """ # # DESCRIPTION of exercise 2: # # Write a Python function sum_numbers(n) that returns the sum of all positive # integers up to and including n. # # For example: sum_numbers(10) returns the value 55 (1+2+3+. . . +10) # # Do N...
true
c0994074084e337bba081ca44c37d2d4d8553f8f
xtom0369/python-learning
/task/Learn Python The Hard Way/task33/ex33_py3.py
368
4.15625
4
space_number = int(input("Input a space number : ")) max_number = int(input("Input a max number : ")) i = 0 numbers = [] while i < max_number: print(f"At the top i is {i}") numbers.append(i) i = i + space_number print("Numbers now: ", numbers) print(f"At the bottom i is {i}") print("The ...
true
27d0745e6199185dc5b1fb8d9739b2d0226fd606
letaniaferreira/guessinggame
/game.py
1,554
4.1875
4
"""A number-guessing game.""" # greet player # get player name # choose random number between 1 and 100 # repeat forever: # get guess # if guess is incorrect: # give hint # increase number of guesses # else: # congratulate player import random name = raw_input("Welcome, what is yo...
true
1532020913bb3d12e049d871a9d544fb0d5f4abc
KD4/TIL
/Algorithm/merge_two_sorted_lists.py
1,227
4.1875
4
# Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. # splice 꼬아 잇다 # 주어준 링크드리스트 두 개를 하나의 리스트로 만들어라. 두 리스트의 노드들을 꼬아서 만들어야한다. # Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x ...
true
b6364e51af1472c1eec2b3bef4e9aa5d68f4e2e4
CHuber00/Simulation
/Sprint-1-Python_and_Descriptive_Statistics/Deliverables/MoreCalculations.py
2,014
4.25
4
""" Christian Huber CMS 380, Fall 2020 / Sprint 1 / MoreCalculations This script reads a text file's values and calculates and prints the mean, median, variance, and standard deviation. """ from math import sqrt import matplotlib matplotlib.use("Agg") from matplotlib import pyplot as plt def mean(x): ...
true
0779044e55eb618e79e6cc91c7d8d59e614713dc
yamiau/Courses
/[Udemy] Web Scraping with Python - BeautifulSoup, Requests, Selenium/00 Data Structures Refresher/List Comprehension 2.py
777
4.21875
4
'''Nested lists''' carts = [['toothpaste', 'soap', 'toilet paper'], ['meat', 'fruit', 'cereal'], ['pencil', 'notebook', 'eraser']] #or person1 = ['toothpaste', 'soap', 'toilet paper'] person2 = ['meat', 'fruit', 'cereal'] person3 = ['pencil', 'notebook', 'eraser'] carts = [person1, person2, person3] print(carts) fo...
true
16ab5543da15a3db9c80b7526c55e3745eadf2af
lithiumspiral/python
/calculator.py
1,196
4.25
4
import math print('This calculator requires you to enter a function and a number') print('The functions are as follows:') print('S - sine') print('C - cosine') print('T - tangent') print('R - square root') print('N - natural log') print('X 0- eXit the program') f, v = input("Please enter a function and a value ").spl...
true
d508ae43c03ea8337d2d5dcfeb3ccfc75555df4d
Emma-2016/introduction-to-computer-science-and-programming
/lecture15.py
1,958
4.34375
4
# Class - template to create instance of object. # Instance has some internal attributes. class cartesianPoint: pass cp1 = cartesianPoint() cp2 = cartesianPoint() cp1.x = 1.0 cp2.x = 1.0 cp1.y = 2.0 cp2.y = 3.0 def samePoint(p1, p2): return (p1.x == p2.x) and (p1.y == p2.y) def printPoint(p): print '(' + ...
true
00ce7ddd2e3fe18691908492ddd2de4ebde05559
ckceddie/OOP
/OOP_Bike.py
878
4.25
4
# OOP Bike # define the Bike class class bike(object): def __init__ (self , price , max_speed): self.price = price self.max_speed = max_speed self.miles = 0 def displayInfo(self): print "bike's price is " + str(self.price) print "maximum speed : " + str(self.max_speed...
true
6604cf3f68749b72d0eeb22a76e03075d2b87a02
jkbstepien/ASD-2021
/graphs/cycle_graph_adj_list.py
1,087
4.125
4
def cycle_util(graph, v, visited, parent): """ Utility function for cycle. :param graph: representation of a graph as adjacency list. :param v: current vertex. :param visited: list of visited vertexes. :param parent: list of vertexes' parents. :return: boolean value for cycle function. "...
true
5512e04c4832ad7b74e6a0ae7d3151643747dd8c
anmolparida/selenium_python
/CorePython/DataTypes/Dictionary/DictionaryMethods.py
1,181
4.28125
4
d = {'A': 1, 'B' : 2} print(d) print(d.items()) print(d.keys()) print(d.values()) print(d.get('A')) print(d['A']) # empty dictionary my_dict = {} # dictionary with integer keys my_dict = {1: 'apple', 2: 'ball'} print(my_dict) # dictionary with mixed keys my_dict = {'name': 'John', 1: [2, 4, 3]} print(my_dict) # us...
true
946d183421857c5896636eac5dcaa797091cb87a
aboyington/cs50x2021
/week6/pset6/mario/more/mario.py
480
4.15625
4
from cs50 import get_int def get_height(min=1, max=8): """Prompt user for height value.""" while True: height = get_int("Height: ") if height >= min and height <= max: return height def print_pyramid(n): """Print n height of half-pyramid to console.""" for i in range(1, n...
true
2b233d93ef2101f8833bbff948682add348fde63
djanibekov/algorithms_py
/inversion_counting.py
2,025
4.21875
4
inversion_count = 0 def inversion_counter_conquer(first, second): """[This function counts #inversions while merging two lists/arrays ] Args: first ([list]): [left unsorted half] second ([list]): [right unsorted half] Returns: [tuple]: [(first: merged list of left and right halves...
true
63ca4f68c05708f2482045d06775fa5d7d22ea55
loudan-arc/schafertuts
/conds.py
1,574
4.1875
4
#unlike with other programming languages that require parentheses () #python does not need it for if-else statements, but it works with it fake = False empty = None stmt = 0 f = 69 k = 420 hz = [60, 75, 90, 120, 144, 240, 360] if k > f: print(f"no parentheses if condition: {k} > {f}") if (k > f): ...
true
4afceabb3673acbe934061dd9888d06e0457a152
dark5eid83/algos
/Easy/palindrome_check.py
330
4.25
4
# Write a function that takes in a non-empty string that returns a boolean representing # whether or not the string is a palindrome. # Sample input: "abcdcba" # Sample output: True def isPalindrome(string, i=0): j = len(string) - 1 - i return True if i >= j else string[i] == string[j] and isPalindrome(stri...
true
7ce3fe03de726250fbad7573e0f6a12afa5fcc4a
AshishKadam2666/Daisy
/swap.py
219
4.125
4
# Taking user inputs: x = 20 y = 10 # creating a temporary variable to swap the values temp = x x = y y = temp print('The value of x after swapping: {}'.format(x)) print('The value of y after swapping: {}'.format(y))
true
bb155d4d67a7611506849ea6160074b6fec2d01f
kalpitthakkar/daily-coding
/problems/Jane_Street/P5_consCarCdr.py
1,420
4.125
4
def cons(a, b): def pair(f): return f(a, b) return pair class Problem5(object): def __init__(self, name): self.name = name # The whole idea of this problem is functional programming. # Use the function cons(a, b) to understand the functional # interface requir...
true
84f2c41dd849d194eb1bbdbb5abc97ae9f05bfcd
trishajjohnson/python-ds-practice
/fs_1_is_odd_string/is_odd_string.py
974
4.21875
4
def is_odd_string(word): """Is the sum of the character-positions odd? Word is a simple word of uppercase/lowercase letters without punctuation. For each character, find it's "character position" ("a"=1, "b"=2, etc). Return True/False, depending on whether sum of those numbers is odd. For example...
true
1991e34b3272b9374e485fb49abe10f2adfb7b3b
smirnoffmg/codeforces
/519B.py
303
4.15625
4
# -*- coding: utf-8 -*- n = int(raw_input()) first_row = map(int, raw_input().split(' ')) second_row = map(int, raw_input().split(' ')) third_row = map(int, raw_input().split(' ')) print [item for item in first_row if item not in second_row] print [item for item in second_row if item not in third_row]
true
42e25fed3a11b28f2bd4eb5070ce2ff7034eeda1
sanapplegates/Python_qxf2_exercises
/bmi.py
288
4.28125
4
#calculate the bmi of user #user height in kg print("Enter the user's weight(kg):") weight = int(input()) #user height in metres print("Enter the user's height(metre) :") height = int(input()) #Body Mass Index of user bmi = weight/(height*height) print("bmi of user:",bmi)
true
b88a715b7625b1b27f47e9cb6098e00e8e616f7e
lexruee/project-euler
/problem_9.py
326
4.125
4
# -*- coding: utf-8 -*- """ A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, a2 + b2 = c2 For example, 32 + 42 = 9 + 16 = 25 = 52. There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product abc """ def main(): #TODO pass if __name__ == '__main__':...
true
91e717e2422ba6a54dcfef0de4292846b9fd1832
Laavanya-Agarwal/Python-C2
/Making functions/countWords.py
271
4.3125
4
def countWords(): fileName = input('Enter the File Name') file = open(fileName, 'r') noOfWords = 0 for line in file: words = line.split() noOfWords = noOfWords + len(words) print('The number of words is ' + str(noOfWords)) countWords()
true
3c54aa7bc9815de81888d9b40085067fa1cf218a
keryl/2017-03-24
/even_number.py
467
4.25
4
def even_num(l): # first, we will ensure l is of type "list" if type(l) != list: return "argument passed is not a list of numbers" # secondly, check l is a list of numbers only for n in l: if not (type(n) == int or type(n) == float): return "some elements in your list are...
true
8bd5806dd9b01c9eb90592e7239e8662ae9f1af5
danny237/Python-Assignment3
/insertion_sort.py
541
4.1875
4
"""Insertion Sort""" def insertion_sort(list1): """function for insertion sort""" for i in range(1, len(list1)): key = list1[i] j = i-1 while j >=0 and key < list1[j] : list1[j+1] = list1[j] j -= 1 list1[j+1] = key return lis...
true
adfba4e45bc9ec9707eeda09767bfde152600426
reachtoakhtar/data-structure
/tree/problems/binary_tree/diameter.py
776
4.125
4
__author__ = "akhtar" def height(root, ans): if root is None: return 0 left_height = height(root.left, ans) right_height = height(root.right, ans) # update the answer, because diameter of a tree is nothing but maximum # value of (left_height + right_height + 1) for each node ...
true
7915e90dd431cedcd1820486783a299df813b0b9
SoumyaMalgonde/AlgoBook
/python/sorting/selection_sort.py
654
4.21875
4
#coding: utf-8 def minimum(array, index): length = len(array) minimum_index = index for j in range(index, length): if array[minimum_index] > array[j]: minimum_index = j return minimum_index def selection_sort(array): length = len(array) for i in range(length - 1): ...
true
3b68f1f217fd64cc0428e93fbfe17745c664cb2e
SoumyaMalgonde/AlgoBook
/python/maths/jaccard.py
374
4.1875
4
a = set() b = set() m = int(input("Enter number elements in set 1: ")) n = int(input("Enter number elements in set 2: ")) print("Enter elements of set 1: ") for i in range(m): a.add(input()) print("Enter elements of set 2: ") for i in range(n): b.add(input()) similarity = len(a.intersection(b))/len(a.union...
true
df7feb3e68df6d0434ed16f02ce3fcf0fd1dbf99
SoumyaMalgonde/AlgoBook
/python/maths/Volume of 3D shapes.py
2,970
4.1875
4
import math print("*****Volume of the Cube*****\n") side=float(input("Enter the edge of the cube ")) volume = side**3 print("Volume of the cube of side = ",side," is " ,volume,) print("\n*****Volume of Cuboid*****\n") length=float(input("Enter the length of the cuboid ")) breadth=float(input("Enter the breadth of the...
true
bb114c561547aa3adbcf855e3e3985e08c748a01
SoumyaMalgonde/AlgoBook
/python/sorting/Recursive_quick_sort.py
834
4.1875
4
def quick_sort(arr, l, r): # arr[l:r] if r - l <= 1: # base case return () # partition w.r.t pivot - arr[l] # dividing array into three parts one pivot # one yellow part which contains elements less than pivot # and last green part which contains elements greater than pivot yellow = l +...
true
edb2d3e1a9f09ce94933b8b223af17dda52143a3
SunshinePalahang/Assignment-5
/prog2.py
327
4.15625
4
def min_of_3(): a = int(input("First number: ")) b = int(input("Second number: ")) c = int(input("Third number: ")) if a < b and a < c: min = a elif b < a and b < c: min = b else: min = c return min minimum = min_of_3() print(f"The lowest of the 3 numbers is {min...
true
34a2bfbe98dfb42c1f3d2a8f444da8e49ca04639
PaxMax1/School-Work
/fbi.py
1,610
4.25
4
# a322_electricity_trends.py # This program uses the pandas module to load a 3-dimensional data sheet into a pandas DataFrame object # Then it will use the matplotlib module to plot comparative line graphs import matplotlib.pyplot as plt import pandas as pd # choose countries of interest my_countries = ['United Stat...
true
c275468117aa43e59ac27afd391e463d0983a979
gevishahari/mesmerised-world
/integersopr.py
230
4.125
4
x=int(input("enter the value of x")) y=int(input("enter the value of y")) if(x>y): print("x is the largest number") if(y>x): print("y is the largest number") if (x==y): print("x is equal to y") print("they are equal")
true
d76dfe561f9111effed1b82da602bf6df98f2405
AdmireKhulumo/Caroline
/stack.py
2,278
4.15625
4
# a manual implementation of a stack using a list # specifically used for strings from typing import List class Stack: # initialise list to hold items def __init__(self): # initialise stack variable self.stack: List[str] = [] # define a property for the stack -- works as a getter @pro...
true
71021e7cf21f47c13df7be87afe4e169eb945ab5
jessicazhuofanzh/Jessica-Zhuofan--Zhang
/assignment1.py
1,535
4.21875
4
#assignment 1 myComputer = { "brand": "Apple", "color": "Grey", "size": 15.4, "language": "English" } print(myComputer) myBag = { "color": "Black", "brand": "MM6", "bagWidth": 22, "bagHeight": 42 } print(myBag) myApartment = { "location": "New York City", "type": "s...
true
15774b26dae087e6ec683e676046c29d2009b904
devimonica/Python-exercises---Mosh-Hamedani-YT-
/4.py
490
4.5
4
# Write a function called showNumbers that takes a parameter called limit. It should # print all the numbers between 0 and limit with a label to identify the even and odd numbers. For example, # if the limit is 3, it should print: # 0 EVEN # 1 ODD # 2 EVEN # 3 ODD # Solution: def showNumbers(limit)...
true
d5d3b540482b581ad95e5a4d4ab4e8dbcc1280fd
gninoshev/SQLite_Databases_With_Python
/delete_records.py
411
4.1875
4
import sqlite3 # Connect to database conn = sqlite3.connect("customer.db") # Create a cursor c = conn.cursor() # Order By Database - Order BY c.execute("SELECT rowid,* FROM customers ORDER BY rowid ") # Order Descending c.execute("SELECT rowid,* FROM customers ORDER BY rowid DESC") items = c.fetc...
true
5a0637856f9dddcb3d6667340def81e831361c7d
kaloyansabchev/Programming-Basics-with-Python
/PB Exam - 20 and 21 February 2021/03. Computer Room.py
755
4.25
4
month = input() hours = int(input()) people_in_group = int(input()) time_of_the_day = input() per_hour = 0 if month == "march" or month == "april" or month == "may": if time_of_the_day == "day": per_hour = 10.50 elif time_of_the_day == "night": per_hour = 8.40 elif month == "june" or month == ...
true
bb2ff59d2062a5b6ab007782f05653c2fd7fb1c1
Ramya74/ERP-projects
/Employee.py
1,296
4.25
4
employees = [] #empty List while True: print("1. Add employee") print("2. Delete employee") print("3. Search employee") print("4. Display all employee") print("5. Change a employee name in the list") print("6. exit") ch = int(input("Enter your choice: ")) if ch is None: print("no data present in Employees")...
true
5491efb3841bc753f8de6fff6b0f5233c132a805
saubhagyav/100_Days_Code_Challenge
/DAYS/Day22/Remove_Duplicates_in_Dictionary.py
364
4.21875
4
def Remove_Duplicates(Test_string): Test_list = [] for elements in Test_string.split(" "): if ((Test_string.count(elements) > 1 or Test_string.count(elements) == 1) and elements not in Test_list): Test_list.append(elements) return Test_list Test_string = input("Enter a String: ...
true
f2f47ab9d8e116d43c619e88b3db0807b4d658f9
saubhagyav/100_Days_Code_Challenge
/DAYS/Day10/String_Palindrome.py
203
4.1875
4
def Palindrome(Test_String): if Test_String == Test_String[::-1]: return True else: return False Test_String = input("Enter a String: ") print(Palindrome(Test_String))
true
bb1a8090d3fc97546339037bbc0e9b06ff43b438
3point14guy/Interactive-Python
/strings/count_e.py
1,153
4.34375
4
# Assign to a variable in your program a triple-quoted string that contains your favorite paragraph of text - perhaps a poem, a speech, instructions to bake a cake, some inspirational verses, etc. # # Write a function that counts the number of alphabetic characters (a through z, or A through Z) in your text and then k...
true
11992691b92d6d74aa41fe6797f70f810ea3bfb9
3point14guy/Interactive-Python
/tkinter/hello_world_tkinter.py
1,249
4.15625
4
import tkinter as tk from tkinter import ttk from tkinter import messagebox from tkinter import simpledialog window = tk.Tk() # my_label = ttk.Label(window, text="Hello World!") # my_label.grid(row=1, column=1) # messagebox.showinfo("Information", "Information Message") # messagebox.showerror("Error", "My error mess...
true
da34092f0d87be4f33072a3e2df047652fb29cf3
sudj/24-Exam3-201920
/src/problem2.py
2,658
4.125
4
""" Exam 3, problem 2. Authors: Vibha Alangar, Aaron Wilkin, David Mutchler, Dave Fisher, Matt Boutell, Amanda Stouder, their colleagues and Daniel Su. January 2019. """ # DONE: 1. PUT YOUR NAME IN THE ABOVE LINE. def main(): """ Calls the TEST functions in this module. """ run_tes...
true
b2e763e72dd93b471294f997d2c18ab041ad665c
Evanc123/interview_prep
/gainlo/3sum.py
1,274
4.375
4
''' Determine if any 3 integers in an array sum to 0. For example, for array [4, 3, -1, 2, -2, 10], the function should return true since 3 + (-1) + (-2) = 0. To make things simple, each number can be used at most once. ''' ''' 1. Naive Solution is to test every 3 numbers to test if it is zero 2. is it possible to c...
true
5ebd4c91bd2fd1b34fbfdcff3198aef77ceb8612
CrazyCoder4Carrot/lintcode
/python/Insert Node in a Binary Search Tree.py
1,676
4.25
4
""" Definition of TreeNode: class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None """ """ Revursive version """ class Solution: """ @param root: The root of the binary search tree. @param node: insert this node into the binary search tree. @return...
true
0046fd9fa359ebfaa81b7fb40ecf2c5f6d278273
sfagnon/stephane_fagnon_test
/QuestionA/QaMethods.py
1,120
4.21875
4
#!/usr/bin/python # -*- coding: utf-8 -*- #Verify if the two positions provided form a line def isLineValid(line_X1,line_X2): answer = True if(line_X1 == line_X2): answer = False print("Points coordinates must be different from each other to form a line") return answer #Verify i...
true
1916ef020df5cb454e7887d2d4bb051d308887e3
sammysun0711/data_structures_fundamental
/week1/tree_height/tree_height.py
2,341
4.15625
4
# python3 import sys import threading # final solution """ Compute height of a given tree Height of a (rooted) tree is the maximum depth of a node, or the maximum distance from a leaf to the root. """ class TreeHeight: def __init__(self, nodes): self.num = len(nodes) self.parent = nodes ...
true
7cafa9fc6b348af6d2f11ad8771c5cca59b1bea7
irina-baeva/algorithms-with-python
/data-structure/stack.py
1,702
4.15625
4
'''Imlementing stack based on linked list''' class Element(object): def __init__(self, value): self.value = value self.next = None class LinkedList(object): def __init__(self, head=None): self.head = head def append(self, new_element): current = self.head ...
true
01ece2001beaf028b52be310a8f1df24858f4e59
amitesh1201/Python_30Days
/OldPrgms/Day3_prc05.py
579
4.375
4
# Basic String Processing : four important options: lower, upper, capitalize, and title. # In order to use these methods, we just need to use the dot notation again, just like with format. print("Hello, World!".lower()) # "hello, world!" print("Hello, World!".upper()) # "HELLO, WORLD!" print("...
true
b9151241f8234f5c1f038c733a5d0ff46da376d3
louishuynh/patterns
/observer/observer3.py
2,260
4.15625
4
""" Source: https://www.youtube.com/watch?v=87MNuBgeg34 We can have observable that can notify one group of subscribers for one kind of situation. Notify a different group of subscribers for different kind of situation. We can have the same subscribers in both groups. We call these situations events (different kinds o...
true
e2ef440e9f140b93cb1adc8bf478baf2beae8fa3
timmichanga13/python
/fundamentals/oop/demo/oop_notes.py
1,389
4.25
4
# Encapsulation is the idea that an instance of the class is responsible for its own data # I have a bank account, teller verifies account info, makes withdrawal from acct # I can't just reach over and take money from the drawer # Inheritance allows us to pass attributes and methods from parents to children # Vehicles...
true
95eaa4c8b527c0ac22bbd95dcfc30dad1fc836ad
notwhale/devops-school-3
/Python/Homework/hw09/problem6.py
973
4.1875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Решить несколько задач из projecteuler.net Решения должны быть максимально лаконичными, и использовать list comprehensions. problem6 - list comprehension : one line problem9 - list comprehension : one line problem40 - list comprehension problem48 - list comprehensio...
true