blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
eba680e70f99c565a0b95c2d230061034bf24291
tdominic1186/Python_Crash_Course
/Ch_3_Lists/seeing_the_world_3-5.py
833
4.40625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Feb 8 20:56:36 2018 @author: Tony_MBP """ places = ['new zealand', 'canada', 'uk', 'australia', 'japan'] print(places) #use sorted to to print list alphabetically w/o modifying list print(sorted(places)) #show list is still in same original order prin...
true
7e9f1fe1a143bd90aea5e8478c703ec8bc980a59
tdominic1186/Python_Crash_Course
/Ch_9_Classes/number_served.py
2,193
4.5
4
''' Start with your program from Exercise 9-1 (page 166). Add an attribute called number_served with a default value of 0. x Create an instance called restaurant from this class. x Print the number of customers the restaurant has served, and then change this value and print it again. x Add a method called set_numb...
true
fe45487f19bd0c0e402cd04b572741b9087d54ab
tdominic1186/Python_Crash_Course
/Ch_9_Classes/login_attempts.py
2,013
4.125
4
""" 9-5. Login Attempts: Add an attribute called login_attempts to your User class from Exercise 9-3 (page 166). x Write a method called increment_login_attempts() that increments the value of login_attempts by 1. x Write another method called reset_login_attempts() that resets the value of login_attempts to 0.x M...
true
153b1a2153121b5d00b452484b9f88d344b73ed6
tdominic1186/Python_Crash_Course
/Ch_8_Functions/unchanged_magicians_8-11.py
1,514
4.53125
5
""" 5/21/18 8-11. Unchanged Magicians: Start with your work from Exercise 8-10. Call the function make_great() with a copy of the list of magiciansโ€™ names. Because the original list will be unchanged, return the new list and store it in a separate list. Call show_magicians() with each list to show that you have one lis...
true
d7d65a0c5695274842767e20e5a337db4640d113
tdominic1186/Python_Crash_Course
/Ch_5_if_Statements/stages_of_life_5-6.py
522
4.125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Mar 18 11:58:03 2018 5-6 Stages of life - Write an if-elif-else chain that determines a person's stage of life. @author: Tony_MBP """ age = 65 if age < 2: print("You're a baby.") elif age >= 2 and age < 4: print("You're a toddler.") elif age ...
true
cbc38a58be400e83c18324be9acba86971729545
vladn90/Data_Structures
/heaps/heap_sort_naive.py
797
4.15625
4
""" Naive implementation of heap sort algorithm using Min Heap data structure. """ import random from min_heap_class import MinHeap def heap_sort_naive(array): """ Sorts an array in non-descending order using heap. Doesn't return anything. Time complexity: O(n * lg(n)). Space complexity: O(n), n is len(array)...
true
7c1249777a1cdf09f1da6fb492cc70e85d092ac0
AnjanaPradeepcs/guessmyno-game
/guessmyno.py
541
4.28125
4
import random number=random.randrange(1,10) guess=int(input("guess a number between 1 and 10)) while guess!= number: if guess>number: print("guess a lesser number.Try again") guess=int(input("guess a number between 1 and 10)) else: ...
true
8aee1e37b8d65fb372d200a9fd173abc719d6443
gloriasalas/GWC-Summer-Immersion-Program
/TextAdventure.py
1,549
4.1875
4
start = '''You wake up one morning and find yourself in a big crisis. Trouble has arised and your worst fears have come true. Zoom is out to destroy the world for good. However, a castrophe has happened and now the love of your life is in danger. Which do you decide to save today?''' print(start) done = False ...
true
58578e34604e68fc5b8fd9315959316a62a94c21
lward27/Python_Programs
/echo.py
240
4.125
4
#prec: someString is a string #times is a integer #postc: #prints someString times times to the screen #if times <=0, nothing prints. def repeat(someString, times): if times <= 0: return print someString repeat(someString, times - 1)
true
f6c9d0c94a80bbaa9db1e9bedc041baf70c2f6fd
jjulch/cti110
/P4HW3_NestedLoops_JeremyJulch.py
356
4.3125
4
# Making Nested Loops # 10-17-2019 # CTI-110 PH4HW3-Nested Loops # Jeremy Julch # # Making the first loop for row in range(6): print('#', end='', sep='') # Making the nested loop to create the spaces between the # for spaces in range(row): print( ' ', end='', sep='') # Mak...
true
e37676e882c196756d7af562c25b8fcb53643f0b
cliffjsgit/chapter-10
/exercise108.py
795
4.15625
4
#!/usr/bin/env python3 __author__ = "Your Name" ############################################################################### # # Exercise 10.8 # # # Grading Guidelines: # - Variable "answer" should be the answer to question 1: If there are 23 # students in your class, what are the chances that two of you have the...
true
b06a2e53ae982a0d013b38968b99d0406aaaffc0
MrSameerKhan/Machine_Learning
/practice/reverse_list.py
1,288
4.40625
4
def reverse_a_list(): my_list = [1,2,3,566,6,7,8] original_list = my_list.copy() list_length = 0 for i in my_list: list_length += 1 for i in range(int(list_length/2)): main_value = my_list[i] mirror_value = my_list[list_length-i-1] my_list[i] = mirror_value ...
true
2a18cc8fd70105eee7c47def0f4c4b8d1202fd04
weiiiiweiiii/AP-statistic-graphs
/Sources-For-Reference/Programs/Poisson.py
1,155
4.4375
4
# -*- coding: utf-8 -*- from scipy.stats import poisson import numpy as np import matplotlib.pyplot as plt import mpld3 #print "Welcome!" #print "This is a program that can help you plot graphs for poisson distributions" #Using poisson.pmf to create a list #rate = raw_input("Please enter the rate(rate should be an ...
true
3118d09cf3963b943a81b04a96e9729cece878f6
ProfessorJas/Learn_Numpy
/ndarray_shape.py
302
4.46875
4
import numpy as np a = np.array([[1, 2, 3], [4, 5, 6]]) print(a.shape) print() # This resize the array a = np.array([[1, 2, 3], [4, 5, 6]]) a.shape = (3, 2) print(a) print() # Numpy also provides a reshape function to resize an array a = np.array([[1, 2, 3], [4, 5, 6]]) b = a.reshape(3, 2) print(b)
true
4e3b1fbdfe12194e77d28b3dcebd47fae42e44c8
dongheelee1/oop
/polymorphism.py
592
4.4375
4
#Polymorphism: #Example of Method Overriding class Animal(object): def __init__(self, name): self.name = name def talk(self): pass class Dog(Animal): def talk(self): print("Woof") class Cat(Animal): def talk(self): print("Meow") cat = Cat('KIT') cat.talk() dog = ...
true
ad56dc7b368603b7d2592573ed26503dcce41e4b
moncefelmouden/python-project-ui-2018
/dbDemo.py
1,594
4.21875
4
import sqlite3 import os.path def initDatabase(): db=sqlite3.connect('dbDemo.db') sql="create table travel(name text primary key,country text)" db.execute(sql) sql="insert into travel(name,country) values('Korea Ski-ing Winter Tour','Korea')" db.execute(sql) db.commit() db.close() ...
true
52008b5181e886e0656108dab34c19823d1caa07
brandonbloch/cisc327
/bCommands.py
2,983
4.21875
4
def find_account(number, accounts): """ This function takes in a account number and the master accounts list to check if the specified account number is in the master accounts list. """ for i in range(len(accounts)): if accounts[i][0] == number: return i+1 return 0 def wi...
true
77cee1eae648b4d90ce87bfd203332c8f49fd0c8
Mb01/Code-Samples
/algorithms/sorting/heapsort.py
1,886
4.25
4
#!/usr/bin/env python import random LENGTH = 100 data = [random.randint(0,100) for _ in range(LENGTH)] def heapsort(lst): def swap(lst, a, b): """given a list, swap elements at 'a' and 'b'""" temp = lst[a] lst[a] = lst[b] lst[b] = temp def siftdown(lst, start, en...
true
1c676ba9bb43be453458060ce539fa12e31e645b
brianaguirre/CS3240
/lab3/lab3_part1.py
1,642
4.28125
4
__author__ = 'BrianAguirre' #USER CREATION user_name = "" password = "" data = {} print("This program takes in usernames and password.") print("If at any point you wish to quit, enter an empty string.") user_name = input("Please enter the first user name:") password = input("Enter a password for " + user_name + ":")...
true
58d8e5da962370d21564be1b4e891a64abfb26da
underwaterlongs/codestorage
/Project_Euler/P3_LargestPrimeFactor.py
1,362
4.15625
4
""" The prime factors of 13,195 are 5,7,13,29. What is the largest prime factor of a given number ? We can utilize Sieve of Eratosthenes to find the prime factors for N up to ~10mil or so efficiently. General pseudocode for sieve: initialize an array of Boolean values indexed by 2 to N, set to True i = 2 for i to ...
true
1044ae5fa1dcff182100ef9f352d2985e2ee924a
Roy-Chandan/Roy-world
/Range1.py
685
4.15625
4
def user_choice(): choice = 'Wrong' accept_range = range(0,10) within_range = False while choice.isdigit() == False or within_range == False: choice = input ("Enter a number between 1-10: ") if choice.isdigit() == False: print ("Please enter a numb...
true
2cd2cee48549e357234920cd03528ecad6b1c5ba
kvega/potentialsim
/src/potentialsim.py
1,020
4.28125
4
#!/usr/bin/python3 import pylab import random """ Generates a text file of values representing the coordinates of n particles in a potential. """ # Create the Particle Class class Particle(object): """ Representation of a simple, non-interacting, massive particle (assumes point-like, does not model charg...
true
861a99afac2f93a6163847d6a9bdc57b21136b19
jflow415/mycode
/dict01/marvelchar01.py
1,290
4.21875
4
#!/usrbin/env python3 marvelchars = { "Starlord": {"real name": "peter quill", "powers": "dance moves", "archenemy": "Thanos"}, "Mystique": {"real name": "raven darkholme", "powers": "shape shifter", "archenemy": "Professor X"}, "She-Hulk":{ "real name": "jennifer walters", "powers": "super...
true
7830f2711cd16350747357b1639b0f72d2974a68
RasikKane/problem_solving
/python/00_hackerrank/python/08_list_comprehension.py
631
4.375
4
""" Let's learn about list comprehensions! You are given three integers x, y and z representing the dimensions of a cuboid along with an integer n. Print a list of all possible coordinates given by (i,j,k) on a 3D grid where the sum of i+j+k is not equal to n. Here, 0 <= i <=x , 0 <=j <=y, 0 <= k <=z. Please use lis...
true
51ac5fba05dea57ebbc98fc66092876f2e867b82
NoraIlisics/FirstRep
/for.py
924
4.34375
4
#Write a program which sums the integers from 1 to 10 using a for loop # (and prints the total at the end). total = 0 for i in range(1,11): total += i print(total) #Can you think of a way to do this without using a loop? total2 = sum(range(1,11)) print(total2) #Write a program which finds the factorial of a g...
true
57ddd657bd402e1b4666223f51ad8efcc17a070f
Nevashka/Project-Euler
/palindrome.py
591
4.1875
4
#Problem 4: Find the largest palindrome made from the product of two 3-digit numbers. def largest(digits): ''' (int) -> int return the largest palindrome from the product of the numbers with the given number of digits palindrome(2) -> 9009 ''' first = 10**(digits-1) last = (10**digits)-1 ...
true
b6de5d4434c5d21dbbafe799879b02b43278c2ec
davidlbyrne/cybersecurity
/assignment2/des_cbc.py
2,882
4.15625
4
#!/usr/local/bin/python3 # Assignment2 - Assignment 2, due November 7, 2018: Problem 6.1 # in the lecture notes. You may import the following packages from # Python libraries: import sys import binascii from Crypto.Cipher import DES from Crypto import Random def checkpad(plaintext): length= len(plaintext) ...
true
72e11ac47280c2ff079353f3e92a744fb16de490
sabasharf123/word-frequency
/word-frequency-starter.py
2,824
4.21875
4
#set up a regular expression that can detect any punctuation import re punctuation_regex = re.compile('[\W]') #open a story that's in this folder, read each line, and split each line into words #that we add to our list of storyWords storyFile = open('short-story.txt', 'r') #replace 'short-story.txt' with 'long-story.t...
true
aec85ea6f687ec7516c577d5ddd58ed90f72e18f
tigerjoy/SwayamPython
/old_programs/cw_17_06_20/year.py
471
4.15625
4
year=int(input("enter year :")) if year%100==0: print("it is a centennial year") if year%400==0: print("it is a leap year") else: print("it is not a leap year") elif year%4==0: print("it is a leap year") else: print("it is not a leap year") # Alternative # if (year % 100 == 0) and (year % 400 == 0):...
true
571a5322ed3b18be4a319ffa3a14a9541b6f08d3
tigerjoy/SwayamPython
/old_programs/cw_2021_01_16/dictionary_exercise.py
639
4.1875
4
dict_users={} for i in range(1,11): # Enter username of user 1: username=input("Enter username of user {}:".format(i)) password=input("Enter password of user {}:".format(i)) dict_users[username]=password print("Enter log in details:") username=input("Enter username of user :") password=input("Enter password o...
true
3b51f2f0f0267366f5c1b246267ca3c10105cf9b
tigerjoy/SwayamPython
/old_programs/cw_2021_01_16/list_exercise.py
623
4.15625
4
list1 = [] list2 = [] size1 = int(input("Enter the size of list 1: ")) print("Enter elements in list 1") for i in range(size1): item = int(input("Enter element {}: ".format(i + 1))) list1.append(item) size2 = int(input("Enter the size of list 2: ")) print("Enter elements in list 2") for i in range(size2): ite...
true
12d9d1eb684dad8946f5c66c30eb5faec45c3f72
tigerjoy/SwayamPython
/old_programs/cw_2020_10_22/list_q15.py
264
4.34375
4
size=int(input("Enter size of a list:")) arr=[] for i in range(0,size): item=int(input("Enter element {}:".format(i+1))) arr.append(item) largest=arr[0] for i in range(1,size): if(arr[i]>largest): largest=arr[i] print("Largest element is:",largest)
true
2cc2a7b4d5e441bdd774cdd94d14d54257b2c91e
tigerjoy/SwayamPython
/old_programs/cw_2020_10_22/list_q16.py
269
4.25
4
size=int(input("Enter size of a list:")) arr=[] for i in range(0,size): item=int(input("Enter element {}:".format(i+1))) arr.append(item) smallest=arr[0] for i in range(1,size): if(arr[i]<smallest): smallest=arr[i] print("smallest element is:",smallest)
true
8c8c861daf4fb6f0c70eb776d8563907dda10f35
Yuchen-Yan/UNSW_2017_s2_COMP9021_principle_of_programming
/labs/lab_1/my_answer/celsius_to_fahrenheit.py
435
4.1875
4
# Written by Yuchen Yan for comp9021 lab 1 question1 ''' Prints out a conversion table of temperatures from Celsius to Fahrenheit degrees, with the former ranging from 0 to 100 in steps of 10. ''' min_temperature = 0 max_temperature = 100 step = 10 print('Celsius\tFahrenheit') for celsius in range(min_temperature,...
true
20e61a14ba04a69c1095840c5b33ff936f6a8d3b
vpiyush/SandBox
/python-samples/rangeOp.py
330
4.15625
4
# sequnce of numbers 0 to 8 for temp in range(9): print(temp) # sequnce of numbers 0 to 8 # range (start, stop) for temp in range(5, 9): print(temp) # sequnce of numbers 0 to 8 # range (start, stop, step) for temp in range(1, 9, 2): print(temp) #typecasting to list oddlist = list(range(1, 19, 2)) print...
true
27a48c5d309c06a6730df859139245bec6106a37
sureshanandcse/Python
/listex.py
693
4.34375
4
# Creating a List with the use of multiple values l= ["Sairam", "Engineering", "College"] print("\nList containing multiple values: ") print(l[0]) print(l[2]) s=l[1] print("s= ",s) print("s[2] =" ,s[2]) print(len(l)) """ list = [ 'abcd', 786 , 2.23, 'john', 70.26 ] list[0]='suresh' # list is mutab...
true
125c4341943e9781fc9ee60b35e6beb13717c4aa
peggybarley/Ch.03_Input_Output
/3.0_Jedi_Training.py
1,568
4.375
4
# Sign your name: Peggy Barley # 1.) Write a program that asks someone for their name and then prints their name to the screen? print() name = str(input("What is your name?")) print("Hello,", name,"!") print() # 2. Write a a program where a user enters a base and height and you print the area of a triangle. print(...
true
7ee6a48e8387a0d45ea82cf44b3e7b679dfcc503
kongxilong/python
/mine/chaptr3/readfile.py
341
4.3125
4
#!/usr/bin/python3 'readTextFile.py--read and display text file' #get file name fname = input('please input the file to read:') try: fobj = open(fname,'r') except: print("*** file open error" ,e) else: #display the contents of the file to the screen. for eachline in fobj: print(eachline,)...
true
6c9b1f856e9c1abb350336b26b76f48a87a9f1bb
antwork/pynote
/source/str.py
1,872
4.25
4
# encoding:utf-8 # len(str) s = 'hello China' print(len(s)) # # capitalize # Return a capitalized version of S, i.e. make the first character # have upper case and the rest lower case. print('big city'.capitalize()) # Big city #encode:utf-8 # # casefold # out: **********************value**********************...
true
8416779fee766e6ad1dbbf23bc88cdd02c7a7706
n0execution/prometheus-python
/lab5_3.py
635
4.40625
4
""" function for calculating superfibonacci numbers it is a list of whole numbers with the property that, every n term is the sum of m previous terms super_fibonacci(2, 1) returns 1 super_fibonacci(3, 5) returns 1 super_fibonacci(8, 2) returns 21 super_fibonacci(9, 3) returns 57 """ def super_fibonacci(n, m) : #chec...
true
5cf0406aa64a6679f4aea84a4662d819dad13d4a
TaylorKolasinski/hackerrank_solutions
/strings/pangrams.py
1,122
4.3125
4
# Difficulty - Easy # Problem Statement # Roy wanted to increase his typing speed for programming contests. So, his friend advised him to type the sentence "The quick brown fox jumps over the lazy dog" repeatedly because it is a pangram. ( pangrams are sentences constructed by using every letter of the alphabet at lea...
true
8c31f4a29804ccecb16daedd837a65ea8fd375bb
JAT117/Notes
/CSCE4910/PythonExamples/TexBoxWidget.py
827
4.25
4
#!/usr/bin/env python3 import tkinter as tk from tkinter import ttk # Create instance win = tk.Tk() # Add a title win.title("Python GUI") #Handles Button Clicked def clickMe(): #When clicked, change name of button. ...
true
674c75a565efdf149d612db8fead1899d1e5336e
vedk21/python-playground
/Intermediate/OOP/Abstraction/abstraction.py
710
4.1875
4
# Abstraction (hiding the details of operation but availabling the interface open) class Car: def __init__(self, name, color, year): self.name = name self.color = color self._year = year # _ represents it understood as private member def drive(self): print('driving {self.name} a car of color {self...
true
104cc6f2a2c4044a905c748603f3998535f84b0f
taylorak/python-demo
/03-if-statement/if_statement.py
767
4.1875
4
''' Working with if-then statements ''' def if_else(correct): "Checks if correct is true or not" if correct: print("true statement") else: print("false statement") if_else(True) if_else(False) def check_nums(num1, num2): ''' Checks which number is greater ''' if num1 > n...
true
2e1e275dd7191f8b18fe73af0a8d7cde49c95289
gaurangalat/SI506
/Gaurang_DYU2.py
1,163
4.3125
4
#Week 2 Demonstrate your understanding print "Do you want a demo of this week's DYU?\nA. Yes B. Not again\n" inp = raw_input("Please enter your option: ") #Take input from user if (inp =="B" or inp =="b"): print "Oh well nevermind" elif(inp == "A" or inp =="a"): #Check Option print "\nHere are a few comic...
true
8db034fea3cc39b02329ea5246f5a526caa3f88d
Ktulu1/Learning_Python3_The_Hard_Way
/ex20-1.py
1,555
4.15625
4
# import argv from library sys from sys import argv # setup variables for argv script, input_file = argv # define a function that prints the entire contents of the file def print_all(f): print(f.read()) # define a function that seeks to the begining of the file def rewind(f): f.seek(0) # define a fuction th...
true
9f04f14496b13a8a9b851f6758bf9b0dfb62c46a
Ktulu1/Learning_Python3_The_Hard_Way
/ex16.py
1,209
4.28125
4
# load argv from the sys library from sys import argv # define variables for argv script, filename = argv # echo some text with a varaible in it print(f"We're going to erase {filename}.") print("If you don't want that, hit CTRL-C (^C).") print("If you want that, hit RETURN.") # set the prompt input("?") # echo some...
true
fdaae9577fa0821a143ca185cc1019d03bcf5202
Nathnos/probabilistic_battleships
/game/board_setup.py
1,920
4.1875
4
""" Main game functions """ import numpy as np from game.game_tools import ( get_direction, get_boat_size, get_random_direction, get_random_position, ) def can_place(grid, boat, position, direction): """ grid : numpy array boats : represented by an integer position : tuple (x, y) ...
true
221c0daa1d412fc285fd01b8386202029931e2d0
arnab-arnab/Python-Course
/06.Chapter 6/Question 4.py
211
4.15625
4
text=input("Enter the text:\n") a=len(text) print("Length is:",a) if(a<10): print("The length is less than 10") if(a>10): print("The length is greater than 10") if(a is 10): print("The length is 10")
true
f1e5cca8210d307dbe84e01717b19d11ee7298f9
arnab-arnab/Python-Course
/04.Chapter 4/Question_3.py
403
4.25
4
print("Enter three elements to be stored in tuple") a1=input("Enter the 1st element: ") a2=input("Enter the 2nd element: ") a3=input("Enter the 3rd element: ") tupl=(a1,a2,a3) print(tupl) print("Which of the element of the tuple would you try to change\n") print("0\t1\t2\n") a4=input("Enter the index value from th...
true
6002071aa47b871e3cfb4121562fcc334392ebf3
arnab-arnab/Python-Course
/05.Chapter 5/02_Dictionary_Methods.py
1,239
4.375
4
myDict={ "Fast":"In a quick manner", "Arnab":"A coder", "Marks":[1,2,5], "Li":(3,44,6), "Number": 5, "anotherDict":{"Devesh":"Doggy", "Sneha":"Bitch", "Deborshi":"Cow", "Sex_Position":69 } } # DICTIONARY METHODS pri...
true
f7ed51b9039ee4b5488431c519be8027e383b5e6
markkampstra/examples
/Python/fizzbuzz.py
1,620
4.25
4
#!/usr/bin/python # FizzBuzz by Mark Kampstra # # Write a program that prints the numbers from 1 to 100. # But for multiples of 3 print "Fizz" instead of the number and for the multiples of five print "Buzz". # For numbers which are multiple of both 3 and 5, print "FizzBuzz". # import string class FizzBuzz: '''The...
true
ea3cd26f2804b5ac8850ea448d8dcb23f9e1cca9
dbozic/useful-functions-exploration
/column_unique_values.py
1,252
4.71875
5
def column_unique_values(data, exclusions): """ This function goes through each column of a dataframe and prints how many unique values are in that column. It will also show what those unique values are. The function is particularly useful in exploratory data analysis for quick understandi...
true
45af716bb44964e643e8bf989626a735719dbdca
judyohjo/Python-exercises
/Python exercise 12 - List.py
396
4.3125
4
''' Exercise 12 - Get the smallest number from each list and create a new list and print that new list. ''' list1 = [1, 3, 5, 0, 2, 3] list2 = [3, 5, 3, 56, 7, 22] list3 = [67, 34, 24, 15, 88, 99] newlist = [] smallest1 = min(list1) smallest2 = min(list2) smallest3 = min(list3) newlist.append(smallest...
true
fbaf080f19aea0424908dfa870cf4213753b719a
judyohjo/Python-exercises
/Python exercise 11 - Input.py
209
4.21875
4
''' Exercise 11 - Input a number and print the number of times of "X" (eg. if number is 3, print... X XX XXX) ''' num = int(input("Input a number: ")) for i in range(1, num+1): print(i*"X")
true
a05605bc741df904178fa79706fc90b7bedd50bf
schappidi0526/IntroToPython
/20_IterateOnDictionary.py
811
4.65625
5
grades={'Math': 100, 'Science': 80, 'History': 60, 'English': 50} grades['Biology']=70 #To print just keys for key in grades: print(key) #To print keys along with their values for key in grades: print(key,grades[key]) for key in grades.keys(): print(key,grades[key]) ...
true
eb63068b4b356aa525322e418921c6b23f681c6b
schappidi0526/IntroToPython
/22_Update&DeleteDictionary.py
1,088
4.3125
4
#Merge/Update dictionary dict1={'Math':99, 'science':98, 'history':33} dict2={'telugu':88, 'hindi':77, 'english':99, 'Math':69}#If you have same keys in both dictionaries,values will be updated dict1.update(dict2) print (dict1) dict2.update(dict1) print(sorted(...
true
9a403dad3118c5410b09b4969f8e2ff2f7fb41f1
problems-forked/Dynamic-Programming
/0_1 Knapsack/Programmes/main(14).py
1,149
4.15625
4
def find_target_subsets(num, s): totalSum = sum(num) # if 's + totalSum' is odd, we can't find a subset with sum equal to '(s + totalSum) / 2' if totalSum < s or (s + totalSum) % 2 == 1: return 0 return count_subsets(num, int((s + totalSum) / 2)) # this function is exactly similar to what we have in 'C...
true
6e6b8dbcdd7d5cbfef4c7ae9005cbd2639671f18
fanliu1991/LeetCodeProblems
/38_Count_and_Say.py
1,473
4.21875
4
''' The count-and-say sequence is the sequence of integers with the first five terms as following: 1. 1 2. 11 3. 21 4. 1211 5. 111221 1 is read off as "one 1" or 11. 11 is read off as "two 1s" or 21. 21 is read off as "one 2, then one 1" or 1211. Given an integer n, generate the n-th term of the count-and-say sequen...
true
da22091944898edbfca31ed8919e568a6802d8ec
fanliu1991/LeetCodeProblems
/75_Sort_Colors.py
2,115
4.28125
4
''' Given an array with n objects colored red, white or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order red, white and blue. Here, we will use the integers 0, 1, and 2 to represent the color red, white, and blue respectively. Note: You are not suppose to use the ...
true
0cd58414e3ad8e23d1532ba3509d4e005d9f5cf0
fanliu1991/LeetCodeProblems
/89_Gray_Code.py
1,833
4.25
4
''' The gray code is a binary numeral system where two successive values differ in only one bit. Given a non-negative integer n representing the total number of bits in the code, print the sequence of gray code. A gray code sequence must begin with 0. For example, given n = 2, return [0,1,3,2]. Its gray code sequence...
true
5a81227b5affe10bfea4b5acabb0dcea57f9ec68
fanliu1991/LeetCodeProblems
/125_Valid_Palindrome.py
1,278
4.1875
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 ''' imp...
true
97de3552794dbc0e04be28659349f09d415702ba
fanliu1991/LeetCodeProblems
/101_Symmetric_Tree.py
2,889
4.25
4
''' Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). Example 1: input: binary tree [1,2,2,3,4,4,3] output: True 1 / \ 2 2 / \ / \ 3 4 4 3 Example 2: input: binary tree [1,2,2,null,3,null,3] output: False 1 / \ 2 2 \ \ 3 3 ''' import ...
true
5c4c4b8c30d09c8a7163d24ff3030fa4b3e0ce34
Shehu-Muhammad/Python_College_Stuff
/Problem4_CupcakeRequest.py
459
4.125
4
# Shehu Muhammad # Problem 4 -Requests the number of cupcakes ordered and displays the total cost # May 7, 2018 orders = int(input("What are the total number of cupcake orders? ")) cost = 0 small = 0.75 large = 0.70 if(orders <= 99 and orders>=1): cost = cost + (orders*small) elif(orders >= 100): cost = cost +...
true
05228bb597c8d13f1e2e6427a2a307e0abf2ee02
Shehu-Muhammad/Python_College_Stuff
/Python Stuff/Guess.py
1,156
4.125
4
# Guess my number # Shehu Muhammad import random import math random.seed() randomNumber = math.floor(random.random() * 100) + 1 # generates a random number between 1 and 100 guess = 0 # initializes guess to zero count = 0 # initiali...
true
5a1e50c525e772ece7944a9c7609ac8cb5ad79bb
CoderDojoNavan/python
/basics/4_inputs.py
985
4.125
4
"""4: Inputs""" # Sometimes you might want to ask the user a question. To do that, we use # a special function called `input`. Functions are covered in `5-functions.py`. # You can ignore the # pylint comment, it is there to tell tools which analyze # the code that in fact everything is OK with this line. days = 365 ...
true
78b7f69d1513f3d252d07e30f3970be2beec094b
benjaminhuanghuang/dl-study
/keras_first_network.py
2,038
4.78125
5
''' Develop Your First Neural Network in Python With Keras Step-By-Step https://machinelearningmastery.com/tutorial-first-neural-network-python-keras/ The steps you are going to cover in this tutorial are as follows: Load Data. Define Model. Compile Model. Fit Model. E...
true
2265d032ca4fc7148a6ff610e6fdd3d095484c5f
charukiewicz/Numerical-Methods
/convergence.py
1,501
4.125
4
# -*- coding: utf-8 -*- """ @author: Christian Charukiewicz (netid: charuki1) This compares the rates of convergence between the Newton and Secant methods. The program will print output values and display a plot in matplotlib. More info: - http://en.wikipedia.org/wiki/Newton's_method - http://en.wi...
true
de96cc585410c8356590a971bd86505045a03f9e
azrlzhao/password-safty-check-
/check_password.py
1,724
4.125
4
#Password security check code # # Low-level password requirements: # 1. The password is composed of simple numbers or letters # 2. The password length is less than or equal to 8 digits # # Intermediate password requirements: # 1. The password must consist of numbers, letters or special characters (only: ~!@#$%...
true
ab7b5ff8e907d45ef3cfbec2bb611ada3b68058d
daninick/test
/word_count.py
1,318
4.375
4
import re filename = input(''' This program returns the words in a .txt file and their count in it. Enter a .txt file name: ''') f = open(filename, 'r') # Read the file and convert it to a string text = f.read() # Ignore the empty lines text = text.replace('\n', ' ') # All words in the text are separated by spac...
true
c38e0d609c3414396e23f7ae50b2bf4695477eb6
rrotilio/MBA539Python
/p20.py
482
4.15625
4
validInt = False def doRepeat (str1,int1): i = 0 while (i < int1): print(str1) i = i + 1 print("I like to repeat things.") varStr = str(input("What do you want me to repeat?: ")) while not validInt: try: varInt = int(input("How many times should I repeat it?: ")) if(varInt < 0): print("I can't repeat ...
true
856f36bd79f0866552aa760bd9cea652ee4cfdbb
dwzukowski/PythonDojo
/funwithfunctions.py
2,051
4.625
5
def multiply(list, num): newList = [] for val in list: newList.append(val*num) return newList #we declare a function called layered_multiples which takes one parameter arr def layered_multiples(arr): #we declare a variable called new_array which is an empty list new_array = [] #we insta...
true
a03dbd25a62938ef0ed68df80d0df1df9983125e
dwzukowski/PythonDojo
/comparingArrays.py
1,379
4.3125
4
#we declare a function called compareArrays which takes two parameters, list one and list two def compareArrays(list_one, list_two): #we delcare a variable answer which is string answer = "" #we compare the lengths of teh two lists; if they are not equal the list cannot be the same if len(list_one) != l...
true
d1f1d9a4d2a03bab8643fb8c00c5dcccf7b1462a
dwzukowski/PythonDojo
/classesIntroBike.py
2,318
4.75
5
#we declare a class called bike class Bike(object): #we set some instance variables; the miles variable will start at zero for every instance of this class def __init__(self, price, max_speed): self.price = price self.max_speed = max_speed self.miles = 0 #we declare a method called ...
true
7654c068f8136a957fd0f17a00f00c130c0af639
dwzukowski/PythonDojo
/typeList.py
1,091
4.34375
4
#we declare a function called typeList that takes one paramater, list def typeList(list): newStr = "" sum = 0 #instantiate a for loop for i in range(0,len(list)): if isinstance(list[i], int): sum+=list[i] elif isinstance(list[i], float): sum+=list[i] ...
true
8e662865c92c45a66ab05eb834ac525f87863c30
19h61a0507/python-programming-lab
/strpalindrome1.py
205
4.375
4
def palindrome(string): if(string==string[::-1]): print("The string is a palindrome") else: print("Not a palindrome") string=input("enter the string") palindrome(string)
true
bdb456492eb7c89a11f0528f2fa631e76f353031
peiyong-addwater/2018SM2
/2018SM2Y1/COMP90038/quizFiveSort.py
2,748
4.28125
4
def insertionSort(arr): assignment = 0 # Traverse through 1 to len(arr) for i in range(1, len(arr)): key = arr[i] assignment = assignment +1 # Move elements of arr[0..i-1], that are # greater than key, to one position ahead # of their current position j = ...
true
9b1f7b2a6b5cf52bd6406563714300f1e32d1f3d
crazywiden/Leetcode_daily_submit
/Widen/LC543_Diameter_of Binary_Tree.py
1,564
4.25
4
""" 543. Diameter of Binary Tree Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path may or may not pass through the root. Example: Given a binary tree 1 / \ ...
true
83163acd94774048c6ed331b41da1d5bb8a904ca
crazywiden/Leetcode_daily_submit
/Widen/LC376_Wiggle_Subsequence.py
1,871
4.25
4
""" A sequence of numbers is called a wiggle sequence if the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may be either positive or negative. A sequence with fewer than two elements is trivially a wiggle sequence. For example, [1,7,4,9,2,...
true
628f8ab619e1460c897cdacfb238dd69b0cb94eb
crazywiden/Leetcode_daily_submit
/Widen/LC394_Decode_String.py
1,811
4.15625
4
""" 394. Decode String Given an encoded string, return its decoded string. The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times. Note that k is guaranteed to be a positive integer. You may assume that the input string is always valid; No extra ...
true
a953d20e0094da3a509afd7ae9a8cda33aeee6cf
crazywiden/Leetcode_daily_submit
/Widen/LC408_Valid_Word_Abbreviation.py
2,325
4.1875
4
""" 408. Valid Word Abbreviation Given a non-empty string s and an abbreviation abbr, return whether the string matches with the given abbreviation. A string such as "word" contains only the following valid abbreviations: ["word", "1ord", "w1rd", "wo1d", "wor1", "2rd", "w2d", "wo2", "1o1d", "1or1", "w1r1", "1o2", "2r...
true
7b98a0b5d9e81cc2d8fc1aca7e1e6e26dd164eae
crazywiden/Leetcode_daily_submit
/Widen/LC71_Simplify_Path.py
1,287
4.28125
4
""" 71. Simplify Path Given an absolute path for a file (Unix-style), simplify it. Or in other words, convert it to the canonical path. In a UNIX-style file system, a period . refers to the current directory. Furthermore, a double period .. moves the directory up a level. For more information, see: Absolute path vs r...
true
94ddc5ac813e101d378660e725d8cf258418e701
elle-johnnie/Arduino_Py
/PythonCrashCourse/fizzbuzz.py
762
4.1875
4
# fizzbuzz in Python 2.7 ## # I just heard about this at a local meetup - thought I'd give it a go. # The rules: # Write a program that prints the numbers from # 1 to 100. But for multiples of three print Fizz instead of the number and for the multiples of five print # Buzz. For numbers which are multiples of both thre...
true
6a26ef4cc53b955a98306b03c895c19e94264020
elle-johnnie/Arduino_Py
/edX_CS_exercises/number_guess_bisect.py
988
4.3125
4
# The program works as follows: you (the user) thinks of an integer between 0 (inclusive) and 100 (not inclusive). # The computer makes guesses, and you give it input - is its guess too high or too low? Using bisection # search, the computer will guess the user's secret number! # edX wk 2 Algorithms # solution attempt ...
true
2ae130d5f467c00cd8c54b05409bbf4839b8579a
shaunn/projecteuler
/Problem1/py/p1.py
1,730
4.21875
4
# divisors of 3 and 5 # # Problem 1 # If we list all the natural numbers below 10 that are divisors of 3 or 5, we get 3, 5, 6 and 9. # The sum of these divisors is 23. # # Find the sum of all the divisors of 3 or 5 below 1000. # Strategies # # 1. `remainder = dividend - divisor * quotient` and `remainder=0` # 2. Using...
true
ab403bbb4698cc504ca55c83af4067710a785ae6
ziyadalvi/PythonBook
/6The Dynamic Typing Interlude/3GarbageCollection.py
1,251
4.28125
4
#when we reassign a variable, what happens to the value it was #previously referencing? For example, after the following statements, what happens to #the object 3? """The answer is that in Python, whenever a name is assigned to a new object, the space held by the prior object is reclaimed if it is not referenced by an...
true
655c7e3810af8e5c502f65f2a95892598a45e1b9
anila-a/CEN-206-Data-Structures
/lab04/mainPolygon.py
1,306
4.5625
5
''' Program: mainPolygon.py Author: Anila Hoxha Last date modified: 03/21/2020 Design a class named Polygon to represent a regular polygon. In regular polygon, all the sides have the same length. The class contains: Constructor: Instance Variable: n โ€“ number of sides with default value 3, side โ€“ length of th...
true
84f6fd7694a4f63abc9c445f7a2d0a6c13ab57a8
anila-a/CEN-206-Data-Structures
/hw01/hw1_2.py
868
4.125
4
''' Program: hw1_2.py Author: Anila Hoxha Last date modified: 04/2/2020 Consider the Fibonacci function, F(n), which I defined such that ๐น(1) = 1, ๐น(2) = 2, ๐‘Ž๐‘›๐‘‘ ๐น(๐‘›) = ๐น(๐‘› โˆ’ 2) + ๐น(๐‘› โˆ’ 1) ๐‘“๐‘œ๐‘Ÿ ๐‘› > 2. Describe an efficient algorithm for determining first n Fibonacci numbers. What is the running tim...
true
500e415d59727e99428a28bb85835e81a35eb836
anila-a/CEN-206-Data-Structures
/midterm/Q1/main_Q1.py
439
4.25
4
''' Program: main_Q1.py Author: Anila Hoxha Last date modified: 05/14/2020 Implement a program that can input an expression in postfix notation (see Exercise C-6.22) and output its value. ''' from postfix import * ''' Test the program with sample input: 52+83-*4/ ''' exp = str(input("Enter the expressi...
true
ac14eab101249ad1f9e19f01f9add32ad7e01e7a
anila-a/CEN-206-Data-Structures
/lab04/mainFlight.py
1,761
4.5
4
''' Program: mainFlight.py Author: Anila Hoxha Last date modified: 03/21/2020 Design then implement a class to represent a Flight. A Flight has a flight number, a source, a destination and a number of available seats. The class should have: โ€ข A constructor to initialize the 4 instance variables. You must shorte...
true
3d4cbfbfc5da19abbc3fd2b8c9e99d4192f48e4c
anila-a/CEN-206-Data-Structures
/midterm/Q2/B/singlyQueue.py
2,276
4.1875
4
''' Program: singlyQueue.py Author: Anila Hoxha Last date modified: 05/16/2020 Write a singlyQueue class, using a singly linked list as storage. Test your class in testing.py by adding, removing several elements. Submit, singlyQueue.py and testing.py. ''' class SinglyQueue: # FIFO queue implementation u...
true
fd59412ce8e23b59d93543166848d4c9ff9f25b6
urmidedhia/Unicode
/Task1Bonus.py
1,543
4.28125
4
number = int(input("Enter number of words : ")) words = [] print("Enter the words : ") for i in range(number): # Taking input in a list words element = input() words.append(element) dist = [] for word in words: # Adding distinct words to a list dist ...
true
d161e2a732a5c0c15610d8145b428419b87bcd9a
Yaasirmb/Alarm-Clock
/alarm.py
602
4.125
4
from datetime import datetime import time from playsound import playsound #Program that will act as an alarm clock. print("Please enter your time in the following format: '07:30:PM \n") def alarm (user = input("When would you like your alarm to ring? ")): when_to_ring = datetime.strptime(user, '%I:%M:%p').tim...
true
5c4d4fd464c0fa9bbb58f4f34125cff05b1a3d57
PauloHARocha/accentureChallenge
/classification_naiveBayes.py
2,036
4.125
4
import pandas as pd from sklearn.naive_bayes import MultinomialNB from sklearn.model_selection import train_test_split from sklearn import metrics # Naive Bayes # The objective of this module is to classify the data from the pre-processed dataset, # based on the alignment of each hero (good or bad), using the Naive B...
true
770dc7e863343aabae12f23a99b7da024c5827d1
ZakOpry/digital-crafts
/week1/day3/introToPython4.py
271
4.15625
4
# Conditionals print("Welcome to this program") firstName = input("What is your first name?") length_of_first_name = len(firstName) print(firstName) if length_of_first_name <= 0: print("Please enter at least one character") else: print(f"Hello {firstName}")
true
07b213e5a72caa2ce55966adfcdeb5ddf8b05362
HughesSvynnr/prg1_homework
/hw4.py
1,891
4.125
4
''' problem 1 Ask a user for a number. Depending on the number, respond with how many factors exist within that number for example: Enter a number >15 15 has 4 factors, which are 1 3 5 15 ''' ''' problem 2 Write a program that will ask a user for a word. For that word, replace each letter with the appropr...
true
be0d9eb645a4aeadd0f5dc9e5c78336aba9d7527
IvanKelber/plattsburgh-local-search
/Circles/circle.py
2,119
4.15625
4
# Created by Ivan Kelber, March 2017 import sys import random import math def circles(points): ''' - points is a list of n tuples (x,y) representing locations of n circles. The point (x,y) at points[i] represents a circle whose center is at (x,y) and whose radius is i. This function retu...
true
743606a3c25a96d1e7addb7ac6294bc04319f527
NaughtyJim/learning-python
/2019-09-16/trees.py
898
4.34375
4
def main(): width = input('How wide should the tree be? ') height = input('How tall should the tree be? ') print("Here's your tree:") print() width = int(width) height = int(height) # this is the call if we omit the height # print_tree(width, width // 2 + width % 2) print_tree(widt...
true
a32ecf010adc0c1fde48a03a73def9282c101def
Pallavi2000/heraizen_internship
/internship/M_1/digit.py
388
4.21875
4
"""program to accept a number from the user and determine the sum of digits of that number. Repeat the operation until the sum gets to be a single digit number.""" n=int(input("Enter the value of n: ")) temp=n digit=n while digit>=10: digit=0 while not n==0 : r=n%10 digit+=r n=n//10 ...
true
82b7d80de1f353d744906bbe3203149cad2299e2
Pallavi2000/heraizen_internship
/internship/armstrong.py
291
4.375
4
"""Program to check whether a given number is armstrong number or not""" n=int(input("Enter the value of n: ")) temp=n sum=0 while not temp==0: r=temp%10 sum+=r**3 temp=temp//10 if n==sum: print(f"{n} is a armstrong number") else: print(f"{n} is not a armstrong number")
true