blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
aa894da9a10e60a2de42056c4c9be3733f1631fb
meltedfork/Python-1
/Python Assignments/dictionary_basics/dictionary_basics.py
287
4.15625
4
def my_dict(): about = { "Name": "Nick", "Age": "31", "Country of birth": "United States", "Favorite Language": "Italian" } # print about.items() for key,data in about.iteritems(): print "My", key, "is", data my_dict()
true
3bed285f835cc5e500ae14e0daaa9d738a53efcf
TamizhselvanR/TCS
/alternative_series.py
967
4.25
4
''' For Example, consider the given series: 1, 2, 1, 3, 2, 5, 3, 7, 5, 11, 8, 13, 13, 17, … This series is a mixture of 2 series – all the odd terms in this series form a Fibonacci series and all the even terms are the prime numbers in ascending order. Now write a program to find the Nth term in this series. ''' d...
true
7d6a397767236554fe50d29a043682d9ac471a6c
ddilarakarakas/Introduction-to-Algorithms-and-Design
/HW3/q4.py
1,373
4.21875
4
import random swap_quicksort=0 swap_insertion=0 def quick_sort(array, low, high): if low<high: pivot = rearrange(array, low, high) quick_sort(array, low, pivot - 1) quick_sort(array, pivot + 1, high) def rearrange(array,low,high): global swap_quicksort p = array[high] left = l...
true
fa6192cee5ee11b819b8037ad641333ded8f9422
Bpara001/Python_Assgn
/03 Functions/varargs_start.py
445
4.1875
4
# Demonstrate the use of variable argument lists # TODO: define a function that takes variable arguments def addition(*args): result = 0 for arg in args: result +=arg return result def main(): # TODO: pass different arguments print(addition(5,10,20,30)) print(addition(1,2,3)) # T...
true
504e64c3d0be1d03c044c54594c9af6785539da2
samsnarrl22/Beginner-Projects
/Song Variables.py
1,116
4.28125
4
# Storing attributes about a song in Variables # First create variables for each of the characteristics that make up a song title = "Ring of Fire" artist = "Jonny Cash" # These variables are strings which can be seen due to the "" album = "The Best of Johnny Cash" genre = "Country" time_in_seconds = 163 # time_in_se...
true
88812cfba755cc4b06a8724ea3def8d51f18dd68
JinHoChoi0104/Python_Study
/Inflearn/chapter05_02.py
850
4.21875
4
# Chapter05-02 # 파이썬 사용자 입력 # Input 사용법 # 기본 타입(str) # ex1 # name = input("Enter Your Name: ") # grade = input("Enter Your Grade: ") # company = input("Enter Your Company name: ") # print(name, grade, company) # ex2 # number = input("Enter number: ") # name = input("Enter name: ") # print("type of number", type(num...
true
9eb1e8456b09fc34a2d11c5c41c63d85704cc70c
JoyP7/BasicPythonProjects
/rock_paper_scissors.py
1,408
4.28125
4
from random import randint #create a list of play options t = ["Rock", "Paper", "Scissors"] #assign a random play to the computer computer = t[randint(0,2)] #set player to False player = False p_score = 0 c_score = 0 #here is the game while player == False: #case of Tie player = input("Rock, Paper, or Sciss...
true
b0652b6f3148c4213d754423c27d40276ef4baab
ddtriz/Python-Classes-Tutorial
/main.py
1,223
4.375
4
#BASIC KNOWLDEGE ABOUT CLASSES #What is a class? class firstClass():#Determine a class in the code by using [class] name = "" identification = 0 print ("hello") firstClass.name = "John" firstClass.identification = 326536123 #If you print the firstClass you'll get something like <class '__main__.firstCla...
true
f7f462a0cc00c3d68b8d0a5bd282151eea24fb9a
ECastro10/Assignments
/rock_paper_scissors_looped.py
2,085
4.125
4
#import random and computer signs list import random signchoices = ["rock", "paper", "scissors"] player1_score = 0 comp_score = 0 game = 0 while game < 3: hand1 = input("Enter rock, paper, or scissors Player1 > ").lower() compSign = random.choice(signchoices) print("Computer chooses " + compSign) i...
true
150747e7e7b6a368e0ac7af28d4a4d10358acdbb
mohitsharma2/Python
/Book_program/max_using_if.py
413
4.59375
5
# Program to accept three integers and print the largest of the three.Make use of only if statement. x=float(input("Enter First number:")) y=float(input("Enter Second number:")) z=float(input("Enter Third number:")) max=x if y>max: max=y if z >max: max=z print("Largest number is:",max) """ output===> Ent...
true
d2db2c0608a6ad6ca1f9c423c55ec4aeffef3939
mohitsharma2/Python
/Book_program/divisor.py
1,068
4.28125
4
#program to find the multiles of a number(divisor) out of given five number. print("Enter the five number below") num1=float(input("Enter first number:")) num2=float(input("Enter second number:")) num3=float(input("Enter third number:")) num4=float(input("Enter fourth number:")) num5=float(input("Enter fifth...
true
e8fc3a72648cfd8d9b857012a27031e7a08b8357
mohitsharma2/Python
/Blackjack.py
1,629
4.3125
4
""" Name: Blackjack Filename: Blackjack.py Problem Statement: Play a game that draws two random cards. The player then decides to draw or stick. If the score goes over 21 the player loses (goes ‘bust’). Keep drawing until the player sticks. After the player sticks draw two computer...
true
3817d594c6261e8d7a51bd820a4c0ed2bfe36dd0
mohitsharma2/Python
/Book_program/sqrt.py
930
4.25
4
# program to calculate and print roots of a quadratic equcation : ax^2 + bx + c=0 (a!=0) import math print("for quadratic equcation : ax^2 + bx + c=0,enter cofficient below:") a=int(input("Enter a:")) b=int(input("Enter b:")) c=int(input("Enter c:")) if a==0: print("Value of 'a' should not be zero.") prin...
true
0f1f74514cd78b6f952e24f923975d82a18e1260
mohitsharma2/Python
/Book_program/identify_character.py
474
4.3125
4
""" program to print whether a given character is an uppercase or a lowercase character or a digit or any other special character. """ inp1=input("Enter the Character:") if inp1>='A' and inp1<="Z" : print("You entered upper case character.") elif inp1>='a' and inp1<='z' : print("You entered lower case c...
true
260ea2d6275282bb8ecc34d2488bbdca52459a45
mohitsharma2/Python
/gravity_cal.py
224
4.21875
4
# Gravity Calculator Acceleration=float(input('enter the Acceleration in m/s^2')) Time=float(input('enter the time in seconds ')) distance=(Acceleration*Time*Time )/ 2 print('object after falling for 10 seconds=',distance)
true
2c894119b5321d953fa1346d722d42f190de8c38
alexdavidkim/Python3-Notes
/numeric_types/booleans.py
2,949
4.53125
5
# All objects in Python have a Truthyness or Falsyness. All objects are True except: # None # False # 0 # Empty sequences (list, tuple, string, etc) # Empty mapping types (dictionary, set, etc) # Custom classes that implement a __bool__ or __len__ that returns False or 0 # Therefore, every built...
true
629d204d76e6545d713ec221aebff2c8bd627a6a
cstarr7/daily_programmer
/hard_2.py
1,852
4.28125
4
# -*- coding: utf-8 -*- # @Author: Charles Starr # @Date: 2016-03-08 23:51:13 # @Last Modified by: Charles Starr # @Last Modified time: 2016-03-09 00:14:55 #Your mission is to create a stopwatch program. #this program should have start, stop, and lap options, #and it should write out to a file to be viewed later...
true
a388858021542a586073ae6f0cea563423bedd17
cstarr7/daily_programmer
/easy_267.py
1,223
4.28125
4
# -*- coding: utf-8 -*- # @Author: Charles Starr # @Date: 2016-07-06 23:20:28 # @Last Modified by: Charles Starr # @Last Modified time: 2016-07-06 23:53:49 #https://www.reddit.com/r/dailyprogrammer/comments/4jom3a/20160516_challenge_267_easy_all_the_places_your/ def input_place(): #ask user what place their dog ...
true
bcdf93ea36a3afa6632324742bf0b9acae82a7ef
nguyent57/Algorithms-Summer-Review
/square_root_of_int.py
1,388
4.28125
4
def square_root(x): # BASE CASE WHEN X == 0 OR X == 1, JUST RETURN X if (x == 0 or x == 1): return(x) # STARTING VALUE FROM 2 SINCE WE ALREADY CHECKED FOR BASE CASE i = 2 # PERFECT SQUARE IS THE SQUARE NUMBER ON THE RIGHT OF THE GIVEN NUMBER # SAY, WE HAVE 7 -> PERSQUARE IS 9, 3 P...
true
fd525d79b0b9b683440ef6e52a268feb1550e4e3
nguyent57/Algorithms-Summer-Review
/shortest_palindrome.py
1,682
4.21875
4
# RUN TIME # USE: TAKE THE REVERSE STRING OF THE GIVEN STRING AND BRING IT TO THE END # TO SEE WHAT IS THE SUFFIX OF THE STRING COMPARING TO THE PREFIX OF THE STRING # REMOVE THE SUFFIX --> SHORTEST PALINDROME def palindrom(str): # CREATE AN EMPTY STRING FOR PALINDROME reverse = '' # FOR...
true
7bbe8947b97d2bd27773d003f3b3eedf9eaa712a
nguyent57/Algorithms-Summer-Review
/all_unique_char.py
814
4.25
4
# METHOD 1: USING A FUNCTION # RUN TIME: O(n) # CREATE A FUNCTION THAT WOULD TAKE ANY STRING def all_unique_char(str): # CREATE A DICTIONARY TO STORE THE COUNT OF EACH CHARACTER count = {} # CREATE AN ARRAY TO STORE THE CHAR char = [] # FOR EVERY ITEM IN STRING for i in str: # ...
true
0f6633f03b958e1c606f41ec4c82e660b6dfd350
UdayQxf2/tsqa-basic
/BMI-calculator/03_BMI_calculator.py
2,937
5.125
5
""" We will use this script to learn Python to absolute beginners The script is an example of BMI_Calculator implemented in Python The BMI_Calculator: # Get the weight(Kg) of the user # Get the height(m) of the user # Caculate the BMI using the formula BMI=weight in kg/height in meters*height in me...
true
fba5a5017e2f9b1f5b91a3f877e45a7c63f758eb
UdayQxf2/tsqa-basic
/BMI-calculator/02_BMI_calculator.py
1,797
5.09375
5
""" We will use this script to learn Python to absolute beginners The script is an example of BMI_Calculator implemented in Python The BMI_Calculator: # Get the weight(Kg) of the user # Get the height(m) of the user # Caculate the BMI using the formula BMI=weight in kg/height in meters*height in me...
true
bd1268244c535712fa6616edbf7b2a015867b30e
mikephys8/The_Fundamentals_pythonBasic
/week7/9-1.py
1,005
4.1875
4
__author__ = 'Administrator' tup = ('a', 3, -0.2) print(tup[0]) print(tup[1]) print(tup[2]) print(tup[-1]) print('-------------') print(tup[:2]) print(tup[1:2]) print(tup[1:3]) print(tup[2:3]) print(tup[2:]) print('-------------') # tuples arer immutable!!cannot be assigned with other # value in opposition with list #...
true
035b6c28e1b373fef200773cdc73a940a98d8f7c
arrpitsharrma/PreCourse_1
/Exercise_4.py
1,528
4.25
4
# Time Complexity : not sure # Space Complexity : not sure # Did this code successfully run on Leetcode : yes # Any problem you faced while coding this : had a hard time dealing with tree, I get stuck when I come across trees and linked list for basic things sometimes # Python program to insert element in binary tree...
true
a662d0ba108c778eabc880a98c81767894b9e31e
jon-rutledge/Notes-For-Dummies
/Python/ListsAndStrings.py
1,198
4.1875
4
#strings and lists testList = list('Hello') print(testList) print(testList) #strings are immutable data types, they cannot be modified #if you need to modify a string value, you need to create a new string based the original #References #with one off variables you can do something like this spam = 42 cheese = spam...
true
34f8a256264e0da898d07b32d613371bc0fecde5
SACHSTech/ics2o1-livehack-2-Kyle-Lue
/problem2.py
1,066
4.5
4
""" ------------------------------------------------------------------------------- Name: problem2.py Purpose: Determine the sides of the traingle and determine if it is a triangle Author: Lue.Kyle Created: 23/02/2021 ------------------------------------------------------------------------------ """ #Input the le...
true
5ba6cfe289b2cec8dd68df78d11253cbb7a5ec0c
ashutosh4336/python
/coreLanguage/ducktyping/lambda.py
1,324
4.28125
4
""" --> What is Lambda function ? Lambda function are Namesless or Anonymous functions 'lambda' is not a function it is a keywork in python --> Why they are Used. One-Time-Use ==> Throw away function as they're only used Once IO of other function ==> They're also passed as inputs or returned as outputs of other Hi...
true
90b19ba814eb586ddae8d0b97068b71901a8627c
Satishchandra24/CTCI-Edition-6-Python3
/chapter1/oneAway.py
2,799
4.15625
4
"""There are three types of edits that can be performed on strings: insert a character, remove a character, or replace a character. Given two strings, write a function to check if they are one edit (or zero edits) away. EXAMPLE pale, ple-> true pales, pale -> true pale,bale-> true pale,bake-> false""" def oneAway(str1...
true
bd897223c898fe68168a467fd41f7b1923bcf6ee
rwedema/master_ontwikkeling
/informatica_start/jupyter_notebooks/informatics01/WC_05/random_dna_template.py
1,231
4.21875
4
#!/usr/bin/env python3 #imports import sys import random def calc_gc(seq): #calculates the percentage of GC in the sequence #finish this function yourself pass def generate_dna(len_dna): #generates random DNA with GC percentage between 50 and 60% #some comments removed. Write your own comments!...
true
ea4d338b844b370f06bdfd9368fac0c1f154a8a7
rwedema/master_ontwikkeling
/informatica_start/jupyter_notebooks/informatics01/WC_03/03_dna_convert_functions_solution.py
1,748
4.15625
4
#!/usr/bin/env python3 #solution for DNA convert #imports import sys def is_valid_dna(seq): #checks if all letters of seq are valid bases valid_dna = "ATCG" for base in seq: if not base in valid_dna: #the break statement is not needed anymore as return automatically breaks the loop. ...
true
e977567aa32b21b6b0a557963a5cd3a01982bca1
boluwaji11/Py-HW
/HW4/HW4-5_Boluwaji.py
674
4.5
4
# This program calculates the factorial of nonnegative integer numbers # Start # Get the desired number from the user # Use a repetition control to calculate the factorial # End # ============================================================== print('Welcome!') number = int(input('\nPlease enter the desired positiv...
true
adf9d5898e666f01c6fb4e8c5a7976fe0242283f
boluwaji11/Py-HW
/HW3/HW3-4_Boluwaji.py
1,191
4.4375
4
# This program converts temperature in degrees Celsius to Fahrenheit. # Start # Get the temperature in celsius from the user # Calculate the Fahrenheit equivalent of the inputted temperature # Check the result # If the result is more than 212F # Display "Temperature is above boiling water temperature" ...
true
0cd27f6603efb0bea65eb78aceff2e0ccb25a884
boluwaji11/Py-HW
/HW5/HW5-3_Boluwaji.py
1,712
4.1875
4
# This program calculates dietary information # Start # Define main function # In the main function,get fat and carbohydrate information from the user # Pass fat to calories_fat and call it # Pass carbohydrate to calories_carbs and call it # Call calories_fat and calories_carbs in main # Define the c...
true
2eece337929e5f114a7a8a2e4dc0e33d4634906b
boluwaji11/Py-HW
/HW6/HW6-1-a_Boluwaji.py
1,476
4.15625
4
# This program saves different video running times for Kevin to the video_running_times.txt file. # Start # Define the main function # Ask Kevin for the number of short videos he's working with # Open a file to save the videos # Enter the different times and write it to file # Close the file # Noti...
true
9f4e5d5c93d94f01f61e924974c34d869a5fa0b1
piyush546/Machine-Learning-Bootcamp
/Basic Python programs/listreverse.py
341
4.21875
4
# -*- coding: utf-8 -*- """ A program to demonstrate list content reversing and optimizing the reversing method of string """ # To take user name input in single command using split name = input().split() # to print the name string after reversing name = name[::-1] name = " ".join(name) print(name) # Input = piyu...
true
68742eb158b913e6e9f3f85f80d669eef018fa2d
piyush546/Machine-Learning-Bootcamp
/Basic Python programs/style.py
290
4.15625
4
# -*- coding: utf-8 -*- """ A program to use some str methods """ # variables to store strings to be styled First_string = input("Enter the string:") # To print the strings after styling print(str.upper(First_string)) print(str.lower(First_string)) print(str.capitalize(First_string))
true
34b635354da1a433f5a0ebc96a481141bf48f1be
Neeraj-Chhabra/Class_practice
/task2.py
454
4.125
4
def square_root(a): z=1 x=a/2 while(z==1): y = (x + (a/x)) / 2 if (abs(y-x) < 0.0000001): print(x) z=2 return(x) else: x=y # print("new value not final", x) # print(y) def test_square_root(a): return(math.sqrt(a)) root=int(input("enter the number for the squareroot")) import math d=square_...
true
30822abe9cc556240dca0da5ade9f60371c89676
RayNieva/Python
/printTable.py
2,165
4.4375
4
#!/usr/bin/env python """Project Table Printer Write a function named printTable() that takes a list of lists of strings and displays it in a well-organized table with each column right-justified. Assume that all the inner lists will contain the same number of strings. For example, the value could look like this:""" ...
true
e3d1598b8864ed8a3bd40b2e9f41894b5028c326
nuneza6954/cti110
/M4T4 P4HW2_ PoundsKilos _AliNunez.py
951
4.3125
4
# Program will display a table of pounds starting from 100 through 300 # (with a step value of 10) and their equivalent kilograms. # The formula for converting pounds to kilograms is: # kg= lb/2.2046 # Program will do a loop to display the table. # 03-07-2019 # CTI-110 P4HW2 - Pounds to Kilos Table # Ali Nunez...
true
6c3e99015bf3c5a132b18f7d55dddf6b7e9952d5
narasimhareddyprostack/Ramesh-CloudDevOps
/Python/Fours/Set/four.py
208
4.40625
4
s = {1,2,3} s.update('hello') print(s) #The Python set update() method updates the set, adding items from other iterables. ''' adding items form other iterable objects, such as list, set, dict, string '''
true
96be9ec136c4bd58d90e56a1f1b6b7e07a08f23a
djndl1/CSNotes
/algorithm/introAlgorithm/python-implementation/bubble_sort.py
1,005
4.125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import operator def optimized_bubble_sort(arr, comp=operator.le): if len(arr) < 2: return arr n = len(arr) while n > 1: next_n = 0 for i in range(1, n): if not comp(arr[i-1], arr[i]): # if out of order, then swap ...
true
99b71f3b737456b6916d801929159ba767e85a55
TBobcat/Leetcode
/CountPrimes.py
1,234
4.25
4
def countPrimes( n): """ :type n: int :rtype: int """ prime_list=is_prime(n) # print(prime_list) return len(prime_list) def is_prime(n): # based on Sieve of Eratosthenes result = [] if n <=1 : return [] # Create a boolean array "prime[0..n]" a...
true
b4ab5c05860d95676bdc24b9813226002a49fc0f
fgarcialainez/RabbitMQ-Python-Tutorial
/rabbitmq/tutorial1/receive.py
1,191
4.3125
4
#!/usr/bin/env python """ In this part of the tutorial we'll write two small programs in Python; a producer (sender) that sends a single message, and a consumer (receiver) that receives messages and prints them out. It's a "Hello World" of messaging. https://www.rabbitmq.com/tutorials/tutorial-one-python.html """...
true
a7b0001a9a204a24607419abd86197464487e184
oskip/IB_Algorithms
/Merge.py
1,152
4.1875
4
# Given two sorted integer arrays A and B, merge B into A as one sorted array. # # Note: You have to modify the array A to contain the merge of A and B. Do not output anything in your code. # TIP: C users, please malloc the result into a new array and return the result. # If the number of elements initialized in A and...
true
81afe70547b88e2216f90d93e901d89282ae7628
oskip/IB_Algorithms
/RevListSample.py
914
4.25
4
# Reverse a linked list. Do it in-place and in one-pass. # # For example: # Given 1->2->3->4->5->NULL, # # return 5->4->3->2->1->NULL. # # PROBLEM APPROACH : # # Complete solution code in the hints # Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = ...
true
9431f2f8c0c10c09878199baf743b0d1f3510781
pr1malbyt3s/Py_Projects
/Advent_of_Code/2021/1_2021.py
1,183
4.4375
4
# AOC 2021 Day 1 import sys # This function is used to read a file input from the command line. It returns the file contents as a list of lines. def read_file() -> list: if len(sys.argv) != 2: print("Specify puzzle input file") sys.exit(-1) else: # Open file at command line position 1:...
true
abbda68a1e2777bae2bdc1ec1903232c81d7d42f
pr1malbyt3s/Py_Projects
/Runcode.ninja/Simple_Addition.py
1,116
4.1875
4
#!/usr/bin/env python3 # This script accepts an input file of mixed value pairs separated by lines. # It check that each value pair can be added and if so, prints the corresponding sum. import sys from decimal import Decimal # Create a master list of all number pairs. numList = [] # Type check function to determine...
true
dd49bbd3212bd1c77674f3b8f68ef134a6f7b253
pr1malbyt3s/Py_Projects
/Runcode.ninja/Simple_Cipher.py
579
4.28125
4
#!/usr/bin/env python3 # This script is used to decode a special 'cipher'. # The cipher pattern is each first word in a new sentence. import sys # Create a list to store each parsed first word from an input file. message = [] with open(sys.argv[1], 'r') as f: cipher = f.read() # While reading file, split the file ...
true
ac0ef21febfd8f26eeec7ae27c2bee55b35ab46f
pr1malbyt3s/Py_Projects
/Runcode.ninja/Third_Letter_Is_A_Charm.py
946
4.21875
4
#!/usr/bin/env python3 # This script accepts an input file containing words with misplaced letters. # Conveniently, the misplaced letter is always from the third position in the word and is at the beginning. import sys # rotate function to perform letter rotation on a provided string. # It first checks to ensure the...
true
812a8a7dac1e22b1bdbd9e47f3c59113b303aa0c
seaboltthomas19/Monty-Hall-Problem
/monty-hall-sim.py
1,111
4.1875
4
import random switch_was_correct = 0 no_switch_was_correct = 0 print("====================================" + "\n" + "*** Monty Hall Problem Simulator ***" + "\n" + "====================================") print("Doors to choose from: ") doors = int(input()) print("Iterations to r...
true
d61a5fe6d5b68073a738d19b93e24a35695cc1d4
luckymime28/Skyjam
/skyjam.py
1,851
4.1875
4
print("- If you need more info or you're confused type 'help'") def help(): print("\n-So basically, this is my first exploit I ever created \n-My name is luckymime28, and this is my exploit skyjam.py \n-skyjam.py is a password combination maker and list creator \n-Simply follow the instructions on screen and you ...
true
1c2ac0372cd46f24e4a6a18d3fb7808154166a31
EthanCornish/AFPwork
/Chapter4-Functions-Tutorial#1.py
759
4.125
4
# Function Tutorial # Creating a main function # In the main function print instructions and ask for a value def main(): print('Hello') print('This program will ask you for a temperature\nin fahrenheit.') print('-----------------------------------------------------------') value = int(input('Enter a ...
true
5fc5f217581a224b9f22be8c91a204a7936a8885
seanmortimer/udemy-python
/python-flask-APIs/functions.py
856
4.1875
4
def hello(name): print(f'Heeyyy {name}') hello('Sean ' * 5) # Complete the function by making sure it returns 42. . def return_42(): # Complete function here return 42 # 'pass' just means "do nothing". Make sure to delete this! # Create a function below, called my_function, that takes two arguments and...
true
832adbc3d78e3496afb1bb180fc1e8ed42be1b76
LiamWoodRoberts/HackerRank
/Anagrams.py
741
4.125
4
'''Solution to: https://www.hackerrank.com/challenges/sherlock-and-anagrams/problem function finds the number of anagrams contained in a certain string''' def substrings(word): strings=[] for l in range(1,len(word)): sub = [word[i:i+l] for i in range(len(word)-l+1)] strings.append(sub) ...
true
4a0e8b5efeb37c0b538ed7b264f9a39ad9d67440
Rockwell70/GP_Python210B_Winter_2019
/examples/office_hours_code/class_inheritence.py
953
4.15625
4
class rectangle: def __init__(self, width, length): self.width = width self.length = length def area(self): return self.width * self.length def present_figure(self): return f'This figure has a width of {self.width}, a length of {self.length} and an area of {self.area()}' ...
true
77b412d9121baf177d930b1072f9870b7f7f6b79
Rockwell70/GP_Python210B_Winter_2019
/examples/office_hours_code/donor_models.py
2,082
4.34375
4
#!/bin/python3 ''' Sample implementation of a donor database using classes ''' class Person: ''' Attributes common to any person ''' def __init__(self, donor_id, name, last_name): self.donor_id = donor_id self.name = name self.last_name = last_name class Donation: ''' ...
true
38ce46230cc6f2c490b97ef27681975750f48ed7
Rockwell70/GP_Python210B_Winter_2019
/examples/office_hours_code/sunday_puzzle.py
1,425
4.1875
4
''' From: https://www.npr.org/2019/01/20/686968039/sunday-puzzle-youre-halfway-there This week's challenge: This challenge comes from listener Steve Baggish of Arlington, Mass. Take the name of a classic song that became the signature song of the artist who performed it. It has two words; five letters in the first, thr...
true
eb3057689fc57e496ee0e3f64cf50ef1ef723fe1
Cody-Hayes97/Sprint-Challenge--Algorithms
/recursive_count_th/count_th.py
706
4.25
4
''' Your function should take in a single parameter (a string `word`) Your function should return a count of how many occurences of ***"th"*** occur within `word`. Case matters. Your function must utilize recursion. It cannot contain any loops. ''' def count_th(word): # return zero if the ength of the word is less ...
true
0a1bf196667cd63dc6f5fe840a88b74aa9593883
RutujaWanjari/Python_Basics
/RenameFileNames/rename_filenames.py
885
4.375
4
# This program demonstrates how to access files from relative path. # Also it changes alphanumeric file names to totally alphabetic names. # To successfully run this program create a directory "AllFiles" and add multiple files with alphanumeric names. from pathlib import Path import os # Path is a class from "pathlib...
true
6d210d6f2ab4cad68112fd06c8704b62352f5d03
DmitryVlaznev/leetcode
/296-reverse-linked-list.py
1,871
4.21875
4
# 206. Reverse Linked List # Reverse a singly linked list. # Example: # Input: 1->2->3->4->5->NULL # Output: 5->4->3->2->1->NULL # Follow up: # A linked list can be reversed either iteratively or recursively. Could # you implement both? # Definition for singly-linked list. class ListNode: def __init__(self, x)...
true
020377082a10915fae20031ccf7b0dc1d6424a3b
DmitryVlaznev/leetcode
/328-odd-even-linked-list.py
2,474
4.34375
4
# 328. Odd Even Linked List # Given a singly linked list, group all odd nodes together followed by # the even nodes. Please note here we are talking about the node number # and not the value in the nodes. # You should try to do it in place. The program should run in O(1) space # complexity and O(nodes) time complexit...
true
f542f1f5c756600310e472c711f84dc787cefc2d
DmitryVlaznev/leetcode
/1329-sort-the-matrix-diagonally.py
1,513
4.21875
4
# 1329. Sort the Matrix Diagonally # Medium # A matrix diagonal is a diagonal line of cells starting from some cell # in either the topmost row or leftmost column and going in the # bottom-right direction until reaching the matrix's end. For example, # the matrix diagonal starting from mat[2][0], where mat is a 6 x 3...
true
c4d5b792263bd949ebe3b6bb5186121c8832307f
DmitryVlaznev/leetcode
/246-strobogrammatic-number.py
1,077
4.15625
4
# 246. Strobogrammatic Number # Easy # Given a string num which represents an integer, return true if num is # a strobogrammatic number. # A strobogrammatic number is a number that looks the same when rotated # 180 degrees (looked at upside down). # Example 1: # Input: num = "69" # Output: true # Example 2: # Inpu...
true
2d94fb484758fb8e9d8c079a8cfa4d94fe03ebaf
DmitryVlaznev/leetcode
/702-search-in-a-sorted-array-of-unknown-size.py
1,982
4.125
4
# 702. Search in a Sorted Array of Unknown Size # Given an integer array sorted in ascending order, write a function to # search target in nums. If target exists, then return its index, # otherwise return -1. However, the array size is unknown to you. You # may only access the array using an ArrayReader interface, wh...
true
aefd7af360fdf3d158e5be8fdf16a3deb939b6b9
DmitryVlaznev/leetcode
/1423-maximum-points-you-can-obtain-from-cards.py
2,553
4.125
4
# 1423. Maximum Points You Can Obtain from Cards # Medium # There are several cards arranged in a row, and each card has an # associated number of points The points are given in the integer array # cardPoints. # In one step, you can take one card from the beginning or from the end # of the row. You have to take exac...
true
284ec6e03f5edb54d8ba5903235f37a74a4d4b32
DmitryVlaznev/leetcode
/902-numbers-at-most-n-given-digit-set.py
1,719
4.21875
4
# 902. Numbers At Most N Given Digit Set # Hard # Given an array of digits, you can write numbers using each digits[i] # as many times as we want. For example, if digits = ['1','3','5'], we # may write numbers such as '13', '551', and '1351315'. # Return the number of positive integers that can be generated that ar...
true
aa350a3b28ad670e494ba35e8865ad519ecb1f14
DmitryVlaznev/leetcode
/701-insert-into-a-binary-search-tree.py
2,224
4.1875
4
# Insert into a Binary Search Tree # You are given the root node of a binary search tree (BST) and a value # to insert into the tree. Return the root node of the BST after the # insertion. It is guaranteed that the new value does not exist in the # original BST. # Notice that there may exist multiple valid ways for t...
true
665b37f3e85a2bdffac567069351cfb071b1322e
DmitryVlaznev/leetcode
/970-powerful-integers.py
1,683
4.15625
4
# 970. Powerful Integers # Medium # Given three integers x, y, and bound, return a list of all the # powerful integers that have a value less than or equal to bound. # An integer is powerful if it can be represented as x^i + y^j for some # integers i >= 0 and j >= 0. # You may return the answer in any order. In you...
true
6ad55eb0f4b036b0c33b0f00dc24de6cd29714cb
DmitryVlaznev/leetcode
/116-populating-next-right-pointers-in-each-node.py
2,141
4.125
4
# 116. Populating Next Right Pointers in Each Node # You are given a perfect binary tree where all leaves are on the same # level, and every parent has two children. The binary tree has the # following definition: # struct Node { # int val; # Node *left; # Node *right; # Node *next; # } # Populate each next ...
true
e4f730d10a30032bce93d1b61c55e741cde27889
DmitryVlaznev/leetcode
/1704-determine-if-string-halves-are-alike.py
1,730
4.15625
4
# 1704. Determine if String Halves Are Alike # Easy # You are given a string s of even length. Split this string into two # halves of equal lengths, and let a be the first half and b be the # second half. # Two strings are alike if they have the same number of vowels ('a', # 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', '...
true
9e0bd15c3f7a2e572618ffc85fdffde3d8579b0a
MicheSi/cs-bw-unit2
/balanced_brackets.py
2,142
4.125
4
''' Write function that take string as input. String can contain {}, [], (), || Function return boolean indicating whether or not string is balance ''' table = { ')': '(', ']':'[', '}':'{' } for _ in range(int(input())): stack = [] for x in input(): if stack and table.get(x) == stack[-1]: ...
true
c317269d86f21534edc00ce2e66e14e2e3b790bd
MicheSi/cs-bw-unit2
/search_insert_position.py
1,016
4.125
4
''' Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You may assume no duplicates in the array. Example 1: Input: [1,3,5,6], 5 Output: 2 Example 2: Input: [1,3,5,6], 2 Output: 1 Example 3: Input: [1,3,5,6], 7 ...
true
88cf81dc127010d9bec8fd09d916a1ddeee26a8e
akimi-yano/algorithm-practice
/tutoring/mockClassmates/officehour_mock2.py
819
4.28125
4
# Valid Palindrome Removal # Return true if the input is a palindrome, or can be a palindrome with no more than one character deletion. # Zero characters can be added. # Return false if the input is not a palindrome and removing any one character from it would not make it a palindrome. # Must be done in constant space...
true
2b0f70093994c026f521f5936967fcc887c74444
akimi-yano/algorithm-practice
/lc/1870.MinimumSpeedToArriveOnTime.py
2,783
4.21875
4
# 1870. Minimum Speed to Arrive on Time # Medium # 152 # 49 # Add to List # Share # You are given a floating-point number hour, representing the amount of time you have to reach the office. To commute to the office, you must take n trains in sequential order. You are also given an integer array dist of length n, wh...
true
683bd029ec511e1c2868af454303d95065e93c23
akimi-yano/algorithm-practice
/lc/438.FindAllAnagramsInAString.py
1,687
4.25
4
# 438. Find All Anagrams in a String # Medium # 6188 # 235 # Add to List # Share # Given two strings s and p, return an array of all the start indices of p's anagrams in s. You may return the answer in any order. # An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typi...
true
beda2c8b84bfa3be65e93edacf33c71c524f2718
akimi-yano/algorithm-practice
/lc/isTreeSymmetric.py
2,043
4.34375
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None # 101. Symmetric Tree # Easy # Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). # For example, this binary tree...
true
0f4bfcbc1f59afbb95c2a2d112b72e1f34c798d0
akimi-yano/algorithm-practice
/lc/111.MinimumDepthOfBinaryTree.py
2,149
4.125
4
# 111. Minimum Depth of Binary Tree # Easy # 1823 # 759 # Add to List # Share # Given a binary tree, find its minimum depth. # The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. # Note: A leaf is a node with no children. # Example 1: # Input: r...
true
a770ed5446cb22606122f0d55488d58aff374679
akimi-yano/algorithm-practice
/examOC/examWeek1.py
2,868
4.15625
4
# Week1 Exam # Complete the 'mergeArrays' function below. # # The function is expected to return an INTEGER_ARRAY. # The function accepts following parameters: # 1. INTEGER_ARRAY a # 2. INTEGER_ARRAY b # merge two sorted arrays def mergeArrays(a, b): ans = [] i = 0 k = 0 while len(a)>i and len(b...
true
94d942c6bc11ceb1a8919f193e31a186f1a90658
akimi-yano/algorithm-practice
/lc/154.FindMinimumInRotatedSortedAr.py
2,593
4.15625
4
# 154. Find Minimum in Rotated Sorted Array II # Hard # 2147 # 315 # Add to List # Share # Suppose an array of length n sorted in ascending order is rotated between 1 and n times. For example, the array nums = [0,1,4,4,5,6,7] might become: # [4,5,6,7,0,1,4] if it was rotated 4 times. # [0,1,4,4,5,6,7] if it was ro...
true
448467cb0445f9e81c67e1c29ff29d4545a47b88
akimi-yano/algorithm-practice
/lc/UniquePaths.py
2,518
4.40625
4
# latice path unique path problems are different problems ! # difference : # lattice path - counting the edges # robot unique path - counting the boxes (so -1) # also for lattice path, # instead of doing this ---- # if m == 0 and n == 0: # return 1 # elif m<0 or n<0: # return 0 # you ...
true
201e5eb0545be43fceece844312c43566b1e0818
akimi-yano/algorithm-practice
/oc/328_Odd_Even_Linked_List.py
2,239
4.1875
4
# 328. Odd Even Linked List ''' Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes. You should try to do it in place. The program should run in O(1) space complexity and O(nodes) time complexity....
true
241ca9304d4b204bfa717ea366abdb73046e7547
akimi-yano/algorithm-practice
/lc/1338.ReduceArraySizeToTheHalf.py
1,686
4.15625
4
# 1338. Reduce Array Size to The Half # Medium # 767 # 64 # Add to List # Share # Given an array arr. You can choose a set of integers and remove all the occurrences of these integers in the array. # Return the minimum size of the set so that at least half of the integers of the array are removed. # Example 1...
true
323585745e2d7f83533a0c8b7273619c21b8ff2b
akimi-yano/algorithm-practice
/lc/1936.AddMinimumNumberOfRungs.py
2,606
4.28125
4
# 1936. Add Minimum Number of Rungs # Medium # 123 # 9 # Add to List # Share # You are given a strictly increasing integer array rungs that represents the height of rungs on a ladder. You are currently on the floor at height 0, and you want to reach the last rung. # You are also given an integer dist. You can only...
true
a316b2d14a524e00985fd59c54d58595f3c2c4a7
ARWA-ALraddadi/python-tutorial-for-beginners
/02-How to Use Pre-defined Functions Demos/2-random_numbers.py
1,626
4.53125
5
#--------------------------------------------------------------------- # Demonstration - Random Numbers # # The trivial demonstrations in this file show how the # functions from the "random" module may produce a different # result each time they're called # Normally when we call a function with the same parameters # ...
true
15e88757e99a4285445e4641ff9e86df0c9ff134
ARWA-ALraddadi/python-tutorial-for-beginners
/03-Workshop/Workshop-Solutions/fun_with_flags.py
1,564
4.28125
4
#-------------------------------------------------------------------- # # Fun With Flags # # In the lecture demonstration program "stars and stripes" we saw # how function definitions allowed us to reuse code that drew a # star and a rectangle (stripe) multiple times to create a copy of # the United States flag. # # As...
true
de5d83e72f9e97e33665e635fd5099dcfb4bec07
ARWA-ALraddadi/python-tutorial-for-beginners
/06-How to Create User Interfaces Demos/02-frustrating_button.py
1,076
4.40625
4
#---------------------------------------------------------------- # # Frustrating button # # A very simple demonstration of a Graphical User Interface # created using Tkinter. It creates a window with a label # and a frustrating button that does nothing. # # Import the Tkinter functions from tkinter import * # Creat...
true
d49423bc7fc93a65763555efc2a9e6aec0ccf1a1
ARWA-ALraddadi/python-tutorial-for-beginners
/10-How to Stop Programs Crashing Demos/0-mars_lander_V5.py
2,361
4.46875
4
#--------------------------------------------------------------------# # # Mars lander example - Exception handling # # This simple program allows us to experiment with defensive # programming, assertions and exception handling. It is based on # a real-life example in which a software failure caused # a Mars lander to ...
true
15eaf7c1be83f2636e171211a049ceda21eb2fe5
ARWA-ALraddadi/python-tutorial-for-beginners
/03-Workshop/Workshop-Solutions/olympic_rings.py
2,327
4.5625
5
#------------------------------------------------------------------------- # # Olympic Rings # # In this folder you will find a file "olympic_rings.pdf" which shows # the flag used for the Olympics since 1920. Notice that this flag # consists of five rings that differ only in their position and colour. # If we wa...
true
43aaf6575d5a423e006fbe4360972d2868e7a8ff
ARWA-ALraddadi/python-tutorial-for-beginners
/08-How to Find Things Demos/08-replacing_patterns.py
2,598
4.3125
4
## Replacing patterns ## ## The small examples in this demonstration show how regular ## expressions with backreferences can be used to perform ## automatic modifications of text. from re import sub ## This example shows how to "normalise" a data representation. ## A common problem at QUT is that student numbe...
true
d69866a1cf193e6eed2cc8abfad5b9a5c6653777
ARWA-ALraddadi/python-tutorial-for-beginners
/01-Workshop/Workshop-Solutions/cylinder_volume.py
939
4.4375
4
# Volume of a cylinder # # THE PROBLEM # # Assume the following values have already been entered into the # Python interpreter, denoting the measurements of a cylindrical # tank: radius = 4 # metres height = 10 # metres # Also assume that we have imported the existential constant "pi" # from the "math" library module...
true
4a1039d67f5927daf41b2aa86fde4cf9d7ead6a8
ARWA-ALraddadi/python-tutorial-for-beginners
/10-How to Stop Programs Crashing Demos/0-mars_lander_V0.py
2,269
4.34375
4
#--------------------------------------------------------------------# # # Mars lander example - No error handling # # This simple program allows us to experiment with defensive # programming, assertions and exception handling. It is based on # a real-life example in which a software failure caused # a Mars lander to c...
true
70d2912f7acbaa964fa09f0d17f11f96a5e3fb26
ARWA-ALraddadi/python-tutorial-for-beginners
/05-How to Repeat Actions demos/09-uniqueness.py
1,090
4.46875
4
#--------------------------------------------------------------------# # # Uniqueness test # # As an example of exiting a loop early, here we develop a small # program to determine whether or not all letters in some text # are unique. It does so by keeping track of each letter seen and # stopping as soon as it sees a l...
true
101c4d993889264c4e592564584242cb96e85754
ARWA-ALraddadi/python-tutorial-for-beginners
/12-How to do more than one thing Demos/B_scribbly_turtles.py
1,501
4.71875
5
#--------------------------------------------------------------------# # # Scribbly turtles # # As a simple example showing that we can create two independent # Turtle objects, each with their own distinct state, here # we create two cursors (turtles) that draw squiggly lines on the # canvas separately. # # To develop ...
true
0598e5896c2b92261ac342485f300d5b0af7c907
ARWA-ALraddadi/python-tutorial-for-beginners
/09-Workshop/print_elements.py
2,663
4.84375
5
#--------------------------------------------------------- # # Print a table of the elements # # In this exercise you will develop a Python program that # accesses an SQLite database. We assume that you have # already created a version of the Elements database using # the a graphical user interface. You can do so by ...
true
189cbe4c2f6cb9b263e5c6f7fba1571040478428
ARWA-ALraddadi/python-tutorial-for-beginners
/08-How to Find Things Demos/01-wheres_Superman.py
1,804
4.65625
5
#--------------------------------------------------------------------- # # Where's Superman? # # To illustrate how we can find simple patterns in a text file using # Python's built-in "find" method, this demonstration searches for # some patterns in an HTML file. # # Read the contents of the file as a single string te...
true
5c6f7af9847b7112297337f1dd5199f9ba6bb97e
ARWA-ALraddadi/python-tutorial-for-beginners
/04-How to Make Decisions Demos/15-un-nesting.py
1,389
4.40625
4
#--------------------------------------------------------------------- # # "Un-nesting" some conditional statements # # There are usually multiple ways to express the # same thing in program code. As an instructive # exercise in using conditional statements, consider # the code below which decides whether or not # an ...
true
3a2ad3460b8151fc7df5ae3232b315b6c5dc9cab
ARWA-ALraddadi/python-tutorial-for-beginners
/03-How to Create Reusable Code Demos/07-ref_transparency.py
1,735
4.21875
4
#--------------------------------------------------------------------- # # Demonstration - Referential transparency # # The small examples in this file illustrate the meaning of # "referentially transparent" function definitions. A # function that is referentially transparent always does this # same thing when given t...
true
d8d0afeca8c35fdfa370f32af41f0ce66e670e58
ARWA-ALraddadi/python-tutorial-for-beginners
/01-Workshop/Workshop-Questions/01_repair_cost.py
854
4.21875
4
# Total repair cost # # THE PROBLEM # # Assume the following values have already been entered into the # Python interpreter, representing the vehicle repair costs in dollars # from several suppliers following a motor accident, and the deposit # paid for the work: panel_beating = 1500 mechanics = 895 spray_painting = 5...
true
072d4198ea1dea7962646af90a14f36fc72bbf81
ARWA-ALraddadi/python-tutorial-for-beginners
/10-How to Stop Programs Crashing Demos/0-mars_lander_V1.py
2,045
4.65625
5
#--------------------------------------------------------------------# # # Mars lander example - Checking input validity # # This simple program allows us to experiment with defensive # programming, assertions and exception handling. It is based on # a real-life example in which a software failure caused # a Mars lande...
true