blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
23c498871baaf75458fb1f6180d7aa9aaa5bf7f0
premkumar0/30DayOfPython
/Day-12/day_12_Premkumar.py
648
4.28125
4
def linearSearch(n, k, arr): """ This function takes k as the key value and linear search for it if the value is found it returns the index of the key value else it will return -1 Example:- n, k = 4, 5 arr = [2, 4, 5, 8] returns 2 """ for i in range(n): if arr[i] == k: return i ...
true
699f261fc02664f070af9158f6a1d158d28f70cc
KuroCharmander/Turtle-Crossing
/player.py
602
4.15625
4
from turtle import Turtle STARTING_POSITION = (0, -280) MOVE_DISTANCE = 10 FINISH_LINE_Y = 280 class Player(Turtle): """The turtle in the Turtle Crossing game.""" def __init__(self): """Initialize the turtle player.""" super(Player, self).__init__("turtle") self.penup() self.s...
true
ddd53c5798d033ce7d85b51b3805aeca263a2ad8
d1l0var86/Dilovar
/classes/cars.py
2,200
4.5
4
class Car(): """This is class to represent a car.""" def __init__(self, make, model, year): self.make = make self.model = model self.year = year self.color = 'White' self.odometer_reading = 0 # getter and setter def get_description(self): msg = f"Your ca...
true
66c2a539db2169fc48436f2faff1ff287765d0ff
JagadishJ4661/Mypython
/Numbers.py
759
4.25
4
'''Take 2 numbers from the user, Print which number is 2 digit number and which number is 3 digit number If it neither, then print the number as it is''' def entry(): num1 = input("Select any number that you wish.") num1 = int(num1) num2 = input("select any number that you wish again.") num2 = int(num...
true
0911c018b5024d7dc525ebc285e67ba1d2e2663b
p-ambre/Python_Coding_Challenges
/125_Leetcode_ValidPalindrome.py
821
4.25
4
""" Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. Note: For the purpose of this problem, we define empty string as valid palindrome. Example 1: Input: "A man, a plan, a canal: Panama" Output: true Example 2: Input: "race a car" Output: false """ clas...
true
2e74ccb9169f92530d7e4eaac320b0786e94bf5c
p-ambre/Python_Coding_Challenges
/M_6_Leetcode_ZigZagConversion.py
1,712
4.40625
4
""" The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H N A P L S I I G Y I R And then read line by line: "PAHNAPLSIIGYIR" Write the code that will take a string and make this conve...
true
8c09eac5594829eb922e78688f3d91a6378cdd68
graag/practicepython_kt
/exercise_9.py
888
4.25
4
import random takes = 0 print("Type 'exit' to end game.") outer_loop_flag = True while outer_loop_flag: #Generate number number = random.randint(1,9) print('Try to guess my number!') takes = 0 while True: user_input = input("Type your guess: ") try: user_input = int(u...
true
aa88db0d81a38fb2d62e01e69d460c166aa2b22e
pranshu798/Python-programs
/Data Types/Strings/accessing characters in string.py
277
4.1875
4
#Python Program to Access characters of string String = "PranshuPython" print("Initial String: ") print(String) #Printing first character print("\nFirst character of String: ") print(String[0]) #Printing last character print("\nLast character of String: ") print(String[-1])
true
8e4d2c3b574445d7e36dfb1e6b3726551f7ec4d8
pranshu798/Python-programs
/Data Types/Strings/string slicing.py
368
4.53125
5
#Python program to demonstrate string slicing #Creating a string String = "PranshuPython" print("Initial String: ") print(String) #Printing 3rd to 12th character print("\nSlicing characters from 3-12: ") print(String[3:12]) #Printing characters between 3rd and 2nd last character print("\nSlicing characters between 3r...
true
7c4808931b9f3a7524eee2d16e53b85d69db4a67
pranshu798/Python-programs
/Data Types/Sets/Adding elements using add() method.py
417
4.65625
5
#Python program to demonstrate Addition of elements in a Set #Creating a Set set1 = set() print("Initial blank set: ") print(set1) #Adding elements and tuple to the Set set1.add(8) set1.add(9) set1.add((6,7)) print("\nSet after Addition of Three elements: ") print(set1) #Adding elements to the Set using Iterator for ...
true
673bda4cbb55311159f64da91f523a3558a430b8
pranshu798/Python-programs
/Data Types/Sets/Removing elements using pop() method.py
275
4.3125
4
#Python program to demonstrate Deletion of elements in a Set #Creating a Set set1 = set([1,2,3,4,5,6,7,8,9,10,11,12]) print("Initial Set: ") print(set1) #Removing element from the Set using the pop() method set1.pop() print("\nSet after popping an element: ") print(set1)
true
c61d200009259fbad763fe8583a8345ed949d31e
pranshu798/Python-programs
/Functions/Python classes and objects/Functions can be passed as arguments to other functions.py
358
4.3125
4
# Python program to illustrate functions # can be passed as arguments to other functions def shout(text): return text.upper() def whisper(text): return text.lower() def greet(func): # storing the function in a variable greeting = func("Hi, I am created by a function passed as an argument.") print(...
true
5bcbac676259b19faa8e8f5144105840ceac6c68
muftring/iu-python
/module-04/Question3.py
640
4.125
4
#!/usr/bin/env python # # Michael Uftring, Indiana University # I590 - Python, Summer 2017 # # Assignment 4, Question 3 # # Write a program that calculates the numeric value of a single name # provided as input. This will be accomplished by summing up the values # of the letters of the name where ’a’ is 1, ’b’ is 2, ...
true
0ec8e80b01fbf1ec69a3b8afe1086415c13ecb23
muftring/iu-python
/module-03/Question2_2.py
633
4.53125
5
#!/usr/bin/env python # # Michael Uftring, Indiana University # I590 - Python, Summer 2017 # # Assignment 3, Question 2.2 # # Given the length of two sides of a right triangle: the hypotenuse, and adjacent; # compute and display the angle between them. # import math def main(): print("Angle between hypotenuse an...
true
932a6b227d1127dbdfa2b4517c92b0b7873a8bed
muftring/iu-python
/module-04/Question1.py
519
4.5625
5
#!/usr/bin/env python # # Michael Uftring, Indiana University # I590 - Python, Summer 2017 # # Assignment 4, Question 1 # # Write a program that takes an input string from the user and prints # the string in a reverse order. # def main(): print("Print a string in reverse!") forward = input("Please enter a str...
true
da8f74d891428c8fd90e7a68b7037c3cf5c8ab4c
muftring/iu-python
/module-07/Question4.py
1,647
4.28125
4
#!/usr/bin/env python3 # # Michael Uftring, Indiana University # I590 - Python, Summer 2017 # # Assignment 7, Question 4 # # Display the sequence of prime numbers within upper and lower bounds. # import math # """ isPrime(n): checks whether `n` is prime using trial division approach (unoptimized)""" # def isPrime(n):...
true
13e22b088fcf09564ac82f25c775564f106310d6
Dadsh/PY4E
/py4e_08.1.py
555
4.5625
5
# 8.4 Open the file romeo.txt and read it line by line. For each line, split the # line into a list of words using the split() method. The program should build a # list of words. For each word on each line check to see if the word is already # in the list and if not append it to the list. When the program completes, so...
true
620bdd6eaeea894aaaf0abc6b716309a907ae181
Dadsh/PY4E
/py4e_13.9.py
2,565
4.34375
4
# Calling a JSON API # In this assignment you will write a Python program somewhat similar to # http://www.py4e.com/code3/geojson.py. The program will prompt for a location, # contact a web service and retrieve JSON for the web service and parse that # data, and retrieve the first place_id from the JSON. A place ID is ...
true
0c078d889ed24a1de6b020b99ebd2456814c2de6
RobertoGuzmanJr/PythonToolsAndExercises
/Algorithms/KthLargest.py
1,391
4.125
4
""" This is an interview question. Suppose you have a list of integers and you want to return the kth largest. That is, if k is 0, you want to return the largest element in the list. If k is the length of the list minus 1, it means that you want to return the smallest element. In this exercise, we want to do this...
true
2760af375842734ef59a5ae070565cf624444ac7
viethien/misc
/add_digits.py
513
4.21875
4
#!/usr/bin/python3 def main(): print ("Hello this program will add the digits of an integer until a singular digit is obtained") print ('For example 38 -> 3+8 = 11 -> 1+1 = 2. 2 will be returned') number = input('Enter an integer value: ') print (number + ' will reduce to ' + str(addDigits(number))) def addDigits...
true
9a2195053cd1dc6597b060e070c10db9a81f67ca
titanspeed/PDX-Code-Guild-Labs
/Python/frilab.py
2,639
4.21875
4
phonebook = { 'daniels': {'name': 'Chase Daniels', 'phone':'520.275.0004'}, 'jones': {'name': 'Chris Jones', 'phone': '503.294.7094'} } def pn(dic, name): print(phonebook[name]['name']) print(phonebook[name]['phone']) def delete(): correct_name = True while correct_name == True: delete_name = ...
true
805efe0ecd2da5e8e225c295f2a34d0902ebcd27
thepavlop/code-me-up
/shapes.py
1,362
4.28125
4
""" This program calculates the area and perimeter of a given shape. Shapes: 'rectangle', 'triangle'. """ shape = input("Enter a shape (rectangle/triangle): ") # User input is 'rectangle': if shape == 'rectangle': # Ask user for a height and width of the rectangle i1 = input ('Enter the width of th...
true
a344c5d1b7a3457d5c63bf45306f8d0106031a60
hpisme/Python-Projects
/100-Days-of-Python/Day-3/notes.py
380
4.4375
4
"""Conditionals / Flow Control""" #If statement if 2 > 1: print('2 is greater than 1') #Adding an else statement if 3 < 2: print('This won\'t print') else: print('This will print!') #Adding an elif statement x = 0 if x == 1: print('This will print if x is 1.') elif x == 2: print('This will print if x i...
true
bd07ed2c24d4cea71914d5ff91109bd3d0c8bd7e
mohitkh7/DS-Algo
/Assignment1/1divisible.py
319
4.3125
4
# 1.WAP to check the divisibilty def isDivisible(a,b): #To check whether a is divisible by b or not if a%b==0: return True; #Divisible else: return False; #Non Divisible num=int(input("Enter Any Number : ")) div=int(input("Enter Number with which divisibilty is to check : ")) print(isDivisible(num,div));
true
29fad1f70a64fb15378c74e16b1bade6f3b12a7e
Wil10w/Beginner-Library-2
/Exam/Check Code.py
1,262
4.21875
4
#Write a function called product_code_check. product_code_check #should take as input a single string. It should return a boolean: #True if the product code is a valid code according to the rules #below, False if it is not. # #A string is a valid product code if it meets ALL the following #conditions: # # - It must be ...
true
41a221f4719dc573f0e7949b0b9b8e8d0ee7e250
Wil10w/Beginner-Library-2
/Loops/if-if-else movie ratings.py
542
4.3125
4
rating = "PG" age = 8 if rating == 'G': print('You may see that movie!') if rating == "PG": if age >= 8: print("You may see that movie!") else: print("You may not see that movie!") if rating == "PG-13": if age >= 13: print("You may see that movie!") else: print('You may not see that movie!') if rating...
true
2da45f99244731fc4207270d95c5ed11a7a604b3
Wil10w/Beginner-Library-2
/Practice Exam/Release Date.py
2,414
4.375
4
#Write a function called valid_release_date. The function #should have two parameters: a date and a string. The #string will represent a type of media release: "Game", #"Movie", "Album", "Show", and "Play". # #valid_release_date should check to see if the date is #a valid date to release that type of media according to...
true
cf730580af6dc9754abfcb9a1e58d63ded705689
HarryBMorgan/Special_Relativity_Programmes
/gamma.py
776
4.1875
4
#Calculation of gamma factor in soecial relativity. from math import sqrt #Define a global variable. c = 299792458.0 #Define speed of light in m/s. #Define a function to calculate gamma. def gamma(v): if v < 0.1 * c: #If v is not in order of c, assume it's a decimal and * c. v *= c return 1 / sqrt(1...
true
b6182a34f51f0393626723f33cd60cfedfef5e5a
nagaprashanth0006/code
/python/remove_duplicate_chars_from_string.py
1,131
4.125
4
from collections import Counter str1 = "Application Development using Python" # Constraints: # Capital letters will be present only at the beginning of words. # Donot remove from start and end of any word. # Duplicate char should match across whole string. # Remove not only the duplicate char but also all of its occur...
true
88d3b4710b222d0787a96f7f4d8216f38e02f8fd
pablocorbalann/codewars-python
/5kyu/convert-pascal-to-snake.py
442
4.21875
4
# Complete the function/method so that it takes CamelCase string and returns the string in snake_case notation. # Lowercase characters can be numbers. If method gets number, it should return string. def to_underscore(string): s = '' for i, letter in enumerate(str(string)): if letter != letter.lower():...
true
69be0a9c8b24ae5882c636d363481f7a9be43775
jonahp1/simple-bill-splitter
/Mainguy.py
1,480
4.3125
4
attendees = int(input("How many people are splitting the bill? : ")) bill_total = float(input("How much is the bill total (before tax)? (DO NOT INCLUDE $) : ")) tax_total = float(input("How much is the Tax total? (DO NOT INCLUDE $) : ")) tax_percentage = (tax_total / bill_total) # useful for math effective_tax_percent...
true
fafeba6ba874c5d7475aa7bf616d2843036d0915
lappazos/Intro_Ex_11_Backtracking
/ex11_sudoku.py
2,894
4.1875
4
################################################################## # FILE : ex11_sudoku.py # WRITERS : Lior Paz,lioraryepaz,206240996 # EXERCISE : intro2cs ex11 2017-2018 # DESCRIPTION : solves sudoku board game with general backtracking ################################################################## from math impo...
true
640dbf5ad0fd5c12bc351f06cdf91bbe1555969b
Fainman/intro-python
/random_rolls.py
860
4.125
4
""" Program to simulate 6000 rolls of a die (1-6) """ import random import statistics def roll_die(num): """ Random roll of a die :param num: number of rolls :return: a list of frequencies Index 0 maps to 1 . . . Index 5 maps to 6 """ frequency = [0] * 6 # Initial values ...
true
7051a6b21b2b930fb09b50df114bc9d66607c7c7
shaunakgalvankar/itStartedInGithub
/ceaserCipher.py
1,287
4.375
4
#this program is a ceaser cipher print("This is the ceaser cipher.\nDo You want to encode a message or decode a message") print("To encode your message press e to decode a messge press d") mode=raw_input() if mode=="e": #this is the ceaser cipher encoder original=raw_input("Enter the message you want to encode:") en...
true
f5936be33f6ea652325db7c9b8c688b11a8e9e53
imclab/DailyProgrammer
/Python_Solutions/115_easy.py
1,220
4.40625
4
# (Easy) Guess-that-number game! # Author : Jared Smith #A "guess-that-number" game is exactly what it sounds like: a number is guessed at #random by the computer, and you must guess that number to win! The only thing the #computer tells you is if your guess is below or above the number. #Your goal is to write a pr...
true
3c443065b603371a6cb3733b5c2bcf52f1ab0c5a
NickAlicaya/Graphs
/projects/graph/interview.py
1,441
4.5
4
# Print out all of the strings in the following array in alphabetical order, each on a separate line. # ['Waltz', 'Tango', 'Viennese Waltz', 'Foxtrot', 'Cha Cha', 'Samba', 'Rumba', 'Paso Doble', 'Jive'] # The expected output is: # 'Cha Cha' # 'Foxtrot' # 'Jive' # 'Paso Doble' # 'Rumba' # 'Samba' # 'Tango' # 'Viennese ...
true
8b7bbd9cc3d0dbb4ccddab9ff8865866f5d03aa0
kochsj/python-data-structures-and-algorithms
/challenges/insertion_sort/insertion_sort.py
416
4.34375
4
def insertion_sort(list_of_ints): """Sorts a list of integers 'in-place' from least to greatest""" for i in range(1, len(list_of_ints)): # starting outer loop at index 1 j = (i - 1) int_to_insert = list_of_ints[i] while j >= 0 and int_to_insert < list_of_ints[j]: list_o...
true
4e1d46b1dd5b16f5e316dfbaedc8fbf5ab674464
kochsj/python-data-structures-and-algorithms
/challenges/quick_sort/quick_sort.py
1,301
4.34375
4
def quick_sort(arr, left_index, right_index): if left_index < right_index: # Partition the array by setting the position of the pivot value position = partition(arr, left_index, right_index) # Sort the left_index quick_sort(arr, left_index, position - 1) # Sort the right_ind...
true
1eda04501f801072b4c16c2f2450cbcc50765a61
sdmiller93/Summ2
/Zed/27-30/ex29studydrills.py
468
4.5625
5
# 1. The if prints the included statement if returned True. # 2. The code needs to be indented to make it known that the print statement is included with that if statement, it's a part of it. # 3. If it's not indented, it isn't included with the if statement and will print regardless of the truth of the if statement....
true
de260d1be0cecc69226b792d1ff4d9bf96f5dd8b
sdmiller93/Summ2
/Zed/04-07/ex6.py
1,015
4.5625
5
# strings are pieces of text you want to export out of the program # assign variables types_of_people = 10 x = f"There are {types_of_people} types of people." # assign more variables binary = "binary" do_not = "don't" # write string with embedded variables y = f"Those who know {binary} and those who {do_not}" # pr...
true
b7edfa22328e165b825e5834edf64fe96df04701
mateuszkanabrocki/LPTHW
/ex19.py
1,071
4.125
4
# defining a function with 2 arguments def cheese_and_crackers(chesse_count, boxes_of_crackers): #print(">>> START chesse_count=:", chesse_count, "boxes_of_crackers:", boxes_of_crackers) print(f"You have {chesse_count} cheeses.") print(f"You have {boxes_of_crackers} boxes of crackers.") print("Man, that...
true
a57b8ccb2942c7c26903d406f6d8343ba0db2ebe
mateuszkanabrocki/LPTHW
/ex16.py
1,071
4.25
4
# import the argv feature from the system module from sys import argv # assign the input values to the variables (strings) script, filename = argv print(f"We're going to erase {filename}.") print("If you don't want that hit Ctrl-C (^C).") print("If you do want that hit RETURN.") input("?") print("Opening the file....
true
5003672f108deea087e056411ee5a08de4cd2f54
Nakshatra-Paliwal/Shining-Star
/Area of the Triangle.py
229
4.15625
4
Base = float(input("Please enter the value of Base of the Triangle : ")) Height = float(input("Please enter the value of Height of the Triangle : ")) Area = (1/2 * Base * Height) print("Area of the Triangle is " + str(Area))
true
38df5b7ab5326cbedddc379d8d931d7ddb1c43b5
Nakshatra-Paliwal/Shining-Star
/Calculate Area of Two Triangles and Compare the Smaller One.py
849
4.25
4
""" Write a code to calculate Area of two triangles. And compare these areas, and print which triangle has the greater area Note : Take input from the user as Base and Height values for two triangles """ Base1 = float(input("Please enter the value of Base of the 1st Triangle : ")) Height1 = float(input("Plea...
true
0a45277982cb8bdf9f34b437b34ed5c017ece3d4
Nakshatra-Paliwal/Shining-Star
/Take two Numbers as Input and Print Their Addition.py
252
4.1875
4
#Write a code to take two numbers as input and print their Addition num1 = int(input("Write a Number 1 : ")) num2 = int(input("Write a Number 2 : ")) Multiply = num1 + num2 print() print("The Addition of Both the Number is " + str(Multiply))
true
186b27c411a681ee1a704dc53d5ecc23ed2746bf
Nakshatra-Paliwal/Shining-Star
/Voice Chatbot about sports input by text.py
2,142
4.28125
4
""" Create a Voice Chatbot about sports. Ask the user to type the name of any sport. The Chatbot then speaks about interesting information about that specific sport. """ import pyttsx3 engine=pyttsx3.init() print("Welcome !! This is a Voice Chatbot about sports.") print("Please choose the Operation...
true
16dd605a3f9efc51f76e2accb45470bcfdb9f767
Nakshatra-Paliwal/Shining-Star
/Write a program for unit converter..py
1,166
4.40625
4
""" Write a program for unit converter. A menu of operations is displayed to the user as: a. Meter-Cm b. Kg-Grams c. Liter-Ml Ask the user to enter the choice about which conversion to be done. Ask user to enter the quantity to be converted and show the result after conversion. Ask user whether he wish to cont...
true
3fe609269efbfddd1c814b1ab0091b868ddb73d2
Nakshatra-Paliwal/Shining-Star
/Create a 'guess the password' game (3 attempts).py
410
4.4375
4
""" Create a 'guess the password' game , the user is given 3 attempts to guess the password. Set the Password as “TechClub!!” """ attempt=1 while(attempt<=3): password=input("Enter the Password : ") if password=="TechClub!!": print("You are Authenticated!!") break else: a...
true
bfe2ac7fb508f2fcca6192a35c893a453f2053f4
brgyfx/Dice-Simulator
/DiceRollSimNew.py
425
4.15625
4
#DiceRollingSimulator import random import time dice = random.randint(0,9) count = 0 count_to = 10 response = input("Would you like to roll a dice? ") if response == "yes": times = int(input("How many times would you like to roll a dice? ")) count_to = times while response == "yes" and count < count_t...
true
1738b878939eabefdeb29a0c0be498d6c2b9981a
mridulpant2010/leetcode_solution
/OOAD/ss_function_injection.py
797
4.1875
4
''' 1- creating function 2- understanding static function more on static-method: 1- static-method are more bound towards a class rather than its object. 2- they can access the properties of a class 3- it is a utility function that doesn't need access any properties of a class but makes sense that it belong to a clas...
true
a41a38938250fe4514ee0db952f31f953422694f
mridulpant2010/leetcode_solution
/tree/right_view_tree.py
1,102
4.125
4
''' given a tree you need to print its right view ''' from collections import deque from typing import List class TreeNode: def __init__(self, val, left=None, right=None): self.val=val self.left=left self.right=right def tree_right_view(root): res=[] q=deque() q.append(roo...
true
a9a2ae4248ac36eb0af0b21b924967595f412b0b
deloschang/project-euler
/005/problem5.py
782
4.125
4
#!/usr/bin/env python # 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. # What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20? def factorize(x): # < 11 don't need to be checked because 12-20 implicitly c...
true
f0236977e3d6ad99197048b5dc077bbb9263d30d
ssw1991/Python-Practice
/Module 1 - Shilo Wilson/Level 1.4 - Shilo Wilson/1.4.2.py
891
4.15625
4
# coding=utf-8 """ Name: Shilo S Wilson Exercise: 1.4.2 Find the length of each list in part b of the previous exercise. Then, verify that the lengths of all three lists indeed add up to the length of the full list in part a. """ import numpy as np def Mortgages(N): """ A function that returns an unsorte...
true
7a156ad4ed677a8315993eb17d0d5f2ccef94f4b
ssw1991/Python-Practice
/Module 3 - Shilo Wilson/Level 3.2/3.2.1 and 3.2.2/main.py
590
4.34375
4
""" Author: Shilo Wilson Create a list of 1000 numbers. Convert the list to an iterable and iterate through it. The instructions are a bit confusing, as a list is already an iterable. Is the intention to create an iterator to iterate through the list? """ def main(): print('========== Exercise 3.2.1 and 3...
true
3d617c48812fd4612ea2a082478efb76ab1b129f
ssw1991/Python-Practice
/Module 3 - Shilo Wilson/Level 3.1/3.1.3/main.py
1,542
4.65625
5
""" Author: Shilo Wilson Create a regular function (called reconcileLists) that takes two separate lists as its parameters. In this example, List 1 represents risk valuations per trade (i.e. Delta) from Risk System A and List 2 has the same from Risk System B. The purpose of this function is to reconcile the two li...
true
8abf8fd8b5e06481ed24e75fa6bcbc24cd641f0f
chi42/problems
/hackerrank/is_binary_search_tree.py
1,167
4.125
4
#!/usr/bin/python # # https://www.hackerrank.com/challenges/ctci-is-binary-search-tree?h_r=next-challenge&h_v=zen class node: def __init__(self, data): self.data = data self.left = None self.right = None def is_valid(data, max_data, min_data): if max_data and data >= max_data: return False if min_data and...
true
72ee90d35585f110e01e929cbfdd27115f14aa49
ztwilliams197/ENGR-133
/Python/Python 2/Post Activity/Py2_PA_Task1_will2051.py
2,595
4.28125
4
#!/usr/bin/env python3 ''' =============================================================================== ENGR 133 Program Description Takes inputs for theta1 and n1 and outputs calculated values for theta2 d3 and critTheta Assignment Information Assignment: Py2_PA Task 1 Author: Za...
true
7b56a008f94895e31074dd7fc25a5ca111e70c02
adrientalbot/lab-refactoring
/your_code/Guess_the_number.py
1,986
4.1875
4
#!/usr/bin/env python # coding: utf-8 # In[ ]: import random import sys # In[100]: def condition_to_play_the_game(string="Choose any integer between 1 and 100. Your number is "): your_number = input(string) if your_number.isdigit(): your_number = int(your_number) if your_number > 100: ...
true
aa3410e31edc7ce603dbf85bff00a80195b619d1
pcmason/Automate-the-Boring-Stuff-in-Python
/Chapter 4 - Lists/charPicGrid.py
1,077
4.1875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Apr 30 01:58:47 2021 @author: paulmason """ #print out a grid of characters with a function called charPrinter #create the that prints out every element in a 2D list def charPrinter(givenChar): #loop through the column for y in range(len(givenC...
true
473b2d32e7aca4f9b4f5850ce767331190f1ab47
pcmason/Automate-the-Boring-Stuff-in-Python
/Chapter 7 - Pattern Matching with Regular Expressions/dateDetection.py
2,067
4.5
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun May 2 17:27:33 2021 @author: paulmason program that detects valid dates in the format of DD/MM/YYYY """ #first import the regex module import re #create the date regex dateRegex = re.compile(r'(\d\d)/(\d\d)/(\d\d\d\d)') #search for a regex object mo ...
true
065bb60114d3f78139202df70c4e4ca23ddde974
saikatsengupta89/PracPy
/BreakContinuePass.py
667
4.125
4
#to showcase break statement x= int(input("How many candies you want? ")) available_candies=5 i=1 while (i<=x): print ("Candy") i=i+1 if (i>available_candies): print("There were only 5 candies available") break print("Bye") #print all values from 1 to 100 but skip those are divi...
true
e4af094f69a9d508f26145e5d56913c88d8e86ad
saikatsengupta89/PracPy
/class_inherit_constructor.py
1,420
4.46875
4
# IF YOU CREATE OBJECT OF SUB CLASS IT EILL FIRST TRY TO FIND INIT OF SUB CLASS # IF IT IS NOT FOUND THEN IT WILL CALL INIT OF SUPER CLASS # class A: def __init__(self): print ("This is from constructor A") def feature1(self): print ("Feature1A is working fine") def feature2(se...
true
8119dc127f1f9b1a05bb1890769527bb08f40d46
m-tranter/cathedral
/python/Y8/hangman.py
1,442
4.125
4
# hangman.py - simple hangman game from random import * def main(): WORDS = ['acorn', 'apple', 'apricot', 'grape', 'grapefruit', 'kiwi', 'lemon', 'mango', 'melon', 'orange', 'peach', 'pear', 'pineapple', 'raspberry', 'satsuma'] # pick a word randomly word = choice(WO...
true
28572191a4f31cf43fd927dca3e721ce4aff03d6
kevmo/pyalgo
/guttag/031.py
618
4.21875
4
# INSTRUCTIONS # input: integer # output: root and power such that 0 < pwr < 6 and # root**pwr = integer from sys import argv user_number = int(argv[1]) def find_root_and_power(num): """ Input: num Returns a root, power such that power is 2 and 5, inclusive, and root**power = num. """ root ...
true
4c5e94f7469efc1849249ab4c47050a2ff62bbf3
moayadalhaj/data-structures-and-algorithms401
/challenges/stack-queue-pseudo/stack_queue_pseudo/stack_queue_pseudo.py
2,378
4.40625
4
class Node: def __init__(self, value): self.value = value self.next = None class Stack: """ create a stack class that containes three methods push: to add a new node at the top of stack pop: to delete the top node in the stack peek: to return the value of top node if it exist ...
true
022ac59fc09a1e47b58038fc2b2c081da84ec48a
maniiii2/PSP-LAB-PYTHON-
/python/condition_demo.py
367
4.1875
4
#Conditional statements #using if statement find the largest among two numbers x=int(input("enter first number")) print("x=",x) print(type(x)) y=int(input("enter second number")) print("y=",y) print(type(y)) if x>y: print("x is greater than y") elif x==y: print("x is equal to y") else: prin...
true
ec9d5a106d1b21e409890b52b34f0c233f17c2e5
thtay/Algorithms_and_DataStructure
/CrackingCodingInterview_Python/Arrays_and_Strings/stringComp.py
1,251
4.1875
4
''' String compression: Implement a method to perform basic string compression using the counts of repeated characters. For example, the string aabcccccaa would be a2b1c5a3. If the "compressed" string would not become smaller than the orignal string, your method should return the original string. You can assume the st...
true
d74ddb75db7228a67bdab656e47e54523277ac5d
kagomesakura/palindrome
/pal.py
291
4.21875
4
def check_palindrome(string): half_len = len(string) // 2 #loop through half the string for i in range(half_len): if string[i] != string[len(string)-1-i]: return False return True user_input = input('what is your word? ') print(check_palindrome(user_input))
true
23a92b7be84aea5b82f891cc5eb99f807c3f0e49
dhilanb/snakifywork
/Unit 1 and 2 Quiz/Problem5.py
280
4.125
4
A= int(input("How many feet does a nail go up during the day? ")) B= int(input("How many feet does the snail fall at night? ")) H= int(input("How high would you like the snail to go up? ")) days= H/(A-B) print("It will take the snail "+str(days)+" days to go up "+str(H)+" feet.")
true
fe732b17a297b599562ad04b0f19832c1e2fdeaf
carlita98/MapReduce-Programming
/1.Distributed greed/P1_mapper.py
569
4.1875
4
#!/usr/bin/python # Filtering parttern: It evaluates each line separately and decides, # based on whether or not it contains a given word if it should stay or go. # In particular this is the Distributed Grep example. # Mapper: print a line only if it contains a given word import sys import re searchedWo...
true
0b070f64a2cb7dfa6e30f39dd56909c8161f7b85
ajaymonga20/Projects2016-2017
/question2.py
1,698
4.53125
5
# AJAY MONGA -- QUESTION 2 -- COM SCI TEST -- FEBRUARY 14, 2017 # imports # Nothing to Import # Functions def caught_speeding(speed, birthday): if (speed <= 60) and (birthday == False): # Returns 0 if the speed is less than 60 return 0 elif (speed >= 61) and (speed <= 80) and (birthday == False): # If the ...
true
f050bb18b1a8914af117e64b15d22d2e2b06a422
nsatterfield2019/Notes
/Week 8_Plotting.py
651
4.25
4
# PLOTTING (withmathploitlib) import matplotlib.pyplot as plt plt.figure(1) # creates a new window plt.plot([1, 2, 3, 4]) # if there is no x axis, it just gives index 0, 1, 2... plt.plot([1, 2, 3, 4], [1, 4, 9, 16]) plt.figure(2, facecolor ='limegreen') # opens up a new window/figure x = [x for x in range(10)] y ...
true
da762ad4794c151ea8f9d3c9133d336b974da541
matt-ankerson/ads
/queues/supermarket_model_1.py
2,103
4.1875
4
from queue import Queue from customer import Customer import random as r # Author: Matt Ankerson # Date: 15 August 2015 # This script models queue behaviour at a supermarket. # The scenario is: 10 checkouts, a customer selects a checkout at random. class SuperMarket(object): def __init__(self): r.se...
true
e6eb97080ddf47dda39b56673e6d47b390fe705a
GiovanniSinosini/cycle_condictions
/area_peri.py
269
4.375
4
pi = 3.1415 # Calculator perimeter and area radius = float(input("Enter radius value (in centimeters): ")) area = pi * (radius **2) perimeter = 2 * pi * radius print("The area value is:{:.2f}".format(area)) print( "The perimeter value is:{:.2f}".format(perimeter))
true
b844861db93e2d99d345d5b0e83ef01a88622fb2
mwharmon1/UnitTestStudentClass
/test/test_student.py
1,875
4.28125
4
""" Author: Michael Harmon Last Date Modified: 10/28/2019 Description: These unit tests will test the Student class constructors and functionality """ import unittest from class_definitions import student as s class MyTestCase(unittest.TestCase): def setUp(self): self.student = s.Student('Harmon', 'Mich...
true
08e693a2fbd53015bf7834908ee32ce141e8db99
SaneStreet/challenge-100
/challenge105/challenge105.py
896
4.1875
4
""" To use the python script in Command Prompt: Write 'python your_file_name.py' Example: 'python challenge101.py' """ # imports the 'month_name' functionality from the calendar module from calendar import month_name # function with int as parameter def MonthName(number): # variable holding the name of the month fr...
true
2a53348c85e88768fd75baa03fa1b7232a4906d7
yjthay/Leetcode
/63.py
1,835
4.375
4
''' 63. Unique Paths II Medium 862 120 Favorite Share A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram ...
true
169c8d5734e4b1e190cc3af9e7c1c47f9e00111a
alimulyukov/Course_Work_2021
/ConVolCylStep4.py
1,218
4.1875
4
import math print("\n\tThe volume of a Cylinder is:") print("\n\t\t\tV = \u03C0 \u00D7 radius\u00B2 \u00D7 height") print("\n\tThis program will take as input the radius and height") print("\tand print the volume.") file = open("data.txt","a") #w,r,a name = input("\n\tWhat is your name: ") radius = 1 height = 1 w...
true
a82fa240bd47e700230e5798dfdb882f29888208
eldadpuzach/MyPythonProjects
/Functions/Display Calendar.py
303
4.46875
4
# Python program to display calendar of given month of the year # import module import calendar yy = 2018 mm = 10 # To ask month and year from the user # yy = int(input("Enter year: ")) # mm = int(input("Enter month: ")) # display the calendar for i in range(1, 13): print(calendar.month(yy, i))
true
874eb33018e94ed35c455f77dec7e86842d4351a
lilliansun/cssi_2018_intro
/python/python-testing/fizzbuzz.py
570
4.34375
4
"""my implementation of fizzbuzz""" def fizz_buzz(num): """Prints different words for certain natural numbers This function prints out fizz when a number is divisible by 3, buzz when divisible by 5, and fizzbuzz when divisible by both. Args: num: (int) The number to convert based on fizzbuzz r...
true
582b693640f4e32601b7b1a7f34049218cbba291
sreehari333/pdf-no-3
/to check male or female.py
379
4.40625
4
gender = input("Please enter your Gender : ") if (gender == "M" or gender == "m" or gender == "Male" or gender == "male"): print("The gender in Male") elif (gender == "F" or gender == "f" or gender == "FeMale" or gender == "Female" or gender == "feMale" or gender == "female"): print("The gender is Female"...
true
6d78a8beb5805d430f4470b07415f09a6d713753
naresh3736-eng/python-interview-problems
/trees/binaryTree_is_fullBinaryTree.py
2,056
4.1875
4
class Node: def __init__(self, key): self.key = key self.leftchild = None self.rightchild = None # using recursion def isFullBT_recursion(root): if root is None: return None if root.leftchild is None and root.rightchild is None: return True if root.leftchild ...
true
62ebadffa4205282a3fb81a7ddd679bf8da0dc94
snekhasri/spring.py
/spring.py
832
4.34375
4
import turtle as t #importing the module as "t" t.bgcolor("green") def spiral_shape(p,c): #creating a function with parameters "p" and "c" if p > 0: #if the p is less than 0, t.forward(p) #moving the turtle forward at p units t.right(c) #setting the turtle right at an angle of c spiral_shape(p-5,c) #callin...
true
c5a328137b59adfa9e23b295e695a2d53026e7e6
Naveen8282/python-code
/palyndrome.py
230
4.15625
4
def IsPalyndrome(input1): txt = input1[::-1] if txt == input1: return "yes" else: return "no" str1=str(input("enter the string: ")) print ("is the string %s Palyndrome? %s" % (str1,IsPalyndrome(str1)))
true
5b8b60e383c8ad3b9597a0774b7c55706fcc0497
acbahr/Python-Practice-Projects
/magic_8_ball_gui.py
1,524
4.3125
4
# 1. Simulate a magic 8-ball. # 2. Allow the user to enter their question. # 3. Display an in progress message(i.e. "thinking"). # 4. Create 20 responses, and show a random response. # 5. Allow the user to ask another question or quit. # Bonus: # - Add a gui. # - It must have box for users to enter the question. # - It...
true
37c3e583c372fc2adbec60ca23e524fa9d4de0fc
dfrog3/pythonClass
/python/week 1/three_sort_david.py
1,772
4.1875
4
print("Hello, I will sort three integers for you.\nPlease enter the first integer now") firstNumber = int(input()) print("Thank you.\nPlease enter the second integer.") secondNumber = int(input()) print("Thank you.\n please eneter the last integer.") thirdNumber = int(input()) #fills starting variables if firstNumber <...
true
1e04b2e77b982dbea75275781f2ed4937dbdca86
k-unker/codewars_katas
/where_is_my_parent.py
1,351
4.21875
4
#!/usr/bin/env python3 ''' Mothers arranged dance party for children in school. On that party there are only mothers and their children. All are having great fun on dancing floor when suddenly all lights went out.Its dark night and no one can see eachother.But you were flying nearby and you can see in the dark and ...
true
0fd5a273d72beb9bf7cbc4c663f13410a4aeb881
prkapadnis/Python
/Programs/eighth.py
440
4.21875
4
""" Reverse a number """ number = int(input("Enter the number:")) reverse = 0 if number < 0: number = number * (-1) while number != 0: remainder = number % 10 reverse = reverse * 10 + remainder number = number // 10 print(-reverse) else : while number != 0: remainder ...
true
b3ed3b8ea862043d0d89d77bc1fceb90325acabe
prkapadnis/Python
/Set.py
620
4.1875
4
myset = set() print(type(myset)) myset = {1,2,3,4,5} print(myset) #built in function myset.add(2)# This does not made any change because set don't allow the duplicate values print(myset) myset.remove(2) print("After removing 2:", myset) # print("Using pop() function: ",myset.pop()) print(myset) second_set = {3,4,5,6...
true
c553606397136f91a2ad94d3c48c0f5d0f999a5b
prkapadnis/Python
/OOP/Class_var.py
1,797
4.25
4
""" Difference between class variable and Instance variable Instance Variable: -The Instance variable is unique for each instance -If we changed the class variable for specific instance then it will create a new instance variable for that instance Class Variable: The class v...
true
4c55155e0f66164f9f1512cb51c007b23234a1be
prkapadnis/Python
/Data Structure/Linked List/SinglyLinkedList.py
2,746
4.15625
4
class Node: def __init__(self, data): # defination of Node self.data = data self.next_node = None class LinkedList: def __init__(self): self.head = None self.size = 0 def reverse(self): privious = None current = self.head next = None wh...
true
48db87ee9b1285a6b269caba3b64b40f9ea89035
prkapadnis/Python
/File/second.py
896
4.40625
4
""" write() function: - The Write function writes the specified text into the file. - Where the specified text is inserted is depends on the file mode and stram position. - if 'a' is a file mode then it well be inserted at the stream position and default is end of the file. ...
true
7ca93f1f2fdf8f757c2206e747681e600453d93b
prkapadnis/Python
/Iterables/Iterable.py
1,178
4.34375
4
""" Iterable : Iterable are objects that are capable of returning their member one at a time means in short anything we can liip over is an iterable. Iterator : Iterable are objects which are representing the stream of data that is iterable. iterator creates something iterat...
true
2a06954878ad58139831283b2ec6ec0a6cb9ec74
marciniakdaw/Python-Udemy
/BMI calculator.py
519
4.25
4
height = float(input("enter your height in m: ")) weight = float(input("enter your weight in kg: ")) BMI_score=round(weight/height**2) if BMI_score<19: print(f"Your BMI is {BMI_score}, you are underweight.") elif BMI_score<25: print(f"Your BMI is {BMI_score}, you have a normal weight.") elif BMI_score<30: print...
true
4b3f73baf3fbd69d6bf149be403396cea9222ab5
j-tanner/Python.Assignments
/Assignment_8.4.py
240
4.1875
4
filename = input("Enter file name: ") filehandle = open(filename) wordlist = list() for line in filehandle: for words in line.split(): if words not in wordlist: wordlist.append(words) wordlist.sort() print(wordlist)
true
ab72ffcb3709b58a3f84c1d70833507f67fbd8da
courses-learning/python-crash-course
/4-1_pizzas.py
225
4.3125
4
# Make a list of 3x types of pizza and use a for loop to print pizzas = ['peperoni', 'hawian', 'meat feast'] for pizza in pizzas: print(f"I like {pizza} pizza.") print('I like pizza takeaway nearly as much as Indian!!!')
true
9bfc0342386bc8efdc7be6ac1f7988ae91ee022c
sacktock/practicals
/adspractical17extra.py
2,981
4.34375
4
#adspractical17extra.py #algorithms and data structures practical week 17 #matthew johnson 22 february 2013, last revised 15 february 2018 ##################################################### """an extra question that has nothing to do with the algorithms from the lectures, but gives some practice on thinking about ...
true
65264cc2e04a26029120617c562595610d3062eb
4RCAN3/PyAlgo
/pyalgo/maths/prime.py
413
4.21875
4
''' module for checking whether a given number is prime or not ''' def prime(n: int): ''' Checking if the number has any factors in the range [2, sqrt(n)] else it is prime ''' if (n == 2): return True result = True for i in range (2, int(n ** 0.5)): if (n % i == 0):...
true
29c43a96ac935c7f9da7b2bfbc227507d74fd02c
4RCAN3/PyAlgo
/pyalgo/graph/bfs.py
977
4.21875
4
''' module for implementation of breadth first search ''' def bfs(graph: list, start: int): """ Here 'graph' represents the adjacency list of the graph, and 'start' represents the node from which to start """ visited, queue = set(), [start] while (queue): vertex = queue.pop(0) ...
true
800dc205db1402fb2c155c6d4ac5af0de549988d
niranjan2822/List
/Key Lists Summations.py
1,147
4.21875
4
# Key Lists Summations # Sometimes, while working with Python Dictionaries, we can have problem in which we need to perform the replace of # key with values with sum of all keys in values ''' Input : {‘gfg’: [4, 6, 8], ‘is’: [9, 8, 2], ‘best’: [10, 3, 2]} output : {‘gfg’: 18, ‘is’: 19, ‘best’: 15} ''' # Method #1 :...
true