blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
4844eb4416c99f709e8d8d7d4219bee020c7adb6
nbpillai/npillai
/Odd or Even.py
205
4.3125
4
print("We will tell you if this number is odd or even.") number = eval(input("Enter a number! ")) if number%2==0: print("This is an even number!") else: print ("This number is an odd number!")
true
ee4bb01eb029819b15ee23c478edab0aada9608b
ari-jorgensen/asjorgensen
/SimpleSubstitution.py
1,140
4.15625
4
# File: SimpleSubstitution.py # Author: Ariana Jorgensen # This program handles the encryption and decryption # of a file using a simple substitution cipher. # I created this algorithm myself, only borrowing the # randomized alphabet from the Wikipedia example # of substitution ciphers # NOTE: For simplicity, all char...
true
f09176c324c14916ee1741dd82077dd667c86353
cbarillas/Python-Biology
/lab01/countAT-bugsSoln.py
903
4.3125
4
#!/usr/bin/env python3 # Name: Carlos Barillas (cbarilla) # Group Members: none class DNAString(str): """ DNAString class returns a string object in upper case letters Keyword arguments: sequence -- DNA sequence user enters """ def __new__(self,sequence): """Returns a copy of sequenc...
true
92db81dc42cd42006e58a7acb64347ef443b4afc
mattin89/Autobiographical_number_generator
/Autobiographic_Numbers_MDL.py
1,542
4.15625
4
''' By Mario De Lorenzo, md3466@drexel.edu This script will generate any autobiographic number with N digits. The is_autobiographical() function will check if numbers are indeed autobiographic numbers and, if so, it will store them inside a list. The main for loop will check for sum of digits and if the number of...
true
801c588912b99c98b0076b70dbbd8d7b2184c23e
garetroy/schoolcode
/CIS210-Beginner-Python/Week 2/counts.py
1,410
4.4375
4
""" Count the number of occurrences of each major code in a file. Authors: Garett Roberts Credits: #FIXME Input is a file in which major codes (e.g., "CIS", "UNDL", "GEOG") appear one to a line. Output is a sequence of lines containing major code and count, one per major. """ import argparse def count_codes(majors_f...
true
2e18fd51ae66bc12003e51accf363523f227a76e
agzsoftsi/holbertonschool-higher_level_programming
/0x06-python-classes/5-square.py
1,007
4.46875
4
#!/usr/bin/python3 """Define a method to print a square with #""" class Square: """Class Square is created""" def __init__(self, size=0): """Initializes with a size""" self.size = size @property def size(self): """method to return size value""" return self.__size ...
true
15c852d2d567f3334eb8c3dea00bf41cc1fa38e8
Zantosko/digitalcrafts-03-2021
/week_1/day5/fibonacci_sequence.py
755
4.34375
4
# Fibonacci Sequence sequence_up_to = int(input("Enter number > ")) # Inital values of the Fibacci Sequence num1, num2 = 0, 1 # Sets intial count at 0 count = 0 if sequence_up_to <= 0: print("Error endter positive numbers or greater than 0") elif sequence_up_to == 1: print(f"fib sequence for {sequence_up_to}"...
true
e6e3fb65e165ec1b9e9f584539499c22d545d2f2
nelsonje/nltk-hadoop
/word_freq_map.py
628
4.21875
4
#!/usr/bin/env python from __future__ import print_function import sys def map_word_frequency(input=sys.stdin, output=sys.stdout): """ (file_name) (file_contents) --> (word file_name) (1) maps file contents to words for use in a word count reducer. For each word in the document, a new key-value pair...
true
b8eb07e732f80f4303e5020aecb26f7711e93d1d
PederBG/sorting_algorithms
/InsertionSort.py
510
4.25
4
""" Sorting the list by iterating upwards and moving each element back in the list until it's sorted with respect on the elements that comes before. RUNTIME: Best: Ω(n), Average: Θ(n^2), Worst: O(n^2) """ def InsertionSort(A): for i in range(1, len(A)): key = A[i] j = i - 1 while j > ...
true
708c3f290a705b46dc828a704a3d4e2a431fee51
zadadam/algorithms-python
/sort/bubble.py
1,066
4.125
4
import unittest def bubble_sort(list): """Sort list using Bubble Sort algorithm Arguments: list {integer} -- Unsorted list Returns: list {integer} -- Sorted list """ swap=True test ="It is a bad code"; while swap: swap = False for n in range(len(li...
true
109ec4c8b4316cc46479ab9cfe93f2fe7a9f817d
vishul/Python-Basics
/openfile.py
500
4.53125
5
# this program opens a file and prints its content on terminal. #files name is entered as a command line argument to the program. #this line is needed so we can use command line arguments in our program. from sys import argv #the first command line argument i.e program call is saved in name and the #second CLA is stor...
true
2e3924cd0819ea47b3d5081e4d24647a31ea19fa
bsextion/CodingPractice_Py
/MS/Fast Slow Pointer/rearrange_linkedlist.py
1,332
4.15625
4
class Node: def __init__(self, value, next=None): self.value = value self.next = next def print_list(self): temp = self while temp is not None: print(str(temp.value) + " ", end='') temp = temp.next print() def reorder(head): middle = find_middle(head) reversed_middle = reverse_...
true
4c5761f987c88512f2b4f0a3240f71ae39f10101
bsextion/CodingPractice_Py
/Google/L1/challenge.py
1,215
4.34375
4
# Due to the nature of the space station's outer paneling, all of its solar panels must be squares. # Fortunately, you have one very large and flat area of solar material, a pair of industrial-strength scissors, # and enough MegaCorp Solar Tape(TM) to piece together any excess panel material into more squares. # For ex...
true
a32fa47fe2f8e571a862e53e89d76ab67efebc21
Lalesh-code/PythonLearn
/Oops_Encapsulation.py
1,484
4.4375
4
# Encapsulation: this restrict the access to methods and variables. This can prevent the data from being get modified accidently or by security point of view. This is achived by using the private methods and variables. # Private methods denoted by "__" sign. # Public methods can be accessed from anywhere but Private me...
true
b9104f7316d95eaa733bbbd4926726472855046e
emma-rose22/practice_problems
/HR_arrays1.py
247
4.125
4
'''You are given a space separated list of nine integers. Your task is to convert this list into a 3x3 NumPy array.''' import numpy as np nums = input().split() nums = [int(i) for i in nums] nums = np.array(nums) nums.shape = (3, 3) print(nums)
true
4239aaee9e02cf22c29b61d6e60efabf702abcb5
asiapiorko/Introduction-to-Computer-Science-and-Programming-Using-Python
/Unit 1 Exercise 1.py
1,616
4.1875
4
""" In this problem you'll be given a chance to practice writing some for loops. 1. Convert the following code into code that uses a for loop. prints 2 prints 4 prints 6 prints 8 prints 10 prints Goodbye! """ # First soultion for count in range(2,11,2): print(count) print("Goodbye!") # F...
true
84fce63f043d3b48c019739dce5d9a58df6c0198
arcstarusa/prime
/StartOutPy4/CH7 Lists and Tuples/drop_lowest_score/main.py
678
4.21875
4
# This program gets a series of test scores and # calculates the average of the scores with the # lowest score dropped. 7-12 def main(): # Get the test scores from the user. scores = get_scores() # Get the total of the test scores. total = get_total(scores) # Get the lowest test scores. lowest...
true
18c597902f1fa9e14de3506f2cce0d357af647b0
arcstarusa/prime
/StartOutPy4/CH12 Recursion/fibonacci.py
457
4.125
4
# This program uses recursion to print numbers from the Fibonacci series. def main(): print('The first 10 numberss in the ') print('Fibonacci series are:') for number in range(1,11): print(fib(number)) # The fib function returns returns the nth number # in the Fibonacci series. def fib(n): if n...
true
1684ed5ced8288e821c464db286a72f0c1098b0a
arcstarusa/prime
/StartOutPy4/CH8 Strings/validate_password.py
420
4.15625
4
# This program gets a password from the user and validates it. 8-7 import login1 def main(): # Get a password from the user. password = input('Enter your password: ') # Validate the password. while not login1.valid_password(password): print('That password is not valid.') password = in...
true
46cba8a43cb65ece9a372e4c99c46b987d88dbd7
LesterAGarciaA97/OnlineCourses
/08. Coursera/01. Python for everybody/Module 1/Week 06/Code/4.6Functions.py
1,004
4.4375
4
#4.6 Write a program to prompt the user for hours and rate per hour using input to compute gross pay. Pay should be the normal rate for hours up to 40 and #time-and-a-half for the hourly rate for all hours worked above 40 hours. Put the logic to do the computation of pay in a function called computepay() and use #the...
true
6cb09e7a8ff19cabb2a5b2218c1fbf3b994ffa5e
Kilatsat/deckr
/webapp/engine/card_set.py
2,455
4.125
4
""" This module contains the CardSet class. """ from engine.card import Card def create_card_from_dict(card_def): """ This is a simple function that will make a card from a dictionary of attributes. """ card = Card() for attribute in card_def: setattr(card, attribute, card_def[attrib...
true
9f0a9465e1d2f2328088cc53093a61101005a17c
CaseyTM/day1Python
/tuples.py
1,320
4.34375
4
# arrays (lists) are mutable (changeable) but what if you do not want them to be so, enter a tuple, a constant array (list) a_tuple = (1,3,8) print a_tuple; # can loop through them and treat them the same as a list in most cases for number in a_tuple: print number; teams = ('falcons', 'hawks', 'atl_united', 'silve...
true
864b676fbc74522541658bec2bc88d3af97b4598
csojinb/6.001_psets
/ps1.3.py
1,208
4.3125
4
import math STARTING_BALANCE = float(raw_input('Please give the starting balance: ')) INTEREST_RATE = float(raw_input('Please give the annual interest' 'rate (decimal): ')) MONTHLY_INTEREST_RATE = INTEREST_RATE/12 balance = STARTING_BALANCE monthly_payment_lower_bound = STARTING_BALAN...
true
ccb1ec3d8b7974b3ad05c38924c2856d2c5f01db
edenuis/Python
/Sorting Algorithms/mergeSortWithO(n)ExtraSpace.py
1,080
4.15625
4
#Merge sort from math import ceil def merge(numbers_1, numbers_2): ptr_1 = 0 ptr_2 = 0 numbers = [] while ptr_1 < len(numbers_1) and ptr_2 < len(numbers_2): if numbers_1[ptr_1] <= numbers_2[ptr_2]: numbers.append(numbers_1[ptr_1]) ptr_1 += 1 else: nu...
true
64fe2ed64c6fe5c801e88f8c1e266538f7d51d40
brodieberger/Control-Statements
/(H) Selection statement that breaks loops.py
345
4.25
4
x = input("Enter string: ") #prompts the user to enter a string y = input("Enter letter to break: ") #Letter that will break the loop for letter in x: if letter == y: break print ('Current Letter:', letter) #prints the string letter by letter until it reaches the letter that breaks the loop. input ...
true
ed767807eae30530f1d4e121217585aff3bcea75
austBrink/Tutoring
/python/Maria/makedb.py
2,370
4.34375
4
import sqlite3 def main(): # Connect to the database. conn = sqlite3.connect('cities.db') # Get a database cursor. cur = conn.cursor() # Add the Cities table. add_cities_table(cur) # Add rows to the Cities table. add_cities(cur) # Commit the changes. ...
true
bf639aca06615e7a8d84d9322024c17873504c00
austBrink/Tutoring
/python/Sanmi/averageRainfall.py
1,362
4.5
4
# Write a program that uses ( nested loops ) to collect data and calculate the average rainfall over a period of two years. The outer loop will iterate once for each year. The inner loop will iterate twelve times, once for each month. Each iteration of the inner loop will ask the user for the inches of rainfall for tha...
true
c25780c144bbff40242092fbbe961a3b5e72c8e4
roshan1966/ParsingTextandHTML
/count_tags.py
862
4.125
4
# Ask the user for file name filename = input("Enter the name of a HTML File: ") def analyze_file(filename): try: with open (filename, "r", encoding="utf8") as txt_file: file_contents = txt_file.read() except FileNotFoundError: print ("Sorry, the file named '" + filename + "...
true
374c16f971fc2238848a91d94d43293c592e6f03
udaybhaskar8/git-project
/functions/ex4.py
322
4.125
4
import math # Calculate the square root of 16 and stores it in the variable a a =math.sqrt(16) # Calculate 3 to the power of 5 and stores it in the variable b b = 3**5 b=math.pow(3, 5) # Calculate area of circle with radius = 3.0 by making use of the math.pi constant and store it in the variable c c = math.pi * (3**2...
true
9affcfc38a322081ef4afeb658aa97ec03f871ab
mckennec2014/cti110
/P3HW1_ColorMix_ChristianMcKenney.py
975
4.28125
4
# CTI-110 # P3HW1 - Color Mixer # Christian McKenney # 3/17/2020 #Step-1 Enter the first primary color #Step-2 Check if it's valid #Step-3 Enter the second primary color #Step-4 Check if it's valid #Step-5 Check for combinations of colors and display that color # Get user input color1 = input('Enter t...
true
7008005de70aadea1bebd51d8a068272c7f7b6af
mckennec2014/cti110
/P5HW2_MathQuiz _ChristianMcKenney.py
2,012
4.375
4
# This program calculates addition and subtraction with random numbers # 4/30/2020 # CTI-110 P5HW2 - Math Quiz # Christian McKenney #Step-1 Define the main and initialize the loop variable #Step-2 Ask the user to enter a number from the menu #Step-3 If the user enters the number 1, add the random numbers and #...
true
7e3ff4cbf422f91773d66991a05720718ec42bd7
cs112/cs112.github.io
/recitation/rec8.py
1,585
4.1875
4
""" IMPORTANT: Before you start this problem, make sure you fully understand the wordSearch solution given in the course note. Now solve this problem: wordSearchWithIntegerWildCards Here we will modify wordSearch so that we can include positive integers in the board, like so (see board[1][1]): board = [ [ 'p'...
true
63d2eda6cbc8cbfc8c992828adb506ffd7f5a075
cs112/cs112.github.io
/challenges/challenge_1.py
759
4.15625
4
################################################################################ # Challenge 1: largestDigit # Find the largest digit in an integer ################################################################################ def largestDigit(n): n = abs(n) answer = 0 check =0 while n >0: ch...
true
ac1c189338811d43945c5e96f729085aaffe26d8
Halal-Appnotrix/Problem-Solving
/hackerrank/Problem-Solving/Algorithm/Implementation/Grading_Students.py
783
4.125
4
# # The function is expected to return an INTEGER_ARRAY. # The function accepts INTEGER_ARRAY grades as parameter. # def gradingStudents(grades): grades_array = [] for grade in grades: the_next_multiple_of_5 = (((grade // 5)+1)*5) if grade < 38: grades_array.append(grade) ...
true
b57b87613722928d3011f9bba5325e962765a403
matsalyshenkopavel/codewars_solutions
/Stop_gninnipS_My_sdroW!.py
833
4.125
4
"""Write a function that takes in a string of one or more words, and returns the same string, but with all five or more letter words reversed (like the name of this kata). Strings passed in will consist of only letters and spaces. Spaces will be included only when more than one word is present.""" def spin_words(sent...
true
e9183dc00682ac9e38bc8f01fd49f4b5f3c9fa37
Isha09/mit-intro-to-cs-python
/edx/week1/prob1.py
552
4.125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Nov 6 14:52:43 2017 @author: esha Prog: Assume s is a string of lower case characters. Write a program that counts up the number of vowels contained in the string s. Valid vowels are: 'a', 'e', 'i', 'o', and 'u'. For example, if s = 'azcbobobegghak...
true
90fd58a60095a888058eb7788255886b6870056a
david778/python
/Point.py
1,233
4.4375
4
import math class Point(object): """Represents a point in two-dimensional geometric coordinates""" def __init__(self, x=0.0, y=0.0): """Initialize the position of a new point. The x and y coordinates can be specified. If they are not, the point defaults to the origin.""" self.move(x, ...
true
47c580cf46d2c83ebf1ca05601c7f4c05ea4d913
nitred/nr-common
/examples/mproc_example/mproc_async.py
1,442
4.15625
4
"""Simple example to use an async multiprocessing function.""" from common_python.mproc import mproc_async, mproc_func # STEP - 1 # Define a function that is supposed to simulate a computationally intensive function. # Add the `mproc_func` decorator to it in order to make it mproc compatible. @mproc_func def get_squa...
true
d6fb8c780bc46b577df3beb95265bf6addd4d2e1
ronBP95/insertion_sort
/app.py
690
4.21875
4
def insertion_sort(arr): operations = 0 for i in range(len(arr)): num_we_are_on = arr[i] j = i - 1 # do a check to see that we don't go out of range while j >= 0 and arr[j] > num_we_are_on: operations += 1 # this check will be good, because we won'...
true
7314f15c59cd41a095c2d6c9e12e824ff23f9dad
davidalanb/PA_home
/Py/dicts.py
1,188
4.4375
4
# make an empty dict # use curly braces to distinguish from standard list words = {} # add an item to words words[ 'python' ] = "A scary snake" # print the whole thing print( words ) # print one item by key print( words[ 'python' ] ) # define another dict words2 = { 'dictionary': 'a heavy book', \ 'cl...
true
f8f481911c4d3d8b79082899528af93978e92957
amitjpatil23/simplePythonProgram
/Atharva_35.py
620
4.25
4
# Simple program in python for checking for armstrong number # Python program to check if the number is an Armstrong number or not y='y' while y == 'y': # while loop # take input from the user x = int(input("Enter a number: ")) sum = 0 temp = x while temp > 0: #loop for ...
true
0c8893cdaadd507fb071816a92dd52f2c8955d65
amitjpatil23/simplePythonProgram
/palindrome_and_armstrong_check.py
630
4.21875
4
def palindrome(inp): if inp==inp[::-1]: #reverse the string and check print("Yes, {} is palindrome ".format(inp)) else: print("No, {} is not palindrome ".format(inp)) def armstrong(number): num=number length=len(str(num)) total=0 while num>0: temp=num%10 ...
true
a26e88d420464e4c075984303274738ce61db468
SongYippee/leetcode
/LinkedList/86 分片链表.py
1,529
4.15625
4
# -*- coding: utf-8 -*- # @Time : 1/14/20 10:17 PM # @Author : Yippee Song # @Software: PyCharm ''' Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the original relative order of the nodes in each of the two partitio...
true
04a19b417325d45e3b776f200eed3d80042a2159
uran001/Small_Projects
/Hot_Potato_Game/hot_potato_classic.py
1,236
4.125
4
# Note the import of the Queue class from queue import ArrayQueue def hot_potato(name_list, num): """ Hot potato simulator. While simulating, the name of the players eliminated should also be printed (Note: you can print more information to see the game unfolding, for instance the list of players to w...
true
474cc9eb3ba257339e9b726479cfa10f03c14e29
rbarrette1/Data-Structures
/LinkedList/LinkedList.py
2,055
4.21875
4
from Node import * # import Node class head = "null" # first node of the linked list class LinkedList(): def __init__(self): self.head = None # set to None for the time being # insert after a specific index def insert_after_index(self, index, new_node): node = self.head # get the first no...
true
642410d99d761e9565cd2829893d08bf901e7c7b
Johnscar44/code
/python/notes/elif.py
331
4.125
4
secret_num = "2" guess = input("guess the number 1 - 3: ") if guess.isdigit() == False: print("answer can only be a digit") elif guess == "1": print("Too Low") elif guess == "2": print("You guessed it!") elif guess == "3": print("Too high") else: print("Guess not in rage 1 - 3") print("please t...
true
a2b2da73552e61cc2a3fbae380186374984d0b0f
Johnscar44/code
/compsci/moon.py
1,207
4.1875
4
phase = "Full" distance = 228000 date = 28 eclipse = True # - Super Moon: the full moon occurs when the moon is at its closest approach to earth (less than 230,000km away). # - Blue Moon: the second full moon in a calendar month. In other words, any full moon on the 29th, 30th, or 31st of a month. # - Blood Moon: a lu...
true
6d2ddc65b018e810f4e4e6dc4424cc6025853faa
Johnscar44/code
/compsci/newloop.py
562
4.375
4
mystery_int_1 = 3 mystery_int_2 = 4 mystery_int_3 = 5 #Above are three values. Run a while loop until all three #values are less than or equal to 0. Every time you change #the value of the three variables, print out their new values #all on the same line, separated by single spaces. For #example, if their values were ...
true
570a915a233eee00cc23b34d7ce3cf2c78940d75
Johnscar44/code
/compsci/forloop.py
957
4.71875
5
#In the designated areas below, write the three for loops #that are described. Do not change the print statements that #are currently there. print("First loop:") for i in range(1 , 11): print(i) #Write a loop here that prints the numbers from 1 to 10, #inclusive (meaning that it prints both 1 and 10, and all #the...
true
691d922adfbb58996dabc180a1073ef06afa000a
choprahetarth/AlgorithmsHackerRank01
/Python Hackerrank/oops3.py
827
4.25
4
# Credits - https://www.youtube.com/watch?v=JeznW_7DlB0&ab_channel=TechWithTim # class instantiate class dog: def __init__(self,name,age): self.referal = name self.age = age # getter methods are used to print # the data present def get_name(self): return self.referal de...
true
5960a9e747851838f2823ab0b3b5027275d12b97
choprahetarth/AlgorithmsHackerRank01
/Old Practice/linkedList.py
1,093
4.46875
4
# A simple python implementation of linked lists # Node Class class Node: # add an init function to start itself def __init__(self,data): self.data = data self.next = None # initialize the linked list with null pointer # Linked List Class class linkedList: # add an init function to initial...
true
b499e6ecc7e711bf74441b89fec4fcc49712b4a3
Mohini-2002/Python-lab
/Method(center,capitalize,count,encode,decode)/main.py
702
4.28125
4
#Capitalize (capital the first of a string and its type print) ST1 = input("Enter a string :") ST1 = ST1.capitalize() print("After capitalize use : ", ST1, type(ST1)) #Center (fill the free space of a string and and its type print) ST2 = input("ENter a string :") ST2 = ST2.center(20, "#") print("After center u...
true
718d8989750b21513fff2c0eea78016432b90a4d
asimihsan/challenges
/epi/ch12/dictionary_word_hash.py
2,509
4.15625
4
#!/usr/bin/env python # EPI Q12.1: design a hash function that is suitable for words in a # dictionary. # # Let's assume all words are lower-case. Note that all the ASCII # character codes are adjacent, and yet we want a function that # uniformly distributes over the space of a 32 bit signed integer. # # We can't simp...
true
70e759634d967837b0faed377ced9807c4a604f8
xct/aoc2019
/day1.py
920
4.125
4
#!/usr/bin/env python3 ''' https://adventofcode.com/2019/day/1 Fuel required to launch a given module is based on its mass. Specifically, to find the fuel required for a module, take its mass, divide by three, round down, and subtract 2. ''' data = [] with open('data/day1.txt','r') as f: data = f.readlines() #...
true
3f26a0de9a124b493c1dc5734a2f9e9d30ef6114
vaishalibhayani/Python_example
/Python_Datatypes/sequence_types/dictionary/dictionary1.py
516
4.28125
4
emp={ 'course_name':'python', 'course_duration':'3 Months', 'course_sir':'brijesh' } print(emp) print(type(emp)) emp1={1:"vaishali",2:"dhaval",3:"sunil"} print(emp1) print(type(emp1)) #access value using key print("first name inside of the dictionary:" +emp1[2]) #access value using ...
true
52c255ca2ffcc9b42da2427997bcfa6b539127d2
NaveenSingh4u/python-learning
/basic/python-oops/python-other-concept/generator-ex4.py
1,121
4.21875
4
# Generators are useful in # 1. To implement countdown # 2. To generate first n number # 3. To generate fibonacci series import random import time def fib(): a, b = 0, 1 while True: yield a a, b = b, a + b for n in fib(): if n > 1000: break print(n) names = ['sunny', 'bunny'...
true
bbb15cfc351270d4c09f884ac0e9debb4804aae5
NaveenSingh4u/python-learning
/basic/python-oops/book.py
920
4.125
4
class Book: def __init__(self, pages): self.pages = pages def __str__(self): return 'The number of pages: ' + str(self.pages) def __add__(self, other): total = self.pages + other.pages b = Book(total) return b def __sub__(self, other): total = self.page...
true
c1a3ee82f1c10cc499283df4e4e95f00df71dc1b
Dhanshree-Sonar/Interview-Practice
/Guessing_game.py
808
4.3125
4
##Generate a random number between 1 and 9 (including 1 and 9). Ask the user to guess the number, ##then tell them whether they guessed too low, too high, or exactly right. # Used random module to generate random number import random def guessing_game(): while True: num = 0 while num not in range...
true
226843bbc68bab71fbe2cfb3416925baa898a273
simplex06/clarusway-aws-devops
/ozkan-aws-devops/python/coding-challenges/cc-003-find-the-largest-number/largest_number.py
270
4.25
4
# The largest Number of a list with 5 elements. lst = list() for i in range(5): lst.append(int(input("Enter a number: "))) largest_number = lst[0] for j in lst: if j > largest_number: largest_number = j print("The largest number: ", largest_number)
true
b86d5d0f2b570cfad3678ce341c44af297399e32
N-eeraj/perfect_plan_b
/armstrong.py
343
4.15625
4
import read num = str(read.Read(int, 'a number')) sum = 0 #variable to add sum of numbers for digit in num: sum += int(digit) ** len(num) #calculating sum of number raised to length of number if sum == int(num): print(num, 'is an amstrong number') #printing true case else : print(num, 'is not an amstrong number'...
true
4b20faae3875ba3a2164f691a4a32e61ca944a27
harishassan85/python-assignment-
/assignment3/question2.py
226
4.21875
4
# Write a program to check if there is any numeric value in list using for loop mylist = ['1', 'Sheraz', '2', 'Arain', '3', '4'] for item in mylist: mynewlist = [s for s in mylist if s.isdigit()] print(mynewlist)
true
07669066a5ce7a1561da978fc173c710f3ec7e3a
neonblueflame/upitdc-python
/homeworks/day2_business.py
1,836
4.21875
4
""" Programming in Business. Mark, a businessman, would like to purchase commodities necessary for his own sari-sari store. He would like to determine what commodity is the cheapest one for each type of products. You will help Mark by creating a program that processes a list of 5 strings. The format will be the na...
true
cdc3ed9862e362dc21b899ef3b059a6a9889d6ee
RobSullivan/cookbook-recipes
/iterating_in_reverse.py
938
4.53125
5
# -*- coding: utf-8 -*- """ This is a quote from the book: Reversed iteration only works if the object in question has a size that can be determined or if the object implements a __reversed__() special method. If neither of these can be satisfied, you’ll have to convert the object into a list first. Be aware th...
true
b4ff9851641f8baea2c54f7dd16f206db16827de
isachard/console_text
/web.py
1,633
4.34375
4
"""Make a program that takes a user inputed website and turn it into console text. Like if they were to take a blog post what would show up is the text on the post Differents Links examples: https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world https://www.stereogum.com/2025831/frou-frou-reu...
true
d89df8cc1bffb63dd1f867650b54c55e141602ed
yuch7/CSC384-Artificial-Intelligence
/display_nonogram.py
2,535
4.125
4
from tkinter import Tk, Canvas def create_board_canvas(board): """ Create a Tkinter Canvas for displaying a Nogogram solution. Return an instance of Tk filled as a grid. board: list of lists of {0, 1} """ canvas = Tk() LARGER_SIZE = 600 # dynamically set the size of each square base...
true
9d7c458469e1303571f12dfa15fa71133c5d2355
suterm0/Assignment9
/Assignment10.py
1,439
4.34375
4
# Michael Suter # Assignment 9 & 10 - checking to see if a string is the same reversable # 3/31/20 def choice(): answer = int(input("1 to check for a palindrome, 2 to exit!>")) while answer != 1 and 2: choice() if answer == 1: punc_string = input("enter your string>") return punc_s...
true
3c3bbefb54ddf8e30798a9115ba4de97aca0d396
chng3/Python_work
/第四章练习题/4-12.py
719
4.46875
4
#4-10 my_foods = ['pizza', 'falafel', 'carrot cake', 'chocolate'] print("The first three items in the list are:") print(my_foods[:3]) print("Three items from the middle of the list are:") print(my_foods[1:3]) print("The last items in the list are:") print(my_foods[-3:]) #4-11 你的披萨和我的披萨 pizzas = ['tomato', 'banana'...
true
86e74e6b83be3976ba48f90728a50334811df18a
cycho04/python-automation
/game-inventory.py
1,879
4.3125
4
# You are creating a fantasy video game. # The data structure to model the player’s inventory will be a dictionary where the keys are string values # describing the item in the inventory and the value is an integer value detailing how many of that item the player has. # For example, the dictionary value {'rope': 1, ...
true
70a3ee1c969065898bdb77d2aa0b8004a0364fbf
rajmohanram/PyLearn
/003_Conditional_Loop/06_for_loop_dict.py
582
4.5
4
# let's look at an examples of for loop # - using a dictionary # define an interfaces dictionary - items: interface names interface = {'name': 'GigabitEthernet0/2', 'mode': 'trunk', 'vlan': [10, 20, 30], 'portfast_enabled': False} # let's check the items() method for dictionary interface_items = interface.items() p...
true
0cd762b867fbd84b8319eeb89b10c0fcb73675ef
rajmohanram/PyLearn
/004-Functions/01_function_intro.py
758
4.46875
4
""" Functions: - Allows reuse of code - To create modular program - DRY - Don't Repeat Yourselves """ # def: keyword to define a function # hello_func(): name of the function - Prints a string when called # () - used to get the parameters: No parameters / arguments used in this function def hello_func(): ...
true
d8d9a875d2a71f214c7041c2df0b0fcf298e4c8b
jda5/scratch-neural-network
/activation.py
2,158
4.21875
4
import numpy as np class ReLU: def __init__(self): self.next = None self.prev = None def forward(self, inputs): """ Implements Rectified Linear Unit (ReLU) function - all input values less than zero are replaced with zero. Finally it sets two new attributes: (1) the i...
true
594edacffdac059e2f6b34a514d402659b9ed4a1
leon-lei/learning-materials
/binary-search/recursive_binary_search.py
929
4.1875
4
# Returns index of x in arr if present, else -1 def binarySearch(arr, left, right, x): # Check base case if right >= left: mid = int(left + (right - left)/2) # If element is present at the middle itself if arr[mid] == x: return mid # If element is smaller than mid...
true
1421aac5bb5d2864179392ec3580146803b0dc22
signalwolf/Algorithm
/Chapter2 Linked_list/Insert a node in sorted linked list.py
1,244
4.28125
4
# https://www.geeksforgeeks.org/given-a-linked-list-which-is-sorted-how-will-you-insert-in-sorted-way/ # insert by position class LinkedListNode(object): def __init__(self, val): self.val = val self.next = None def create_linked_list(arr): dummy_node = LinkedListNode(0) prev = dummy_node...
true
cc2ca652d4ef4f7b5b6f4198f1e92a6f3a85ad63
YSreylin/HTML
/1101901079/list/Elist10.py
289
4.21875
4
#write a Python program to find the list of words that are longer than n from a given list of words a = [] b = int(input("Enter range for list:")) for i in range(b): c = input("Enter the string:") a.append(c) for j in a: d = max(a, key=len) print("\n",d,"is the longest one")
true
97d96de1162239c5e135bc9ce921625b5c88a080
YSreylin/HTML
/1101901079/Array/array.py
242
4.40625
4
#write python program to create an array of 5 integers and display the array items. #access individual element through indexes. import array a=array.array('i',[]) for i in range(5): c=int(input("Enter array:")) a.append(c) print(a)
true
7d6b9fc6ddd4a6cc4145d1568965666b48b030ed
YSreylin/HTML
/1101901079/0012/04.py
204
4.125
4
#this program is used to swap of two variable a = input('Enter your X variable:') b = input('Enter your Y variable:') c=b d=a print("Thus") print("The value of X is:",c) print("The value of Y is:",d)
true
1a1d300c97c45ce4e321530f3a30d296fe165bf2
YSreylin/HTML
/1101901079/0012/Estring6.py
394
4.25
4
'''write a Python program to add 'ing' at the end of a given string (length should be at least 3). If the given string already ends with 'ing' then add 'ly' instead. if the string lenth of the given string is less then 3, leave it unchanged''' a = input("Enter the word:") x = a[-3:] if len(a)>3: if x=='ing': ...
true
4373addc9af220054ff54a7d6abb1073bf7a602d
TaviusC/cti110
/P3HW2_MealTipTax_Cousar.py
1,327
4.25
4
# CTI-110 # P3HW2 - MealTipTax # Tavius Cousar # 2/27/2019 # # Enter the price of the meal # Display tip choices # Enter the tip choice # Calculate the total price of meal (price of meal * tip + price) # Calculate the sales tax (charge * 0.07) # Calculate the total (charge + sales tax) # if tip == '0.15', '0...
true
09e2ea08b77fa1a4e33180cac2ed46e872f281fb
ImayaDismas/python-programs
/variables_dict.py
455
4.3125
4
#!/usr/bin/python3 def main(): d = {'one': 1, 'two': 2, 'three': 3, 'four': 4, 'five': 5} for k in sorted(d.keys()): #sorted sorts the alphabetically print(k, d[k]) #using a different definition of the dictionaries a = dict( one=1, two = 2, three = 3, four = 4, five = 'five' )#usually are mutable a['seven'...
true
278144e8d19ad06065719defc62f8b4c2e29c786
Mansalu/python-class
/003-While/main.py
1,093
4.34375
4
# While Loops -- FizzBuzz """ Count from 1 to 100, printing the current count. However, if the count is a multiple of 3, print "Fizz" instead of the count. If the count is a multiple of 5 print "Buzz" instead. Finally, if the count is a multiple of both print "FizzBuzz" instead. Example 1, 2, Fizz, 4, Buzz, Fizz, 7,...
true
d741d285f023ad8223a5c095775a8d0b225f4b4a
cabhishek/python-kata
/loops.py
1,045
4.3125
4
def loop(array): print('Basic') for number in array: print(number) print('Basic + Loop index') for i, number in enumerate(array): print(i, number) print('Start from index 1') for i in range(1, len(array)): print(array[i]) print('Choose index and start position') ...
true
a1d66f9acca5ecd0062f9842e07a5158b109587b
cabhishek/python-kata
/word_break.py
1,280
4.28125
4
""" Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words. For example, given s = "leetcode", dict = ["leet", "code"]. Return true because "leetcode" can be segmented as "leet code". """ def word_break_2(word, dict): for ...
true
ec077fa4521bd2584b13d15fe3b3866dd4ff4fde
rtyner/python-crash-course
/ch5/conditional_tests.py
337
4.34375
4
car = 'mercedes' if car == 'audi': print("This car is made by VW") else: print("This car isn't made by VW") if car != 'audi': print("This car isn't made by VW") car = ['mercedes', 'volkswagen'] if car == 'volkswagen' and 'audi': print("These cars are made by VW") else: print("Not all of these cars...
true
0c04919a425328f8a1dfcf7e612a6d8f1780e61d
UWPCE-PythonCert-ClassRepos/Python210_Fall2019
/students/matthew_denko/lesson03/slicing_lab.py
1,731
4.21875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Oct 28 15:08:38 2019 @author: matt.denko """ """Write some functions that take a sequence as an argument, and return a copy of that sequence: with the first and last items exchanged. with every other item removed. with the first 4 and the last 4 items...
true
51cf6b8c764ffef5e24eede476fff19f76d66df4
UWPCE-PythonCert-ClassRepos/Python210_Fall2019
/students/jraising/lesson02/series.py
2,261
4.15625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Oct 17 17:09:09 2019 @author: jraising """ def fibo(n): fib = [0,1] for i in range(n-1): fib.append(fib[i] + fib[i+1]) return (fib[n]) ans = fibo(5) print (ans) def lucas(n): luc = [2,1] for i in range(n-1): lu...
true
e1f1be756bda5a8452dd18deec0c7e936c17f673
UWPCE-PythonCert-ClassRepos/Python210_Fall2019
/students/jammy_chong/lesson03/list_lab.py
1,919
4.3125
4
def create_list(): global fruit_list fruit_list = ["Apples", "Pears", "Oranges", "Peaches"] #Seris 1 create_list() print(fruit_list) new_fruit = input("Add another fruit to the end of the list: ") fruit_list.append(new_fruit) print(fruit_list) user_number = input(f"Choose a number from 1 to {len(fruit_list)}...
true
45e749325dc2d163416366a6a3046a83d97bbd76
UWPCE-PythonCert-ClassRepos/Python210_Fall2019
/students/matthew_denko/lesson02/fizz_buzz.py
603
4.15625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Oct 21 20:51:19 2019 @author: matt.denko """ """Write a program that prints the numbers from 1 to 100 inclusive. But for multiples of three print “Fizz” instead of the number. For the multiples of five print “Buzz” instead of the number. For numbers wh...
true
000a7bafb0c973ba1869c322e84efb75ee41e6f1
mohamedamine456/AI_BOOTCAMP
/Week01/Module00/ex01/exec.py
249
4.125
4
import sys result = "" for i, arg in enumerate(reversed(sys.argv[1:])): if i > 0: result += " " result += "".join(char.lower() if char.isupper() else char.upper() if char.islower() else char for char in reversed(arg)) print(result)
true
dffcce747fb2c794585df237849517bd8b637d9f
data-pirate/Algorithms-in-Python
/Arrays/Two_sum_problem.py
1,690
4.21875
4
# TWO SUM PROBLEM: # In this problem we need to find the terms in array which result in target sum # for example taking array = [1,5,5,15,6,3,5] # and we are told to find if array consists of a pair whose sum is 8 # There can be 3 possible solutions to this problem #solution 1: brute force # this might not be the bes...
true
aa990f7844b6d49bc9eb2c019150edbc65b32833
oskar404/code-drill
/py/fibonacci.py
790
4.53125
5
#!/usr/bin/env python # Write a function that computes the list of the first 100 Fibonacci numbers. # By definition, the first two numbers in the Fibonacci sequence are 0 and 1, # and each subsequent number is the sum of the previous two. As an example, # here are the first 10 Fibonnaci numbers: 0, 1, 1, 2, 3, 5, 8, 13...
true
959cd3062b855c030b92cfe0f2edbbe141018508
kctompkins/my_netops_repo
/python/userinput.py
220
4.125
4
inputvalid = False while inputvalid == False: name = input("Hey Person, what's your name? ") if all(x.isalpha() or x.isspace() for x in name): inputvalid = True else: inputvalid = False print(name)
true
3759abcbab3aff89acc59fe4228f0146ee2eaa56
HSabbir/Design-pattern-class
/bidding/gui.py
1,717
4.1875
4
import tkinter as tk from tkinter import ttk from tkinter import * from bidding import biddingraw # this is the function called when the button is clicked def btnClickFunction(): print('clicked') # this is the function called when the button is clicked def btnClickFunction(): print('clicked') # this is the funct...
true
cd79e3b1ce72569bb62b994695e4483798346a0c
Luke-Beausoleil/ICS3U-Unit3-08-Python-is_it_a_leap_year
/is_it_a_leap_year.py
926
4.28125
4
#!/usr/bin/env python3 # Created by: Luke Beausoleil # Created on: May 2021 # This program determines whether inputted year is a leap year def main(): # this function determines if the year is a leap year # input year_as_string = input("Enter the year: ") # process & output try: year = ...
true
322be9bbf093725a12f82482cd5b9d0ffdf98dcc
bgschiller/thinkcomplexity
/Count.py
1,966
4.15625
4
def count_maker(digitgen, first_is_zero=True): '''Given an iterator which yields the str(digits) of a number system and counts using it. first_is_zero reflects the truth of the statement "this number system begins at zero" It should only be turned off for something like a label system.''' def counter(n): ...
true
a8f2158fe199c282b8bdc33f257f393eb70e6685
iamaro80/arabcoders
/Mad Libs Generator/06_word_transformer.py
737
4.21875
4
# Write code for the function word_transformer, which takes in a string word as input. # If word is equal to "NOUN", return a random noun, if word is equal to "VERB", # return a random verb, else return the first character of word. from random import randint def random_verb(): random_num = randint(0, 1) if ra...
true
7c017d73da7b2e702aecf6fa81114580389afe09
Numa52/CIS2348
/Homework1/3.18.py
862
4.25
4
#Ryan Nguyen PSID: 180527 #getting wall dimensions from user wall_height = int(input("Enter wall height (feet):\n")) wall_width = int(input("Enter wall width (feet):\n")) wall_area = wall_width * wall_height print("Wall area:", wall_area, "square feet") #calculating gallons of paint needed #1 gallon of paint covers 3...
true
f5540eb90b304d519809c8c010add05fc11e491f
sindhumudireddy16/Python
/Lab 2/Source/sortalpha.py
296
4.375
4
#User input! t=input("Enter the words separated by commas: ") #splitting words separated by commas which are automatically stored as a list. w=t.split(",") #sorting the list. w1=sorted(w) #iterating through sorted list and printing output. for k in w1[:-1]: print(k+",",end='') print(w1[-1])
true
263387b1a516c9558c26c0d6fd2df142ff9edcc6
muondu/caculator
/try.py
528
4.40625
4
import re def caculate(): #Asks user to input operators = input( """ Please type in the math operation you will like to complete + for addition - for subtraction * for multiplication / for division """ ) #checks if the opertators match with input if not re.match("^[+,-,*,/]*$", operators)...
true
1edd3809d431ece230d5d70d15425bd2fa62e43a
jabhij/DAT208x_Python_DataScience
/FUNCTIONS-PACKAGES/LAB3/L1.py
445
4.3125
4
""" Instructions -- Import the math package. Now you can access the constant pi with math.pi. Calculate the circumference of the circle and store it in C. Calculate the area of the circle and store it in A. ------------------ """ # Definition of radius r = 0.43 # Import the math package import math # Calculate C C ...
true
c82f373f42c0124c42d3ec8dd89184a0897998a1
jabhij/DAT208x_Python_DataScience
/NUMPY/LAB1/L2.py
614
4.5
4
""" Instructions -- Create a Numpy array from height. Name this new array np_height. Print np_height. Multiply np_height with 0.0254 to convert all height measurements from inches to meters. Store the new values in a new array, np_height_m. Print out np_height_m and check if the output makes sense. """ # height is a...
true