blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
44be8c3c7f6920bdb8329af683afa045634d682e
ajakaiye33/pythonic_daily_capsules
/concatenate_string.py
602
4.34375
4
def concatenate_string(stringy1, stringy2): """ A function that receives two strings and returns a new one containing both strings cocatenated """ return "{} {}".format(stringy1, stringy2) print(concatenate_string("Hello", "World")) print(concatenate_string("Hello", "")) # some other way... d...
true
7ba818effcd4db9905ca6814f4679184224e9d27
ajakaiye33/pythonic_daily_capsules
/color_mixer.py
970
4.25
4
def color_mixer(color1, color2): """ Receives two colors and returns the color resulting from mixing them in EITHER ORDER. The colors received are either "red", "blue", or "yellow" and should return: "Magenta" if the colors mixed are "red" and "blue" "Green" if the colors mixed are "blue" and "...
true
195b3d1288769e60d0aa6d0023f308a6e0675523
ajakaiye33/pythonic_daily_capsules
/make_number_odd.py
288
4.25
4
def make_number_odd(num): """ Receives a number, adds 1 to that number if it's even and returns the number if the original number passed is odd, just return it """ if num % 2 == 0: num += 1 return num print(make_number_odd(2)) print(make_number_odd(5))
true
d46bd897ee359b69d2f3fc29d7d6803883590c23
rhydermike/PythonPrimes
/primes.py
1,641
4.40625
4
#Prime number sieve in Python MAXNUMBER = 1000 #Total number of numbers to test results = [] #Create list to store the results for x in range (1,MAXNUMBER): #Begin outer for loop to test all numbers between 1 and MAXNUMBER isprime = True #Set boolean variable ispri...
true
7a02905d8b244c6e96eb871ff8099d6c0db26e03
SamJ2018/LeetCode
/python/python语法/pyexercise/Exercise04_11.py
1,309
4.125
4
# Prompt the user to enter input month = eval(input("Enter a month in the year (e.g., 1 for Jan): ")) year = eval(input("Enter a year: ")) numberOfDaysInMonth = 0; if month == 1: print("January", year, end = "") numberOfDaysInMonth = 31; elif month == 2: print("February", year, end = "") if year % 40...
true
be6bed1c6c15377c1bd5d78c321d8413fcb85bf5
SamJ2018/LeetCode
/python/python语法/pyexercise/Exercise06_17.py
643
4.28125
4
import math def main(): edge1, edge2, edge3 = eval(input("Enter three sides in double: ")) if isValid(edge1, edge2, edge3): print("The area of the triangle is", area(edge1, edge2, edge3)) else: print("Input is invalid") # Returns true if the sum of any two sides is # greater than the th...
true
5a326e8c133c4fb3fc2d0581f1c8d6c7feb72376
Ayman-M-Ali/Mastering-Python
/Assignment_015.py
2,725
4.15625
4
#-------------------------------------------------------- # Assignment (1): # Write the following code to test yourself and do not run it # After the last line in the code write a comment containing the Output that will come out from your point of view # Then run Run to see your result sound or not # Make a com...
true
694a06ab8f7ca681fb5b16f273cb2be1f725abbd
Lydia-Li725/python-basic-code
/排序.py
369
4.1875
4
def insertion_sort(array): for index in range(1,len(array)): position = index temp_value = array[index] while position > 0 and array[position - 1] > temp_value: array[position] = array[position-1] position -= 1 array[position] = temp_value return a...
true
acbf854d06bfa1e458cf65cca8af844fb40cd094
swavaldez/python_basic
/01_type_and_statements/04_loops.py
620
4.21875
4
# student_names = [] student_names = ["Mark", "Katarina", "Jessica", "Sherwin"] print(len(student_names)) # for loops for name in student_names: print("Student name is {0}".format(name)) # for range x = 0 for index in range(10): x += 10 print("The value of x is {0}".format(x)) # start in 5 and ends in 9 ...
true
a1ba2026687b109cdd7c72113cc222d4cffdd804
cassandraingram/PythonBasics
/calculator.py
1,427
4.1875
4
# calculator.py # Cassie Ingram (cji3) # Jan 22, 2020 # add function adds two inputs def add(x, y): z = x + y return z #subtract function subtracts two inputs def subtract(x, y): z = x - y return z # multiply function multiplies two inputs def multiply(x, y): z = x * y return z # divide function divides two ...
true
9527efcef31dba3ca25ec33f2115ebfc5ec1d53a
snowpuppy/linux_201
/python_examples/example1/guessnum.py
855
4.21875
4
#!/usr/bin/env python #Here we import the modules we need. import random random.seed() #We need to seed the randomizer number = random.randint(0,100) #and pull a number from it. trys = 10 #We're only giving them 10 tries. guess = -1 #And we need a base guess. while guess != number and trys != 0: #So, we need to let...
true
26f06216b4cf66c2bb236dccb89ae7cf0d7b2713
rchristopfel/IntroToProg-Python-Mod07
/Assignment07.py
2,304
4.125
4
# ------------------------------------------------------------------------ # # Title: Assignment 07 # Description: using exception handling and Python’s pickling module # ChangeLog (Who,When,What): # Rebecca Christopfel, 11-18-19, test pickle module # Rebecca CHristopfel, 11-20-19, create try/except block for scri...
true
919d4323cdb5dd99e5aff75710d00fe279bbf712
XavierKoen/lecture_practice_code
/guessing_game.py
254
4.125
4
question = input("I'm thinking of a number between 1 and 10, what is it? ") ANSWER = '7' print(question) while question != ANSWER: question = input("Oh no, please try again. ") print (question) print("Congrtulations! You were correct, it was 7!")
true
1a8f986972d5f0ec326aaeb3f901cc259bf47ecd
XavierKoen/lecture_practice_code
/name_vowel_reader.py
786
4.125
4
""" Asks user to input a name and checks the number of vowels and letters in the name. """ def main(): name = input("Name: ") number_vowels = count_vowels(name) number_letters = count_letters(name) print("Out of {} letters, {}\nhas {} vowels".format(number_letters, name, number_vowels)) def count_vo...
true
04cb412cecc6d49bd15ebde03cc729f51d1e19aa
milanvarghese/Python-Programming
/Internshala/Internshala Assignments/W5 Assignment - Connecting to SQLite Database/insert_data.py
1,124
4.28125
4
#Importing Necessary Modules import sqlite3 #Establishing a Connection shelf=sqlite3.connect("bookshelf.db") curshelf=shelf.cursor() #Creating a table with error check try: curshelf.execute('''CREATE TABLE shelf(number INT PRIMARY KEY NOT NULL ,title TEXT NOT NULL, author TEXT STRING, price FLOAT NOT NULL);''') ...
true
dc73601bced9a16c9b52abdb42a53b04df5da287
Ktheara/learn-python-oop
/advaced-review/2.tuple.py
959
4.5625
5
# A tuple is a collection of objects which is ordered and immutable(unchangeable). # https://www.python-engineer.com/courses/advancedpython/02-tuples/ # So similar to list but elements are protected mytuple = ('a', 'p', 'p', 'l', 'e') #create a tuple print(mytuple) # number of elements print(len(mytuple)) # number ...
true
d7948b4af779d68ed87af1d832c4cf6c558ec274
cuongv/LeetCode-python
/BinaryTree/PopulatingNextRightPointersInEachNode.py
2,802
4.21875
4
#https://leetcode.com/problems/populating-next-right-pointers-in-each-node/ """ You are given a perfect binary tree where all leaves are on the same level, and every parent has two children. The binary tree has the following definition: struct Node { int val; Node *left; Node *right; Node *next; } Populate ea...
true
1dfcc2fe5bcac12d235391d073b5991fca58960b
sudhamshu091/Daily-Dose-of-Python-Coding
/Qsn_21/string_punctuation.py
232
4.25
4
from string import punctuation string = "/{Python @ is actually an > interesting //language@ " replace = '#' for char in punctuation: string = string.replace(char, replace) print("String after replacement is: ", string)
true
88fa596a897959b76862605be56a153b606f4555
devil-cyber/Data-Structure-Algorithm
/tree/count_node_complete_tree.py
643
4.125
4
from tree import Tree def height_left(root): hgt = 0 node = root while node: hgt += 1 node = node.left return hgt def height_right(root): hgt = 0 node = root while node: hgt += 1 node = node.right return hgt def count_node(root): if root is None: ...
true
9179d31d9eeda1d0767924c0714b62e22875fb34
MeeSeongIm/trees
/breadth_first_search_02.py
611
4.1875
4
# find the shortest path from 1 to 14. # graph in list adjacent representation graph = { "1": ["2", "3"], "2": ["4", "5"], "4": ["8", "9"], "9": ["12"], "3": ["6", "7"], "6": ["10", "11"], "10": ["13", "14"] } def breadth_first_search(graph, start, end): next_start = [(node, pat...
true
21ef42736c7ef317b189da0dc033ad75615d3523
LiloD/Algorithms_Described_by_Python
/insertion_sort.py
1,505
4.1875
4
import cProfile import random ''' this is the insertion sort Algorithm implemented by Python Pay attention to the break condition of inner loop if you've met the condition(the key value find a place to insert) you must jump out of the loop right then Quick Sort is Moderately fast for small input-size(<=30) but weak for...
true
bedf86dafe10f5dc96b2ebd355040ab2fdfbd469
jpacsai/MIT_IntroToCS
/Week5/ProblemSet_5/Problem1.py
1,832
4.21875
4
# -*- coding: utf-8 -*- """ Created on Sat Oct 6 16:04:29 2018 @author: jpacsai """ def build_shift_dict(self, 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 a...
true
5902f17e71a3630344ab79f9c22ee2985cb80d3e
GorTIm/DailyCoding
/2020-01-17-Medium-Google-DONE.py
987
4.21875
4
""" This problem was asked by Google. You are given an array of nonnegative integers. Let's say you start at the beginning of the array and are trying to advance to the end. You can advance at most, the number of steps that you're currently on. Determine whether you can get to the end of the array. For example, giv...
true
8e0f519ea8d1c1fb701a718929fb35e1319c2faf
pemburukoding/belajar_python
/part002.py
2,128
4.40625
4
# Get input from console # inputString = input("Enter the sentence : ") # print("The inputted string is :", inputString) # Implicit Type # num_int = 123 # num_flo = 1.23 # num_new = num_int + num_flo # print("Value of num_new : ", num_new) # print("datatype of num_new : ", type(num_new)) # num_int = 123 # num_str ...
true
639934c70afa23f042371ce06b3ed89fdd6245ca
baluneboy/pims
/recipes/recipes_map_filter_reduce.py
1,824
4.53125
5
#!/usr/bin/env python """Consider map and filter methodology.""" import numpy as np def area(r): """return area of circle with radius r""" return np.pi * (r ** 2) def demo_1(radii): """method 1 does not use map, it fully populates in a loop NOT AS GOOD FOR LARGER DATA SETS""" areas = [] for r...
true
1e6201d2f6f6df652f7ca66b1347c59c3121d067
ThoPhD/vt
/question_1.py
918
4.25
4
# Question 1. Given an array of integer numbers, which are already sorted. # E.g., A = [1,2,3,3,3,4,4,5,5,6] # • Find the mode of the array # • Provide the time complexity and space complexity of the array, and your reasoning # • Note: write your own function using the basic data structure of your language, # please av...
true
604be482da6a2aea20bf660763b23019eea9571f
cloudzfy/euler
/src/88.py
1,356
4.1875
4
# A natural number, N, that can be written as the sum and # product of a given set of at least two natural numbers, # {a1, a2, ... , ak} is called a product-sum number: # N = a_1 + a_2 + ... + a_k = a_1 x a_2 x ... x a_k. # For example, 6 = 1 + 2 + 3 = 1 x 2 x 3. # For a given set of size, k, we shall call the smalle...
true
03f028686704d0b223621546b04893a844ef9148
NathanJiangCS/Exploring-Python
/Higher Level Python Concepts/Closures.py
2,029
4.6875
5
#Closures ''' Closures are a record storing a function together with an environment: a mapping associating each free variable of the function with the value or storage location to which the name was bound when the closure was created. A closure, unlike a plain function, allows the function to access those captured var...
true
d3ea582ed28b3eaa9f7a0376c649bab202c94ffa
NathanJiangCS/Exploring-Python
/Higher Level Python Concepts/String Formatting.py
2,862
4.125
4
#String formatting #Advanced operations for Dicts, Lists, and numbers person = {'name':'Nathan', 'age':100} ####################### #Sentence using string concatenation sentence = "My name is " + person['name'] + ' and I am ' + str(person['age']) + ' years old.' print sentence #This is not readable as you have to ope...
true
616e0af829a12d78b50fdf016704bb179d2a721c
RonakNandanwar26/Python_Programs
/zip_enumerate.py
2,367
4.40625
4
# zip # zip returns iterator that combines multiple iterables into # one sequence of tuples # ('a',1),('b',2),('c',3) # letters = ['a','b','c'] # nums = [1,2,3] # lst = [4,5,6] # print(zip(nums,letters,lst)) # # # # for letters,nums,lst in zip(letters,nums,lst): # print(letters,nums,lst) # # unzip ...
true
9a84af3077b599c11231def2af09cb8ccf40141c
stavernatalia95/Lesson-5.3-Assignment
/Exercise #1.py
448
4.5
4
#Create a function that asks the user to enter 3 numbers and then prints on the screen their summary and average. numbers=[] for i in range(3): numbers.append(int(input("Please enter a number:"))) def print_sum_avg(my_numbers): result=0 for x in my_numbers: result +=x avg=result/le...
true
bcacc85fdc2fde42a3f3636cedd1666adaa24378
Chia-Network/chia-blockchain
/chia/util/significant_bits.py
991
4.125
4
from __future__ import annotations def truncate_to_significant_bits(input_x: int, num_significant_bits: int) -> int: """ Truncates the number such that only the top num_significant_bits contain 1s. and the rest of the number is 0s (in binary). Ignores decimals and leading zeroes. For example, -0b01111...
true
f3d569ebc4192a0e60d95944b91ac33bac1f17aa
chimaihueze/The-Python-Workbook
/Chapter 2/44_faces_on_money.py
1,118
4.1875
4
""" Individual Amount George Washington $1 Thomas Jefferson $2 Abraham Lincoln $5 Alexander Hamilton $10 Andrew Jackson $20 Ulysses S. Grant ...
true
87a475ae20b4dde09bc00f7ca8f0258ead316aa4
chimaihueze/The-Python-Workbook
/Chapter 1/exercise24_units_of_time.py
670
4.4375
4
""" Create a program that reads a duration from the user as a number of days, hours, minutes, and seconds. Compute and display the total number of seconds represented by this duration. """ secs_per_day = 60 * 60 * 24 secs_per_hour = 60 * 60 secs_per_minute = 60 days = int(input("Enter the number of days: ")) hours =...
true
621e85bdd3efd63d3d3fccd18e6d77d83ef9d6f3
chimaihueze/The-Python-Workbook
/Chapter 1/exercise29_wind_mill.py
1,266
4.4375
4
""" When the wind blows in cold weather, the air feels even colder than it actually is because the movement of the air increases the rate of cooling for warm objects, like people. This effect is known as wind chill. In 2001, Canada, the United Kingdom and the United States adopted the following formula for computing ...
true
420c2501440b97e647d1eff05559561e5c5b3869
chimaihueze/The-Python-Workbook
/Chapter 1/exercise23_area_of_a_regular-polygon.py
531
4.46875
4
""" Polygon is regular if its sides are all the same length and the angles between all of the adjacent sides are equal. Write a program that reads s and n from the user and then displays the area of a regular polygon constructed from these values. """ # s is the length of a side and n is the number of sides: import...
true
61628dc6e1c6d4ba2c8bdc112d25aa1b2d334f96
cheikhtourad/MLND_TechnicalPractice
/question2.py
1,628
4.125
4
# Question 2 # Given a string a, find the longest palindromic substring contained in a. # Your function definition should look like question2(a), and return a string. # NOTE: For quetions 1 and 2 it might be useful to have a function that returns all substrings... def question2(a): longest_pal = '' # Base Case: The...
true
3c6a3ffb396896360f45c373f871e4e15fafc181
vivekinfo1986/PythonLearning
/Oops-Polymorphism_AbstractClass_Overwrite.py
530
4.46875
4
#Define a base class with abstract method and using inheritence overwrite it. class Animal(): def __init__(self,name): self.name = name #Testing abstract class def speak(self): raise NotImplementedError('Subclass must implement this abstract method') class Dog(Animal): def speak(self)...
true
cd4f7ca00ff3f3336e8899c75f10fc5d69fedc7e
AndyWheeler/project-euler-python
/project-euler/5 Smallest multiple/smallestMultiple.py
1,105
4.15625
4
import primeFactors #primePower(num) returns True if num is a prime power, False otherwise def primePower(num): factors = primeFactors.primeFactorsOf(num) #print "prime factors of " + str(num) + ": " + str(factors) isPrimePower = not factors or factors.count(factors[0]) == len(factors) return isPrimePo...
true
4ca1429fa78294b81f05a18f22f23a5bad106c73
jammilet/PycharmProjects
/Notes/Notes.py
2,014
4.1875
4
import random # imports should be at the top print(random.randint(0, 6)) print('Hello World') # jamilet print(3 + 5) print(5 - 3) print(5 * 3) print(6 / 2) print(3 ** 2) print() # creates a blank line print('see if you can figure this out') print(5 % 3) # taking input name = input('What is your name?') print('...
true
976d7a598201141e0a1b4ae033be763da80fd5b2
Genyu-Song/LeetCode
/Algorithm/BinarySearch/Sqrt(x).py
1,003
4.15625
4
# -*- coding: UTF-8 -*- ''' Implement int sqrt(int x). Compute and return the square root of x, where x is guaranteed to be a non-negative integer. Since the return type is an integer, the decimal digits are truncated and only the integer part of the result is returned. ''' class Solution(object): def mySqrt(se...
true
d188291d13c688c3fd3404e49c785336f160a075
Genyu-Song/LeetCode
/Algorithm/Sorting/SortColors.py
1,598
4.15625
4
# -*- coding: UTF-8 -*- ''' 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...
true
f13838e403245f0e5e00dd3db6d7cdd4a3425631
driscollis/Python-101-Russian
/code/Chapter 2 - Strings/string_slicing.py
248
4.25
4
# string slicing my_string = "I like Python!" my_string[0:1] my_string[:1] my_string[0:12] my_string[0:13] my_string[0:14] my_string[0:-5] my_string[:] my_string[2:] # string indexing print(my_string[0]) # prints the first character of the string
true
b7bdff3a5a9043d42ec3dd26c63c67c239f1b3cf
traj1593/LINEAR-PREDICTION-PROGRAM
/linearPrediction-tRaj-00.py
1,173
4.25
4
''' Program: LINEAR PREDICTION Filename: linearPrediction-tRaj-00.py Author: Tushar Raj Description: The program accepts two integers from a user at the console and uses them to predict the next number in the linear sequence. Revisions: No revisions made ''' ### Step 1: Announce, prompt and get response #Anno...
true
42fd723316a51442c22fb676a3ec9f12ae82056b
HeimerR/holbertonschool-higher_level_programming
/0x0B-python-input_output/7-save_to_json_file.py
302
4.125
4
#!/usr/bin/python3 """module writes an Object to a text file """ import json def save_to_json_file(my_obj, filename): """ writes an Object to a text file, using a JSON representation""" with open(filename, encoding="utf-8", mode="w") as json_file: json_file.write(json.dumps(my_obj))
true
e5666f5f6d68cc0fbc6d57012f6b9c3e740a09a8
bmihovski/PythonFundamentials
/count_odd_numbers_list.py
429
4.15625
4
""" Write a program to read a list of integers and find how many odd items it holds. Hints: You can check if a number is odd if you divide it by 2 and check whether you get a remainder of 1. Odd numbers, which are negative, have a remainder of -1. """ nums_odd = list() nums_stdin = list(map(int, input().split('...
true
d03229593c9e605f31320e0200b0b258e191acee
bmihovski/PythonFundamentials
/sign_of_int_number.py
581
4.25
4
""" Create a function that prints the sign of an integer number n. """ number_stdin = int(input()) def check_int_type(int_to_check): """ Check the type of input integer and notify the user :param int_to_check: Int :return: message_to_user: Str """ if int_to_check > 0: msg_to_user = f'T...
true
f6a011b92ee7858403ea5676b01610ff962e1c0d
bmihovski/PythonFundamentials
/wardrobe.py
2,079
4.21875
4
""" On the first line of the input, you will receive n - the number of lines of clothes, which came prepackaged for the wardrobe. On the next n lines, you will receive the clothes for each color in the format: " "{color} -> {item1},{item2},{item3}…" If a color is added a second time, add all items from it and count th...
true
b80cb0d8e3d127c6f859b761403cce0f9a9fcc0e
g423221138/chebei
/bs4_study.py
1,766
4.21875
4
#bs4官方文档学习 #例子文档 html_doc = """ <html><head><title>The Dormouse's story</title></head> <body> <p class="title"><b>The Dormouse's story</b></p> <p class="story">Once upon a time there were three little sisters; and their names were <a href="http://example.com/elsie" class="sister" id="link1">Elsie</a>, <a href="http:/...
true
c1279076e019dd32f1e2fd30c52d1831b9ffe504
NicsonMartinez/The-Tech-Academy-Basic-Python-Projects
/For and while loop statements test code.py
2,469
4.46875
4
mySentence = 'loves the color' color_list = ['red','blue','green','pink','teal','black'] def color_function(name): lst = [] for i in color_list: msg = "{0} {1} {2}".format(name,mySentence,i) lst.append(msg) return lst def get_name(): go = True while go: name = input('What...
true
a59a8a3825c2b2d1c790e24f3fd2e7738b7b999d
veterinarian-5300/Genious-Python-Code-Generator
/Py_lab/Lab 1,2/plotting_a_line.py
345
4.375
4
# importing the module import matplotlib.pyplot as plt # x axis values x = [1,2,3,4,5] # corresponding y axis values y = [2,4,1,3,5] # plotting the points plt.plot(x, y) # naming the x axis plt.xlabel('x - axis') # naming the y axis plt.ylabel('y - axis') # Title to plot plt.title('Plot') # function to ...
true
41da6593087fa6ce2e17fff89aa8179832563cfb
prmkbr/misc
/python/fizz_buzz.py
536
4.125
4
#!/usr/local/bin/python """ 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 three and five print 'FizzBuzz'. """ def main(): """ Main body of the script. """ for i in xra...
true
5782fa59d65af071e8fb004f42c8321f17fb6fd3
mljarman/Sorting
/src/iterative_sorting/iterative_sorting.py
1,383
4.25
4
# TO-DO: Complete the selection_sort() function below arr = [5, 2, 1, 6, 8, 10] def selection_sort(arr): # loop through n-1 elements for i in range(len(arr)-1): cur_index = i smallest_index = cur_index # TO-DO: find next smallest element # (hint, can do in 3 loc) # iterat...
true
de2c80883264b731c748c09d2a20c8c27995d03e
bjucps/cps110scope
/Lesson 2-3 String Processing/greeter.py
481
4.21875
4
# Demonstrates string processing full_name = input('Enter your first and last name:') if full_name == '': print('You did not enter a name!') else: space_pos = full_name.find(' ') if space_pos == -1: print('You did not enter your first and last name!') else: first_name = full_name[0:spa...
true
3d9018bea5f64544cb6abc8c06a27385262d73c3
bjucps/cps110scope
/Lesson 2-4 Unit Testing/addnums.py
409
4.1875
4
def addNums(num: str) -> int: """Adds up all digits in `num` Preconditions: `num` contains only digits Postconditions: returns sum of digits in `num` """ sum = 0 for digit in num: sum += int(digit) return sum def test_addNums(): assert addNums('123') == 6 if __name__ == "__ma...
true
09dcca918dee39291a7de4a3e15cbe89e3e7dfd6
vinayakentc/BridgeLabz
/AlgorithmProg/VendingMachine.py
1,042
4.3125
4
# 10. Find the Fewest Notes to be returned for Vending Machine # a. Desc ­> There is 1, 2, 5, 10, 50, 100, 500 and 1000 Rs Notes which can be # returned by Vending Machine. Write a Program to calculate the minimum number # of Notes as well as the Notes to be returned by the Vending Machine as a # Change # b. I/P ­> rea...
true
032e58342dd4dd263ae96aabb6563dad78d68b15
vinayakentc/BridgeLabz
/DataStructProg/Palindrome_Checker.py
1,363
4.46875
4
# Palindrome­Checker # a. Desc ­> A palindrome is a string that reads the same forward and backward, for # example, radar, toot, and madam. We would like to construct an algorithm to # input a string of characters and check whether it is a palindrome. # b. I/P ­> Take a String as an Input # c. Logic ­> The solution to ...
true
25fab75d27473ef6b0949ddcbb0a2678eefbf108
vinayakentc/BridgeLabz
/FunctionalProg/Factors.py
1,012
4.21875
4
# 6. Factors # a. Desc ­> Computes the prime factorization of N using brute force. # b. I/P ­> Number to find the prime factors # c. Logic ­> Traverse till i*i <= N instead of i <= N for efficiency . # d. O/P ­> Print the prime factors of number N # ----------------------------------------------------------------------...
true
8475bd109f4efb302b35f5d16ef5aaf358d43ad6
vinayakentc/BridgeLabz
/DataStructProg/UnOrderedList.py
1,985
4.28125
4
# UnOrdered List # a. Desc ­> Read the Text from a file, split it into words and arrange it as Linked List. # Take a user input to search a Word in the List. If the Word is not found then add it # to the list, and if it found then remove the word from the List. In the end save the # list into a file # b. I/P ­> Read fr...
true
7d46a845ad0bed2298511f782e37faee1f7701ac
afurkanyegin/Python
/The Art of Doing Code 40 Challenging Python Programs Today/2-MPH to MPS Conversion App.py
262
4.15625
4
print("Welcome to the MPH to MPS Conversion App") speed_in_miles=float(input("What is your speed in miles:")) speed_in_meters=speed_in_miles * 0.4474 rounded_speed_in_meters=round(speed_in_meters,2) print(f"Your speed in MPS is: {rounded_speed_in_meters}")
true
23a71da2a35150b6dd70cc4f5507cce6c37b87a6
TonyVH/Python-Programming
/Chapter 02/Calculator.py
541
4.25
4
# Calculator.py # This is a simple, interactive calulator program def calculator(): print('Calculator guide:') print('Use + to add') print('Use - to subtract') print('Use * to multiply') print('Use / to divide') print('Use ** for exponentials') print('Use // for floor division') print('U...
true
0c7a6dc53b0e75076918ef422b5cf3da28b052a1
TonyVH/Python-Programming
/Chapter 05/acronym.py
330
4.34375
4
# acronym.py # Program to create an acronym from a user given sentence/phrase def main(): print('This program will create an acronym from a word or phrase\n') phrase = input('Enter a sentence or phrase: ') phrase = phrase.split() for words in phrase: print(words[0].upper(), end='') print(...
true
a0ee9db42b6a9cc7f4a423e2281a718a1789981f
DeepeshYadav/AutomationMarch2020
/PythonPractice/Lambda_function/practice/Decorator Introdcution.py
740
4.3125
4
""" Decorators 1. Need to take a function as parameters 2. Add Functionality to the function. 3. Function need to return another function. -> In general language a decorator means , the person who does decoration job. to make things more presentable. for examples i want to given gift to my friend like watch 1 -> I ...
true
cde40dccf5ea9938c8572de56bb6de3a9f8d131e
DeepeshYadav/AutomationMarch2020
/PythonPractice/Decorators/property_decor_example1.py
544
4.28125
4
# In this class will how to set values using setter # and next example2 will explain how achieve this using @propert decorator class Student: def __init__(self, name, grade): self.name = name self.grade = grade def msg(self): return self.name +" got the grade "+self.grade def set...
true
0248a047a97752eb6028adf81022ad57b765e5e2
ahmed-t-7/Programming-Foundations-Fundamentals
/3. Variables and Data Types/Challenge_What_is_The_output.py
496
4.40625
4
print("Challenge 1:") # A message for the user message = "This is going to be tricky ;)" Message = "Very tricky!" print(message) # show the message on the screen this statement will print the first message variable # Perform mathematical operations result = 2**3 print("2**3 =", result) result = 5 - 3 #Change the v...
true
8bcdc627379f686bbc937d6c6c756cadd1d9cc75
JeffreyAsuncion/Study-Guides
/Unit_3_Sprint_2/study_part1.py
2,472
4.28125
4
import os import sqlite3 """ ## Starting From Scratch Create a file named `study_part1.py` and complete the exercise below. The only library you should need to import is `sqlite3`. Don't forget to be PEP8 compliant! 1. Create a new database file call `study_part1.sqlite3` """ DB_FILEPATH = os.path.join(os.path.dirna...
true
223b6e68740e9411f390b37869df3125c8fe49c0
usamarabbani/Algorithms
/squareRoot.py
996
4.15625
4
'''take user input number = int(input("Enter a number to find the square root : ")) #end case where user enter less than 0 number if number < 0 : print("Please enter a valid number.") else : sq_root = number ** 0.5 print("Square root of {} is {} ".format(number,sq_root))''' def floorSqrt(x): # Base cases ...
true
f3e397a744558c935850f18001b4a5bf14e56ec6
usamarabbani/Algorithms
/mergeTwoSortedList.py
2,189
4.46875
4
# Defining class which will create nodes for our linked lists class Node: def __init__(self, data): self.data = data self.next = None # Defining class which will create our linked list and also defining some methods class LinkedList: def __init__(self): self.head = None def printLi...
true
970f23ef1afa5d5c2ae538b25c9c9fbc191745f9
BigThighDude/SNS
/Week3/Ch5_Ex2.py
1,133
4.34375
4
num = int(input("Enter integer to perform factorial operation:\n")) #prompt user to enter number, converts string to interger. program doesnt work if float is entered def fact_iter(num): #define iterative function product = 1 # define product before it is used for i in range(1,num+1): #count up from 1 (w...
true
dce29aacbef5e86574b300659dd52c9edb4868f5
waltermblair/CSCI-220
/random_walk.py
723
4.28125
4
from random import randrange def printIntro(): print("This program calculates your random walk of n steps.") def getInput(): n=eval(input("How many steps will you take? ")) return n def simulate(n): x=0 y=0 for i in range(n): direction=randrange(1,5) if direction==1: ...
true
ddb747b2b03438b099c0cf14b7320473be16888b
waltermblair/CSCI-220
/word_count_batch.py
404
4.28125
4
print("This program counts the number of words in your file") myfileName=input("Type your stupid ass file name below\n") myfile=open(myfileName,"r") mystring=myfile.read() mylist=mystring.split() word_count=len(mylist) char_count=len(mystring) line_count=mystring.count("\n") print("Words: {0}".format(word_count))...
true
28f61625f6cc35e07557140465f6b2dcc3974d77
delgadoL7489/cti110
/P4LAB1_LeoDelgado.py
549
4.21875
4
#I have to draw a square and a triangle #09/24/13 #CTI-110 P4T1a-Shapes #Leonardo Delgado # #import the turtle import turtle #Specify the shape square = turtle.Turtle() #Draws the shape for draw in range(4): square.forward(100) square.right(90) #Specify the shape triangle = turtle.Turtle()...
true
714c9c402b65cf3102425a3467c1561eaa20f2dd
delgadoL7489/cti110
/P3HW2_Shipping_LeoDelgado.py
532
4.15625
4
#CTI-110 #P3HW2-Shipping Charges #Leonardo Delgado #09/18/18 # #Asks user to input weight of package weight = int(input('Enter the weight of the package: ')) if weight <= 2: print('It is $1.50 per pound') if 2 < weight <=6: print('It is $3.00 per pound') if 6 < weight <=10: print('It is $4.0...
true
05be92d0a985f8b51e2478d52d0d476539b1f96c
delgadoL7489/cti110
/P5T1_KilometersConverter_LeoDelgado.py
659
4.59375
5
#Prompts user to enter distance in kilmoters and outputs it in miles #09/30/18 #CTI-110 P5T1_KilometerConverter #Leonardo Delgado # #Get the number to multiply by Conversion_Factor = 0.6214 #Start the main funtion def main(): #Get the distance in kilometers kilometers = float(input('Enter a distan...
true
b97e8694dd80c4207d2aef3db11326bef494c1d5
aju22/Assignments-2021
/Week1/run.py
602
4.15625
4
## This is the most simplest assignment where in you are asked to solve ## the folowing problems, you may use the internet ''' Problem - 0 Print the odd values in the given array ''' arr = [5,99,36,54,88] ## Code Here print(list(i for i in arr if not i % 2 ==0)) ''' Problem - 1 Print all the prime numbers from 0-100 ...
true
c487f10008953853ffce904974c01f60be0e9874
justus-migosi/desktop
/database/queries.py
1,179
4.40625
4
import sqlite3 from sqlite3 import Error # Create a connection def create_connection(file_path): """ Creates a database connection to the SQLite database specified by the 'path'. Parameters: - path - Provide path to a database file. A new database is created where non exists. Return: - Retu...
true
0acadc79127f5cc53cb616bac3e31c2ef120822f
shahzadhaider7/python-basics
/17 ranges.py
926
4.71875
5
# Ranges - range() range1 = range(10) # a range from 0 to 10, but not including 10 type(range1) # type = range range1 # this will only print starting and last element of range print(range1) # this will also print same, starting and last element list(range1) # this will list the whole range from...
true
69f33f4919562b4dd54d868fbc63c81ecf4567ca
youssefibrahim/Programming-Questions
/Is Anagram.py
725
4.15625
4
#Write a method to decide if two strings are anagrams or not from collections import defaultdict def is_anagram(word_one, word_two): size_one = len(word_one) size_two = len(word_two) # First check if both strings hold same size if size_one != size_two: return False dict_chars = defaultdict(int) # Use di...
true
65778e41f5d2fae0c62993edd0c98ca8c603783d
EXCurryBar/108-2_Python-class
/GuessNumber.py
374
4.125
4
import random number = random.randint(0,100) print(number) print("Guess a magic number between 0 to 100") guess = -1 while guess != number : guess = eval(input("Enter your guess: ")) if guess == number : print("Yes, the number is ",number) elif guess > number : print("Your guess is too high...
true
112da84fe029bfec6674f8fdf8cea87da361a96f
tminhduc2811/DSnA
/DataStructures/doubly-linked-list.py
2,053
4.3125
4
""" * Singly linked list is more suitable when we have limited memory and searching for elements is not our priority * When the limitation of memory is not our issue, and insertion, deletion task doesn't happend frequently """ class Node(): def __init__(self, data): self.data = data self.nex...
true
4e60800182b8bb8fccbb924b21ebc40cdfb497b5
jessiicacmoore/python-reinforcement-exercises
/python_fundamentals1/exercise5.py
319
4.125
4
distance_traveled = 0 while distance_traveled >= 0: print("Do you want to walk or run?") travel_mode = input() if travel_mode.lower() == "walk": distance_traveled += 1 elif travel_mode.lower() == "run": distance_traveled += 5 print("Distance from home is {}km.".format(distance_traveled))
true
bcc2045e953975bbdf2d78dc2888346072a0af24
chantigit/pythonbatch1_june2021data
/Python_9to10_June21Apps/project1/listapps/ex5.py
407
4.3125
4
#II.Reading list elements from console list1=list() size=int(input('Enter size of list:')) for i in range(size): list1.append(int(input('Enter an element:'))) print('List elements are:',list1) print('Iterating elements using for loop (index based accessing)') for i in range(size): print(list1[i]) print('Iterat...
true
7ccc459d2ab9e420b47bfefd00e04dddff87fa8a
NSO2008/Python-Projects
/Printing to the terminal/HelloWorld.py
584
4.21875
4
#This is a comment, it will not print... #This says Hello World... print('Hello World') #This is another example... print("This uses double quotes") #Quotes are characters while quotation is the use quotes... print("""This uses triple quotation... it will be displayed however I type it""") #This is an exampe of...
true
0b8f08d1f44d32eac328848be344c8d5e7cca3ad
cbolles/auto_typing
/auto_type/main.py
2,162
4.125
4
""" A tool that simulates keypresses based on a given input file. The program works by accepting a source file containing the text and an optional delimeter for how to split up the text. The program then creates an array of string based on the delimeter. Once the user presses the ESCAPE key, each value in the array wil...
true
3aa1d42dbbe55beadaeafe334950694fa9ece8f2
mickeyla/gwc
/Test A/test.py
596
4.125
4
#Comments are not for the code #Comments are for you #Or whoever answer1 = input ("What is your name?") print ("My name is", answer1) answer2 = input ("How old are you?") print ("I am", answer2, "years old!") answer3 = input ("Where are you from?") print ("I am from", answer3) answer4 = input ("Do you like coding?"...
true
cc8bf4379d575d1d414c7fd61e236c3d4d904b12
hauqxngo/PythonSyntax
/words.py
1,385
4.75
5
# 1. For a list of words, print out each word on a separate line, but in all uppercase. How can you change a word to uppercase? Ask Python for help on what you can do with strings! # 2. Turn that into a function, print_upper_words. Test it out. (Don’t forget to add a docstring to your function!) def print_upper_w...
true
1f52ebb74b762dcce6213360939086acb0b59f46
getconnected2010/testing123
/adventure story.py
1,194
4.1875
4
name = input('What is your name?:') print(f'Hello {name.capitalize()}, you are about to go on an adventure. You enter a room and see two doors. One is red and the other blue.') door_input = input('which door do you choose?: ') if door_input == 'red': print('Red door leads you to the future. You have to help a s...
true
cd7793038854eab3c67e631d3c158f2f00e9ad70
gauravraul/Competitive-Coding
/lcm.py
485
4.15625
4
# Program to get the lcm of two numbers def lcm(x,y) : #take the greater number if x>y: greater = x else: greater = y #if greater is divisible by any of the inputs , greater is the lcm #else increment greater by one until it is divisible by both the inputs while(True)...
true
ecf0d4117ad8aab226e9808899b922d720cb0294
2018JTM2248/assignment-8
/ps2.py
1,919
4.65625
5
#!/usr/bin/python3 ###### this is the second .py file ########### ####### write your code here ########## #function definition to rotate a string d elemets to right def rotate_right(array,d): r1=array[0:len(array)-d] # taking first n-d letters r2=array[len(array)-d:] # last d letters rotate = r2+r1 # r...
true
b71a8ef228748fe80c9696c057b4f6c459c13f49
vikashvishnu1508/algo
/Revision/Sorting/ThreeNumSort.py
521
4.15625
4
def threeNumSort(array, order): first = 0 second = 0 third = len(array) - 1 while second <= third: if array[second] == order[0]: array[first], array[second] = array[second], array[first] first += 1 second += 1 elif array[second] == order[2]: ...
true
fff30ad774cb793bd20a0832cf45a1855e75a263
kacifer/leetcode-python
/problems/problem232.py
2,563
4.34375
4
# https://leetcode.com/problems/implement-queue-using-stacks/ # # Implement the following operations of a queue using stacks. # # push(x) -- Push element x to the back of queue. # pop() -- Removes the element from in front of queue. # peek() -- Get the front element. # empty() -- Return whether the queue is empty. # Ex...
true
44bd4d30acfddb690556faaf26174f6a6faee6fe
Carvanlo/Python-Crash-Course
/Chapter 8/album.py
412
4.15625
4
def make_album(artist_name, album_title, track=''): """Return a dictionary of information of an album.""" album = {'artist': artist_name, 'title': album_title} if track: album['track'] = track return album album_1 = make_album('Adam Levine', 'Begin Again', 3) print(album_1) album_2 = make_album('Emma Stevens...
true
94d9bca02dd044b5574522ef5f3185f8223a74e0
kumk/python_code
/donuts.py
593
4.15625
4
#Strings Exercise 1: Donuts # # Given an int count of a number of donuts, return a string of the form 'Number # #of donuts: <count>', where <count> is the number passed in. However, if the # #count is 10 or more, then use the word 'many' instead of the actual count. # So #donuts(5) returns 'Number of donuts: 5' and don...
true
7b418a8b46b44fe6913f808024e6c2ba683885d2
loknath0502/python-programs
/28_local_global_variable.py
374
4.25
4
a=8 # global variable def n(): a=10 print("The local variable value is:",a) # local variable n() print("The global variable value is:",a) '''Note: The value of the global variable can be used by local function variable containing print . But the value of the local variable cannot be used by the gl...
true
db8502678f3b850ad743cc8464436efcc6e01b20
ryanfirst/NextGen
/problem_types_set2.py
799
4.15625
4
# first_num = input('enter first number') # second_num = input('enter second number') # third_num = input('enter third number') # print(int(first_num) * int(second_num)) # print(int(first_num) * int(second_num) / int(third_num)) # num = input('pick a number') # print(int(num) % 2 == 0) # money = input('how much money w...
true
09c8da67245a500ea982344061b5d25dbc1d0a58
olive/college-fund
/module-001/Ex1-automated.py
1,456
4.25
4
# 1*.1.1) Rewrite the following function so that instead of printing strings, # the strings are returned. Each print statement should correspond to # a newline character '\n' in the functiono's output. def bar_print(a, b, c): if a == b: print("1") elif b == c: print("2") ...
true
e1146f7a613892b9d79b70a5fdf218eafd812681
AjayKumar2916/python-challenges
/047-task.py
280
4.15625
4
''' Write a program which can filter() to make a list whose elements are even number between 1 and 20 (both included). Hints: Use filter() to filter elements of a list. Use lambda to define anonymous functions. ''' e = range(1, 21) a = filter(lambda x:x%2==0, e) print(list(a))
true
ed08b421996fab5b1db393c23496aff72939db24
svukosav/crm
/database.py
1,603
4.375
4
import sqlite3 db = sqlite3.connect("database") cursor = db.cursor() # cursor.execute("""DROP TABLE users""") if db: # Create a table cursor.execute("""CREATE TABLE users(id INTEGER PRIMARY KEY, name TEXT, phone TEXT, email TEXT unique, password TEXT)""") db.commit() name1 = 'Andres' phone1 = '3366858' email1 = '...
true
4dd828096a5eb69c493930c8381a4b0bb6e7f9ca
si20094536/Pyton-scripting-course-L1
/q4.py
673
4.375
4
## 4. Given a list of non-empty tuples, return a list sorted in increasing order by the last element in each tuple. ##e.g. [(1, 7), (1, 3), (3, 4, 5), (2, 2)] yields [(2, 2), (1, 3), (3, 4, 5), (1, 7)] ## Hint: use a custom key= function to extract the last element form each tuple. ##i. [(1, 3), (3, 2), (2, 1...
true
9acba907b818c3e591571dbadaf3bdb751b91d99
kishan-pj/python_lab_exercise_1
/pythonproject_lab2/temperature.py
323
4.5
4
# if temperature is greater than 30, it's a hot day other wise if it's less than 10; # it's a cold day;otherwise,it's neither hot nor cold. temperature=int(input("enter the number: ")) if temperature>30: print("it's hot day") elif temperature<10: print("it's cold day") else: print("it's neither hot nor col...
true