blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
8a527fd405d5c59c109252f58527d9b4d5e73eeb | sahaib9747/Random-Number-Picker | /App_Manual.py | 607 | 4.125 | 4 | # starting point
import random
number = random.randint(1, 1000)
attempts = 0
while True: # infinite loop
input_number = input("Guess the number (berween 1 and 1000):")
input_number = int(input_number) # converting to intiger
attempts += 1
if input_number == number:
print("Yes,Your guess is c... | true |
19eff193956da31d7bf747a97c0c0a7fe5da9f91 | Sukhrobjon/Codesignal-Challenges | /challenges/remove_duplicates.py | 433 | 4.1875 | 4 | from collections import Counter
def remove_all_duplicates(s):
"""Remove all the occurance of the duplicated values
Args:
s(str): input string
Returns:
unique values(str): all unique values
"""
unique_s = ""
s_counter = Counter(s)
for key, value in s_counter.items():
... | true |
e18278d472ab449a3524864656540432b7efbfb9 | robinsuhel/conditionennels | /conditionals.py | 365 | 4.34375 | 4 | name = input("What's your name: ")
age = int(input("How old are you: "))
year = str(2017-age)
print(name + " you born in the year "+ year)
if age > 17:
print("You are an adult! You can see a rated R movie")
elif age < 17 and age > 12:
print("You are a teenager! You can see a rated PG-13 movie")
else:
print("You are... | true |
43264f35f210963e7b6aeda37a534bc52302fec5 | wscheib2000/CS1110 | /gpa.py | 966 | 4.21875 | 4 | # Will Scheib wms9gv
"""
Defines three functions to track GPA and credits taken by a student.
"""
current_gpa = 0
current_credit_total = 0
def add_course(grade, num_credit=3):
"""
This function adds a class to the gpa and credit_total variables, with credits defaulting to 3.
:param grade: Grade in the ... | true |
583480d2f366d7fcbf1a9f16c03c40c8e3f1248b | SeanLuTW/codingwonderland | /lc/lc174.py | 2,254 | 4.15625 | 4 | """
174. Dungeon Game
The demons had captured the princess (P) and imprisoned her in the bottom-top corner of a dungeon. The dungeon consists of M x N rooms laid out in a 2D grid. Our valiant knight (K) was initially positioned in the top-left room and must fight his way through the dungeon to rescue the princess.
The... | true |
30a665a286f0dcd8bd5d60d78fae0d1669f2e0c1 | SeanLuTW/codingwonderland | /lc/lc1464.py | 761 | 4.25 | 4 | """
1464. Maximum Product of Two Elements in an Array
Given the array of integers nums, you will choose two different indices i and j of that array. Return the maximum value of (nums[i]-1)*(nums[j]-1).
Example 1:
Input: nums = [3,4,5,2]
Output: 12
Explanation: If you choose the indices i=1 and j=2 (indexed from ... | true |
a0f06e65c70862194f25bee20a4ad1eed82ae586 | dharmit/Projects | /Numbers/mortgage.py | 460 | 4.25 | 4 | #!/usr/bin/env python
def mortgage_calculator(months, amount, interest):
final_amount = amount + ((amount * interest)/100)
return int(final_amount / months)
if __name__ == "__main__":
amt = int(raw_input("Enter the amount: "))
interest = int(raw_input("Enter the interest rate: "))
months = int(ra... | true |
baf234ed556488a5d5a8f1229b5bf69958b232e1 | krakibe27/python_objects | /Bike.py | 802 | 4.125 | 4 | class Bike:
def __init__(self,price,max_speed):
self.price = price
self.max_speed = max_speed
self.miles = 200
#self.miles = self.miles + self.miles
def displayInfo(self):
print "Price :", self.price
print "max_speed :" + self.max_speed
print "total ... | true |
832a79bbaf9f1961dc580f064efbf1903057d803 | OnurcanKoken/Python-GUI-with-Tkinter | /6_Binding Functions to Layouts.py | 1,154 | 4.3125 | 4 | from tkinter import * #imports tkinter library
root = Tk() #to create the main window
#binding a function to a widget
#define a function
def printName():
print("My name is Koken!")
#create a button that calls a function
#make sure there is no parantheses of the function
button_1 = Button(root, text="Print my na... | true |
36c4a847bad96bae252543ca9c12fb6ac5dc1abc | Juan55Camarillo/pattern-designs | /strategy.py | 1,433 | 4.625 | 5 | '''
Strategy pattern designs example
it allows make an object can behave in different ways
(which will be define in the moment of its instantiation or make)
'''
from __future__ import annotations
from abc import ABC, abstractmethod
from typing import List
class Map():
def __init__(self, generateMap: Ge... | true |
a34063f6b6ba6e086b633508fad186b4e9622df7 | sachinsaini4278/Data-Structure-using-python | /insertionSort.py | 622 | 4.15625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Mar 2 07:18:31 2019
@author: sachin saini
"""
def insertion_sort(inputarray):
for i in range(size):
temp=inputarray[i]
j=i
while(inputarray[j-1]>temp and j >=1):
inputarray[j]=inputarray[j-1];
j=j-1
i... | true |
9259a3b6575504831a6c9a4601035771b48e1ced | mattwright42/Decorators | /decorators.py | 1,560 | 4.15625 | 4 | # 1. Functions are objects
# def add_five(num):
#print(num + 5)
# add_five(2)
# 2. Functions within functions
# def add_five(num):
# def add_two(num):
# return num + 2
#num_plus_two = add_two(num)
#print(num_plus_two + 3)
# add_five(10)
# 3. Returning functions from functions
# def get_math_function(operati... | true |
db09cc8134b15bce20a0f6f74d73e67e2ec723ee | The-Coding-Hub/Comp-Class-Code-Notes | /Python/q1.py | 451 | 4.4375 | 4 | # Enter 3 number and print the greatest one.
n1 = int(input("Number 1: "))
n2 = int(input("Number 2: "))
n3 = int(input("Number 3: "))
if n1 > n2 and n1 > n3:
print(f"{n1} is largest")
if n2 > n1 and n2 > n3:
print(f"{n2} is largest")
if n3 > n2 and n3 > n1:
print(f"{n3} is largest")
# OR
if n1 > n2 and... | false |
da463aae470f86a5d4bc9a9175f6c4b32f71f323 | The-Coding-Hub/Comp-Class-Code-Notes | /Python/calculator.py | 438 | 4.4375 | 4 | # Simple Calculator
num_1 = float(input("Number 1: "))
num_2 = float(input("Number 2: "))
operator = input("Operator (+, -, *, /): ")
result = None
if (operator == "+"):
result = num_1 + num_2
elif (operator == "-"):
result = num_1 - num_2
elif (operator == "*"):
result = num_1 * num_2
elif (operator == "/"):
... | false |
f5edb7b29e99421eff0a071312619d011e833038 | lucipeterson/Rock-Paper-Scissors | /rockpaperscissors.py | 2,800 | 4.125 | 4 | #rockpaperscissors.py
import random
print("~~ Rock, Paper, Scissors ~~")
weapon_list = ["rock", "paper", "scissors"]
user = input("Rock, paper, or scissors? ")
while user.lower() not in weapon_list:
user = input("Rock, paper, or scissors? ")
computer = random.choice(weapon_list)
print("Computer chooses " + comput... | true |
05e109d5d83c0e438b89cdb3e6d4f650885eae16 | jdb158/problems | /problem108-try2.py | 1,246 | 4.15625 | 4 | import math
primes = [2,3]
largestprime = 3
def main():
test = 80
pflist = primeFactors(test)
print (pflist)
def primeFactors(number):
factors = []
global largestprime # grab our largest generated prime
# check already generated primes
while (number > 1):
for i in primes:
if (number % i == 0)... | false |
ef949c39755d56c5dbf3ef5bd9212bfb36a2df92 | aseemchopra25/Integer-Sequences | /Juggler Sequence/juggler.py | 706 | 4.21875 | 4 | # Program to find Juggler Sequence in Python
# Juggler Sequence: https://en.wikipedia.org/wiki/Juggler_sequence
# The juggler_sequence function takes in a starting number and prints all juggler
# numbers starting from that number until it reaches 1
# Keep in mind that the juggler sequence has been conjectured to reach... | true |
f013a0c4604d3a39edf17405d34a5a1ff4722167 | aseemchopra25/Integer-Sequences | /Golomb Sequence/Golomb.py | 1,460 | 4.25 | 4 | # A program to find the nth number in the Golomb sequence.
# https://en.wikipedia.org/wiki/Golomb_sequence
def golomb(n):
n = int(n)
if n == 1:
return 1
# Set up a list of the first few Golomb numbers to "prime" the function so to speak.
temp = [1, 2, 2, 3, 3]
# We will be modifying the li... | true |
0b8cfda80341f33b7ec168156f82dcc2dc32e618 | anildhaker/DailyCodingChallenge | /GfG/Mathematical Problems/fibMultpleEff.py | 695 | 4.21875 | 4 | # Efficient way to check if Nth fibonacci number is multiple of a given number.
# for example multiple of 10.
# num must be multiple of 2 and 5.
# Multiples of 2 in Fibonacci Series :
# 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 ….
# every 3rd number - is divisible by 2.
# Multiples of 5 in Fibonacci ... | true |
87e12cbe64f2cfcdf00157e8bc34e39485f64773 | anildhaker/DailyCodingChallenge | /GfG/Mathematical Problems/makePerfectSq.py | 842 | 4.1875 | 4 | # Find minimum number to be divided to make a number a perfect square.
# ex - 50 dividing it by 2 will make it perfect sq. So output will be 2.
# A number is the perfect square if it's prime factors have the even power.
# all the prime factors which has the odd power should be multiplied and returned(take 1 element ... | true |
014cad9a68bf6b18ab7d860dff49d1e1393137eb | anildhaker/DailyCodingChallenge | /GfG/Mathematical Problems/primeFactors.py | 401 | 4.25 | 4 | # for 12 -- print 2,2,3
import math
def primeFactors(n):
while n % 2 == 0 and n > 0:
print(2)
n = n // 2
# n becomes odd after above step.
for i in range(3, int(math.sqrt(n) + 1), 2):
while n % i == 0:
print(i)
n = n // i
# until this stage all the composite numbers ha... | false |
bc28541b378f69e1b7ef435cff0f4094c4ca75e2 | PSDivyadarshini/C-97 | /project1.py | 298 | 4.21875 | 4 | myString=input("enter a string:")
characterCount=0
wordCount=1
for i in myString :
characterCount=characterCount+1
if(i==' '):
wordCount=wordCount+1
print("Number of Word in myString: ")
print(wordCount)
print("Number of character in my string:")
print(characterCount)
| true |
119132fefe6c5cb1a977f2128e39676187b178f4 | suryaprakashgiri01/Mini-Calculator | /calc.py | 1,375 | 4.1875 | 4 |
# This is a Mini calculator
print()
print(' ------------------------------------------------------------------')
print(' | Welcome to the mini calculator |')
print(' | Code By : SP |')
print(' ---------------------------... | false |
8aff8f034cb41fa3efa60a2441b29e8cd056d3aa | katteq/data-structures | /P2/problem_1.py | 1,315 | 4.34375 | 4 | def sqrt(number):
"""
Calculate the floored square root of a number
Args:
number(int): Number to find the floored squared root
Returns:
int: Floored Square Root
"""
if number == 0 or number == 1:
return number
start = 0
end = number
res = 0
i = 0
whil... | true |
23766aad682eccf45ca95ba6cd539d82568a7192 | blbesinaiz/Python | /displayFormat.py | 286 | 4.125 | 4 | #Program Title: Formatted Display
#Program Description: Program takes in a string, and outputs the text
# with a width of 50
import sys
string = input("Please enter a string: ")
for i in range(10):
sys.stdout.write('['+str(i)+']')
print(string)
| true |
e2b69836a22a3feda9a41bdc13c7a7761a276faf | tomcusack1/python-algorithms | /Arrays/anagram.py | 841 | 4.125 | 4 | def anagram(str1, str2):
'''
Anagram function accepts two strings
and returns true/false if they are
valid anagrams of one another
e.g. 'dog' and 'god' = true
:string str1:
:string str2:
:return: boolean
'''
str1 = str1.replace(' ', '').lower()
str2 = str2.replace(' ', '').l... | true |
b66019522fe2066decb573e28901a0014f73f41d | guilmeister/holbertonschool-higher_level_programming | /0x01-python-if_else_loops_functions/8-uppercase.py | 274 | 4.15625 | 4 | #!/usr/bin/python3
def uppercase(str):
result = ''
for letters in str:
if ord(letters) >= 97 and ord(letters) <= 122:
result = result + chr(ord(letters) - 32)
else:
result = result + letters
print("{:s}".format(result))
| true |
dac58c8d8c1ad1f712734e2d33407c270ba38aae | cloudavail/snippets | /python/closures/closure_example/closure_example.py | 1,039 | 4.375 | 4 | #!/usr/bin/env python
# objective: create and explain closures and free variables
def add_x(x):
def adder(num):
# closure:
# adder is a closure
#
# free variable:
# x is a free variable
# x is not defined within "adder" - if "x" was defined within adder
# if... | true |
293ae711c7822c3d67b20ae236d6c9d4445b4ee7 | sonalisharma/pythonseminar | /CalCalc.py | 2,514 | 4.3125 | 4 | import argparse
import BeautifulSoup
import urllib2
import re
def calculate(userinput,return_float=False):
"""
This methos is used to read the user input and provide and answer. The answer is computed dircetly
using eval method if its a numerical expression, if not the wolfram api is used to get the appropriate ans... | true |
e06b35be36c3eed153be97a95a5aa802b9c33008 | khanma1962/Data_Structure_answers_Moe | /100 exercises/day10.py | 2,799 | 4.34375 | 4 | '''
Question 31
Question:
Define a function which can print a dictionary where the keys are numbers between
1 and 20 (both included) and the values are square of keys.
'''
def print_dict(start = 1, end = 20):
d = {}
for i in range(start, end+1):
# print(i)
d[i] = i ** 2
print(d)
# print_d... | true |
3e19b68db20afb1391f15588b5b559546479eb76 | 3l-d1abl0/DS-Algo | /py/Design Patterns/Structural Pattern/decorator.py | 1,356 | 4.25 | 4 | '''
Decorator Pattern helps us in adding New features to an existing Object Dynamically,
without Subclassing.
The idea behind Decorator Patter is to Attach additional responsibilities to an object Dynamically.
Decorator provide a flexible alternative to subclassing for extending Functionality.
'''
class WindowInterf... | true |
a9c3eaf87fb86da5486d03a66ca702d6d27f083e | Nikoleta-v3/rsd | /assets/code/src/find_primes.py | 697 | 4.3125 | 4 | import is_prime
import repeat_divide
def obtain_prime_factorisation(N):
"""
Return the prime factorisation of a number.
Inputs:
- N: integer
Outputs:
- a list of prime factors
- a list of the exponents of the prime factors
"""
factors = []
potential_factor = 1
... | true |
4923d24d114c3ce22708e6f941fe5cc89e660547 | EmonMajumder/All-Code | /Python/Guest_List.py | 1,399 | 4.125 | 4 | #Don't forget to rename this file after copying the template for a new program!
"""
Student Name: Emon Majumder
Program Title: IT Programming
Description: Data_to_file
"""
def main(): #<-- Don't change this line!
#Write your code below. It must be indented!
fileName=input("File Name: ")
accessMode=input("A... | true |
e1457e85ef66c4807ffcb5446b89813e27644908 | EmonMajumder/All-Code | /Python/Leap_Year.py | 1,319 | 4.4375 | 4 | #Don't forget to rename this file after copying the template for a new program!
"""
Student Name: Emon Majumder
Program Title: IT Programming
Description: Leap_year
"""
#Pseudocode
# 1. Define name of the function
# 2. Select variable name
# 3. Assign values to 3 variable for input %4, 100 & 400
# 4. determine if inpu... | true |
0182b73ebf8268ed9fd3ecb5fb18fe3feaf0ba84 | LarisaOvchinnikova/Python | /HW11 - lottery and randoms/methods strptime and strftime.py | 1,651 | 4.15625 | 4 | from datetime import datetime, date, timedelta
today = datetime.today()
print(str(today)) # 2020-05-10 20:46:17.842205
print(type(str(today))) # <class 'str'>
# strftime - переводим время из формата datetime в строку
today = today.strftime("%B %d, %Y") # %B - полный месяц, % d - номер дня, %Y год
print(today) # "Ma... | false |
a595f993f1f05e9bd3552213aca426ca69610ab1 | LarisaOvchinnikova/Python | /HW2/5 - in column.py | 401 | 4.3125 | 4 | # Print firstname, middlename, lastname in column
firstName = input("What is your first name? ")
middleName = input("What is your middle name? ")
lastName = input("What is your last name? ")
m = max(len(firstName), len(lastName), len(middleName))
print(firstName.rjust(m))
print(middleName.rjust(m))
print(lastName.rjus... | true |
e2b2a0b23cc2271707705eb92870c6a1a5a34d9f | LarisaOvchinnikova/Python | /HW12 (datetime)/2 - Transorm datetime into a string.py | 584 | 4.3125 | 4 | from datetime import datetime
# strftime - переводим время из формата datetime в строку
today = datetime.today()
print(today)
year = today.strftime("%Y")
print(f"year: {year}")
month = today.strftime("%m")
print(f"month: {month}")
day = today.strftime("%d")
print(f"day: {day}")
time = today.strftime("%I:%M:%S") #12-... | false |
97a0e169f4df4ea8a11dd6ff0db8d627d92ffcf4 | LarisaOvchinnikova/Python | /strings/string.py | 1,032 | 4.34375 | 4 | s = "Hi "
print(s * 3)
print('*' * 5)
num = 6
num = str(num)
print(num)
print("Mary\nhas\na\nlittle\nlamb ")
print("I\'m great")
print("I have a \"good\" weight")
print(len("hello"))
name = "Lara"
print(name[0])
print(name[len(name)-1])
print(name.index("a"))
indexOfR = name.index('r')
print(indexOfR)
# Python console:... | false |
ef36ed78ceee68ae2d14c1bb4a93605c164c9795 | LarisaOvchinnikova/Python | /1 - Python-2/10 - unit tests/tests for python syntax/variable assignment1.py | 682 | 4.15625 | 4 | # Name of challenger
# Variable assignment
# Create a variable with the name `pos_num` and assign it the value of any integer positive number in the range from 10 to 200, both inclusive.
#Open test
class TestClass(object):
def test_1(self):
"""Type of variable is int"""
assert type(pos_num) == in... | true |
855ba74add997a86ac15e0e9627cc3b1fb1ff388 | LarisaOvchinnikova/Python | /1 - Python-2/19 - arguments/from lesson.py | 752 | 4.28125 | 4 | # def func(x=10, y=20): #дефолтные значения без пробелов
# return x + y
#
# print(func(8, 5)) # 13
# print(func(12)) # 32
# print(func()) # 30
# def func(x, y, z=1): # все дефолтные справа
# return (((x, y),) * z)
#
# print(func(1,2,3)) #((1, 2), (1, 2), (1, 2))
# print(func(1,2)) # ((1, 2),)
# def func(... | false |
04f9664ad8d43e67c386a917ee8b28127b32315d | LarisaOvchinnikova/Python | /1 - Python-2/4 - strings functions/Determine the properties of a string.py | 1,124 | 4.25 | 4 | #Print word " has lowercase letters" if it has only lowercase alphabet characters
# Print word " has uppercase letters"
# if it has only uppercase alphabet characters
# Print word " has so many letters. Much wow."
# if it has both uppercase and lowercase alphabet characters but no digits
# Print word " has digits" if
#... | true |
6f276eac15ebf4813598a2fc867dbac8843b69d9 | LarisaOvchinnikova/Python | /Sets/sets from lesson.py | 2,564 | 4.5 | 4 | # set is unordered(unindexed), mutable collection of data items
# (items - inmutable - numbers, strings, tuples, boolean)
# set contains only unique values
x = {1, "hello", 3, 5, "world"}
print(len(x))
# to create new empty set, use set() function
x = set()
#length of the set
print(len(x)) # ---> 0
x = {1,1,1,1}
... | false |
703bd7118ff467dc98f9b6a3802ca1b74df9e2a5 | itsmesanju/pythonSkills | /leetCode/7.reverseInteger.py | 912 | 4.15625 | 4 | '''
Given a 32-bit signed integer, reverse digits of an integer.
Note:
Assume we are dealing with an environment that could only store integers within the 32-bit signed integer range: [−231, 231 − 1]. For the purpose of this problem, assume that your function returns 0 when the reversed integer overflows.
Example ... | true |
132c2bba74dfd857faaf3ed42033376e3e9dfb0c | ACNoonan/PythonMasterclass | /ProgramFlow/aachallenge.py | 287 | 4.21875 | 4 | number = 5
multiplier = 8
answer = 0
# iterate = 0
# add your loop after this comment
# My Soultion:
# while iterate < multiplier:
# answer += number
# iterate += 1
# The solution she told you not to worry about
for i in range(multiplier):
answer += number
print(answer)
| true |
03b78a88aad855b84b82a2fda9673e807012bc5d | ACNoonan/PythonMasterclass | /Sets/sets.py | 2,625 | 4.375 | 4 | # # # 2 Ways to Create Sets:
# #
# # farm_animals = {'sheep', 'cow', 'hen'}
# # print(farm_animals)
# #
# # for animal in farm_animals:
# # print(animal)
# #
# # print('-' * 40)
# #
# # wild_animals = set(['lion', 'tiger', 'panther',
# # 'elephant', 'hare'])
# # print(wild_animals)
# #
# # for a... | false |
e548491168889093d7cfee3532810a4af1a92051 | ACNoonan/PythonMasterclass | /Lists/tuples.py | 1,032 | 4.40625 | 4 | # # Tuples are IMMUTABLE
# # Declaring a tuple w/o parenthesis
# t = "a", "b", "c"
# print(t)
#
#
# print("a", "b", "c")
# # Declaring a tuple w/ parenthesis
# print(("a", "b", "c"))
# Tuples w/o parenthesis w/ multiple data types
welcome = 'Welcome to my Nightmare', 'Alice Cooper', 1975
bad = 'Bad Company', 'Bad Comp... | false |
915de4df06984d86f0237064bb6d0bf015a1d893 | v2webtest/python | /app.py | 307 | 4.25 | 4 | print("Starting programme..")
enType: int = int(input("\n\nEnter program type.. ").strip())
print(enType)
# Checking of Type and printing message
if enType == 1:
print("-- Type is First.")
elif enType == 2:
print("-- Type is Second.")
else:
print("-- Unknown Type!")
print("End of program.")
| true |
b9be0492e6edd04f2f5bf78d3ea0ec63915baed4 | Ayon134/code_for_Kids | /tkinter--source/evet.py | 649 | 4.3125 | 4 | #handling button click
#when you press button what will happen
import tkinter
#create a window
window = tkinter.Tk()
window.title("Welcome to Tkinter World :-)")
window.geometry('500x500')
label = tkinter.Label(window, text = "Hello Word!", font=("Arial Bold", 50))
label.grid(column=0, row=0)
def clicked():
... | true |
9df7f613f1f637be2df86dd57d4b255abd91b932 | infantcyril/Python_Practise | /Prime_Count_Backwards.py | 2,061 | 4.1875 | 4 | check_a = 0
a = 0
def prim(check,a):
check_a = 0
while (check_a == 0):
try:
check_a = 1
a = int(input("Enter the Number from where you want to start searching: "))
if (a <= 2):
check_a = 0
print("Please enter a value greater t... | true |
137820c8f3df39e0456ad149c8003925985bd0fb | infantcyril/Python_Practise | /Prime_Number.py | 1,151 | 4.15625 | 4 | check_a = 0
a = 0
def prime(check,a):
check_a = 0
while (check_a == 0):
try:
check_a = 1
a = int(input("Enter the Number from where you want to start searching: "))
if (a <= 1):
check_a = 0
print("Please enter a value greater ... | false |
722d462d7142bc66c5abcbcf23867507d5f116cb | r4isstatic/python-learn | /if.py | 417 | 4.4375 | 4 | #!/usr/bin/env python
#This takes the user's input, stores it in 'name', then runs some tests - if the length is shorter than 5, if it's equal to, and if it equals 'Jesse'.
name = raw_input('Please type in your name: ')
if len(name) < 5:
print "Your name is too short!"
elif len(name) == 5:
print "Your name is the ... | true |
1c9ec18cd80266e53d4e2f01d73dc0c9fb0099f0 | npradaschnor/algorithms_module | /caesar_cipher.py | 960 | 4.34375 | 4 | # Based on Caesar's Cipher
#Substitution cipher in which each letter in the plaintext is replaced by a letter some fixed number (offset) of positions down the alphabet.
#In this case is upper in the alphabet
def encrypt(plain_text, offset):
cipher_text = ""
for i in plain_text: #for every char in text inputted
... | true |
3bbce6604801ae9019975edc3ce0e07ea347b90c | npradaschnor/algorithms_module | /odd_position_elements_array.py | 1,141 | 4.15625 | 4 | #Write an algorithm that returns the elements on odd positions in an array.
#Option 1 using 2 functions
def range_list(array):
array = range(0,len(array))
i = []
for e in array:
i.append(e)
return i
def odd_index(array):
oddl = []
a = range_list(array)
for n in a:
if n%2 != 0: #... | true |
ea07e7f7353344e90bbc9e4b0ccdff5ebc22a87f | npradaschnor/algorithms_module | /merge.py | 561 | 4.1875 | 4 | #recursive function that returns a merged list (1 element of str1 + 1 element of str2...and so on)
def merge(str1,str2):
if len(str1) == 0: #if the number of element in the str1 is zero, return str2
return str2
elif len(str2) == 0: # if the number of element in the str2 is zero, return str1
return str1
... | true |
4657fb179ddf454b1e09b4e501028a70fdcc3062 | rnem777/python-project | /class_try.py | 743 | 4.25 | 4 | #it is to modify between the subject and the behaviour
# the name has always to stat with cabital litter
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
def walk(self):#self here will give us access to name
print(self.name + ' is a student at sunderla... | false |
360bb0aae3cf4d6aa936a500cdb2e0c716dbbaac | Morgan1you1da1best/unit2 | /unitConverter.py | 439 | 4.21875 | 4 | #Morgan Baughman
#9/15/17
#unitConverter.py - COnverting Units of stuff
a = ('1) Kilotmeters to Miles')
b = ('2) Kilograms to Pounds')
c = ('3) Liters to Gallons.')
d = ('4) Celsius to Fahrenheit')
print('choose a convertion.')
print('a) Kilotmeters to Miles')
print('b) Kilograms to Pounds')
print('c) Liters to Gallo... | false |
9a892afe4a0528cbd26ebba1d5861b54e358cecd | Morgan1you1da1best/unit2 | /warmUp3.py | 336 | 4.34375 | 4 | #Morgan Baughman
#9/15/17
#warmUp3.py - practicing if statements
num = int(input('Enter a number: '))
if num% 2 == 0 and num% 3 == 0:
print(num, 'is divisible by both 2 and 3')
elif num% 2 == 0:
print(num, 'is divisible by 2')
elif num% 3 == 0:
print(num, 'is divisible by 3')
else:
print(num , 'is divi... | false |
7ca02e4f2af417d3a67f16cd90e3f87c722515c2 | Necron9x11/udemy_pythonWorkbook100Exercises | /ex-20/ex-20.py | 1,065 | 4.15625 | 4 | #!/usr/bin/env python3
#
# Python Workbook - 100 Exercises
# Exercise # NN
#
# Points Value: NN
#
# Author: Daniel Raphael
#
# ---------------------------------------------------------------------------------------------------------------------
#
# Question: Calculate the sum of all dictionary values.
#
# d = {"a"... | true |
7db32d46a6e1435dd916719ac8093b32206e4688 | hfu3/text-mining | /Session12/anagrams.py | 945 | 4.375 | 4 | """
1. read the file, save the words into a list
2. (option 1) count letters for each word
'rumeer' -> 6
'reemur' - 6
'kenzi' -> 5
(option2) sort the word
'rumeer' -> 'eemrru' sig
'reemur' - 'eemrru' sig
'kenzi' -> 'ekinz' sig
create empty list for each signature
expected:
['rumeer', 'reemur']
['kenzi']
4. creat... | true |
54861c9c20c34fb60f1507432dec0e7db836758a | kalebinn/python-bootcamp | /Week-1/Day 3/linear_search.py | 1,164 | 4.25 | 4 | # TODO: Write a function that takes a integer and a list as the input.
# the function should return the index of where the integer was found
# on the list
def search(x, list):
"""
this function returns the index of where the element x was found
on the list.
\tparam : x - the element you're searching fo... | true |
c9f4678ea364b027e5577856fe95ac2fd07c23e0 | kalebinn/python-bootcamp | /Week-1/Day 1/4-loops.py | 265 | 4.1875 | 4 | counter = 0
while counter <= 0:
print(counter)
counter += 1
# range(start, stop, increment)
print("using three inputs to range()")
for number in range(0,5,1):
print(number)
print("using one input to range()")
for number in range(5):
print(number) | true |
6626cc27b8cd0fb44aa658cf215aa65a33c003ad | rivet9658/Rivet9658-Python-University-Works | /Python Final Test/python final test 第三題.py | 226 | 4.125 | 4 | #python final test 第三題
print("輸入字串:")
str=input()
print("輸入要取代的字串:")
ch=input()
print("輸入取代的字串:")
bh=input()
if ch in str:
print(str.replace(ch,bh))
else:
print("not found")
| false |
d8ca838e737250e107433c0cd070aafcbdd74c56 | Muratozturknl/8.hafta_odevler-Fonksiyonlar | /week8_11_func_ozgunelaman.py | 424 | 4.125 | 4 | # Verilen bir listenin içindeki özgün elemanları ayırıp
# yeni bir liste olarak veren bir fonksiyon yazınız.
# Örnek Liste : [1,2,3,3,3,3,4,5,5]
# Özgün Liste : [1, 2, 3, 4, 5]
def ozgunlist(a):
list = []
for i in a:
if i not in list:
list.append(i)
return list
a = [1,2,2,4,1,4,1029,5,... | false |
e05b380f577208e1df340765ae6a0232b7c5b7f4 | Katezch/Python_Fundamentals | /python_fundamentals-master/02_basic_datatypes/2_strings/02_07_replace.py | 382 | 4.34375 | 4 | '''
Write a script that takes a string of words and a symbol from the user.
Replace all occurrences of the first letter with the symbol. For example:
String input: more python programming please
Symbol input: #
Result: #ore python progra##ing please
'''
s = input(" please input words here: ")
symbol = input("please ... | true |
8b8af177b6a6b2af1f96d5d9c75d7b166f1e15ab | Katezch/Python_Fundamentals | /python_fundamentals-master/07_classes_objects_methods/07_01_car.py | 852 | 4.4375 | 4 | '''
Write a class to model a car. The class should:
1. Set the attributes model, year, and max_speed in the __init__() method.
2. Have a method that increases the max_speed of the car by 5 when called.
3. Have a method that prints the details of the car.
Create at least two different objects of this Car class and dem... | true |
14d06fa26fb51aecf4a59fa232e410742d8c0487 | nietiadi/svm4r | /old/proving.py | 1,023 | 4.125 | 4 | #!/usr/bin/python3
"""
using ctl-rp to prove all proofs and give the answer, which is either 'sat' or 'unsat'
"""
import itertools
import csv
def proving(num_of_propositions=2, with_empty_clause=False):
"""
create the csv file containing the results from ctl-rp
"""
if with_empty_clause:
fname = 'data/pro... | true |
caa45bf56cd1b83f43c9ee05ebd9c618b74f8527 | rtejaswi/python | /rev_str_loop.py | 794 | 4.34375 | 4 | '''str = "Python"
reversedString=[]
index = len(str) # calculate length of string and save in index
while index > 0:
reversedString += str[ index - 1 ] # save the value of str[index-1] in reverseString
index = index - 1 # decrement index
print(reversedString) # reversed string'''
'''str = 'Python' #initial s... | true |
6c1b6b9a6c235826ace320eae96868b1a754a05d | gregorybutterfly/examples | /Decorators/1-python-decorator-example.py | 886 | 4.46875 | 4 | #!/usr/bin/python
""" A very simple example of how to use decorators to add additional functionality to your functions. """
def greeting_message_decorator(f):
""" This decorator will take a func with all its contents and wrap it around WRAP func.
This will create additional functionality to the 'greeting_mess... | true |
3f78094152b4c5759fa4776296a4dd47e48d4b61 | sam676/PythonPracticeProblems | /Robin/desperateForTP.py | 1,004 | 4.28125 | 4 | """
You've just received intel that your local market has received a huge
shipment of toilet paper! In desperate need, you rush out to the store.
Upon arrival, you discover that there is an enormously large line of
people waiting to get in to the store. You step into the queue and start
to wait. While you wait, you bei... | true |
269910439e357f1e3e9b1576e08dc319918b9406 | sam676/PythonPracticeProblems | /Robin/reverseMessage.py | 1,083 | 4.21875 | 4 | """
Today's question
You are a newbie detective investigating a murder scene in the boardroom
at the Macrosoft Corp. While searching for clues, you discover a red notebook.
Inside of the notebook are long journal entries with inverted messages.
At that moment, you remembered from your profiler father’s advice that
you ... | true |
26ccdbc2bae76c99ce4409f4dbaef17419d78086 | sam676/PythonPracticeProblems | /Robin/palindromeNumber.py | 1,709 | 4.3125 | 4 | """
Sheltered at home, you are so bored out of your mind that you start thinking
about palindromes. A palindrome, in our case, is a number that reads the
same in reverse as it reads normally. Robin challenges you to write a
function that returns the closest palindrome to any number of your choice.
If your number is exa... | true |
095000b97fa3e4993fef3682cb33e688586eb4ae | sam676/PythonPracticeProblems | /Robin/isMagic.py | 1,199 | 4.53125 | 5 | """
You've heard about Magic Squares, right?
A magic square is one big square split into separate squares
(usually it is nine separate squares, but can be more), each containing a unique number.
Each horizontal, vertical, and diagonal row MUST add up to the same number
in order for it to be considered a magic squar... | true |
57a76e4402bad59476588863a63a67e89e5d5bd0 | sam676/PythonPracticeProblems | /Robin/numScanner.py | 1,174 | 4.25 | 4 | """
How are our lovely number people doing today?
We're going to have an exclusive numbers-only party next week.
You can bring any type of friends that wear "String" clothes as long as they are real number.
As we expect the infinite number of numbers to come to the party,
we should rather build a scanner that will ... | true |
a4b9901488a005c10a02c477fa009b2131fa8906 | sam676/PythonPracticeProblems | /Robin/addPositiveDigit.py | 501 | 4.125 | 4 | """
Beginner programmer John Doe wants to make a program that adds and outputs each positive digit
entered by the user (range is int). For instance, the result of 5528 is 20 and the result of 6714283 is 31.
"""
def addPositiveDigit(n):
total = 0
if n >= 0:
for x in str(n):
total += int(x)... | true |
245316d9ddeaa983b1e6047eb83085bd33d3c6ae | gas8310/python_git | /sequence_data.py | 481 | 4.1875 | 4 | #시퀀스 자료형
#문자열, 리스트, 튜플 등 인덱스를 가지는 자료형
#기본적 사용법?
#1.
string = "hello - world"
list = ['h', 'e', 'l', 'l', 'o', '-', 'w', 'o', 'r', 'l', 'd']
tuple = ('h', 'e', 'l', 'l', 'o', '-', 'w', 'o', 'r', 'l', 'd')
print(string[0:5])
print(list[0:5])
print(tuple[0:5])
for i in string:
# print(string[i])
print(i)
print... | false |
e241aa2106c8e48c37c3531b6d7fa8bdbbf216e7 | amirrulloh/python-oop | /leetcode/2. rverse_integer.py | 863 | 4.1875 | 4 | #Definition
"""
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
wi... | true |
ac5807601d45d4f350e0b0efb8cd2c7395d5eb3d | DDan7/CoffeeMachine | /Problems/Palindrome/task.py | 396 | 4.125 | 4 | user_input = input()
def palindrome(a):
backward = a[::-1]
if backward == a:
print("Palindrome")
else:
print("Not palindrome")
palindrome(user_input)
# def palindrome(a):
# backward = ''
# for i in a:
# backward += i
# if backward == a:
# print("Palindrome")... | false |
c097cfa78f6c8bc2a62eb04cd86023c51f221b5d | miller9/python_exercises | /17.py | 1,337 | 4.625 | 5 | print ('''
17. Write a version of a palindrome recognizer that also accepts phrase palindromes
such as "Go hang a salami I'm a lasagna hog.", "Was it a rat I saw?",
"Step on no pets", "Sit on a potato pan, Otis", "Lisa Bonet ate no basil",
"Satan, oscillate my metallic sonatas", "I roamed under it as a tired nude... | true |
571f2c597feb3192b9d5f7cf72e6403ef8b332c9 | miller9/python_exercises | /12.py | 384 | 4.21875 | 4 | print ('''
12. Define a procedure histogram() that takes a list of integers and prints a histogram to the screen.
For example, histogram( [ 4, 9, 7 ] ) should print the following:
****
*********
*******
''')
def histogram(l):
for value in l:
print ("*" * value)
int_list = [4, 9, 7]
print ('The histogra... | true |
111e530378568654c44b14627fe5f11fe8493a43 | miller9/python_exercises | /10.py | 1,024 | 4.34375 | 4 | print ('''
10. Define a function overlapping() that takes two lists and
returns True if they have at least one member in common, False otherwise.
You may use your 'is_member()' function, or the 'in' operator,
but for the sake of the exercise, you should (also) write it using two nested for-loops.
''')
def o... | true |
aff950e6eb663d1dc7defdf7a8e1b19c480da3fd | yogeshwaran01/Python-Scripts | /Scripts/anagram.py | 540 | 4.1875 | 4 | """
What is an anagram?
Two words are anagrams of each other
if they both contain the same letters.
For example:
'abba' & 'baab' == true
'abba' & 'bbaa' == true
'abba' & 'abbba' == false
'abba' & 'abca' == false
"""
def is_anagram(a: str, b: str) -> bool:
"""
>>> is_anagram("xyxyc", "xyc")
False
... | false |
e14c143ea086ca19b10c2f4f9cb59e0d4d55f651 | benjaminhuanghuang/ben-leetcode | /0306_Additive_Number/solution.py | 2,106 | 4.21875 | 4 | '''
306. Additive Number
Additive number is a string whose digits can form additive sequence.
A valid additive sequence should contain at least three numbers. Except for the first two numbers,
each subsequent number in the sequence must be the sum of the preceding two.
For example:
"112358" is an additive number bec... | true |
a4ff52bf767bec2d17ad4e192855aa4380807c6b | benjaminhuanghuang/ben-leetcode | /0398_Random_Pick_Index/solution.py | 1,366 | 4.125 | 4 | '''
398. Random Pick Index
Given an array of integers with possible duplicates, randomly output the index of a given target number.
You can assume that the given target number must exist in the array.
Note:
The array size can be very large. Solution that uses too much extra space will not pass the judge.
Example:
i... | true |
fc6127107d0807ee269b4505543ee30741c4695a | benjaminhuanghuang/ben-leetcode | /0189_Rotate_Array/solution.py | 1,649 | 4.1875 | 4 | '''
189. Rotate Array
Rotate an array of n elements to the right by k steps.
For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4].
Note:
Try to come up as many solutions as you can, there are at least 3 different ways to solve this problem.
'''
class Solution(object):
de... | true |
45929efac6474bb344733cd8130f9c2ea68f7bcd | benjaminhuanghuang/ben-leetcode | /0414_Third_Maximum_Number/solution.py | 2,003 | 4.1875 | 4 | '''
414. Third Maximum Number
Given a non-empty array of integers, return the third maximum number in this array. If it does not exist,
return the maximum number. The time complexity must be in O(n).
Example 1:
Input: [3, 2, 1]
Output: 1
Explanation: The third maximum is 1.
Example 2:
Input: [1, 2]
Output: 2
Expl... | true |
e6cdd47a3fe566991b401e000debe99d16451178 | benjaminhuanghuang/ben-leetcode | /0031_Next_Permutation/solution.py | 1,715 | 4.125 | 4 | '''
31. Next Permutation
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.
If such arrangement is not possible, it must rearrange it as the lowest possible order (ie, sorted in ascending order).
The replacement must be in-place, do not allocate extra... | true |
b8f6e39447a33973e6a3d806cc407b73b372f7be | walokra/theeuler | /python/euler-1_fizzbuzz.py | 413 | 4.125 | 4 | # Problem 1
# 05 October 2001
#
# If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9.
# The sum of these multiples is 23.
#
# Find the sum of all the multiples of 3 or 5 below 1000.
#
# Answer: 233168
#
#!/usr/bin/python
sum = 0
max = 1000
for i in range(1,max):
if i%3 ... | true |
8eeb3b9fb2593f8a3c84b80cb7bd220d2b221ccb | dipnrip/Python | /Python/Labs/lab2.py | 294 | 4.15625 | 4 | weight = int(input("Enter weight: "),10)
height = int(input("Enter height: "),10)
bmi = (weight/(height**2))*703
if(bmi < 18.5):
print("underweight")
if(bmi > 18.5 and bmi < 24.9):
print("normal")
if(bmi < 29.5 and bmi > 25.0):
print("overweight")
if(bmi >= 30):
print("obese")
| false |
d8b1d9e71ccb9fd29781aa4eb62ae3b175921fb0 | yansolov/gb | /gb-python/lesson03/ex06.py | 967 | 4.1875 | 4 | # Реализовать функцию int_func(), принимающую слово из маленьких латинских букв и
# возвращающую его же, но с прописной первой буквой.
# Например, print(int_func(‘text’)) -> Text.
# Продолжить работу над заданием. В программу должна попадать строка
# из слов, разделенных пробелом. Каждое слово состоит из латинских
... | false |
364b39ae12c52f969ec99a0d0111042efbca5cf5 | yansolov/gb | /gb-python/lesson04/ex06.py | 917 | 4.125 | 4 | # Реализовать два небольших скрипта:
# а) итератор, генерирующий целые числа, начиная с указанного,
# б) итератор, повторяющий элементы некоторого списка, определенного заранее.
from itertools import count, cycle
def count_func(start, stop):
for el in count(start):
if el > stop:
bre... | false |
503423d6683506ce9ff4fde7f73cfbd7b1cb5145 | tolaoner/Python_Exercises | /different_numbers.py | 613 | 4.125 | 4 | '''Create a sequence of numbers and determine whether
all the numbers of it are different from each other'''
import random
list_numbers=[]
different=True
for i in range(5):
list_numbers.append(random.randrange(1,10,1))
print(list_numbers[i])
for i in range(5):
for j in range(5):
if i==j:
continue
if list_nu... | true |
399474bdd93e47d000ed9ae9734dd2e5b85fe660 | Siddhant6078/Placement-Programs | /Python/factors_of_a_num.py | 214 | 4.25 | 4 | # Python Program to find the factors of a number
def print_factors(n):
print 'Factors of {0} are:'.format(n)
for x in xrange(1,n+1):
if n % x == 0:
print x
n1 = int(input('Enter a n1: '))
print_factors(n1) | true |
92f4bea4efbe1c7549407a44b85bf03ceeb25104 | Siddhant6078/Placement-Programs | /Python/swap two variables.py | 663 | 4.34375 | 4 | # Python program to swap two variables using 3rd variable
x = input('Enter value of x: ')
y = input('Enter value of y: ')
print 'The value of x: Before:{0}'.format(x)
print 'The value of y: Before:{0}'.format(y)
temp = x
x = y
y = temp
print 'The value of x: After:{0}'.format(x)
print 'The value of y: After:{0}'.fo... | true |
e3f91759b3e4661e53e1c5bb42f6525cef89b2d5 | Siddhant6078/Placement-Programs | /Python/Positive or Negative.py | 319 | 4.5 | 4 | # Program to Check if a Number is Positive, Negative or 0
# Using if...elif...else
num = float(input('Enter a Number: '))
if num > 0:
print 'Positive'
elif num == 0:
print 'Zero'
else:
print 'Negative'
# Using Nested if
if num >= 0:
if num == 0:
print 'Zero'
else:
print 'Positive'
else:
print 'Negative' | true |
73fed6743975942f340fc78009c16b9e2cf7b875 | abhinavkuumar/codingprogress | /employeeDict.py | 1,049 | 4.1875 | 4 | sampleDict = {
'emp1': {'name': 'John', 'salary': 7500},
'emp2': {'name': 'Emma', 'salary': 8000},
'emp3': {'name': 'Tim', 'salary': 6500}
}
while 1:
answer = input("Do you want to add or remove an employee? Select q to quit (a/r/q) ")
newlist = list(sampleDict.keys())
if answer == 'a':
... | true |
2da72ad227e82145ffd64f73b39620330c83c21d | greenhat-art/guess-the-number | /guessingGame.py | 604 | 4.3125 | 4 | import random
print("Number guessing game")
number = random.randint(1, 9)
chances = 0
print("Guess a number between 1 to 9:")
while chances < 5:
guess = int(input("Enter your guessed number:- "))
if guess == number:
print("Congratulation you guessed the right number!")
break
... | true |
d347de34c5058cfabd6dfc1ad64bebde56569461 | Solannis/Python-Examples | /list_test.py | 549 | 4.125 | 4 | #!/usr/bin/python
class test:
def __init__(self):
self.name = ""
self.code = ""
list = ['physics', 'chemistry', 1997, 2000];
print "Value available at index 2 : "
print list[2]
list[2] = 2001;
print "New value available at index 2 : "
print list[2]
print len(list)
list2 = []
print list2
... | false |
957d95428e0af1b303930e7071dfbe710f84f99b | anasm-17/DSA_collaborative_prep | /Problem_sets/fizzbuzz/fizzbuzz_jarome.py | 1,879 | 4.3125 | 4 | from test_script.test import test_fizzbuzz
"""
A classic Data Structures an algorithms problem, you are given an input array of integers from 1 to 100 (inclusive).
You have to write a fizzbuzz function that takes in an input array and iterates over it. When your function receives
a number that is a factor of 3 you ... | true |
dd80e66757066ef8d97911680ffb0e47411d9c25 | jineshshah101/Python-Fundamentals | /Casting.py | 580 | 4.3125 | 4 | # variable example
x = 5
print(x)
# casting means changing one data type into another datatype
# casting the integer x into a float
y = float(x)
print(y)
# casting the integer x into a string
z = str(x)
print(z)
# Note: Cannot cast a string that has letters in it to a integer. The string itself mu... | true |
6141bb86224dbc1c19efca92f530682d1a04e570 | jineshshah101/Python-Fundamentals | /Calendar.py | 1,448 | 4.46875 | 4 | import calendar
#figuring things out with calendar
# printing out the week headers
# using the number 3 so we can get 3 characters for the week header
week_header = calendar.weekheader(3)
print(week_header)
print()
# print out the index value that represents a weekday
# in this case we are getting the ind... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.