blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
0fa5f57b1351604b6f1c7d8858d26909637ca57b
dakshitgm/Specialization-Data-structure-and-Algorithm-Coursera
/algorithm on string/week4/kmp.py
827
4.125
4
# python3 import sys def find_pattern(pattern, text): """ Find all the occurrences of the pattern in the text and return a list of all positions in the text where the pattern starts in the text. """ result = [] # Implement this function yourself conc=pattern+'$'+text values=[0]*len(conc) last=0 ...
true
366ffad8460a65261f57e99b28789147a915e3d0
TimothyCGoens/Assignments
/fizz_buzz.py
613
4.21875
4
print("Welcome back everyone! It's now time for the lighting round of FIZZ or BUZZ!") print("""For those of you following at home, it's simple. Our contestants need to give us a number that is either divisible by 3, by 5, or by both!""") name = input("First up, why don't you tell us your name? ") print(f"""Well {name...
true
f2ce2ad7ad3703bb800c7fc2dfd79b6bab76d491
thedern/algorithms
/recursion/turtle_example.py
835
4.53125
5
import turtle max_length = 250 increment = 10 def draw_spiral(a_turtle, line_length): """ recursive call example: run the turtle in a spiral until the max line length is reached :param a_turtle: turtle object "charlie" :type a_turtle: object :param line_length: length of line to draw :t...
true
bc87f755b34064cc614504c41092be4765251e03
njg89/codeBasics-Python
/importSyntax.py
1,007
4.15625
4
# Designate a custom syntax for a default function like th example 'statistics.mean()' below: ''' import statistics as stat exList = [5,3,2,9,7,4,3,1,8,9,10] print(stat.mean(exList)) ''' # Only utilize one function, like the 'mean' example below: ''' from statistics import mean exList2 = [3,2,3,5,6,1,0,3,8...
true
66b5826912e87770d5e305e93f2faacba745ac7e
CleonPeaches/idtech2017
/example_02_input.py
499
4.15625
4
# Takes input from user and assigns it to string variable character_name character_name = input("What is your name, adventurer? ") print("Hello, " + character_name + ".") # Takes input from user and assigns it to int variable character_level character_level = (input("What is your level, " + character_name + "? ")) # ...
true
4e17d157d0abc7d7f36a454b3a3fe62887e98cc4
ian7aylor/Python
/Programiz/GlobKeyWrd.py
654
4.28125
4
#Changing Global Variable From Inside a Function using global c = 0 # global variable def add(): global c c = c + 2 # increment by 2 print("Inside add():", c) add() print("In main:", c) #For global variables across Python modules can create a config.py file and store global variables there #Using a Glo...
true
b220370ca9ffd82ea7189e0a5167c9bae233f223
ian7aylor/Python
/Programiz/For_Loop.py
1,260
4.28125
4
#For Loop ''' for val in sequence: Body of for ''' # Program to find the sum of all numbers stored in a list # List of numbers numbers = [6, 5, 3, 8, 4, 2, 5, 4, 11] # variable to store the sum sum = 0 # iterate over the list #iterates through list of numbers and sums them together for val in numbers: sum = ...
true
1c14df00fa1f6304216b8fd1d7a28186610c3182
rishabmehrotra/learn_python
/Strings and Text/ex6.py
879
4.625
5
#use of f and .format() """F-strings provide a concise and convenient way to embed python expressions inside string literals for formatting. f'some stuff here {avariable}'""" #.format() """ The format() method formats the specified value(s) and insert them inside the string's placeholder. txt1 = "My name is {fname}, I...
true
806969204ed0adab1f751fc6c3aa6ac07eb4cf7d
DonaldButters/Module5
/input_while/input_while_exit.py
1,300
4.28125
4
""" Program: input_while_exit.py Author: Donald Butters Last date modified: 9/25/2020 The purpose of this program is prompt for inputs between 1-100 and save to list. Then the program out puts the list """ #input_while_exit.py user_numbers = [] stopvalue = 404 x = int(input("Please Enter a number between 1 and ...
true
8abda8068278d4ceba6a2e60d5d76db6e2c02a86
DannyMcwaves/codebase
/pythons/stack/stack.py
1,526
4.125
4
__Author__ = "danny mcwaves" """ i learnt about stacks in the earlier version as a record activation container that holds the variables during the invocation of a function. so when the function is invoked the, the stack stores all the variables in the function and release them as long as their parent functions once the...
true
951c7e5183fa5c141cc354c47dadf1b4821c19e8
BlackHeartEmoji/Python-Practice
/PizzaToppings.py
511
4.15625
4
toppings = ['pepperoni','sausage','cheese','peppers'] total = [] print "Hey, let's make a pizza" item = raw_input("What topping would you like on your pizza? ") if item in toppings: print "Yes we have " + item total.append(item) else: print "Sorry we don't have " + item itemtwo = raw_input("give me anothe...
true
030e3abfd6bce4b33f9f5735aefbc21d94543304
jamarrhill/CS162Project6B
/is_decreasing.py
810
4.15625
4
# Name: Jamar Hill # Date: 5/10/2021 # Description: CS 162 Project 6b # Recursive functions # 1. Base case -> The most basic form of the question broken down # 2. If not base, what can we do to break the problem down # 3. Recursively call the function with the smaller problem # lst = [5, 6, 10, 9, 8, 7, 64, 10] # ...
true
58a4de9900cdfcc825800f5c2a39f660ece015ab
pnovotnyq/python_exercises
/12_Fibonacci.py
947
4.75
5
#! /usr/bin/env python ''' Write a program that asks the user how many Fibonnaci numbers to generate and then generates them. Take this opportunity to think about how you can use functions. Make sure to ask the user to enter the number of numbers in the sequence to generate.(Hint: The Fibonnaci seqence is a sequence of...
true
9e81f8e5faf23a690b9a20eb06227c4a779848e4
Goutam-Kelam/Algorithms
/Square.py
813
4.25
4
''' This program produces the square of input number without using multiplication i:= val:= square of i th number ''' try : num = int(raw_input("\n Enter the number\n")) if(num == 0): # FOR ZERO print "\nThe square of 0 is 0\n" exit(1) ...
true
e8a587f892f49edeaf6927e57113a7eeec0f3495
prasadhegde001/Turtle_Race_Python
/main.py
1,115
4.28125
4
from turtle import Turtle,Screen import random is_race_on = False screen = Screen() screen.setup(width=500, height=400) user_input = screen.textinput(title="Please Make Your Bet", prompt="Which Turtle Will win the Race? Enter a color") colors = ["red", "orange", "yellow", "green", "blue", "purple"] y_positio...
true
d6e91528d13834231a950e675781ddccab502986
shabbir148/A-Hybrid-Approach-for-Text-Summarization-
/fuzzy-rank/Summarizers/file_reader.py
1,100
4.15625
4
# Class to simplify the reading of text files in Python. # Created by Ed Collins on Tuesday 7th June 2016. class Reader: """Simplifies the reading of files to extract a list of strings. Simply pass in the name of the file and it will automatically be read, returning you a list of the strings in that file.""" ...
true
b0304411d3408c08056d86457ef288d10ecf461d
pole55/repository
/Madlibs.py
1,360
4.21875
4
"""Python Mad Libs""" """Mad Libs require a short story with blank spaces (asking for different types of words). Words from the player will fill in those blanks.""" # The template for the story STORY = "This morning %s woke up feeling %s. 'It is going to be a %s day!' Outside, a bunch of %ss were protesting to keep %s...
true
1f48d9529ae94ae0deb313d495ffce1ee57179ec
Apropos-Brandon/py_workout
/code/ch01-numbers/e01_guessing_game.py~
634
4.25
4
#!/usr/bin/env python3 import random def guessing_game(): """Generate a random integer from 1 to 100. Ask the user repeatedly to guess the number. Until they guess correctly, tell them to guess higher or lower. """ answer = random.randint(0, 100) while True: user_guess = int(input("What is your...
true
eedde460936b41c711402499160c903855636a3a
Struth-Rourke/cs-module-project-iterative-sorting
/src/searching/searching.py
1,332
4.21875
4
def linear_search(arr, target): # for value in the len(arr) for i in range(0, len(arr)): # if the value equals the target if arr[i] == target: # return the index value return i # # ALT Code: # for index, j in enumerate(arr): # if j == target: # ...
true
ddf570644ae74b247569a0f9a303abf2906f83b9
Dagim3/MIS3640
/factor.py
381
4.25
4
your_number = int(input("Pick a number:")) #Enter value for factor in range( 1, your_number+1): #Range is from 1 to the entered number, +1 is used as the range function stops right before the last value factors = your_number % factor == 0 #This runs to check that the entered number doesn't have a remainder if ...
true
3df59ff6049246c715d31544df192d245fba4da6
Dagim3/MIS3640
/BMIcalc.py
616
4.3125
4
def calculate_bmi(Weight, Height): BMI = 703* (Weight / (Height*Height)) if BMI>= 30: print ('You are {}'.format(BMI)) print ('Obese') elif BMI>= 25 and BMI< 29.9: print ('You are {}'.format(BMI)) print ('Overweight') elif BMI>= 18.5 and BMI<24.9: print ('You a...
true
69d1287d9328bb83dc8cd52f8a587a90a0614feb
derekdyer0309/interview_question_solutions
/Array Sequences/sentence_reversal.py
1,416
4.40625
4
""" Given a string of words, reverse all the words. For example: Given: 'This is the best' Return: 'best the is This' As part of this exercise you should remove all leading and trailing whitespace. So that inputs such as: ' space here' and 'space here ' both become: 'here space' ###NOTE: DO NOT USE .re...
true
4ba8df598a59c5f1ce1bdf81046b1719d447d277
derekdyer0309/interview_question_solutions
/Strings/countingValleys.py
964
4.21875
4
import math def countingValleys(steps, path): #Make sure steps and len(path) are == or greater than zero if steps == 0: return 0 if len(path) == 0: return 0 if steps != len(path): return 0 #keep track of steps down, up, and valleys sea_level = 0 steps = 0 valley...
true
acb3c73a5497db189795a56cea70fda0895ed9e5
msinnema33/code-challenges
/Python/almostIncreasingSequence.py
2,223
4.25
4
def almostIncreasingSequence(sequence): #Take out the edge cases if len(sequence) <= 2: return True #Set up a new function to see if it's increasing sequence def IncreasingSequence(test_sequence): if len(test_sequence) == 2: if test_sequence[0] < test_sequence[1]: ...
true
96eb009a11129f84ea3bb1c98abbc7fc93c0937e
jayceazua/wallbreakers_work
/week_1/detect_cap.py
1,407
4.4375
4
""" Given a word, you need to judge whether the usage of capitals in it is right or not. We define the usage of capitals in a word to be right when one of the following cases holds: All letters in this word are capitals, like "USA". All letters in this word are not capitals, like "leetcode". Only the first letter in ...
true
325c1a34c36080380709be79330a2ded62c4e4fe
jayceazua/wallbreakers_work
/practice_facebook/reverse_linked_list.py
658
4.3125
4
""" Reverse a singly linked list. Example: Input: 1->2->3->4->5->NULL Output: 5->4->3->2->1->NULL Follow up: A linked list can be reversed either iteratively or recursively. Could you implement both? """ def reverseList(head): # if not head or not head.next: # return head # ...
true
83aa02c1e5f13e596e4858f4d56f50acf6ccc559
jayceazua/wallbreakers_work
/week_1/reverse_int.py
1,049
4.21875
4
""" Given a 32-bit signed integer, reverse digits of an integer. Example 1: Input: 123 Output: 321 Example 2: Input: -123 Output: -321 Example 3: Input: 120 Output: 21 Note: Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [−231, 231 − 1]. For the pu...
true
db18748f39f1d17bfbcf5e28daa511b4b49df53b
jayceazua/wallbreakers_work
/week_1/transpose_matrix.py
1,179
4.28125
4
""" Given a matrix A, return the transpose of A. The transpose of a matrix is the matrix flipped over it's main diagonal, switching the row and column indices of the matrix. Example 1: Input: [ [1,2,3], [4,5,6], [7,8,9] ] Output: [[1,4,7],[2,5,8],[3,6,9]] Example 2: Input: [[1,2,3],[4,5,6]] Output: ...
true
8c05cf6c225a14f05bc041485267a6a22bdb3929
Crick25/First-Project
/First Project ✓.py
908
4.15625
4
#ask if like basketball, if yes display nba heights the same, if no ask if like football, #if yes display football heights the same, if no to that print you boring cunt #height from 5ft8 to 6ft5 myString = 'User' print ("Hello " + myString) name = input("What is your name?: ") type(name) print("Welcome, "...
true
5f0d3e5837cd98a06f4e0234d896f430ad4dc4e3
houdinii/datacamp-data-engineering
/data-engineering/streamlined-data-ingestion-with-pandas/importing-data-from-flat-files.py
1,550
4.25
4
import pandas as pd import matplotlib.pyplot as plt import seaborn as sns def get_data_from_csvs(): """ Get data from CSVs In this exercise, you'll create a data frame from a CSV file. The United States makes available CSV files containing tax data by ZIP or postal code, allowing us to analyze income ...
true
4cb6ced5de1ffb717fb617b881d655510f508cd9
Muneshyne/Python-Projects
/Abstractionassignment.py
1,157
4.375
4
from abc import ABC, abstractmethod class Mortgage(ABC): def pay(self, amount): print("Your savings account balance is: ",amount) #this function is telling us to pass in an argument. @abstractmethod def payment(self, amount): pass class HomePayment(Mortga...
true
7eb969c50bcb0c462c0711f044891b0a6f4bfe58
mgardiner1354/CIS470
/exam1_Q21.py
911
4.21875
4
import pandas as pd #Without using pandas, write a for loop that calculates the average salary of 2020 Public Safety per division of workers in the Cambridge Data Set# import csv #adding csv library total_salary = 0 #defining total salary across all employees emp_count = 0 #defining how many employees work at ...
true
846ba86bb7a3468ad1ff09035f74e8c992cd093c
lewiss9581/CTI110
/M3LAB_Lewis.py
978
4.1875
4
# The purpose of this program is to calculate user input of their number grades and then output the letter grade # Lewis. # The def main or code being excuted later sets the following variables: A_score = 90, B_score = 80, C_score = 70, D_score = 60, F_score = 50, A_score = 90 B_score = 80 C_score = 70 D_score ...
true
938e7ec894153df47319fd6d88581ee7c30e6dc8
cx1802/hello_world
/assignments/XiePeidi_assign5_part3c.py
2,558
4.125
4
""" Peidi Xie March 30th, 2019 Introduction to Programming, Section 03 Part 3c: Custom Number Range """ ''' # iterate from 1 to 1000 to test whether the iterator number is a prime number for i in range(1, 1001): # 1 is technically not a prime number if i == 1: print("1 is technically not a prime number....
true
1da87e75e533b3dd33251cc8a75c2fdd699eb236
GunjanPande/tutions-python3
/Challenges/While Loop Challenges/050.py
824
4.15625
4
""" 50 Ask the user to enter a number between 10 and 20. If they enter a value under 10, display the message “Too low” and ask them to try again. If they enter a value above 20, display the message “Too high” and ask them to try again. Keep repeating this until they enter a value that is between 10 and ...
true
032151fc2846316feeeabdda96fd724783d7b18e
GunjanPande/tutions-python3
/Challenges/Basics/005.py
404
4.28125
4
# 005 # Ask the user to enter three # numbers. Add together the first # two numbers and then multiply # this total by the third. Display the # answer as The answer is # [answer]. . def main(): num1 = int( input("Enter number 1: ") ) num2 = int( input("Enter number 2: ") ) num3 = int( input("Enter number 3: "...
true
b2fe7b891e4f40d446d2cb784df8d5f0c5b6b342
GunjanPande/tutions-python3
/22. List Methods/main2.py
700
4.25
4
def main(): # 5. Combining items of two different lists in one single list using the + operator rishavList = ["GTA", "Notebooks", "Bicycle"] harshitList = ["Pens", "Hard disk", "Cover"] shoppingList = rishavList + harshitList print( str(shoppingList) ) # Note - when we use + operator -> ...
true
f9a8a7021c76d91edb5ff3d0903a9d9ebb41e1dd
GunjanPande/tutions-python3
/10-12. Loops/wholeNos.py
275
4.21875
4
""" Print WHOLE numbers upto n. Ask value of n from user. """ def main(): print("program to print whole numbers upto n") n = int(input("Enter value of n: ")) i = 0 # whole number starts from 0 while( i <= n ): print( i ) i = i + 1 main()
true
92582e199045c37d0bf11ffc564deb37ca2f4c3e
GunjanPande/tutions-python3
/14. String Methods/StringFunctions-2.py
882
4.28125
4
def main(): name = input("enter a string: ") print(name) # harshit jaiswal # always remember, in coding, couting starts from 0 and it is called # variable_name[start_index: end_index + 1] will give a part of the complete string stored in the variable_name first_name = name[0: 7] print(fi...
true
d5e67654ccf34d7b953a87ee29c731d7c7c7e9fd
vanshika-2008/Project-97
/NumberGuess.py
616
4.25
4
import random number = random.randint(1 , 9) chances = 0 print("Number Guessing Game") print("Guess a number (between 1 to 9)") while chances<5 : guess = int(input("Enter your guess :")) if(guess == number) : print("Congratulations!! You won the game") if(guess> number) : print("Your gue...
true
58cfb075dbcaa11e511c92a6a5d42b336498096f
bainco/bainco.github.io
/course-files/tutorials/tutorial05/warmup/a_while_always_true.py
803
4.125
4
import time ''' A few things to note here: 1. The while loop never terminates. It will print this greeting until you cancel out of the program (Ctl+C or go the Shell menu at the top of the screen and select Interrupt Execution), and "Program terminated" will never print. 2. This is known as...
true
dc67ecd32fc7e602e97675510c2d97d2cb2e184b
bainco/bainco.github.io
/course-files/homework/hw01/calculator_programs.py
329
4.21875
4
# Exercise 1: # Exercise 2: # Exercise 3: # Exercise 4: # Hint: to find the length in number of letters of a string, we can use the len function # like so: len("hello"). If we wanted to find the number of characters in a string # that's stored in a variable, we'd instead use the variable's name: len(v...
true
32ce4bc7ed6d3c02f8c2f9a1f1fe74d56c4eb724
bainco/bainco.github.io
/course-files/lectures/lecture04/turtle_programs.py
837
4.5625
5
from MyTurtle import * ### TURTLE CHEATSHEET ############################################### # Pretend we have a turtle named: turtle_0 # If we want turtle_0 to go forward 100 steps we just say: # turtle_0.forward(100) # If we want turtle_0 to turn left or right 90 degrees, we just say: # turtle_0.left(90) # turtle_0...
true
8f4230226c46ca9ff049e2289b97df9be0604840
fmacias64/CourseraPython
/miniProject1/miniProject1.py
2,328
4.125
4
import random # Rock-paper-scissors-lizard-Spock template # The key idea of this program is to equate the strings # "rock", "paper", "scissors", "lizard", "Spock" to numbers # as follows: # # 0 - rock # 1 - Spock # 2 - paper # 3 - lizard # 4 - scissors # helper functions def name_to_number(name): # convert name ...
true
9499eb017ab1052f331ee3e9bef2e98b0926b5e9
MeghaSah/python_internship1
/day_4.py
681
4.28125
4
# write a prrogram to create a list of n integer values and add an tem to the list numbers = [1,2,3,4,5,6] numbers.append(7) print(numbers) #delete the item from the list numbers.remove(5) print(numbers) # storing largest number to the list largest = max(numbers) print(largest) # storing smallest number...
true
bda340062aed8861e6fb566b06c034619b3ae70f
Jonnee69/Lucky-Unicorn
/05_Lu_statement_generator.py
1,032
4.21875
4
token = input("choose a token: ") COST = 1 UNICORN = 5 ZEB_HOR = 0.5 balance = 10 # Adjust balance based on the chosen and generate feedback if token == "unicorn": # prints unicorn statement print() print("*******************************************") print("***** Congratulations! It's ${:.2f} {} **...
true
65dd78967adb237925b4c3f68f502fb610ed1318
alifa-ara-heya/My-Journey-With-Python
/day_02/Python_variables.py
1,672
4.3125
4
#Day_2: July/29/2020 #In the name 0f Allah.. #Me: Alifa Ara Heya Name = "Alifa Ara Heya" Year = 2020 Country = "Bangladesh" Identity = "Muslim" print(Name) print(Country) print(Year) print(Identity) print("My name is", Name) #Calculating and printing the number of days, weeks, and months in 27 years: days_in_27_year...
true
73465c62f71a8a0a5b83eab5bba074212aa322c3
alifa-ara-heya/My-Journey-With-Python
/day_14/exercise7.py
1,011
4.28125
4
# Day_14: August/10/2020 # In the name 0f Allah.. # Me: Alifa # From: Book : Python for everybody # Chapter:4 (Functions) # Exercise 3: Write a program to prompt for a score between 0.0 and 1.0. If the score is out of range, print an error message. If the score is between 0.0 and 1.0, print a grade using the following...
true
9d3f67cf1ab645c4d5744187c8d53ac6f84df0a6
alifa-ara-heya/My-Journey-With-Python
/day_03/formatting_strings.py
1,864
4.375
4
#Topic: Formatting strings and processing user input & String interpolation: #Day_2: July/30/2020 #In the name 0f Allah.. #Me: Alifa Ara Heya print("Nikita is 24 years old.") print("{} is {} years old".format("John", 24)) print("My name is {}.".format("Alifa")) output="{} is {} years old, and {} works as a {}." ...
true
4fe2d1fece511b56dc3851f01a2119b4b7575ac7
alifa-ara-heya/My-Journey-With-Python
/day_14/exercise6.py
1,372
4.34375
4
# Day_14: August/10/2020 # In the name 0f Allah.. # Me: Alifa # From: Book : Python for everybody # Chapter:4 (Functions) # Write a program to prompt the user for hours and rate per hour using input to compute gross pay. Pay the hourly rate for the hours up to 40 and 1.5 times the hourly rate for all hours worked abov...
true
1c6b11c96f7f9afb0f6ce92883e0433e78f37042
alifa-ara-heya/My-Journey-With-Python
/day_13/coditional_execution.py
2,354
4.53125
5
# Day_13: August/09/2020 # In the name 0f Allah.. # Me: Alifa # From: Book : Python for everybody # chapter: 3 # Conditional operator: print("x" == "y") # False n = 18 print(n % 2 == 0 or n % 3 == 0) # True (the number is divisible by both 2 and 3) x = 4 y = 5 print(x > y) # False print(not x > y) ...
true
ebfe1976b54c596ca0e4a8355e26f8903e7d42a0
alifa-ara-heya/My-Journey-With-Python
/day_13/exercise 3.1.py
780
4.46875
4
# 3.1 Write a program to prompt the user for hours and rate per hour using input to compute gross pay. Pay the hourly rate for the hours up to 40 and 1.5 times the hourly rate for all hours worked above 40 hours. Use 45 hours and a rate of 10.50 per hour to test the program (the pay should be 498.75). You should use in...
true
439c26ee1127ae5be9cb49356e83e1456f23d71c
Royalsbachl9/Web-page
/dictionary_attack.py
726
4.125
4
#Opens a file. You can now look at each line in the file individually with a statement like "for line in f: f = open("dictionary.txt","r") print("Can your password survive a dictionary attack?") #Take input from the keyboard, storing in the variable test_password #NOTE - You will have to use .strip() to strip whitesp...
true
e0d22fcafd6e0c8ede004ca82ae7ea77165ebc67
Vignesh77/python-learning
/chapter3/src/list_add.py
607
4.34375
4
""" @file :list_add.py @brief :Create the list and add the elements. @author :vignesh """ list_len = input("Enter the length of list :") input_list =[ ] print "Enter the values to list" for index in range(list_len) : list1 = input("") input_list.append(list1) print input_list print "Enter do u w...
true
d3b86b7af656f2fcbf08d7184c04bd0abe1fda81
Daksh/CSE202_DBMS-Project
/pythonConnection.py
1,233
4.34375
4
# Proof of Concept # A sample script to show how to use Python with MySQL import mysql.connector as mysql from os import system, name def clear(): if name == 'nt': # for windows system('cls') else: # for mac and linux system('clear') def createDB(): db = mysql.connect( host = "localhost", user = "ro...
true
b769423ba1874f1202146751959087287fcc8e07
valdergallo/pyschool_solutions
/Tuples/remove_common_elements.py
778
4.40625
4
""" Remove Common Elements ====================== Write a function removeCommonElements(t1, t2) that takes in 2 tuples as arguments and returns a sorted tuple containing elements that are not found in both tuples. Examples >>> removeCommonElements((1,2,3,4), (3,4,5,6)) (1, 2, 5, 6) >>> removeCommonElements(('b','a',...
true
8ebb9a939d3b9070c959fd0af7ce6e7e9c2bf723
ramanuj760/PythonProject
/oops cl1.py
508
4.125
4
class A: #print("this is a parent class") #d={"name":"ram"} "this is a sample string" def __init__(self): print("inside construcor") def display(self): print("inside method") class B(A): pass #a is an instance of class A. A() is an object of class A #calling a default constr...
true
297845ca1a3fc0719816d32e0aa30a324e404299
Aguniec/Beginners_projects
/Fibonacci.py
306
4.21875
4
""" Write a program that asks the user how many Fibonnaci numbers to generate and then generates them. """ number = int(input("Give me a number")) list_of_numbers = [0, 1] for i in range(0, number): a = list_of_numbers[-1] + list_of_numbers[-2] list_of_numbers.append(a) print(list_of_numbers)
true
28f439a0a623ffd4654f51d37a9fe5d5abc84f0f
Aguniec/Beginners_projects
/Reverse Word Order.py
376
4.21875
4
""" Write a program that asks the user for a long string containing multiple words. Print back to the user the same string, except with the words in backwards order. """ def reverse_order(string): words_to_array = string.split() reverse_words_order = a[::-1] return " ".join(reverse_words_order) string...
true
ba0bf66c366c1a195984487975f8ac734263fe52
Prones94/Leet-Code
/vowel_removal.py
2,534
4.25
4
# 1. Remove Vowels From String ''' 1. Restate Problem - Question is asking if given a string, remove all the vowels from that string 'a,e,i,o,u' and then return the string without the vowels 2. Ask Clarifying Questions - How large is the string? - Is there other data types as well besid...
true
20124716905e7280df81672bdfe4b95187a57db6
Anubis84/BeginningPythonExercises
/chapter6/py_chapter6/src/chapter6_examples.py
808
4.53125
5
''' Created on Nov 21, 2011 This file shows some examples of how to use the classes presented in this chapter. @author: flindt ''' # import the classes from Ch6_classes import Omelet,Fridge # making an Omelet # Or in python speak: Instatiating an object of the class "Omelet" o1 = Omelet() print( o1 ) print( o1.ge...
true
8bcdf622949e650a300e33433de3edfbafdfbebd
jdotjdot/Coding-Fun
/programmingchallenge2.py
2,683
4.1875
4
def __init__(): print('''Programming-Challenge-2 J.J. Fliegelman At least starting off with this now, this strikes me as a a textbook example of the knapsack problem. I'll start with that on a smaller scale, and then see how that scales when we go up to 70 users. As we scale to 70 people, it ...
true
d6b4a5b0e05d8305f318b22958eba3dc58b3ff5b
bestcourses-ai/math-through-simulation
/monty-hall.py
1,019
4.34375
4
''' https://en.wikipedia.org/wiki/Monty_Hall_problem Suppose you're on a game show, and you're given the choice of three doors: Behind one door is a car; behind the others, goats. You pick a door, say No. 1, and the host, who knows what's behind the doors, opens another door, say No. 3, which has a goat. He then says t...
true
838819204e66a2e58e3a602e0db827d5120c24ed
bestcourses-ai/math-through-simulation
/hht-or-htt.py
836
4.25
4
''' You're given a fair coin. You keep flipping the coin, keeping tracking of the last three flips. For example, if your first three flips are T-H-T, and then you flip an H, your last three flips are now H-T-H. You keep flipping the coin until the sequence Heads Heads Tails (HHT) or Heads Tails Tails (HTT) appears. ...
true
a2a6008f7c2d7b189bbea9f694f4d7cad454ca0d
rapenumaka/pyhton-cory
/Strings/python_strings.py
2,310
4.4375
4
""" Namespace is a way to implement scope. In Python, each package, module, class, function and method function owns a "namespace" in which variable names are resolved. When a function, module or package is evaluated (that is, starts execution), a namespace is created. Think of it as an "evaluation context". When a fu...
true
e33352708de4d7a14e320021cc983a02f00561cc
yang15/integrate
/integrate/store/order.py
862
4.46875
4
""" Example introduction to OOP in Python """ class Item(object): # count = 0 # static variable def __init__(self, name, num_items, unit_price): self.name = name self.num_items = num_items self.unit_price = unit_price print ('Hello world OOP') # Item.count += 1 ...
true
e336b79128e8b59a036545dade31c816a1e19f42
lukaa12/ALHE_project
/src/BestFirst.py
2,416
4.25
4
import Graph from Path import Path import datetime class BestFirst: """Class representing Best First algorithm It returns a path depending on which country has the highest number of cases on the next day""" def __init__(self, starting_country, starting_date, alg_graph, goal_function): """Initializ...
true
7309a377af0802fee1b441108e9bd1768e0044ba
Athenian-ComputerScience-Fall2020/mad-libs-eskinders17
/my_code.py
1,164
4.15625
4
# Collaborators (including web sites where you got help: (enter none if you didn't need help) # name = input("Enter your name: ") town = input("Enter a name of a town: ") feeling = input("Enter how are you feeling now. Happy, sad or bored: ") trip = input("Enter a place you want to visit: ") friend = input("Enter the n...
true
daeaba5d4388308be9aa532cc91b1d8efa32b6b7
Pocom/Programming_Ex
/9_PalindromeNumber/t_1.py
831
4.375
4
""" Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward. Example 1: Input: 121 Output: true Example 2: Input: -121 Output: false Explanation: From left to right, it reads -121. From right to left, it becomes 121-. Therefore it is not a palindrome. """ ...
true
31fc463b4b6ddf773f3db7ca30d431184562f711
tofritz/example-work
/practice-problems/reddit-dailyprogramming/yahtzee.py
1,614
4.25
4
# The game of Yahtzee is played by rolling five 6-sided dice, and scoring the results in a number of ways. # You are given a Yahtzee dice roll, represented as a sorted list of 5 integers, each of which is between 1 and 6 inclusive. # Your task is to find the maximum possible score for this roll in the upper section of ...
true
4ab26eb65f520448e489c6707fc46fd16c7e6ecd
venkateshchrl/python-practice
/exercises/stringlists.py
269
4.25
4
def reverse(word): revStr = '' for ch in range(len(word)): revStr += word[len(word)-1-ch] return revStr str = input("Enter a word: ") revStr = str[::-1] if revStr == str: print("This is a Palindrome") else: print("This is NOT a Palindrome")
true
7958bb9a2065fafa59e99133a7df9008079f6e95
JavaRod/SP_Online_PY210
/students/Tianx/Lesson8/circle.py
849
4.5625
5
# ------------------------------------------------------------------------# # !/usr/bin/env python3 # Title: Circle.py # Desc: Create a class that represents a simple circle # Tian Xie, 2020-05-11, Created File # ------------------------------------------------------------------------# import math class Circle(object...
true
ec3aac36e8e11d4e5da44a56e9c53588b3ab6877
rajeshsvv/Lenovo_Back
/1 PYTHON/9 PYTHON PROGRAMS/PYTHON PROGRAMS NOUS/5_Guru(regex and unit test logging here)/regex.py
1,919
4.65625
5
print("Hello world") ''' Match Function: This method is used to test whether a regular expression matches a specific string in Python. The re.match(). The function returns 'none' of the pattern doesn't match or includes additional information about which part of the string the match was found. syntax: re.match (...
true
063fc481e2df9783a23b39a2a3ae7b57f2023b1f
rajeshsvv/Lenovo_Back
/1 PYTHON/9 PYTHON PROGRAMS/PYTHON PROGRAMS NOUS/1_Dataflair/Intermediate/Generators.py
885
4.21875
4
#A Python generator is a kind of an iterable, like a Python list or a python tuple. # It generates for us a sequence of values that we can iterate on. # You can use it to iterate on a for-loop in python, but you can’t index it # def counter(): # i=1 # while i<10: # yield i # i+=1 # # for i in c...
true
ed1decde6fc97b53b1ab2026b61be047f22125ca
rajeshsvv/Lenovo_Back
/1 PYTHON/9 PYTHON PROGRAMS/PYTHON PROGRAMS NOUS/1_Dataflair/Beginner/4_tuple_functions.py
1,416
4.28125
4
# Python Tuples Packing b=1,2.0,"three", x,y,z=b print(b) print(type(b)) percentages=(99,95,90,89,93,96) a,b,c,d,e,f=percentages # print(a,b,d,e,f,c) # print(type(percentages)) # print(percentages[1]) # print(percentages[2:-1]) # print(percentages) # print(percentages[:-2]) # print(percentages[2:-3]) # prin...
true
3e1029de5c6d8dd891f5b0265d6f9bd28a2ee562
rajeshsvv/Lenovo_Back
/1 PYTHON/7 PROGRAMMING KNOWLEDGE/11_If_else_if.py
603
4.125
4
''' x=100 if x!=100: print("x value is=",x) else: print("you entered wrong value") ''' ''' x=100 if x==100: print("x is =") print(x) if x>0: print("x is positive") else: print("finish") ''' name=input("Enter Name:") if name=="Arjun": print("The Name is",name) elif name=="Ashok": pri...
true
4ee34cde27b1028f5965db21d5adcd3311859a62
rajeshsvv/Lenovo_Back
/1 PYTHON/2 COREY SCHAFER/PART 1/25_File Objects Reading and Writing.py
2,058
4.59375
5
# File Object How to read and write File in Python using COntext manager # Reading(r) Writing(w) Appending(a) or Reading and Writing(r+) Operations on File Default is Reading if we dont mention anything # context manager use is no need to mention the close the file it automatically take care about that. # with open("t...
true
1c068daa9bc712bd4ce6d49ed728da8666c080a9
rajeshsvv/Lenovo_Back
/1 PYTHON/3 TELUSKO/42_Filter_Map_Reduce.py
1,155
4.34375
4
# program to find even numbers in the list with basic function # def is_even(a): # return a%2==0 # # nums=[2,3,4,5,6,8,9] # # evens=list(filter(is_even,nums)) # print(evens) # program to find even numbers in the list with lambda function # nums=[2,3,4,5,6,8,9] # # evens=list(filter(lambda n:n%2==0,nums)) # prin...
true
3c0c21e334d161aa174acd2875a8b8bf9afdc56d
rajeshsvv/Lenovo_Back
/1 PYTHON/2 COREY SCHAFER/PART 1/4.2_Sets.py
689
4.25
4
# sets are unorder list of items and no duplicates in it means it throws the duplicate values and in output it gives unique values k #strange when we execute each time set its output order will be change strnage right cs_courses={"History","Math","Physics","ComputerScience"} print(cs_courses) cs_courses={"History","...
true
f6e317ef55d8b358a5b2a97a8366375d876d1afd
rajeshsvv/Lenovo_Back
/1 PYTHON/2 COREY SCHAFER/PART 2/33_Generators.py
1,324
4.5
4
# Generators have advantages over Lists # Actual way to find the square root of the numbers # def sqaure_numbers(nums): # result = [] # for i in nums: # result.append(i * i) # return result # my_numbers = sqaure_numbers([1, 2, 3, 4, 5]) # print(my_numbers) # through Generator we can find the s...
true
9f919efc97f5d420ac4e5fe9bcc7894ae34bb20d
dehvCurtis/Fortnight-Choose-Your-Own-Adventure
/game.py
754
4.1875
4
print ("Welcome to Fortnite - Battle Royal") #When the gamer first starts the game print ("Your above Tilted Towers do you jump?.") print('Do you want to jump') ## raw_input gets input from the user ## Here, we take the input, and *assign* it to a variable called 'ans' answer = input("please type yes or no ") ## con...
true
2122beb8f83cb24f1c617d9fb388abdf42becd63
Laurentlsb/Leetcode
/leetcode/editor/en/[101]Symmetric Tree.py
2,992
4.375
4
#Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). # # For example, this binary tree [1,2,2,3,4,4,3] is symmetric: # # # 1 # / \ # 2 2 # / \ / \ #3 4 4 3 # # # # # But the following [1,2,2,null,3,null,3] is not: # # # 1 # / \ # 2 2 # \ \ # 3 ...
true
b27939b3a840c30900ec11f6c41372108c8a78d0
njenga5/python-problems-and-solutions
/Solutions/problem62.py
224
4.46875
4
''' Question 62: Write a program to read an ASCII string and to convert it to a unicode string encoded by utf-8. Hints: Use unicode() function to convert. ''' word = 'Hello world' word2 = unicode(word, 'utf-8') # print(word2)
true
b8b8639b7244a36bce240fd61986e799027c1c4e
njenga5/python-problems-and-solutions
/Solutions/problem47.py
396
4.15625
4
''' Question 47: Write a program which can map() and filter() to make a list whose elements are square of even number in [1,2,3,4,5,6,7,8,9,10]. Hints: Use map() to generate a list. Use filter() to filter elements of a list. Use lambda to define anonymous functions. ''' nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] nums3 =...
true
cd526869d4d51b2b674b9335c89ad71efddde994
njenga5/python-problems-and-solutions
/Solutions/problem59.py
621
4.34375
4
''' Question 59: Assuming that we have some email addresses in the "username@companyname.com" format, please write program to print the company name of a given email address. Both user names and company names are composed of letters only. Example: If the following email address is given as input to the program: john...
true
4eac214e15a3d21aef858726865d0e633c8e799d
njenga5/python-problems-and-solutions
/Solutions/problem49.py
293
4.15625
4
''' Question 49: Write a program which can map() to make a list whose elements are square of numbers between 1 and 20 (both included). Hints: Use map() to generate a list. Use lambda to define anonymous functions. ''' nums = [i for i in range(1, 21)] print(list(map(lambda x: x**2, nums)))
true
878e52902b63ed79cd80fd9ceefe909528bc7abd
njenga5/python-problems-and-solutions
/Solutions/problem28.py
210
4.1875
4
''' Question 28: Define a function that can convert a integer into a string and print it in console. Hints: Use str() to convert a number to string. ''' def convert(n): return str(n) print(convert(5))
true
62ed099d5b99fafc9fa44d21f696402333524451
romitheguru/ProjectEuler
/4.py
821
4.125
4
""" A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest palindrome made from the product of two 3-digit numbers. """ def num_reverse(n): reverse = 0 while n: r = n % 10 n = n // 10 revers...
true
230f3b9c7735deadb877274b1dfc9c6203f407c7
umahato/pythonDemos
/4_MethodAndFunctions/7_argsAndKwargs.py
1,279
4.1875
4
''' def myfunc(a,b): #Return 5% of the sum of a and b return sum((a,b)) * 0.05 print(myfunc(40,60)) def myfunc(*args): return sum(args) * 0.05 print(myfunc(34,53,53)) def myfunc (**kwargs): print(kwargs) if 'fruit' in kwargs: print('My fruit of choise is {}'.format(kwargs['fruit'])) ...
true
cf4bf78e08205d21f77080dc552247a94a3283e4
umahato/pythonDemos
/3_PythonStatements/3_whileLoops.py
909
4.375
4
# While loops will continue to execute a block of code while some condition remain true. # For example , while my pool is not full , keep filling my pool with water. # Or While my dogs are still hungry, keep feeding my dogs. ''' x = 0 while x < 5: print(f'The current value of x is {x}') #x = x +1 x += 1 el...
true
b7f0c53ae0215250ecf91d5f59489c8fd1f8793c
SilviaVazSua/Python
/Basics/coding_life.py
376
4.15625
4
# a program about something in real life :D number_of_stairs_1_2 = int(input("Tell me how many stairs from floor 1 to floor 2, please: ")) floor = int(input("In which floor you live? ")) total_stairs = number_of_stairs_1_2 * floor print("Then, if the elevator doesn\'t work, you will have ", total_stairs, "until you...
true
247b7c1a9aba17644415a90f117b4d327e3f332d
SilviaVazSua/Python
/Basics/leap_years.py
719
4.25
4
# This program asks for a starting year and an ending year and then puts all the leap years between them (and including them, if they are also leap years). Leap years are years divisible by 4 (like 1984 and 2004). However, years divisible by 100 are not leap years (such as 1800 and 1900) unless they are also divisible ...
true
43c40e8eb46f891023aea282aa8fff1e081581fc
razvanalex30/Exercitiul3
/test_input_old.py
1,138
4.21875
4
print("Hi! Please choose 1 of these 3 inputs") print("1 - Random joke, 2 - 10 Random jokes, 3 - Random jokes by type") while True: try: inputus = int(input("Enter your choice: ")) if inputus == 1: print("You have chosen a random joke!") break elif inputus == 2: print("You have chos...
true
a70be84406ab8fdf4944f6030533fbda0297b11e
ashishp0894/CS50
/Test folder/Classes.py
910
4.125
4
"""class point(): #Create a new class of type point def __init__(self,x_coord,y_coord): #initialize values of class self.x = x_coord self.y = y_coord p = point(10,20) q = point (30,22) print(f"{p.x},{p.y} ") """ class flight(): def __init__(self,capacity): self.capacity = capacity ...
true
23f6a8643e06ed18a73c9bf1519b9719e0a3283c
christophe12/RaspberryPython
/codeSamples/fileManipulation/functions.py
933
4.25
4
#----handy functions---- #The os() function #os.chdir('directory_name') -> changes your present working directory to directory_name #os.getcwd() -> provides the present working directory's absolute directory reference #os.listdir('directory_name') -> provides the files and subdirectories located in directory_name. if...
true
ff0e7cbbf0cff9dd00e60a14d1382e52aac4331f
SuryakantKumar/Data-Structures-Algorithms
/Functions/Check_Prime.py
554
4.21875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Dec 24 05:36:47 2019 @author: suryakantkumar """ ''' Problem : Write a function to check whether the number N is prime or not. Sample Input 1 : 5 Sample output 1 : prime Sample input 2 : 4 Sample output 2: Not Prime ''' def IsPrime(n): if n...
true
1c4ccd633778efae1e6d402385ff2eb10a509c91
SuryakantKumar/Data-Structures-Algorithms
/Exception Handling/Else-And-Finally-Block.py
1,101
4.1875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Mar 7 14:42:20 2020 @author: suryakantkumar """ while True: try: numerator = int(input('Enter numerator : ')) denominator = int(input('Enter denominator : ')) division = numerator / denominator except Valu...
true
b895e3cd708cd102baaf7f4126f4d1a13c32e889
SuryakantKumar/Data-Structures-Algorithms
/Object Oriented Programming/Class-Method.py
1,374
4.25
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Jan 6 06:20:20 2020 @author: suryakantkumar """ from datetime import date class Student: def __init__(self, name, age, percentage = 80): # Init method self.name = name self.age = age self.percentage = percentage ...
true
0beb688b4af8803550204cf01f8879b8f327050e
SuryakantKumar/Data-Structures-Algorithms
/Functions/Fahrenheit_To_Celcius.py
878
4.1875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Dec 24 07:44:35 2019 @author: suryakantkumar """ ''' Problem : Given three values - Start Fahrenheit Value (S), End Fahrenheit value (E) and Step Size (W), you need to convert all Fahrenheit values from Start to End at the gap of W, into their correspo...
true
2450c7cccafa7d66157ef16b35ced3b903ee0b60
SuryakantKumar/Data-Structures-Algorithms
/Searching & Sorting/Insertion-Sort.py
1,120
4.25
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Jan 1 08:42:58 2020 @author: suryakantkumar """ ''' Problem : Given a random integer array. Sort this array using insertion sort. Change in the input array itself. You don't need to return or print elements. Input format : Line 1 : Integer N, Array S...
true