blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
4d831645a79f5e033d17666419695bf3679de4e1
tkachyshyn/move_in_json
/move_in_json.py
1,210
4.25
4
''' this module helps the user to move in the json file ''' import json def open_file(path): ''' open file and convert data into dictionary ''' f = open(path) data = json.load(f) return data lst = [] def keys(data): ''' help the user to choose keys and to move within them in t...
true
f185cf0f7b3352771916dc9ab3a2a936ee6751ee
sharvarij09/LMSClub
/Find_Monday
933
4.6875
5
#!/usr/bin/env python3 # #This is my code which includes a function that will check if i have "Monday" in my calender and prints it in Uppercase # def find_monday(mycalender1): mycalendar1 = """Day Time Subject Monday 9:10 AM - 10:15 AM LA ...
true
fabe66fb9a56ea0cef30df8dc94fa5d05ebf2274
erlaarnalds/TileTraveller
/int_seq.py
660
4.34375
4
num=int(input('Enter an integer: ')) cumsum=0 maxnum=0 odd=0 even=0 while num>0: cumsum=cumsum+num print('Cumulative total: ', cumsum) #finding the maximum number if num>maxnum: maxnum=num #counting odd and even numbers if num%2==0: even+=1 else: odd+=1 ...
true
fcc48fbf44c772f1a894bc4a79afbb21f90eff89
Pav-lik/Maturita-CS
/Programy/06 - Eratosthenovo síto/sieve.py
533
4.28125
4
limit = int(input("The limit under which to look for primes: ")) # create a boolean array sieve_list = [True] * limit primes = [] for i in range(2, limit): # if the number hasn't been crossed out, cross out all its multiplicands and add it to the list if sieve_list[i]: primes.append(i) ...
true
9f90c56bc44c827e75a879f8e343865dc3a7fc7f
amberheilman/info636
/3BHeilmanCODE.py
2,655
4.125
4
""" Name: Assignment 2B Purpose: - read out one number at a time from a file - User may (A) Accept (R) Replace (I) Insert or (D) Delete the number shown - User may (S) Save file with remainder of numbers unchanged - User may (W) Rename file and leave original file undisturbed Error Conditions: -Reach end of file -Impr...
true
a8e42771a2f2a89fd53f18b05c19f9de68ad1108
ndanielsen/intro-python
/class_two/04_exercise.py
1,136
4.59375
5
""" Extracting city names from a list of addresses Exercise: Modify `extract_city_name()` to get the city name out of the address_string """ list_of_addresses = [ "Austin, TX 78701", "Washington, DC 20001", "Whittier, CA 90602", "Woodland Hills, CA 91371", "North Hollywood, CA 91601" "Baltim...
true
64bd846c948d790a2870d7a84465b090730a8abf
datazuvay/python_assignments
/assignment_1_if_statements.py
249
4.125
4
#!/usr/bin/env python # coding: utf-8 # In[ ]: name = input("Please enter your name: ") user_name = "Joseph" if name == user_name: print("Hello, {}! The password is: W@12".format(name)) else: print(f"Hello {name}! See you later!")
true
b324e1c6fc51aa01ce6567a7ef9cc60dfaae23be
RajanIsBack/Python_Codes
/Bank_ATM_simulation.py
941
4.28125
4
'''ATM Simulation Check Balance Make a Withdrawal Pay In Return Card ''' bank_pin =5267 entered_pin = int(input("Enter your bank pin")) if(entered_pin != bank_pin): print("Wrong pin.Exiting and returning card") else: print("WELCOME USER !!. Choose from below options") print("1.Check Balance") pri...
true
52aba9b05d89481b5ef529a911c7e4e1bb7d8e78
davkandi/MITx-6.00.1x
/ps6/test.py
1,582
4.71875
5
import string def build_shift_dict(shift): ''' Creates a dictionary that can be used to apply a cipher to a letter. The dictionary maps every uppercase and lowercase letter to a character shifted down the alphabet by the input shift. The dictionary should have 52 keys of all the uppercase letters a...
true
95c22214e2e788540f942e9bf8380852fa33d23e
anikahussen/algorithmic_excercises
/functions/check_answer.py
506
4.25
4
def check_answer(number1,number2,answer,operator): '''processing: determines if the supplied expression is correct.''' expression = True if operator == "+": a = number1 + number2 if answer == a: expression = True elif answer != a: expression = False ...
true
ee8969f29c4e9f16093c5b50bee0ad0d38f4ed94
thphan/Nitrogen-Ice-cream-Shop-Monte_Carlo_Simulation
/Distribution.py
2,450
4.40625
4
# Distribution needed in simulation import random class RandomDist: # RandomDist is a base abstract class to build a Random distribution. # This class contains an abstract method for building a random generator # Inherited class must implement this method def __init__(self, name): self._name ...
true
0d1c478f529b2ec27f98f77c0b03e799c12e0479
trejp404/FileWritingProgram
/week10program.py
2,831
4.21875
4
# Prepedigna Trejo # Assignment 10.1 import os #imports OS library import time #imports time # print() for cleaner output print() # welcome message print("---Welcome---") # print() for cleaner output print() # sleep for 2 seconds time.sleep(2) print("---To create and store a new file, follow the directions below.---"...
true
291638d0af06b1379f39c69a86a9290d0607607d
sapnajayavel/FakeReview-Detector
/features/edit_distance.py
2,264
4.15625
4
#!/usr/bin/env python2.7 #encoding=utf-8 """ Code about implementing calculate min edit distance using Dynamic Programming. Although the method is used for compare similariy of two strings,it can also be used to compare two vectors Code from http://blog.csdn.net/kongying168/article/details/6909959 """ class EditDista...
true
fc46624c8d57c289ea99c4efdb5cc0de0c6d8e71
namnhatpham1995/HackerRank
/findthepositionofnumberinlist.py
559
4.28125
4
#Given the participants' score sheet for your University Sports Day, #you are required to find the runner-up score. You are given scores. #Store them in a list and find the score of the runner-up. # in put n=5, arr= 2 3 6 6 5 => output 5 if __name__ == '__main__': n = int(input()) arr = map(int, input(...
true
64234ee7f6d0b26f6a512e3da1526a4a82835b77
dyrroth-11/Information-Technology-Workshop-I
/Python Programming Assignments/Assignemt2/18.py
633
4.15625
4
#!/usr/bin/env python3 """ Created on Thu Apr 2 10:49:02 2020 @author: Ashish Patel """ """ Define a function reverse() that computes the reversal of a string. For example, reverse(“I am testing”) should return the string ”gnitset ma I”. LOGIC:In this we take a string as input and define a empty string rev_string ...
true
0a3fdbe0b48cedd0c706d38fd17273080ef34e43
dyrroth-11/Information-Technology-Workshop-I
/Python Programming Assignments/Assignemt1/7.py
884
4.21875
4
#!/usr/bin/env python3 """ Created on Wed Mar 25 07:34:41 2020 @author: Ashish Patel """ """ # Write a Python function that prints out the first ‘n’ rows of Pascal's triangle. ‘n’ is user input. LOGIC:1)As we know pascals triange consist of the binomial coefficient of (1+x)^(n-1) for nth row. 2)Therefore we com...
true
1c36f2fee1cdbb19c9a4bc35467bb10216776c70
dyrroth-11/Information-Technology-Workshop-I
/Python Programming Assignments/Assignemt4/13.py
642
4.1875
4
#!/usr/bin/env python3 """ Created on Thu Apr 16 09:46:08 2020 @author: Ashish Patel """ """ Write a NumPy program to find the number of elements of a given array, length of one array element in bytes, and the total bytes consumed by the elements of the given array. Example: Array = [1,2,3] Size of the array...
true
3f4871250a9a6d56f16f5ada8afd808db44b83c8
tanjased/design_patterns
/04. prototype/prototype.py
896
4.34375
4
import copy class Address: def __init__(self, street_address, city, country): self.street_address = street_address self.city = city self.country = country def __str__(self): return f'{self.street_address}, {self.city}, {self.country}' class Person: def __init__(self, name...
true
a18155b85b4e0e3c27707d4c6691c57d3070277e
mkatkar96/python-basic-program
/all python code/file handing.py
832
4.1875
4
'''file handling -1.file handing is very important for accessing other data. 2.there are three modes in file hanling as read , write and append. 3.in read you can red only 4.in write you can write a data but when you write new line old one gets deletd ...
true
fc428bc197e2fd2d8f7312d5c3f5255278fd09ee
gamladz/LPTHW
/ex16.py
1,208
4.53125
5
from sys import argv script, filename = argv # Takes the filename arguments and tells user its is liable to deletion print "We're going to erase %r." % filename print "if you don't want that, hit CTRL-C (^C)." print "If you do want that, hit RETURN." raw_input("?") #Takes input of RETURN or CTRL-C to determine the u...
true
a0b89a3cd0583036d7a6bbf23c8db205b77df95c
Astrolopithecus/SearchingAndSorting
/Searching & Sorting/binarySearch2.py
1,219
4.34375
4
#Program to search through a sorted list using a binary search algorithm #Iterative version returns the index of the item if found, otherwise returns -1 def binarySearch(value, mylist): low = 0 high = len(mylist)-1 while (low <= high): mid = (low + high) // 2 if (mylist[mid] == valu...
true
2d4c8c7933257b9cc535082659548d04061bbe6d
GBoshnakov/SoftUni-OOP
/Polymorphism and Abstraction/vehicles.py
1,265
4.125
4
from abc import ABC, abstractmethod class Vehicle(ABC): def __init__(self, fuel_quantity, fuel_consumption): self.fuel_quantity = fuel_quantity self.fuel_consumption = fuel_consumption @abstractmethod def drive(self, distance): if distance * self.fuel_consumption <= self.fuel_quan...
true
bc4c750579fbe676caa0b2360af236cff60f0d73
rogeriog/dfttoolkit
/structure_editing/rotate.py
2,081
4.28125
4
##################################################### ### THIS PROGRAM PERFORMS SUCCESSIVE ROTATIONS IN A GIVEN VECTOR ### FOR EXAMPLE: ### USE $> python rotate.py [vx,vy,vz] x=30 y=90 ### TO ROTATE VECTOR V=[vx,vy,vz] 30 degrees in X and 90 degrees in Y ##################################################### import nu...
true
6456b274762f583c97fa7862acd1afc27ceaf9af
Akshaya-Dhelaria-au7/coding-challenges
/coding-challenges/week03/day5/index.py
602
4.28125
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.''' element=7 list=[1,3,5,6,8] n=len(list) #Index is used to find the position of the value within the list index=list.index(6) print("Position of index in list...
true
d9aabbc9a3e63ec8d48091ab8f49ce9a49f1f799
Ashish-Surve/Learn_Python
/Training/Day5/Functional Programming/1_map_demo_in_python3.py
1,232
4.21875
4
nums = [1,2,3] squareelemnts = [i**2 for i in nums if i<3] #list comprehension print("Original nums list = ", nums) print("List of square elemnts = ", squareelemnts) #[1, 4] def sq_elem(x): return x**2 squareelemnts2 = [sq_elem(i)for i in nums] print("List of square elemnts = ", squareelemnts2)#[1, 4, 9] print(...
true
9489322aa60c348a7da1c9d6f2b10fe94533578a
sarahmarie1976/CS_Sprint_Challenges
/src/Sprint_1/01_csReverseString.py
838
4.4375
4
""" Given a string (the input will be in the form of an array of characters), write a function that returns the reverse of the given string. Examples: csReverseString(["l", "a", "m", "b", "d", "a"]) -> ["a", "d", "b", "m", "a", "l"] csReverseString(["I", "'", "m", " ", "a", "w", "e", "s", "o", "m", "e"]) -> ["e", "m"...
true
7eb2d3d1f9dec31542a2ff7c1c948c73f5394b31
nishant-sethi/HackerRank
/DataStructuresInPython/sorting/MergeSort.py
919
4.21875
4
''' Created on Jun 4, 2018 @author: nishant.sethi ''' def merge_sort(unsorted_list): if len(unsorted_list) <= 1: return unsorted_list # Find the middle point and devide it middle = len(unsorted_list) // 2 left_list = unsorted_list[:middle] right_list = unsorted_list[middle:] ...
true
855da4aad48c1bdcef773f0b768a6469fe90e948
gtr25/python-basic
/Favorite Character Line Formation.py
1,340
4.21875
4
# This code gets a Maximum Characters per line, Favorite Character and words separated by commas # From all the possible combinations of the words, # After excluding the "Favorite Character" and white space, # if the total number of characters is less than the "Maximum Characters" given by the user, # That specific...
true
5e06d754b4b7553f56d4a2350eba508fc50c8de4
ponka07/pythoncalc
/calculator.py
865
4.21875
4
print("this will only work with 2 numbers") print('what do you want to calculate?') print("1: add") print("2: subtract") print('3: multiply') print('4: divide') while True: choice = input('add:1, subtract:2, multiply:3, divide:4, which one do you want? ') if choice in ('1', '2', '3', '4'): num1 = f...
true
c18d0e7c99f628c2c5503881b86eac33473c5502
frankhinek/Deep-Learning-Examples
/tf-max-pool.py
1,450
4.15625
4
''' A simple max pooling example using TensorFlow library tf.nn.max_pool. tf.nn.max_pool performs max pooling on the input in the form (value, ksize, strides, padding). - value is of shape [batch, height, width, channels] and type tf.float32 - ksize is the filter/window size for each dimension of the input tensor - s...
true
4a1e8de9890faa7ab037b47ff1dc503fea90e772
goremd/Password-Generator
/pswd_gen.py
846
4.25
4
# Generate pseudo-random numbers import secrets # Common string operations import string # Defines what characters to use in generated passwords. # String of ASCII characters which are considered printable. # This is a combination of digits, ascii_letters, punctuation, and whitespace. characters = string.asc...
true
90ce5be2b14021e4a40e2682612c6c7fffceea5b
maryakinyi/trialgauss
/hon.py
974
4.1875
4
import math def calculate_area_of_circle(radius): area=math.pi*(radius*radius) print("%.2f" % area) calculate_area_of_circle(6) def area_of_cylinder(radius,height): area=math.pi*(radius*radius)*height print("%.2f" %area) area_of_cylinder(23,34) player_name = input("Hello, What's your name?") number_o...
true
12beda910c4fcbb13e1b9094142c8140a2b47675
marwanforreal/SimpleCeaserModular
/code.py
860
4.125
4
# this is just a fun project you can use it for whatever import string import re #List Of Upper Case Letters For Cipher A = list(string.ascii_uppercase) Cipher = [] #To Decrypt Or Encrypt Flag = input("To Encrypt Enter 1 to Decrypt Enter 0: ") while(True): Key = int(input("Please Enter a Key Between 1 and 25: "...
true
d0e47a40d7dc896f2646c85ba6b70ddfc413af57
AkibSamir/FSWD_Python_Django
/third_class.py
765
4.21875
4
# Set # declaration data_set = set() print(type(data_set)) data_set2 = {1, 2, 3, 4, 5} print(data_set2, type(data_set2)) # access item # print(data_set2[1]) # Python set does not maintain indexing that's why we can't able to access any item # update item # data_set2.update(9) # typeerror: int object is not iterable ...
true
4c4beb3e71d405a3c427d55aee8c130e5f4fa851
emilybisaga1/emilybisaga2.github.io
/Hws/wordcloud.py
1,024
4.3125
4
def generate_wordcloud(text): ''' You can earn up to 10 points of extra credit by implementing this function, but you are not required to implement this function if you do not want the extra credit. To get the extra credit, this function should take as input a string and save a file to your computer...
true
3e44c4ef971a823812c72bf4a08a9a25b6dfbb56
ore21/PRG105
/average rainfall.py
662
4.1875
4
years = int(input("Please enter the number of years: ")) grand_total = 0 for year in range(0, years): year_total = 0 print("Year " + str(year + 1)) for months in ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec "): rainfall_inch = float(input("Enter the inches of ra...
true
34d3a22fc681d55be6c4d0358f960e943dfdcf0d
ore21/PRG105
/calories by macronutrient.py
1,026
4.1875
4
"""Calories by Macronutrient""" fat_grams = float(input("enter a number of fat grams:")) carbohydrate_grams = float(input("enter a number of carbohydrate grams:")) protein_grams = float(input("enter a number of protein grams:")) def calories_from_fat(fat_grams): total = fat_grams * 9 print("calo...
true
d4473972a201e825f635bf891f8763f128c48695
kirankumar-7/python-mini-projects
/hangman.py
496
4.125
4
import random print("Welcome to the hangman game ") word_list=["python","java","programming","coding","interview","dsa","javascript","html","css","computer"] chosen_word=random.choice(word_list) #creating a empty list display=[] word_len=len(chosen_word) for _ in range(word_len): display += "_" p...
true
cbc1ae8e2cf208c50c6ea112b4b9802d1a4e2b8c
kirankumar-7/python-mini-projects
/lovecalculator.py
1,172
4.125
4
print("welcome to the love calculator! ") name1=input("What is your name? ").lower() name2=input("What is their name? ").lower() combined_name=name1+name2 t=combined_name.count("t") r=combined_name.count("r") u=combined_name.count("u") e=combined_name.count("e") true =t+r+u+e ...
true
f931a44604fa5cb283be4c7c904a7795aa38a03e
Gyanesh-Mahto/Practice-Python
/string/index_rindex.py
1,716
4.53125
5
# index() method is also used to find substring from main string from left to right(begin to end). # It returs as follows: # If substring is found then index() method returns index of first occurance of substring # But if substring is not found in main string then index() will generate ValueError instead of -1 as compa...
true
a85a63008d812d2ed0cc260ec38a209493227b60
Gyanesh-Mahto/Practice-Python
/control_flow/biggest_smallest_num_3_input.py
448
4.4375
4
#WAP to find biggest of 3 given numbers num1=int(input('Please enter your first number: ')) num2=int(input('Please enter your second number: ')) num3=int(input('Please enter your third number: ')) if num1>num2 and num1>num3: print('{} is greater'.format(num1)) elif num2>num1 and num2>num3: print('{} is greater...
true
4717626688d17378fba8cb068262cc886b126904
greenca/checkio
/three-points-circle.py
1,529
4.4375
4
# You should find the circle for three given points, such that the # circle lies through these point and return the result as a string with # the equation of the circle. In a Cartesian coordinate system (with an # X and Y axis), the circle with central coordinates of (x0,y0) and # radius of r can be described with the ...
true
e2b49d23784a27bb16540c7b7665694dbc0f406b
greenca/checkio
/most-wanted-letter.py
1,671
4.1875
4
# You are given a text, which contains different english letters and # punctuation symbols. You should find the most frequent letter in the # text. The letter returned must be in lower case. # While checking for the most wanted letter, casing does not matter, so # for the purpose of your search, "A" == "a". Make sure y...
true
17f9605c4bbde3c512d322f9fc0f52ac05b47b30
angrajlatake/codeacademyprojects
/Scrabble dictonary project.py
2,817
4.1875
4
'''In this project, you will process some data from a group of friends playing scrabble. You will use dictionaries to organize players, words, and points. There are many ways you can extend this project on your own if you finish and want to get more practice!''' letters = ["A", "B", "C", "D", "E", "F", "G", "H", "I",...
true
f9fd421e081da8c9617af08604ce70228a8318fa
aj112358/python_practice
/(1)_The_Python_Workbook/DICTIONARIES/unique_characters.py
821
4.5625
5
# This program determines the number of unique characters in a string. # Created By: AJ Singh # Date: Jan 8, 2021 from pprint import pprint # Places characters of string into a dictionary to count them. # @param string: String to count characters for. # @return: Dictionary of character counts. def check_unique(strin...
true
f7116009a799a92e16f1434c4c5d7f30c26f8737
aj112358/python_practice
/(1)_The_Python_Workbook/LISTS/infix_to_postfix.py
1,751
4.25
4
# This program converts a list of tokens representing a mathematical expression, and # converts it from infix form to postfix form. # Created By: AJ Singh # Date: Jan 7, 2021 from tokenizing_strings import tokenize, identify_unary from string_is_integer import is_integer from operator_precedence import precedence OPE...
true
4a304cfabcd09a9e64f518ebe06c97de188c2321
aj112358/python_practice
/(1)_The_Python_Workbook/FILES_EXCEPTIONS/letter_frequency.py
948
4.3125
4
# Exercise 154: Letter Frequency Analysis. from string import ascii_uppercase from string import punctuation from string import digits import sys if len(sys.argv[1]) < 2: print("Input file needed.") quit() def open_file(): try: file = open(sys.argv[1], mode="r") return file except F...
true
d150af4735c935c4007f9ed797656fd39b26650f
aj112358/python_practice
/(1)_The_Python_Workbook/FUNCTIONS/string_is_integer.py
683
4.5
4
# This program determines if a string is an integer, and takes the sign into account. # Created By: AJ Singh # Date: Jan 7, 2021 # Check if a string represents a valid integer # @param num: String to check. # @return: Boolean value. def is_integer(num: str) -> bool: """Determine if a string represents a valid pos...
true
6f112b3d3d079773fea42c67408b770b8b239cbc
aj112358/python_practice
/(1)_The_Python_Workbook/LISTS/proper_divisors.py
739
4.625
5
### This program compute the list of proper divisors of an integer # Created By: AJ Singh # Date: Jan 6, 2021 from math import sqrt, floor # This function computes the divisors of an integer # @param n: Input to factor. # @return: List of divisors. def divisors(n: int) -> list: """Compute all the (positive) divi...
true
ff2b2ad084e8ce4f0ffe6484ce87094f68b9db12
aj112358/python_practice
/(1)_The_Python_Workbook/LISTS/evaluate_postfix_expr.py
1,503
4.4375
4
# This programs evaluates a basic mathematical expression, given via tokens in postfix form. # Created By: AJ Singh # Date: Jan 7, 2021 from tokenizing_strings import tokenize, identify_unary from infix_to_postfix import to_postfix OPERATORS = list("+-*/^") # Evaluates a postfix expression, given the tokens. # @par...
true
02974eec581d9a28f995a6b187f13bfd7a272664
ricaenriquez/intro_to_ds
/project_3/other_linear_regressions/advanced_linear_regressions.py
2,740
4.59375
5
import numpy as np import pandas as pd import statsmodels.api as sm """ In this optional exercise, you should complete the function called predictions(turnstile_weather). This function takes in our pandas turnstile weather dataframe, and returns a set of predicted ridership values, based on the other information in ...
true
45362e23912a3f3fae4021f27f5983875cf64aaf
DonNinja/111-PROG-Assignment-5
/max_int.py
610
4.59375
5
num_int = int(input("Input a number: ")) # Do not change this line # Fill in the missing code max_int = 0 while num_int > 0: if num_int > max_int: max_int = num_int num_int = int(input("Input a number: ")) print("The maximum is", max_int) # Do not change this line # First we have to take in nu...
true
92fb6e42ffea61173e20c30d7541d68501156ef7
cyber-holmes/temperature_conversion_python
/temp.py
333
4.5
4
#Goal:Convert the given temperature from Celsius to Farenheit. #Step1:Take the user-input on temperature the user wish to convert. cel= input("Enter your temperature in Celsius ") #Step2:Calculate the conversion using formula (celsius*1.8)+32 far = (cel*1.8)+32 #Step3:Print the output. print ("It is {} Farenheit".f...
true
8f6ca9ea53f6cfad80afb24783e381e78e0c595d
Youngjun-Kim-02/ICS3U-Unit6-03-python
/smallest_number.py
852
4.21875
4
#!/usr/bin/env python3 # Created by: Youngjun Kim # Created on: June 2021 # This program uses a list as a parameter import random def find_smallest_number(random_numbers): Smallest_number = random_numbers[0] for counter in random_numbers: if Smallest_number > counter: Smallest_number =...
true
92beb7b2e2a8e8819ff0d48605a174b899a37b18
paulthomas2107/TKinterStuff
/entry.py
388
4.21875
4
from tkinter import * root = Tk() e = Entry(root, width=50, bg="blue", fg="white", borderwidth=5) e.pack() e.insert(0, "Enter your name: ") def myClick(): hello = "Hello " + e.get() my_label = Label(root, text=hello) my_label.pack() myButton = Button(root, text="Enter name", padx=50, pady=50, command=...
true
5b3e1e1e415cddbc0eccf6358731a28a31025bc9
darren11992/think-Python-homework
/Chapter 9/Exercise9-3.py
924
4.125
4
"""Write a function named avoids that takes a word and a string of forbidden letters and returns True if the word doesn't use any of the forbidden letters. Modify the program to prompt the user to enter a string of forbidden letters and then print the number of words that don't contain any of them. Can you find a c...
true
1e015d5e59880d86ebf92721884242b31393bf0e
darren11992/think-Python-homework
/Chapter 7/exercise7-1.py
1,058
4.21875
4
"""Copy the loop from "Square roots" on page 79 and encapsulate it in a function called mysqrt that takes a as a parameter, chooses a reasonable value of x, and returns an estimate of the square root of a. To test it, write a function named "test_square_root that prints a table like this: First column: a number, a...
true
2d5540b41a118e786295696f6914076900f3d2d8
darren11992/think-Python-homework
/Chapter 10/Exercise 10-3.py
406
4.125
4
"""Write a function called middle that takes a list and returns a new list that contains all but the first and last elements. For example: >>> t = [1, 2, 3, 4] >>> middle(t) >>> [2, 3]""" def middle(t): new_t = t[:] # new_t = t will use the same reference for both lists del new_t[0]...
true
4b6588e9bfbadac7f21f380fa94f1a7de79ad444
darren11992/think-Python-homework
/Chapter 9/Exercise9-9.py
2,279
4.15625
4
"""Here's another car talk Puzzler you can solve with a search; "Recently I had a visit with my mum and we realised that the two digits that make up my age reversed resulted in her age. For example, if she's 73, I'm 37. We wondered how often this has happened over the years but we got sidetracted with other top...
true
0b6a86223916b8161c66054f5eb03afcbf301b4e
darren11992/think-Python-homework
/Chapter 8/notes8.py
1,379
4.25
4
""" - Strings are sequences of characters. - The bracket operator allows you to select individual characters in a string: eg: fruit = 'banana' letter = fruit[2] --> 'n' Note: string indexs begin at 0. -The len() function returns the length of a string. The final index of a string is always i...
true
018e5b31a3717d11a37460be83c42d97ff4b673b
Jagadeshwaran-D/Python_pattern_programs
/simple_reverse_pyramid.py
291
4.25
4
""" python program for simple reverse pyramid * * * * * * * * * * * * * * * """ ### get input from the user row=int(input("enter the row")) ##logic for print the pattern for i in range(row+1,0,-1): for j in range(0,i-1): print("* " ,end="") print()
true
f639317fbaab1d84ef7bbc939185c52ddeabd531
AbilashC13/module1-practice-problems-infytq
/problem05.py
715
4.15625
4
#PF-Prac-5 ''' Write a python function which accepts a sentence and finds the number of letters and digits in the sentence. It should return a list in which the first value should be letter count and second value should be digit count. Ignore the spaces or any other special character in the sentence. ''' def count_dig...
true
75115dbfa45590ecebc885a7fcc2f6637ea5e281
Midhun10/LuminarPython
/Luminar_Python/exceptionHandling/except.py
451
4.21875
4
num1=int(input("Enter num1")) num2=int(input("Enter num2")) # res=num1/num2#exception can be raised in this code. # print(res) try: res=num1/num2 print(res) except Exception as e:#Exception is a class in the # print("exception occured") print("Error:",e.args) finally: print("Printing finally") # i...
true
ae0c5498a64706c510bdad26b28d32c3b1ee121c
drewgoodman/Python-Exercises
/birthday_lookup.py
1,305
4.53125
5
# keep track of when our friend’s birthdays are, and be able to find that information based on their name. Create a dictionary (in your file) of names and birthdays. When you run your program it should ask the user to enter a name, and return the birthday of that person back to them. The interaction should look somethi...
true
cd379021d642213e5d3879485d53610283277e09
robbyorsag/pands-problem-set
/solution-9.py
360
4.3125
4
# Solution to problem 9 # Open the file moby-dick.txt for reading and mark as "f" with open('moby-dick.txt', 'r') as f: count = 0 # set counter to zero for line in f: # for every line in the file count+=1 # count +1 if count % 2 == 0: # if the remainder is 0 print(line) ...
true
f8024b9b4a567f1d38a0db933953e6273a305bb0
britneh/Intro-Python-I
/src/03_modules.py
961
4.25
4
""" In this exercise, you'll be playing around with the sys module, which allows you to access many system specific variables and methods, and the os module, which gives you access to lower- level operating system functionality. """ import sys # See docs for the sys module: https://docs.python.org/3.7/library/sys.html...
true
f7a7dbafab4f54888a363b34f2bf7e60b64056de
aishuse/luminarprojects
/two/inpulseOperator.py
1,223
4.34375
4
# list1 = [10,11,23,45] # list2 = list1 # # # print("2nd list : ",list2) # # list1 += [1, 2, 3, 4] # # print(list2) # # print(list1) # print("next") # list1=list1+[1,2,3,4] # # print(list1) # print(list2) # Python code to demonstrate difference between # Inplace and Normal operators in Immutable Targets # importing o...
true
c42869a5b6d2d2052c01b7305b35f59a03b2064a
YunJ1e/LearnPython
/DataStructure/Probability.py
1,457
4.21875
4
""" Updated: 2020/08/16 Author: Yunjie Wang """ # Use of certain library to achieve some probabilistic methods import random def shuffle(input_list): """ The function gives one of the permutations of the list randomly As we know, the perfect shuffle algorithm will give one specific permutation with the probabili...
true
24c9c43afea201cba04dc20b1cd6bef2ec32f71d
frclasso/python_examples_one
/name.py
292
4.28125
4
#!/usr/bin/env python3 import readline def name(): """Input first and last name, combine to one string and print""" fname = input("Enter your first name: ") lname = input("Enter your last name: ") fullname = fname + " " + lname print("You name is ", fullname) name()
true
3352a7824e6e62b969d5507b9e6cb791b15216fc
JaygJr/Pie
/Bmi/Test/testlong.py
2,081
4.28125
4
#!/usr/bin/env python3 """This script will calculate BMI via height/weight input""" import string from time import sleep from gpiozero import LED # ToDo accept input for positive integers ONLY, and make it a function # DONE INTERNALLY ONLY - ToDo change bmi height/weight calculations to a func # ToDo change code ...
true
64eb2ebc38fc4c2b5201dae4b75e61e97eda4fc2
MouChakraborty/JISAssasins
/Question15.py
277
4.25
4
#!/usr/bin/env python # coding: utf-8 # In[2]: #Program to find the value of x^(y+z) By Moumita Chakraborty import math x=int(input("Enter the value of x")) y=int(input("Enter the value of y")) z=int(input("Enter the value of z")) a=y+z b=pow(x,a) print("The value is",b) # In[ ]:
true
320e3160f26f2b52fe22825a9e676719bb31ac15
MouChakraborty/JISAssasins
/Question16.py
404
4.5625
5
#!/usr/bin/env python # coding: utf-8 # In[1]: #Question 16 ##Write a Program to Accept character and display its # Ascii value and its Next and Previous Character. #chr() for ascii to char By Moumita Chakraborty x= input("Enter the input :") n= ord(x) prev= n - 1 next= n + 1 a=chr(prev) b=chr(next) print(" ASCII va...
true
24ed34ca93e72f8f56a0ec16e8e2e5733c40e768
rchen00/Algorithms-in-Python
/string reverse recursive.py
801
4.15625
4
# -*- coding: utf-8 -*- """ Created on Sat Jan 16 21:12:26 2021 @author: robert """ def string_reverse1(s): if len(s) == 0: return s else: return string_reverse1(s[1:]) + s[0] s = "Robert" print ("The original string is: ",end="") print (s) ...
true
b022fcf0e10ca9d637ccafa31a018a2523770c30
optionalg/python-programming-lessons
/rock_paper_scissors.py
2,520
4.1875
4
# pylint: disable=C0103 # 2 players # 3 possibles answers: rock, paper, scissors # rock > scissors > paper > rock ... # ask the players their name # ------- loop start ------- # ask their choice # check their choice (needs to be valid) # find a way to hide the choice???? https://stackoverflow.com/questions/2084508/cl...
true
7be942bc1eed5186e5867bbb05d684dedecc67ba
ENAIKA/PasswordLocker
/user_test.py
2,726
4.15625
4
import unittest # Importing the unittest module from user import User # Importing the user class class TestUser(unittest.TestCase): ''' Test class that defines test cases for the user class behaviours. ''' def setUp(self): ''' Set up method runs before each test cases. ''' ...
true
b429f034f7810ef4e4331ae80cb648710e8ff4ac
charliealpha094/Python_Crash_Course_2nd_edition
/Chapter_8/try_8.8.py
961
4.53125
5
#Done by Carlos Amaral in 29/06/2020 """ Start with your program from Exercise 8-7. Write a while loop that allows users to enter an album’s artist and title. Once you have that information, call make_album() with the user’s input and print the dictionary that’s created. Be sure to include a quit value in the while lo...
true
40f000710dba311de1cfb53c3740df002537de25
charliealpha094/Python_Crash_Course_2nd_edition
/Chapter_8/try_8.3.py
728
4.34375
4
#Done by Carlos Amaral in 28/06/2020 """ Write a function called make_shirt() that accepts a size and the text of a message that should be printed on the shirt. The function should print a sentence summarizing the size of the shirt and the message printed on it. Call the function once using positional arguments to mak...
true
03741ecd81689dce53ca5f31115f635db5b2b3ee
charliealpha094/Python_Crash_Course_2nd_edition
/Chapter_3/try_3.10.py
341
4.3125
4
cities = ['Porto', 'Lisboa', 'Viseu', 'Vigo', 'Wien'] print(cities) print(len(cities)) #Reverse alphabetical order cities.sort(reverse=True) print(cities) #Sorting a list temporarily with the sorted() function print("\nHere is the sorted list:") print(sorted(cities)) #Printing a list in Reverse Order print(cities) ...
true
a330687c3ff041d17b9530c05c074555b284a919
charliealpha094/Python_Crash_Course_2nd_edition
/Chapter_5/try_5.2.py
1,259
4.1875
4
#Done by Carlos Amaral in 17/06/2020 """ 5-2. More Conditional Tests: You don’t have to limit the number of tests you create to ten. If you want to try more comparisons, write more tests and add them to conditional_tests.py. Have at least one True and one False result for each of the following: • Tests for equality an...
true
6f35e52ecc19b49821a12684fcc4bc77d2ad0257
charliealpha094/Python_Crash_Course_2nd_edition
/Chapter_10/try_10.2/learn_C.py
656
4.375
4
#Done by Carlos Amaral in 11/07/2020 """You can use the replace() method to replace any word in a string with a different word. Here’s a quick example showing how to replace 'dog' with 'cat' in a sentence: >>> message = "I really like dogs." >>> message.replace('dog', 'cat') 'I really like cats.' Read in each line f...
true
d16f147994679c01cebbcab39ec9d80969a1f30a
charliealpha094/Python_Crash_Course_2nd_edition
/Chapter_6/try_6.2.py
953
4.3125
4
#Done by Carlos Amaral in 21/06/2020 """ Use a dictionary to store people’s favorite numbers. Think of five names, and use them as keys in your dictionary. Think of a favorite number for each person, and store each as a value in your dictionary. Print each person’s name and their favorite number. For even more fun, po...
true
894bd27767bb90b0c1e66344b4e38ec462681c13
charliealpha094/Python_Crash_Course_2nd_edition
/Chapter_5/try_5.3.py
708
4.1875
4
#Done by Carlos Amaral in 18/06/2020 """ Imagine an alien was just shot down in a game. Create a variable called alien_color and assign it a value of 'green' , 'yellow' , or 'red' . • Write an if statement to test whether the alien’s color is green. If it is, print a message that the player just earned 5 points. • Wri...
true
f9493f994afa60ee4ea4e5177eb87f2deb60d39a
charliealpha094/Python_Crash_Course_2nd_edition
/Chapter_11/try_11.1/city_functions.py
812
4.25
4
#Done by Carlos Amaral in 16/07/2020 """ Write a function that accepts two parameters: a city name and a country name. The function should return a single string of the form City, Country , such as Santiago, Chile . Store the function in a module called city _functions.py. Create a file called test_cities.py that test...
true
c2e0671c986eaeb5cbdad8c2b193a2f21617dc4c
rajeevbkn/fsdHub-mathDefs
/factorialNum.py
371
4.40625
4
# This snippet is to find factorial of a positive integer number. n = int(input('Enter a positive integer number: ')) factorial = 1 if n < 0: print('Factorial of a negative number is not possible.') elif n == 0: print('Factorial of 0 is 1.') else: for i in range(1, n+1): factorial = factorial * i ...
true
bd1fddbe81544186001b12fd84faf35b17f688bb
MariusArhaug/bicycleLocation
/highestProduct.py
948
4.40625
4
def highestProduct(listA): length = len(listA) if length < 3: return "List is not big enough to find biggest product of 3 integers!" listA.sort() #ascending order #Check if a list only contains negative numbers count = 0 for integer in listA: if integer < 0: count ...
true
724078ce3c84dca14dada8889fc0c4828a63670a
RyanMullin13/Euler
/problem1.py
400
4.1875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Jul 5 13:58:41 2021 @author: ryan """ """ If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. """ ans = 0 for i ...
true
7014468d396a9f3b4a8eb43a8f4f71d0d3e8004f
meenakshikathiresan3/sorting_algorithms
/insertion_sort/insertion_sort.py
2,442
4.4375
4
""" Python insertion sort implementation 20210920 ProjectFullStack """ import random def insertion_sort(the_list): # outer loop, we start at index 1 because we always assume the # FIRST element in the_list is sorted. That is the basis of how # insertion sort works for i in range(1, len(the_list)): ...
true
f965af6dd3aed580e083dd2040e2ea63fb6d5707
GuilhermeZorzon/Project-Euler
/Problem6.py
558
4.15625
4
def sqr_sum_difference(num = 100): ''' (int/ ) -> int Given num, finds the diference between the sum of all the squares of the numbers lower than num and the square of the sum of these same numbers. Num is set to 100 if no value is passed To use: >>> sqr_sum_difference(2) 4 >>> sqr_...
true
fe4f040f406b291c774ed2d9d7aaeb559e29bdb3
Dheeraj809/dheeraj-b2
/rev of string.py
217
4.34375
4
def reverse(s): if len(s)==0: return s else: return reverse(s[1:])+s[0] s= input('enter the string') print("The original string is:") print(s) print("The reversed string is:") print(reverse(s))
true
5b0b9b23d2be5485525cddee396049237b17c1e4
f034d21a/leetcode
/344.reverse_string.py
753
4.25
4
#! /usr/bin/python # -*- coding: utf-8 -*- """ 344. Reverse String Write a function that takes a string as input and returns the string reversed. Example: Given s = "hello", return "olleh". """ class Solution(object): def reverseString(self, s, method='a'): _method = getattr(self, meth...
true
ae8ee04522609dd86fb35bb7c38dacdb6d5c3ff9
bethanyuo/DSA
/inputs.py
401
4.40625
4
# user_input = input("What's the meaning of life? ") TypeError: '<' not supported between instances of 'str' and 'int' user_input = int(input("What's the meaning of life? ")) # ==> Converts any input into an interger if user_input == 42: print("Correct answer!") elif user_input < 42: print("Sorry, but you e...
true
6e671ccc023ecbcd163aecc57633d93a78d106e7
chidoski/Python-Projects
/ex32.py
1,040
4.625
5
the_count = [1, 2, 3, 4, 5] fruits = ['apples', 'oranges', 'pears', 'apriocts'] change = [1, 'pennies', 2, 'dimes', 3, 'quarters'] #the first kind of for-loop goes through a list for number in the_count: print "This is count %d" % number #same as above for fruit in fruits: print "These are the fruit %s" % fruit #G...
true
64902aa98e5a99ae3401b8cd647936eb77f0202e
tsvielHuji/Intro2CSE-ex10
/ship.py
2,050
4.21875
4
# Relevant Constants SHIP_RADIUS = 1 SHIP_LIFE = 3 TURN_LEFT = "l" TURN_RIGHT = "R" VALID_MOVE_KEY = {TURN_RIGHT, TURN_LEFT} class Ship: """Handles the methods and characteristics of a single Ship""" def __init__(self, location, velocity, heading): self.__location_x = location[0] # Locati...
true
0a9dd5c965612b6907fb7c4acb2a2bd09a34a2ca
JiWenE/pycode
/函数部分/ex10.py
739
4.25
4
def break_words(stuff): """This function will break up words for us.""" words = stuff.split(' ') # 以空格为分隔符将其转换为列表 return words def sort_words(words): """Sorts the words.""" return sorted(words) # 排序 def print_first_word(words): """Prints the first word after popping it off.""" word = ...
true
04c3436776290503c57409b445a8681e302a7bbc
shreyanse081/Some-Algorithms-coded-in-Python
/QuickSort.py
1,137
4.15625
4
""" QuickSort procedure for sorting an array. Amir Zabet @ 05/04/2014 """ import random def Partition(a,p): """ Usage: (left,right) = Partition(array, pivot) Partitions an array around a pivot such that the left elements <= and the right elements >= the pivot value. """ pivot = a[p] ## the pivot value ...
true
853c3a462260bc1e20f624ff80b784701ab4ba01
ernestas-poskus/codeacademy
/Python/io_buffering.py
820
4.125
4
# PSA: Buffering Data # We keep telling you that you always need to close your files after you're done writing to them. Here's why! # During the I/O process, data are buffered: this means that they're held in a temporary location before being written to the file. # Python doesn't flush the buffer—that is, write data ...
true
c5987e266f3beb69d15ac78d21b0eada3f09527c
ernestas-poskus/codeacademy
/Python/int.py
631
4.28125
4
# int()'s Second Parameter # Python has an int() function that you've seen a bit of already. It can turn non-integer input into an integer, like this: # int("42") ==> 42 # What you might not know is that the int function actually has an optional second parameter. # If given a string containing a number and th...
true
8ad6c8bd609d664314df0a35cf3b81ded0b32250
BeefAlmighty/CrackingCode
/ArraysStrings/Problem6.py
989
4.15625
4
# String compression: Compress a string on basis of character counts # SO, e.g. aaabccaaaa --> a3b1c2a4. If the compressed string is not smaller # than the original string, then the method should return the original string. def compress(string): letter_list = [] count_list = [] idx = 0 compressed = [...
true
09d52ea26960f115db480abec979775cee4b7c99
Redlinefox/Games_and_Challenges
/Guessing_Game/Guessing_Game_v2.py
2,106
4.28125
4
# Write a program that picks a random integer from 1 to 100, and has players guess the number. # The rules are: # If a player's guess is less than 1 or greater than 100, say "OUT OF BOUNDS" # On a player's first turn, if their guess is within 10 of the number, return "WARM!" # further than 10 away from the number, re...
true
6264b6239d29e1aee3a9b7139ffe1c93d549d980
alialavia/python-workshop-1
/sixth.py
1,671
4.375
4
""" To evaluate the good or bad score of a tweet, we count the number of good and bad words in it. if a word is good, increase the value of good_words by one else if a word is bad, increase the value of bad_words by one if good_words > bad_words then it's a good tweet otherwise it's a bad tweet """ import json import...
true