blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
89a4b8735d13a7a2536d3fa18c80cda5c8b46b68
cartoonshow57/SmallPythonPrograms
/array_replacement.py
661
4.21875
4
"""Given an array of n terms and an integer m, this program modifies the given array as arr[i] = (arr[i-1]+1) % m and return that array""" def array_modification(arr1, m1): test_arr = [] index = 0 for _ in arr1: s = (arr1[index - 1] + 1) % m1 test_arr.append(s) index += 1 retur...
true
40247c58ddd68593214c719ac84db9252174b69c
cartoonshow57/SmallPythonPrograms
/first_and_last.py
431
4.1875
4
"""This program takes an array and deletes the first and last element of the array""" def remove_element(arr1): del arr1[0] del arr1[-1] return arr1 arr = [] n = int(input("Enter number of elements in the list: ")) for i in range(n): arr.append(int(input("Enter array element: "))) print("The give...
true
8c841eabc2a03af875f2b7286a86c2e5ac14eae4
motirase/holbertonschool-higher_level_programming-1
/0x07-python-test_driven_development/0-add_integer.py~
472
4.21875
4
#!/usr/bin/python3 """ function 0-add_integer adds two integers """ def add_integer(a, b=98): """adds two numbers >>> add_integer(4, 3) 7 >>> add_integer(5, 5) 10 """ fnum = 0 if type(a) is int or type(a) is float: fnum += int(a) else: raise TypeError("a must be a...
true
fb7d4013fd9394072a043c958e1e35b1ff8f3b63
Dyke-F/Udacity_DSA_Project1
/Task4.py
1,441
4.125
4
""" Read file into texts and calls. It's ok if you don't understand how to read files. """ import csv with open('texts.csv', 'r') as f: reader = csv.reader(f) texts = list(reader) with open('calls.csv', 'r') as f: reader = csv.reader(f) calls = list(reader) """ TASK 4: The telephone company want to i...
true
d6396e1980649d9fcfbe3e5a50f3fb6f37016731
aditya-sengupta/misc
/ProjectEuler/Q19.py
1,067
4.21875
4
"""You are given the following information, but you may prefer to do some research for yourself. 1 Jan 1900 was a Monday. Thirty days has September, April, June and November. All the rest have thirty-one, Saving February alone, Which has twenty-eight, rain or shine. And on leap years, twenty-nine. A leap year occurs o...
true
5d393e90f23624f1a27ca7af73fa9606e08beaf4
B3rtje/dataV2-labs
/module-1/Code-Simplicity-Efficiency/your-code/challenge-2_test.py
1,678
4.25
4
import string import random def new_string(length): letters = string.ascii_lowercase+string.digits str = ''.join(random.choice(letters) for num in range(length)) return str #print(get_random_string(10)) def string_gen (): strings = [] number_of_strings = input("How many strings do you want...
true
486440929bfc62b5fc48823002c695afeacd67bb
sailesh190/pyclass
/mycode/add_book.py
252
4.375
4
address_book = [] for item in range(3): name = input("Enter your name:") email = input("Enter your email:") phone = input("Enter your phone number:") address_book.append(dict(name=name, email=email, phone=phone)) print(address_book)
true
405fbc0f2d07a41d15ff248af2e429e45de498e7
AhmUgEk/tictactoe
/tictactoe_functions.py
1,974
4.125
4
""" TicTacToe game supporting functions. """ # Imports: import random def display_board(board): print(f' {board[1]} | {board[2]} | {board[3]} \n-----------\n {board[4]} | {board[5]} | {board[6]}\ \n-----------\n {board[7]} | {board[8]} | {board[9]} \n') def player_input(): marker = 0 ...
true
8c988bf453d8f1c5bb69272e69e254df77c1b874
shreeji0312/learning-python
/python-Bootcamp/assignment1/assignment1notes/basicEx2.py
2,924
4.5625
5
# WPCC # basicEx2.py # Let's take a look at some different types of data that Python # knows about: print(10) print(3.14) print("Python is awesome!") print(True) # There are 4 fundamental types of data in Python: # integers, floating point numbers, strings, and booleans # You can create more types of data, but we'll...
true
46004672cd99417c2bc0027e364ecb4441f1c8f9
shreeji0312/learning-python
/python-Bootcamp/assignment1/assignment1notes/basicEx6.py
1,907
4.84375
5
# WPCC # basicEx6.py # So far we've made our own variables that store # data that we have defined. Let's look at how we can # ask the user to enter in data that we can manipulate # in our program # We will use the `input` function to ask the user to enter # some data user_input = input("Please enter a number: ") # ...
true
6c4c8561cb46045307cf14a1481f97b3e63c1af8
shreeji0312/learning-python
/python-Bootcamp/assignment5/assignment5notes/2dlistEx1.py
2,000
4.71875
5
# WPCC # 2dlistEx1.py # We're going to look at what a 2D list is. # A 2D list is a list that contains other lists. # For example: marks = [ [90, 85, 88], [68, 73, 79] ] # The list `marks` contains 2 other lists, each containing # integers. We would say that this list is of size 2x3: # two lists, each containing 3 ele...
true
291d09272a542e9b24fab373d154466f9d1b0c30
shreeji0312/learning-python
/python-Bootcamp/assignment4/assignment4notes/functionEx2.py
1,611
4.84375
5
# WPCC # functionEx2.py # When we call some Python standard functions, it gives us back # a value that we can assign to a variable and use later in our programs. # For example: import random randomNumber = random.randint(0, 10) # This function will return the value it generates so we can assign its # value to `rand...
true
20656a0b0704de6339feab22f2a2a4d539cda92f
fantasylsc/LeetCode
/Algorithm/Python/75/0056_Merge_Intervals.py
977
4.15625
4
''' Given a collection of intervals, merge all overlapping intervals. Example 1: Input: [[1,3],[2,6],[8,10],[15,18]] Output: [[1,6],[8,10],[15,18]] Explanation: Since intervals [1,3] and [2,6] overlaps, merge them into [1,6]. Example 2: Input: [[1,4],[4,5]] Output: [[1,5]] Explanation: Intervals [1,4] ...
true
a312e0acb76d0747602ccf4c39d799a3c814c30c
fantasylsc/LeetCode
/Algorithm/Python/1025/1007_Minimum_Domino_Rotations_For_Equal_Row.py
2,473
4.1875
4
''' In a row of dominoes, A[i] and B[i] represent the top and bottom halves of the i-th domino. (A domino is a tile with two numbers from 1 to 6 - one on each half of the tile.) We may rotate the i-th domino, so that A[i] and B[i] swap values. Return the minimum number of rotations so that all the values in A...
true
a18260a2c70db8afa8c17a910f0ea09a4d1802b1
fantasylsc/LeetCode
/Algorithm/Python/100/0079_Word_Search.py
2,907
4.15625
4
''' Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or vertically neighboring. The same letter cell may not be used more than once. Example: board = [ ['A','B','C','E']...
true
955c1c68bdd8c6c869585f98009b603eb3938d28
amirhosseinghdv/python-class
/Ex4_Amirhossein Ghadiri.py
1,617
4.1875
4
"""#Ex12 num1=int(input("addad avval?")) num2=int(input("addad dovvom?")) if num1 >= num2: print(num2) print(num1) else: print(num1) print(num2) """ """#13: num=int(input("please enter a number lower than 20: ")) if num >= 20: print("Too high") else: print("Thank you") """ ...
true
07d431c2473e33a00b597bc6412af322f116abab
AnumaThakuri/pythonassignment
/assignment4/question 1.py
310
4.28125
4
#average marks of five inputted marks: marks1=int(input("enter the marks 1:")) marks2=int(input("enter the marks 2:")) marks3=int(input("enter the marks 3:")) marks4=int(input("enter the marks 4:")) marks5=int(input("enter the marks 5:")) sum=marks1+marks2+marks3+marks4+marks5 avg=sum/5 print("average=",avg)
true
e343ff42820c7d794248635ec646eb8d4b184181
lxiong515/Module13
/GuessGame/topic1.py
2,385
4.15625
4
""" Program: number_guess.py Author: Luke Xiong Date: 07/18/2020 This program will have a set of buttons for users to select a number guess """ import tkinter as tk from random import randrange from tkinter import messagebox window = tk.Tk() window.title("Guessing Game") label_intro = tk.Label(window, text = "Guess...
true
a970f1be719d68082548cf222aeff5beaea5da64
cyan33/leetcode
/677-map-sum-pairs/map-sum-pairs.py
1,235
4.15625
4
# -*- coding:utf-8 -*- # # Implement a MapSum class with insert, and sum methods. # # # # For the method insert, you'll be given a pair of (string, integer). The string represents the key and the integer represents the value. If the key already existed, then the original key-value pair will be overridden to the new ...
true
f7eb0bfd643b4d386350d8a220d768d734e2041b
vaibhavranjith/Heraizen_Training
/Assignment1/Q8.py
354
4.25
4
#registration problem (register only people above the age 18) name=input("Enter the name: \n") mbno=int(input("Enter the mobile number:\n")) age=int(input("Enter the age:\n")) if age<=18: print("Sorry! You need to be at least 18 years old to get membership.") else : print(f"Congratulations {name} for...
true
bb3b04baf74550ea0cc12ff62e717d90fc2ceca7
hack-e-d/Rainfall_precipitation
/Script/prediction_analysis.py
1,567
4.5
4
# importing libraries import pandas as pd import numpy as np import sklearn as sk from sklearn.linear_model import LinearRegression import matplotlib.pyplot as plt # read the cleaned data data = pd.read_csv("austin_final.csv") # the features or the 'x' values of the data # these columns are used t...
true
e3187b055b6db5a497b94602820ac86b8671e637
rajagoah/Tableua_rep
/EmployeeAttritionDataExploration.py
2,105
4.125
4
import pandas as pd df = pd.read_csv("/Users/aakarsh.rajagopalan/Personal documents/Datasets for tableau/Tableau project dataset/WA_Fn-UseC_-HR-Employee-Attrition.csv") #printing the names of the columns print("names of the columns are:") print(df[:0]) #checking if there are nulls in the data #note that in pandas do...
true
2c25567847813a6b87ab0952612e89fad3123b66
EGleason217/python_stack
/_python/python_fundamentals/course_work.py
1,988
4.25
4
print("Hello World!") x = "Hello Python" print(x) y = 42 print(y) print("this is a sample string") name = "Zen" print("My name is", name) name = "Zen" print("My name is " + name) first_name = "Zen" last_name = "Coder" age = 27 print(f"My name is {first_name} {last_name} and I am {age} years old.") first_name = "Zen" la...
true
cdf54f108bf8e4d7b26613b3d6ac3dcac3083157
ColorfulCodes/ATM
/ATM .py
1,073
4.15625
4
# We will be creating a bank account class BankAccount(object): balance = 0 def __init__(self, name): self.name = name def __repr__(self): return "This account belongs to %s and has a balance of %.2f dollars." % (self.name, self.balance) def show_balance(self): print "Y...
true
dde5c4982b3a03e1c44d086a5a86924d91e83b1b
kylejablonski/Python-Learning
/conditionals.py
786
4.46875
4
print("Hello, World! This is a conditionals program test.") # prompts for a value and checks if its more or less than 100 maxValue = int(input("Please enter a value: ")) if maxValue > 100: print("The max value of {0} is greater than 100!".format(maxValue)) elif maxValue < 100: print("The max value of {0} is l...
true
33de7e691ca65a230c76d269d1ae6f5a9e6647eb
Lonabean98/pands-problem-sheet
/es.py
812
4.40625
4
#This program reads in a text #file and outputs the number of e's it contains. #It can also take the filename from an argument on the command line. #Author: Lonan Keane #The sys module provides functions and variables used to # manipulate different parts of the Python runtime environment. import sys # sys.argv retur...
true
028ef354ab87048c660f7c74c1d117f43b23b757
elimbaum/euler
/002/002.py
411
4.21875
4
#! /usr/bin/env python3.3 """ Project Euler problem 002 Even Fibonacci Numbers by Eli Baum 14 April 2013 """ print("Project Euler problem 002") print("Even Fibonacci Numbers") n = int(input("Upper Limit: ")) # Brute-Force calculate all of the fibonacci numbers a, b = 0, 1 sum = 0 while True: a, b = a + b, a i...
true
1f341dec6a19daad68ae3cd636a1d395d1c539dd
elimbaum/euler
/003/003.py
687
4.25
4
#! /usr/bin/env python3.3 """ Project Euler problem 003 Largest Prime Factor by Eli Baum 14 April 2013 """ from math import * print("Project Euler problem 003") print("Largest Prime Factor") n = float(input("n = ")) """ We only need to find ONE prime factor. Then we can divide, and factor that smaller number. ...
true
e05d23b8f68f0fcf422ce4a91f5aed4fdfa7630c
samiatunivr/NLPMLprojects
/linearRegression.py
1,821
4.53125
5
__author__ = 'samipc' from numpy import loadtxt def linearRegression(x_samples, y_labels): length = len(x_samples) sum_x = sum(x_samples) sum_y = sum(y_labels) sum_x_squared = sum(map(lambda a: a * a, x_samples)) sum_of_products = sum([x_samples[i] * y_labels[i] for i in range(length)]) a...
true
91f974b6597229fe3904f31e9ebc98b52e966a5d
timfornell/PythonTricksDigitalToolkit
/Lesson4.py
514
4.25
4
""" Lesson 4: Implicit returns """ # Python will automatically return None, all following functions will return the same value def foo1(value): if value: return value else: return None def foo2(value): """ Bare return statement implies 'return None'""" if value: return value ...
true
5d54fac367fd107da96dbebc34f99ffa55188742
geeta-kriselva/python_excercise
/Prime_number.py
599
4.125
4
# Checking, if user input number is prime a number. if not printing all the facors. n= input("Enter the number: ") try: num = int(n) except: print("Enter only integer number") quit() if num > 1: factor = [] a = 0 for i in range(2,num+1): if (num % i) == 0: factor.insert(a,i) ...
true
bee70d6fa16e25998f08830db5669e8b260e93d7
DriesDD/python-workshop
/Examples/guess.py
1,237
4.21875
4
""" This uses the random module: https://www.w3schools.com/python/module_random.asp Exercises: 1. Can you make it a number between one and 100? Give more hints depending on whether the player is close or not? And change the number of guesses that the player can make? 2. Can you make the game into a function called sta...
true
554f0ccf1ca0bd3bd7da513e690f74fa1f170f4e
Rockforge/python_training
/exercise17.py
321
4.15625
4
# exercise17.py # Data type: tuple denominations = ('pesos', 'centavos') # denominations = ('pesos',) # this should be the syntax for one element tuples print(denominations) print(type(denominations)) print(denominations[1]) print('--- Entering loop ---') for denomination in denominations: print(denomination) ...
true
8e5c4b8fbcf49eb02931a653bbbba9d49be94611
tazi337/smartninjacourse
/Class2_Python3/example_00630_secret_number_exercise_1.py
771
4.21875
4
# Modify the secret number game code below such # that it shows the number of attempts # after each failed attempt # Modify the secret number game code below such # that it shows the number of attempts # after each failed attempt secret = "1" counter = 5 while counter > 0: counter -= 1 guess = input("guess ...
true
dae58627d930502a1a950949637285e6a1275921
mjftw/design-patterns
/example-design-patterns/iterator/iterator_example.py
240
4.40625
4
'''Trivially simple iterator example - python makes this very easy!''' def main(): a = 'a' b = 'b' c = 'c' iterable = [a, b, c] for element in iterable: print(element) if __name__ == '__main__': main()
true
d0a2a502929ec839607ab88eb4fa6eca97141342
jkoppel/QuixBugs
/python_programs/sqrt.py
420
4.3125
4
def sqrt(x, epsilon): approx = x / 2 while abs(x - approx) > epsilon: approx = 0.5 * (approx + x / approx) return approx """ Square Root Newton-Raphson method implementation. Input: x: A float epsilon: A float Precondition: x >= 1 and epsilon > 0 Output: A float in the interva...
true
14857cf1f6d3397403c422ebad8994bc33848216
jkoppel/QuixBugs
/correct_python_programs/mergesort.py
2,389
4.15625
4
def mergesort(arr): def merge(left, right): result = [] i = 0 j = 0 while i < len(left) and j < len(right): if left[i] <= right[j]: result.append(left[i]) i += 1 else: result.append(right[j]) j +...
true
23bf4b2a12455334e5fb0ffa4fce75a11cdb2378
jkoppel/QuixBugs
/python_programs/hanoi.py
1,138
4.40625
4
def hanoi(height, start=1, end=3): steps = [] if height > 0: helper = ({1, 2, 3} - {start} - {end}).pop() steps.extend(hanoi(height - 1, start, helper)) steps.append((start, helper)) steps.extend(hanoi(height - 1, helper, end)) return steps """ Towers of Hanoi hanoi An a...
true
c0421854953fd6080d9eefc56fade47695ffa823
Raghumk/TestRepository
/Functions.py
1,076
4.46875
4
# Parameter functions is always pass by reference in Python def fun1( Name ): Name = "Mr." + Name return Name def fun2(Name = "Raghu"): Name = "Mr." + Name return Name print (fun1("Raghu")) print (fun1(Name="Kiran")) # Named argument print (fun2()) # Default argument #### Variable l...
true
24851e56fd5704a5693657d13cee92004aa81d7c
kneesham/cmp_sci_4250
/Main.py
2,458
4.25
4
### # Name: Theodore Nesham # Project: 4 # Date: 11/02/2019 # Description: This project was used to show inheritance, polymorphism, and encapsulation. The parent class is Product # and the two children classes are Book and Movie. The two subclasses override the print_description # function sho...
true
c269df6a9e5ab28181e7073991e7fcd6756e1c6d
ahermassi/Spell-Checker
/src/trie/trie.py
1,712
4.125
4
from src.node.trie_node import TrieNode class Trie: def __init__(self): self.root = TrieNode() def __contains__(self, word): """ Returns if the word is in the trie. :type word: str :rtype: bool """ word = word.strip() root = self.root f...
true
580d41a8f9f430feaac5bdfbd8126afffa481d00
Tochi-kazi/Unit3-10
/calculate_average .py
358
4.15625
4
# Created by : Tochukwu Iroakazi # Created on : oct-2017 # Created for : ICS3UR-1 # Daily Assignment - Unit3-10 # This program displays average print('type in your score') userinput = input() counter = 0 numtotal = 0 for userinput in range (0,100): numtotal = numtotal + userinput counter = counter + 1 ...
true
70277b5371bcdb5190de68567903b4ed8aade82f
thomasdephuoc/bootcamp_python
/day_00/ex_03/count.py
651
4.4375
4
def text_analyzer(text=None): """This function counts the number of upper characters, lower characters, punctuation and spaces in a given text.""" if text is None: text = input("What is the text to analyse?") nb_char = sum(1 for c in text if c.isalpha()) nb_upper = sum(1 for c in text if c.isu...
true
c696337cda0492a06385ab26fdff89cf8de0aa8f
irene-yi/Classwork
/Music.py
2,108
4.28125
4
class Music: # if you pass in artists while calling your class # you need to add it to init def __init__(self, name, artists): self.name = name self.artists = artists self.friends = {} # Pushing information to the array def display(self): print() print ("Your artists:") for artists in self.artists: ...
true
7c78cdd9a7c791a82adfe6e19f2f9e1a63f3a953
IronManCool001/Python
/Guess The Number/main.py
590
4.125
4
import random chances = 5 print("Welcome To Guess The Number Game") no = random.randint(0,256) run = True while run: guess = int(input("Enter your guess")) if guess == no: print("You Got It") run = False break elif guess > no: ...
true
b8ecc471b73c1c9ff01b74835b490b29a803b8db
giovanna96/Python-Exercises
/Divisors.py
279
4.125
4
#Practice Python #Create a program that asks the user for a number and then prints out a list of all the divisors of that number. divisor = [] value = int(input("enter a number: \n")) for i in range(value): if value%(i+1)==0: divisor.append(i+1) print(divisor)
true
b4b8658f9f4ad759f4111193d3763690ad9265b3
wahome24/Udemy-Python-Bible-Course-Projects
/Project 10.py
1,420
4.4375
4
#This is a bank simulator project using classes and objects class Bank: #setting a default balance def __init__(self,name,pin,balance=500): self.name = name self.pin = pin self.balance = 500 #method to deposit money def deposit(self,amount): self.balance += amount print(f'Your new balance ...
true
cebc11a76eba589bec28dd26b3a4bab75e1e5ee8
shashankmalik/Python_Learning
/Week_4/Modifying the Contents of a List.py
787
4.34375
4
# The skip_elements function returns a list containing every other element from an input list, starting with the first element. Complete this function to do that, using the for loop to iterate through the input list. def skip_elements(elements): # Initialize variables new_list = [] i = 0 # Iterate through the lis...
true
4d540640c41d61c2472b73dceac524eb6494797e
chao-shi/lclc
/489_robot_cleaner_h/main.py
2,788
4.125
4
# """ # This is the robot's control interface. # You should not implement it, or speculate about its implementation # """ #class Robot(object): # def move(self): # """ # Returns true if the cell in front is open and robot moves into the cell. # Returns false if the cell in front is blocked and r...
true
93897a144a08baf27692f9dd52da610be41c0ad3
p-perras/absp_projects
/table_printer/tablePrinter.py
788
4.1875
4
# !python3 # tablePrinter.py # ABSP - Chapter 6 def print_table(table): """ Summary: Prints a table of items right justified. Args: table (list): A 2d list of items to print. """ # Get the max length string of each row. rowMaxLen = [] for row in range(len(table)): ...
true
fc607af81e8f640a2dce4593f55301346b268054
rubenhortas/python_examples
/native_datatypes/none.py
759
4.53125
5
#!/usr/bin/env python3 # None is a null number # Comparing None to anything other than None will always return False # None is the only null number # It has its own datatype (NoneType) # You can assign None to any variable, but you can not create other NoneType objects CTE_NONE1 = None CTE_NONE2 = None if __name__ =...
true
cd22aa8ee2bc1ba44c8af3f5bd7d880c7edac4eb
krishnavetthi/Python
/hello.py
817
4.5
4
message = "Hello World" print(message) # In a certain encrypted message which has information about the location(area, city), # the characters are jumbled such that first character of the first word is followed by the first character of the second word, # then it is followed by second character of the first word and...
true
f4fad1000ed28895c819b3bc71a98e7a9f3e87b6
ofreshy/interviews
/hackerrank/medium/merge_the_tools.py
2,042
4.46875
4
""" Consider the following: A string, , of length where . An integer, , where is a factor of . We can split into substrings where each subtring, , consists of a contiguous block of characters in . Then, use each to create string such that: The characters in are a subsequence of the characters in . An...
true
06f8cf70cd26e9c71b989fcb63f7525fb4fc3fff
ofreshy/interviews
/interviewcake/apple_stock.py
2,451
4.21875
4
# -*- coding: utf-8 -*- """ Suppose we could access yesterday's stock prices as a list, where: The values are the price in dollars of Apple stock. A higher index indicates a later time. So if the stock cost $500 at 10:30am and $550 at 11:00am, then: stock_prices_yesterday[60] = 500 Write an efficient funct...
true
7ddd97ed6cc317d4fdf9fc1731d8425d2eb3b6a4
gunjan-madan/Namith
/Module4/1.3.py
915
4.40625
4
#Real Life Problems '''Task 1: Delivery Charges''' print("***** Task 1: *****") print() # Create a program that takes the following input from the user: # - The total number of sand sack and cement sack # - Weight of each sack [Hint: use for loop to get the weight] # - Use a variable to which the weight of the sack...
true
c8b8060d5aeb1374f0ef0bb89f436884e1b32748
gunjan-madan/Namith
/Module2/3.1.py
1,328
4.71875
5
# In the previous lesson, you used if-elif-else statements to create a menu based program. # Now let us take a look at using nested if-elif statements in creating menu based programs. '''Task 1: Nested If-else''' print() print("*** Task 1: ***") print() #Make a variable like winning_number and assign any number to it b...
true
552c0f6239df522b27684179f216efe7b10a7037
gunjan-madan/Namith
/Module2/1.3.py
1,705
4.21875
4
# You used the if elif statement to handle multiple conditions. # What if you have 10 conditions to evaluate? Will you write 10 if..elif statements? # Is it possible to check for more than one condition in a single if statement or elif statement? # Let's check it out """-----------Task 1: All in One ------------...
true
f36fd365929003b92229a08a013b4cf1af4cc5bd
NasserAbuchaibe/holbertonschool-web_back_end
/0x00-python_variable_annotations/1-concat.py
383
4.21875
4
#!/usr/bin/env python3 """Write a type-annotated function concat that takes a string str1 and a string str2 as arguments and returns a concatenated string """ def concat(str1: str, str2: str) -> str: """[Concat two str] Args: str1 (str): [string 1] str2 (str): [string 2] Returns: ...
true
31bc1789c9cddfef609d48fc36f7c1ecb0542864
Lionelding/EfficientPython
/ConcurrencyAndParallelism/36a_MultiProcessing.py
2,434
4.46875
4
# Item 36: Multi-processing """ * For CPU intensive jobs, multiprocessing is faster Because the more CPUs, the faster * For IO intensive jobs, multithreading is faster Because the cpu needs to wait for the I/O despite how many CPUs available GIL is the bottleneck. * Multi-core multi-threading is worse than single...
true
368b25a3c24acd2bd61811676f685cb5083bbd46
Lionelding/EfficientPython
/3_ClassAndInheritance/27_Private_Attributes.py
1,778
4.28125
4
# Item 27: Prefer Public Attributes Over Private Attributes ''' 1. classmethod has access to the private attributes because the classmethod is declared within the object 2. subclass has no direct access to its parent's private fields 3. subclass can access parents' private fields by tweeking its attribute names 4. Docu...
true
d1d051a33cc4da4eeec7a394394b976926ea51d8
jenny-liang/uw_python
/week05/screen_scrape_downloader.py
2,061
4.3125
4
""" Assignment: choose one or both or all three. I suspect 2 is a lot harder, but then you would have learned a lot about the GitHub API and JSON. 1. File downloader using screen scraping: write a script that scrapes our Python Winter 2012 course page for the URLs of all the Python source files, then downloads them a...
true
86528dd845be83a71b90850b26a7880f85a0f758
mk346/Python-class-Projects
/Guess_Game.py
492
4.25
4
secret_word ="trouser" guess= "" count=0 guess_limit = 3 out_of_guesses= False print("HINT: I have two legs but i cant walk") while guess!= secret_word and not(out_of_guesses): if count<guess_limit: guess = input("Enter Your Guess: ") count+=1 else: out_of_guesses= True i...
true
a8a4f8ecc948c07a6c8f96173bb2b6e32ee550aa
deepgautam77/Basic_Python_Tutorial_Class
/Week 1/Day 2/for_loop.py
253
4.15625
4
#for i in range(10): # print("This is fun..") #range() function #print odd number from 0-100 for i in range(1,100,2): print(i, end=' ') #WAP to print even numbers from 2000-2500 #WAP to print odd numbers starting from 5200 and ending at 4800
true
d49cedb5535e851045d759e51e9a37f833f6c460
deepgautam77/Basic_Python_Tutorial_Class
/Day 5/homework_1.py
659
4.34375
4
#Create a phone directory with name, phone and email. (at least 5) #WAP to find out all the users whose phone number ends with an 8. #all the users who doesn't have email address. --done d=[{'name':'Todd', 'phone':'555-1414', 'email':'todd@mail.net'}, {'name':'Helga', 'phone':'555-1618', 'email':'helga@mail.net'}, {'...
true
694759e96c8e1988ff347b36ff6c50b55b113639
deepgautam77/Basic_Python_Tutorial_Class
/Week 1/Day 2/simple_task.py
294
4.3125
4
# -273 degree celsius < invalid.. temp = float(input("Enter the temperature: ")) while temp<-273: temp = eval(input(("Impossible temperature. Please enter above -273 degree celsius: "))) print("The temperature of ",temp," Celsius in Farenheit is: ", 9/5*temp+32) #break #continue #pass
true
00af72c64e08a9f15b7f869ed9745e3130e676e7
markap/PythonPlayground
/language_features/decorator.py
535
4.375
4
""" a decorator example to multiply to numbers before executing the decorated function """ def multiply(n, m): def _mydecorator(function): def __mydecorator(*args, **kw): # do some stuff before the real # function gets called res = function(args[0] * n, args[1] *...
true
8c763d12a5708eaf31d2da130d47304f4414bd6b
sean-blessing/20210424-python-1-day
/ch07/classes/main.py
640
4.1875
4
from circle import Circle class Rectangle: """Rectangle class holds length and width attributes""" # above doctring is optional area_formula = "area = length * width" def __init__(self, length, width): pass self.length = length self.width = width def area(self): ""...
true
b8387b9ee340e02727a089494ef37a9d80ed5de5
sean-blessing/20210424-python-1-day
/ch01/rectangle-calculator/main.py
352
4.15625
4
print("Welcome to the area and perimeter calculator!") choice = "y" while choice == "y": length = int(input("enter length:\t")) width = int(input("enter width:\t")) perimeter = 2*length + 2*width area = length * width print(f"Area:\t\t{area}") print(f"Perimeter\t{perimeter}") choice = in...
true
de513e18abf270601e74fc0e738dc4f6ef7c5c1a
guam68/class_iguana
/Code/Richard/python/lab25-atm.py
1,914
4.34375
4
""" author: Richard Sherman 2018-12-16 lab25-atm.py, an ATM simulator, an exercise in classes and functions """ import datetime class ATM(): def __init__(self, balance = 100, rate = 0.01): self.balance = balance self.rate = rate self.transactions = [] def check_withdrawal(self, amount)...
true
7a9349976447f50f8a54c6999aa1419e5e382f2e
guam68/class_iguana
/Code/Scott/Python/lab_11_simple_calculator_version2.py
898
4.28125
4
#lab_11_simple_calculator_version2.py #lab_11_simple_calculator_lvl_1 #operator_dict = {'+': +,} operator = input("What type of calculation would you like to do? Please enter '+', '-', '**', or '/' :") operand_a = input('Please enter the first number:') operand_b = input('Please enter the second number:') operand_a...
true
b7816fc8efb71a1535030bc5c2a0dc583c29116c
yvette-luong/first-repo
/data-types.py
668
4.1875
4
""" Boolean = True or False String = "Yvette" Undefined = A value that is not defined Integer = 132432 Camel Case = lower case first word and then capitalize each following word: example: helloWorld """ "1231314" Yvette = 123 Yvette def helloYvette(): # this is a function, which is indicated by brackets pr...
true
2e7839e32546b9cf8a790c16b71c24986d8f12cb
stevenhughes08/CIT120
/work/python/unit7/SuperMarket.py
1,337
4.28125
4
# SuperMarket.py - This program creates a report that lists weekly hours worked # by employees of a supermarket. The report lists total hours for # each day of one week. # Input: Interactive # Output: Report. # Declare variables. HEAD1 = "WEEKLY HOURS WORKED" DAY_FOOTER = "Day Total " SENTINEL = "done" # Named cons...
true
a3d6d0d7062c1452341c59741ea67aada4dc9ed8
danangsw/python-learning-path
/sources/8_loops/4_else_loop.py
640
4.3125
4
# Python supports `else` with a loops. # When the loop condition of `for` or `while` statement fails then code part in `else` is executed. # If `break` statement is executed then `else` block will be skipped. # Even any `continue` statement within a loops, the `else` block will be executed. count = 0 while count < 5:...
true
2e4761e091c6838cfdedbd8bdd48c727a606afd5
hjhorsting/Bootrain2
/PythonBasics.py
549
4.4375
4
# 1. Write a code that outputs your name and surname in one line. print("Harald Horsting") # or: print("Harald", "Horsting") # 2. Write a 1-line code that outputs your name and surname in two separate lines by using # a single print() call. print("Harald \n Horsting") # 3. Use print() function that returns the fol...
true
2c099c78fb2eff10a340d1ba214e333cfb17d720
MarKuchar/intro_to_algorithms
/1_Variables/operators.py
1,205
4.15625
4
# Operators # =, -, *, /, // (floor division) # % (modulo): 'mod' remainder # ** (power) print(10 % 3) # 1 print(10 ** 2) # 100 print(100 // 3) # 33 print(100 - 5) # = : assignment number = 7 number = number + 3 # increment number by 3 number += 3 # increment number by 3 # -= : decrement operator print("number =...
true
5b25724eae900e42228b5687f4f2691b7bb10031
MarKuchar/intro_to_algorithms
/8_Functions/functions.py
1,050
4.28125
4
# Functions are a very convenient way to divide your code into useful blocks, make it more readable and help 'reuse' it. # In python, functions are defined using the keyword 'def', followed by function's name. # "input --> output", "A reusable block of code" def print_menu(): print("----- Menu -----") print("...
true
1d7501c04e7e41331f36b5085202c7c1da7aa91b
MarKuchar/intro_to_algorithms
/4_Tuples/tuples_basics.py
970
4.34375
4
# Tuples are almost identical to lists # The only big difference between lists and tuples is that tuples cannot be modified (Immutable) # You can NOT add(append), changed(replace), or delete "IMMUTABLE LIST" # elements from the tuple vowels = ("a", "e", "i", "o", "u") # consonants (b, c, d, ...) print(vowels[0]) prin...
true
e783da31a78d9b2f0f786c0a7f5b9a7bd707833e
MarKuchar/intro_to_algorithms
/1_Variables/variable_type.py
883
4.3125
4
# Data types # There are many different data types in Python # int: integer # float: floating point (10.23, 3.14, etc) # bool: boolean (True, False) # str: a sequence of characters in quotes "aa", 'aa' language = "en_us" print(type(language)) # check the type of the variable users = 10 """ print(users + language) #...
true
46f360e2ece2d5195fe417c92cc1b91cd1f467ae
Chauhan98ashish/Hacktoberfest_2020
/newton_sqrt.py
219
4.34375
4
print("*****Square Root By Newton's Method*****") x=int(input("Enter the number::>>")) r=x a=10**(-10) while abs(x-r*r)>a: r=(r+x/r)/2 print(r) r=round(r,3) print("Square root of {} is {}".format(x,r))
true
c7aa27a1bd3cb900533845dd60eada06f6773b7f
sairaj225/Python
/Regular Expressions/5Find_a_word_in_string.py
307
4.28125
4
import re # if re.search("hello", "we have said hello to him, and he replied with hellora hello"): # print("There is hello in the string") # findall() returns list of all matches words = re.findall("hello", "we have said hello to him, and he replied with hellora hello") for i in words: print(i)
true
6c7e393680152b14a04838a6406298cce3e9e3fb
sairaj225/Python
/Generators/1demo.py
774
4.5625
5
''' Generators are used to create iterators, but with a different approach. Generators are simple functions which return an iterable set of items, one at a time, in a special way. ''' # If a function contains at least one yield statement # It becames a Generator function. # Generator function contains one or more yi...
true
f7917d704ac0e45d8b0ffc804eeac7dc65eac66b
Dnavarro805/Python-Programming
/Data Structures - Arrays/StringReverse.py
358
4.1875
4
# Problem: Create a funciton that reverses a string. # Input: "Hi My Name is Daniel" # Output: "lienaD si emaN yM iH" def reverse(str): reversed = [] for x in range (len(str)-1, -1, -1): reversed.append(str[x]) return ''.join(reversed) def reverse2(str): return str[::-1] print(reverse...
true
53f1c9eee659d35d7ed4b563d21a6e4502d811e5
nolanroosa/intermediatePython
/hw21.py
1,835
4.25
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Nov 12 16:59:35 2020 @author: nolanroosa """ # Question 1 import pandas as pd pop = pd.read_csv("/Users/nolanroosa/Desktop/Python/pop.csv") def menu(): print (''' Population Menu: 1. Display the entire...
true
e50af84ac8ce77f08597c3ef94481e5aef55fd48
yogeshBsht/CS50x_Plurality
/Plurality.py
1,469
4.34375
4
# Plurality max_candidates = 5 candidates = ['Lincoln', 'Kennedy', 'Bush', 'Obama', 'Trump', 'Biden'] # Taking number of candidates as input flag = 1 while flag: num_candidates = int(float(input("Enter number of candidates: "))) if num_candidates < 2: print("Value Error! At least 2 candidate...
true
d8fd09cbd25c6fe085aacf33768aedcc713b7e04
jurbanski/week2
/solution_10.py
2,721
4.34375
4
#!/usr/local/bin/python3 # 2015-01-14 # Joseph Urbanski # MPCS 50101 # Week 2 homework # Chapter 8, Question 10 solution. # Import the sys module to allow us to read the input filename from command line arguments import sys # This function will prompt the user for a filename, then check to see if the file exists. I...
true
e8e74b30ac6da31bb4907216ea45f4a3136c23cb
eembees/molstat_water
/rotation.py
2,600
4.15625
4
## rotation.py Version 1.0 ## Written by Magnus Berg Sletfjerding (eembees) ########################################################### """Rotation Functions, inspired by http://paulbourke.net/geometry/rotate/ Verified as working 01/07/17 by eembees""" """Importing modules""" import numpy as np from math import pi, si...
true
7c57ed755f03c05a03c281e2b9a03529f8b441a2
Re-Creators/ScriptAllTheThings
/Temperature Scale Converter/temperature_scale_converter.py
1,211
4.5
4
""" Temperature Scale Converter - Inputs the value from the user and converts it to Fahrenheit,Kelvin & Celsius Author : Niyoj Oli Date : 01/10/21 """ temp = input("Input the temperature you would like to convert? (e.g., 45F, 102C, 373K ) : ") degree = float(temp[:-1]) # the first value of the input is taken as th...
true
efc8169de6a436f2ba9910ae37a8526d92bd7456
JuliasBright/Python
/Simple Calculator.py
1,685
4.3125
4
import sys while True: print("Welcome To My Simple Calculator") print("Enter this Abbreviations To Continue") print("Enter + for Adding") print("Enter - for Substractiing") print("Enter * for Multiplication") print("Enter / for Dividing") print("Enter ** for Exponation") print("...
true
5a5bfac15fdf423e125b8aa56655bdb3dbccff7a
Gagan-453/Python-Practicals
/Searching names from a list.py
1,103
4.1875
4
# Searching elements in a list lst=['Gagan Adithya', 'Advith', 'Harsha', 'Praveen'] for i in range(len(lst)): lst[i] = lst[i].lower() #Converting all the names in the list into lower case letters print(lst) x = input("enter element to search:") x = x.lower() #Converting all the letters into lower case...
true
3756486b3c91b557bff353dff8708ef25cca9a32
Gagan-453/Python-Practicals
/GUI/Canvas/Creating oval.py
1,375
4.875
5
# Creating Oval using Canvas from tkinter import * #Create a root window root = Tk() # var c is Canvas class object # root is the name of the parent window, bg is background colour, height is the height of the window and width is the breadth of window, cursor represents the shape of the cursor in the canvas c = Canva...
true
44c151aff1f59e0ca9418405b9a4d7ba2ce98f30
Gagan-453/Python-Practicals
/GUI/Canvas/Creating images.py
939
4.125
4
#We can display an image with the help of create_image function from tkinter import * #Create a root window root = Tk() #Create Canvas as a child to root window c = Canvas(root, bg='white', height=700, width=1200) #Copy images into files file1 = PhotoImage(file="Peacock.png") file2 = PhotoImage(file='Screenshot (40)....
true
554f38054fbb5da57d3a88668beb4acae711007d
Gagan-453/Python-Practicals
/GUI/Frame/Frame and Widget.py
1,701
4.375
4
# FRAME Container #a frame is similar to canvas that represents a rectangular area where some text or widgets can be displayed from tkinter import * #Create root window root = Tk() #Give a title for root window root.title('Gagan\'s frame') #Create a frame as child to root window f = Frame(root, height=400, width=50...
true
21e92d5add01747577aac38d6d9e46180f0492eb
Gagan-453/Python-Practicals
/GUI/Frame/Listbox Widget.py
2,547
4.40625
4
# LISTBOX WIDGET # It is useful to display a list of items, so that he can select one or more items from tkinter import * class ListBox: def __init__(self, root): self.f = Frame(root, width=700, height=400) #Let the frame will not shrink self.f.propagate(0) # Attach the f...
true
d96e1b7876aebe651540e50fa717d03bd162c853
Gagan-453/Python-Practicals
/GUI/Frame/Button Widget/Arranging widgets in a frame/Place layout manager.py
1,899
4.5625
5
# PLACE LAYOUT MANAGER # Place layout manager uses place() method to arrange widgets #The place() method takes x and y coordinates of the widget along with width and height of the window where the widget has to be displayed from tkinter import * class MyButton: #Constructor def __init__(self, root): #...
true
c0309348cb3d4dba07c8d321cbc157e5dbdd6d0f
Gagan-453/Python-Practicals
/GUI/Frame/Menu Widget.py
1,979
4.1875
4
# MENU WIDGET # Menu represents a group of items or options for the user to select from. from tkinter import * class MyMenu: def __init__(self, root): # Create a menubar self.menubar = Menu(root) # attach the menubar to the root window root.config(menu=self.menubar) ...
true
56b0a0a2582b0e26197affa6d27865dbfe5abb26
Gagan-453/Python-Practicals
/Date and Time.py
2,356
4.5625
5
#The epoch is the point where the time starts import time epoch = time.time() #Call time function of time module print(epoch) #Prints how many seconds are gone since the epoch .i.e.Since the beginning of the current year #Converting the epoch into date and time # locatime() function converts the epoch time into time_s...
true
ec4fc0042d9e6100b485588b60be49413925bcb7
Gagan-453/Python-Practicals
/Exceptions.py
2,030
4.59375
5
# Errors which can be handled are called 'Exceptions' # Errors cannot be handled but exceptions can be handled #to handle exceptions they should be written in a try block #an except block should be written where it displays the exception details to the user #The statements in thefinally block are executed irrespective...
true
58d37c8c9a0be25faee85b7d15e6a1958cbf466f
harshbhardwaj5/Coding-Questions-
/Allsubarrayrec.py
501
4.15625
4
# Python3 code to print all possible subarrays def printSubArrays(arr, start, end): # Stop if we have reached the end of the array if end == len(arr): return # Increment the end point and start from 0 elif start > end: return printSubArrays(arr, 0, end + 1) # Print the subarray and inc...
true
93fe621719192fd6fc2a29f328bdb0181be8ba54
ncamperocoder1017/CIS-2348
/Homework1/ZyLabs_2_19.py
1,885
4.125
4
# Nicolas Campero # 1856853 # Gather information from user of ingredients and servings amount print('Enter amount of lemon juice (in cups):') l_juice_cups = float(input()) print('Enter amount of water (in cups):') water_cups = float(input()) print('Enter amount of agave nectar (in cups):') agave_cups = float(input()) ...
true
e38197efcd64d6ad928d207bf789273cb0a6fb08
cr8ivecodesmith/basic-programming-with-python
/lpthw/ex11.py
756
4.25
4
# Exercise 11: Asking questions print('How old are you?', end=' ') age = input() print('How tall are you?', end=' ') height = input() print('How much do you weigh?', end=' ') weight = input() print("So you're %r old, %r tall and %r heavy." % (age, height, weight)) # Note # Notice that we put an end=' ' after the str...
true