blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
359b1f4d28ca3238a2c91373735629256c0bcdc6 | kingpipi/rock-paper-scissors | /rps.py | 2,751 | 4.125 | 4 | from random import randint
#intro
print("Rock...")
print("Paper...")
print("Scissors...")
player_name = str(input("New player, choose your nickname:")).capitalize()
#Interact with user
comp_react = randint(0,2)
if comp_react == 0:
greeting = f"Welcome {player_name} to Rock, Paper, Scissors!"
elif comp_react == ... | true |
991fea54251d20bc2692341536bb60739384fdf5 | fabianmroman/python | /IBM Cognitive Classes/Python2DS/strings.py | 1,188 | 4.1875 | 4 | mike = 'Michael Jackson'
print (mike[0]) # First character
print (mike[-1]) # Last character
print (len(mike)) # Lenght of string
print (mike[-len(mike)]) # First character
# Print the string forward
for i in range(len(mike)):
print (mike[i], end = '') # " end = '' " Prints everything in a single line
print('')
... | false |
295326313450fc889ee9506753e6a14c698f48d8 | busrabek/Python-Tasks | /fizzbuzz.py | 239 | 4.15625 | 4 | number = int(input("Please enter a number: "))
if 1 <= number <= 100:
if number % 3 == 0 and number % 5 == 0:
print("FizzBuzz")
elif number % 5 == 0:
print("Buzz")
elif number % 3 == 0:
print("Fizz")
else:
print(number) | false |
03c56238131336fc92e230f52d2e744dc9fb63f3 | KiranBahra/PythonWork | /PythonTraining/Practice/6.StringLists.py | 484 | 4.65625 | 5 | #Ask the user for a string and print out whether this string is a palindrome or not. (A palindrome is a string that reads the same forwards and backwards.)
varInput = input("Enter Text:")
#this reverses the text as a string is a list
varReverse=varInput[::-1]
print(varReverse)
if (varInput== varReverse):
print("This ... | true |
65ffd09d4d2d792f58d772e43a8253587a66813c | anupamnepal/Programming-for-Everybody--Python- | /3.3.py | 621 | 4.46875 | 4 | #Write a program to prompt the user for a score using raw_input. Print out a letter
#grade based on the following table:
#Score Grade
#>= 0.9 A
#>= 0.8 B
#>= 0.7 C
#>= 0.6 D
#< 0.6 F
#If the user enters a value out of range, print a suitable error message and exit.
#For the test, enter a score of 0.85.
score = raw_i... | true |
6d9960c8e6239326706f88c882ff21e9d0116b20 | ad002/LPTHW | /ex39_Notes.py | 1,709 | 4.3125 | 4 | things = ['a', 'b', 'c', 'd']
print(things[1])
#= b
things[1]='z'
print(things[1])
#=z
print(things)
#output:['a', 'z', 'c', 'd']
#lists = you can only use numbers to get items out of a list
#e.g. things[1]
#dict = lets you use anything, not just numbers. It associates one thing
#to another, no matter what it is
st... | true |
b763e434e634b62133f12244cc3112eb8987b930 | ad002/LPTHW | /ex25.py | 2,132 | 4.21875 | 4 | def break_words(stuff):
#Gespannt, ob das hier beim Aufrufen der Funktion mit gedruckt wird
#Die Dinger heißen "documentation comments" und wenn wir die Funktionen
#über die Console aufrufen und z.b. help(ex25) eingeben, könenn wir
#Sie über den Funktionsdefinitionen sehen als Hilfestellung
"""This ... | false |
8e94a7d2a71ea6b2de0cb595ff79e2cfb36d5120 | jnkg9five/Python_Crash_Course_Work | /Styling_Python_Code.py | 1,833 | 4.375 | 4 | #Python_List_Exercise
#PYTHON CRASH COURSE Chapter#3
#When changes will be made to the Python language, they write a Python Enhancement Proposal (PEP)
#The oldest PEPs is PEP8 which instructs programmers on how to style their code.
#Code will be read more often then its written.
#You will write your code and then rea... | true |
36e177cc82bfb45369922fbcad512fd334f7d56d | gabrielyap/early-works-python | /32ahw2/part3.py | 376 | 4.15625 | 4 | one = int(input("Enter first number: "))
two = int(input("Enter second number: "))
three = int(input("Enter third number: "))
if (one <= two):
if (one <= three):
print("Lowest number:", one)
elif (two <= one):
if(two <= three):
print("Lowest number:", two)
elif (three <= one):
if (... | false |
1f9426a958a249bb01f48035782704ebc906e27e | saisai/tutorial | /python/python_org/library/data_types/itertools/product.py | 360 | 4.1875 | 4 | from itertools import product
def cartesian_product(arr1, arr2):
# return the list of all the computed tuple
# using the product() method
return list(product(arr1, arr2))
if __name__ == '__main__':
arr1 = [1, 2, 3]
arr2 = [5, 6, 7]
print(cartesian_product(arr1, arr2))
# https://www.geek... | true |
853bb4c8af140d5d7b6ce04b19708b23446c1f9f | saisai/tutorial | /python/techiedelight_com/stack/check-given-expression-balanced-expression-not.py | 1,501 | 4.28125 | 4 | '''
https://www.techiedelight.com/check-given-expression-balanced-expression-not/
'''
from collections import deque
# function to check if given expression is balanced or not
def balance_parenthesis(exp):
# base case: length of the expression must be even
if len(exp) & 1:
return False
# take a... | true |
16759348c64f450a463cd8c1ad363bd51675995b | saisai/tutorial | /python/python_org/tutorial/introduction.py | 1,563 | 4.15625 | 4 |
print("""\
Usage: thingy [OPTIONS]
-h Display this usage message
-H hostname Hostname to connect to
""")
print()
# 3 times 'un', followed by 'ium'
print(3 * 'un' + 'ium')
print(40 * '-' + 'end')
print()
print("Py" "thon")
print()
text = ('Put several strings within parentheses '
'to have... | true |
49f37fcc2b6474a9e8eb03eb4de38ffb9e0213fb | Issaquah/NUMPY-PYTHON | /EDX_DATA-SCIENCE/NUMPY/Sorting/sorting.py | 1,226 | 4.375 | 4 | import numpy as np
random_array = np.random.rand(10) # generate array of random values
unsorted_array = np.array(random_array)
print("Unsorted array=\n", unsorted_array)
print("")
sorted_array = np.sort(unsorted_array) # use sort to arrange array elements in ascending order
print("Sorted array=\... | true |
2185d6e49b8f3909d05e18bbe27fb3e0eea6be58 | simrangrover5/Advance_batch2020 | /t3.py | 362 | 4.46875 | 4 |
import turtle
rad = int(input("\n Enter the radius : "))
pen = turtle.Pen()
pen.right(90)
pen.up() #it will not show anything that will be drawn on the interface
pen.forward(50)
pen.down()
pen.color('red','blue') #color(foreground,background)
pen.begin_fill()
pen.circle(rad)
pen.end_fill() #fill the background col... | true |
e5da9a08bf869df6258aa66149a1835d082b78ea | 18zgriffin/AFP-Work | /Test Python.py | 289 | 4.1875 | 4 | print("Hello World")
name = input("You?: ")
age = int(input("Age: "))
print("Hello", name, age)
print("Hello " + name + " " + str(age))
#the comma simply outputs the result
#the plus tries to output the variables as they are
#therefore we must convert the integer to a string outselves
| true |
5fc0397b2c2934f177f857aca178db27d28e43e4 | bedralin/pandas | /Lesson4/slicedice_data.py | 1,886 | 4.3125 | 4 | # Import libraries
import pandas as pd
import sys
print 'Python version ' + sys.version
print 'Pandas version: ' + pd.__version__
# Our small data set
d = [0,1,2,3,4,5,6,7,8,9]
# Create dataframe
df = pd.DataFrame(d)
print d
print df
# Lets change the name of the column
df.columns = ['Rev']
print "Lets change name ... | true |
f0836493a5aabd316d71a60b2478c108aa442040 | bedralin/pandas | /Lesson2/create_data.py | 1,070 | 4.28125 | 4 | # Import all libraries needed for the tutorial
import pandas as pd
from numpy import random
import matplotlib.pyplot as plt
import sys #only needed to determine Python version number
# Enable inline plotting
#matplotlib inline
print 'Python version ' + sys.version
print 'Pandas version ' + pd.__version__
print "\nCr... | true |
113f1e6b37f3cdf9e0fee294b24af7b359fac917 | abegpatel/LinkedList-Data-Structure-Implementation | /DataStructure/linkedlist/SinglyLinkedlist.py | 2,298 | 4.15625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Mar 24 20:28:33 2021
@author: Abeg
"""
#singly Linkedlist Implementation
# Create a node
class Node:
def __init__(self, item):
self.item = item
self.next = None
class LinkedList:
def __init__(self):
self.head = None
#... | true |
4c2a3fa7101263b3a820397fe9b54f2c11e956ee | NunoTomas83/Python | /lists_functs.py | 494 | 4.28125 | 4 | """ Script to use several python list functions"""
my_list = [5, 2, 9, 1]
second_list = list(range(5))
print("Length :", len(my_list))
print("1st Index :", my_list[0])
print("1st 3 Values :", my_list[0:3])
print("9 in List :", 9 in my_list)
print("Index for 2 :", my_list.index(2))
print("How Many 2s :", my_list.coun... | true |
83825e787a8d45bed32f76904a68446f733dc183 | NunoTomas83/Python | /elevevator.py | 1,409 | 4.15625 | 4 | """ Simulates the an elevator """
class Elevator:
def __init__(self, bottom, top, current):
"""Initializes the Elevator instance."""
self.bottom = bottom
self.top = top
self.current = current
pass
def __str__(self):
return "The elevator is in the {}th floor".for... | true |
b493d9f16771f592ca6e7a4e0d41f10e61f056c9 | gmkerbler/Learn-Python-the-hard-way-Tutorial | /ex10_1.py | 794 | 4.25 | 4 | print "ASCII backspace, deletes a single space before it"
print "** blabla \b blabla" #\b is an ASCII backspace, which deletes a single space before it
print "ASCII bell, puts a single space before it"
print "** blabla \a blabla" #\a is an ASCII bell, which puts a single space before it
print "ASCII formfeed, puts a ... | true |
36574929054c1d21c46a45bb0f04d1f1de1ea1bc | nathantau/YouuuuRL | /flask/string_utils/string_utils.py | 354 | 4.21875 | 4 | def get_6_digit_representation(code: str) -> str:
'''
Given a code, it fills it up with 0s to make it 6-digits.
Parameters:
code (str): The code to add 0s to.
'''
num_zeroes_needed = 6 - len(code)
zeroes_str = ''
for _ in range(num_zeroes_needed):
zeroes_str = str(0) + zeroes... | true |
9fbe9cf530242d1065d9fa5c2e973c99c80fd1c7 | venkunikku/exercises_learning | /PycharmProjects/HelloWorldProject/inheritance_polymorphism.py | 1,251 | 4.28125 | 4 | #Inheritance and polymorphism example
class Animal:
""" Example of poly."""
"""More comments about this class."""
def quack(self):
return self.strings['quack']
def bark(self): return self.strings['bark']
def talk(self): return self.strings['talk']
def mcv_pattern(self): return self._do... | true |
264736c4a5eac5a0d7fc36c8180ec640ccb7a792 | andyskan/26415147 | /python/array.py | 942 | 4.28125 | 4 | #!/usr/bin/python3
#this is a list, that looks like an array, just say that this is array
list = [ 'John', 1998 , 'Cena', 70.2,4020 ]
list2 = ['ganteng', 91]
print (list) # print complete list
print (list[0]) # print element n
print (list[1:3]) # print element on a range
print (list[2:]) # pr... | true |
f467112e148356b0fb35020bd7ca4a0a16356370 | andyskan/26415147 | /python/time.py | 462 | 4.15625 | 4 | #!/usr/bin/python
#Learning time in python
import calendar;
import time;
#unformatted time
localtime=time.localtime(time.time())
print "Sekarang waktunya :",localtime
#timeformatting
localtime= time.asctime( time.localtime(time.time()))
print localtime
tanggalan=calendar.month(2016,10)
print "Calendar bulan okto... | false |
df2b5d7c681a944cbe9e4998ef149a5a14737c92 | onionmccabbage/advPythonMar2021 | /my_special.py | 609 | 4.21875 | 4 | # special operators
# for example the asterisk can mean mathematical multiply or repeat a string
# __mult__
# overriding the __eq__ built-in operator
class Word():
def __init__(self, text):
self.text = text
def __eq__(self, other_word):
return self.text.lower() == other_word.text.low... | true |
4e9e6fd0802da69251fda87b6e8d87a16ec64370 | onionmccabbage/advPythonMar2021 | /using_functions.py | 933 | 4.125 | 4 | # args and kwargs allow handling function parameters
# we use args for positionl/ordinal arguments and kwargs for keyword arguments
def myFn(*args): # *args will make a tuple containing zero or more arguments passed in
# one-arg outcome
if(len(args)== 1):
return 'one argument: {}'.format(args[0])
... | true |
1e6eda8ef2ccf528295680be48a94c61ac7a9184 | AmruthaRajendran/Python-Programs | /Counting_valleys.py | 1,551 | 4.59375 | 5 | # HackerRank Problem
''' Gary is an avid hiker. He tracks his hikes meticulously, paying close attention to small details like topography. During his last hike he took exactly n steps.
For every step he took, he noted if it was an uphill,U, or a downhill, D step. Gary's hikes start and end at sea level and each step ... | true |
701792debbb3529c73a5f97fa159f0cbbd594bc6 | AmruthaRajendran/Python-Programs | /Cats_and_Mouse.py | 2,111 | 4.21875 | 4 | # Hackerrank Problem
''' Question:
Two cats and a mouse are at various positions on a line. You will be given their starting positions. Your task is to determine which cat will reach the mouse first,
assuming the mouse doesn't move and the cats travel at equal speed. If the cats arrive at the same time, the mouse wil... | true |
608807c992a9013012f15cc155633e8b5c4914f0 | AmruthaRajendran/Python-Programs | /Password_Problem.py | 1,549 | 4.21875 | 4 | # This was asked on the SAP Labs online preplacement test.
# Question: you are given two strings from which you have to create a new string which is considered as a password.
# The password should be made by combining the letters from each string in alternate fashion.
# eg: input: abc, def output: adbecf
#Program:
de... | true |
062f2c51748e40ea410c1c6fd8fbe436fd93d164 | vechaithenilon/Python-learnings | /MORNINGPROJECTRemovingVowels.py | 409 | 4.375 | 4 | VOWEL = ('a','e','i','o','u') #Tuple
message = input('Enter your message here: ')
new_message = ''
for letter in message:
if letter in VOWEL:
print(letter, 'is a vowel') #the latter part is used to print the end of line with a space in between
if letter not in VOWEL:
# new_mess... | true |
f5bfd1699b1d9dba71f41840add964af2209b890 | nanodoc2020/Physics | /timeDilator.py | 1,249 | 4.3125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Dec 31 20:15:48 2019
timeDilator calculates the relativistic time dilation between two reference
frames. This is an application of Einstein's special relativity and can be used
to compute the time passed in either frame of reference, moving or stationary.
No units necessarry f... | true |
6b03b117630c9ee39ad2f472b0a530a66c0d0d76 | jordanNewberry21/python-practice | /lesson20-string-methods.py | 2,534 | 4.5 | 4 | # string methods return a new value rather than modifying in place
# this is because strings as a data type are immutable
spam = 'Hello world!'
print(spam.upper())
print(spam.lower())
answer = input()
if answer == 'yes':
print('Playing again.')
answer.lower()
# lower() and upper() methods return the string a... | true |
c4444916d978830857d3471c73a7ba4258c760f3 | kshiv29/PandasEx | /Udemy python/String1.py | 692 | 4.15625 | 4 | String="This is the string"
String1="this is 1 string"
print(String)
# print(len(String))
# print(String[::-1])
# print(String*2)
# print("hello" " guys")
# word="Ford"
# word= "L"+word[1:]
# print(word)
formatstarting= "Today I will Learn {0} hours {1}".format(2,"python")
formatstarting2 ="Today I will Learn {x} hou... | false |
552940c34e423babaf52f2c62449d29bc3850db8 | robwa10/pie | /python/unpacking-function-arguments.py | 1,342 | 4.71875 | 5 | # Unpacking Function Arguments
"""
## Function params
- args passes in a tuple
- *args unpacks the tuple before passing them in
"""
def multiply(*args):
total = 1
for arg in args:
total = total * arg
return total
# print(multiply(1, 3, 5))
"""
## Passing multiple arguments
"""
def add(x, y... | true |
51a029659882714adb03b696cd70e4f38353a1d2 | VisheshSingh/Get-to-know-Python | /stringformatting.py | 877 | 4.28125 | 4 | # STRING FORMATTING
radius = int(input("Enter the radius: "))
area = 3.142 * radius ** 2
print('The area of circle with radius =', radius,'is', area)
num1 = 3.14258973
num2 = 2.95470314
#PREVIOUS METHOD
print('num1 is', num1, 'and num2 is', num2) # num1 is 3.14258973 and num2 is 2.95470314
#FORMAT METHOD
print('num... | true |
433db8f06cf604fd9e95cbce266bd315bbdc7cdf | orikhoxha/itmd-513 | /hw4/hw4-1.py | 1,607 | 4.1875 | 4 | '''
fn: get_user_input(message)
Gets the user input.
Parameters
----------
arg1 : string
message for the console
Returns
---------
string
returns the input of the user
'''
def get_user_input(message):
return input(message)
'''
fn: validate_input_blank(messag... | true |
0f2b90e06bd55e069eb02f6e90e6206c5c43a9af | Acrelion/various-files | /Python Files/ex34.py | 648 | 4.34375 | 4 | # Looping through a list, printing every item + string.
# In the last line we print index of the elements and then the element itself.
# The element is being selected/called by using its index:
# Give me the element from list animals with index i.
animals = ['bear', 'python', 'peacock', 'kangaroo',
'whale',... | true |
f1dcc3ab3be3fc15b4f3ef9cad8269e3d3f6aa6e | amitsng7/Leetcode | /Multiply number without using operator.py | 207 | 4.21875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Feb 7 18:38:11 2017
@author: Amit
"""
def multiple(x,y):
if (y==0):
return 0
if(y>0):
return (x + (multiple(x,y-1)))
print(multiple(2,3)) | false |
159e9cfd8bc0e50f2cd0a8d699b29ca71c906fa1 | emilyvroth/cs1 | /homework/homework3/hw3Part3.py | 787 | 4.125 | 4 | name=input("Name of robot => ")
print(name)
x=int(input("X location => "))
print(x)
y=int(input("Y location => "))
print(y)
energy=10
command=''
while command !='end':
print("Robot {} is at ({},{}) with energy: {}".format(name,x,y,energy))
command=input("Enter a command (up/left/right/down/attack/end) => ")
print(... | true |
ed00f211b21e7c0c4d7f991ef5f07c03f1d8369e | kamran1231/INHERITENCE-1 | /inheritance1.py | 887 | 4.125 | 4 | # INHERITANCE METHOD
class Mobile:
def __init__(self, brand, model, price):
self.brand = brand
self.model = model
self.price = price
def display_all(self):
return f'MOBILE: {self.brand}, MODEL: {self.model} and PRICE: {self.price}'
class Smartphone(Mobile):
... | true |
1a901ca15f4d9254980157bbd2a0ef07e8e31d69 | SaiPranay-tula/DataStructures | /PY/Da.py | 427 | 4.25 | 4 | #generators
def prints(ran):
for i in range(1,ran):
yield(i*i)
a=prints(10)
print(next(a))
for i in a:
print(i)
g=(i for i in range(10))
print(list(g))
#generator dont until they are called
#they are effecient than list when dont want to store the values
#generator adds functionality to f... | true |
238367ef3065bb99512044a89bd1c61bd85defdf | J040-M4RC0S-Z/first-programs | /Player text/Condições para triângulos.py | 1,733 | 4.15625 | 4 | print("\033[1;35mTriângulo type\033[m")
r1 = float(input("Digite a primeira medida do triângulo: "))
r2 = float(input("Digite a segunda medida do triângulo: "))
r3 = float(input("Digite a terceira medida do triângulo: "))
if r1 < (r2+r3) and r2 < (r1+r3) and r3 < (r1+r2):
if r1 == r2 and r2 == r3 and r3 == r1:
... | false |
457a30dc984dc1f9d23b3af76eab9e79ae8dfe68 | kyrienguyen5701/LeetCodeSolutions | /Medium/ZigZagConversion.py | 738 | 4.1875 | 4 | '''
The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)
P A H N
A P L S I I G
Y I R
And then read line by line: "PAHNAPLSIIGYIR"
Write the code that will take a string and make this conve... | true |
b860e390ffe1908ea53b1ce7ce41bde96dae4726 | kyrienguyen5701/LeetCodeSolutions | /Hard/ShortestPalindrome.py | 588 | 4.21875 | 4 | '''
You are given a string s. You can convert s to a palindrome by adding characters in front of it.
Return the shortest palindrome you can find by performing this transformation.
'''
def shortestPalindrome(s):
def isPalindrome(word, i, j):
while i < j:
if word[i] != word[j]:
r... | true |
11d1a81c923da796cf20d053f9b3e7c678102d65 | kyrienguyen5701/LeetCodeSolutions | /Medium/MergeInBetweenLinkedLists.py | 847 | 4.125 | 4 | '''
You are given two linked lists: list1 and list2 of sizes n and m respectively.
Remove list1's nodes from the ath node to the bth node, and put list2 in their place.
'''
class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
def mergeInBetween(self, list1, a, b, l... | true |
017a603f8be512c3564cb9d72db5e61e0063c7ab | dylcruz/Automate_The_Boring_Stuff | /chapter2/guessTheNumber.py | 662 | 4.15625 | 4 | #This is a guess the number game. The player has 6 tries to guess a random number between 1 and 20
import random
import sys
number = random.randint(1,20)
guess = 0
tries = 0
print('I\'m thinking of a number between 1 and 20.')
while guess != number:
if tries > 5:
print("You lose! My number was " + str(n... | true |
13a94688618057631f760685cfb529e03499ed95 | akavenus/Calculator | /Calculater.py | 1,242 | 4.25 | 4 | print('Welcome to the vennus calculater')
print('Addition is +')
print('Subtraction is -')
print('Multiplication is *')
print('Division is /')
xe=input('Enter a operater ')
num_1=float(input('Enter your first number: '))
num_2=float(input('Enter your second number: '))
if xe == '+':
print('Your answer is... | true |
e941ba4379ca69ed4a8a76bc6cbe66f20101e419 | abhigun1234/jsstolearnpython | /weekendbatch/sequence/chapter1/operators.py | 749 | 4.21875 | 4 | #aretemetic operators
# + - / * ** %
# print('enter a no and check the no is even or odd')
# a=int(input('enter a no '))
# reminder=a%2
# print("result",reminder)
# if(reminder==1):
# print('it is a odd no')
# else :
# print("it is a even no ")
# result=a+b
# print(result)
# result=a*b
# print(result)
#if
'... | true |
00b3ff2a9e3e8e13011c9999524622db10856ef9 | kidexp/91leetcode | /array_stack_queue/380InsertDeleteGetRandomO(1).py | 1,789 | 4.15625 | 4 | import random
class RandomizedSet:
def __init__(self):
"""
Initialize your data structure here.
"""
self.num_index_dict = {}
self.value_list = []
def insert(self, val: int) -> bool:
"""
Inserts a value to the set. Returns true if the set did not already... | true |
b5435b55106086b7ef25eda59668ef25ae2565ba | apisitse/workshop2 | /string/modifystring.py | 304 | 4.25 | 4 | string = "Hello, World!"
print (string.upper()) #output: "HELLO,WORLD!"
print (string.lower()) #output: "hello,world!"
print (string.strip()) #output: "Hello,World!"
print (string.replace("H", "J")) #output: Jello,World!
print (string.split(",")) #output: [" Hello" , "World! "]
print (len(string)) # 15 | false |
360e24dfc79fdf12562cbad8fc8075c087d3ba71 | yashasvi-goel/Algorithms-Open-Source | /Sorting/Quick Sort/Python/QuickSort.py | 1,202 | 4.15625 | 4 | #Implementation of QuickSort in Python
def partition(arr,low,high):
# index of smaller element
i = (low-1)
# Pivot is the last element in arr
pivot = arr[high]
print("Pivot is: " + str(pivot))
for j in range(low,high):
# Checks if the current element is smaller than or
# equal ... | true |
864b1739ea38bb0e8578ae5d89844e56f978b19d | mrdebator/171-172 | /DrawingARightTriangle.py | 925 | 4.5625 | 5 | # This program will output a right triangle based on user specified height triangle_height and symbol triangle_char.
#
# (1) The given program outputs a fixed-height triangle using a * character. Modify the given program to output a right triangle that instead uses the user-specified triangle_char character. (1 pt)
#
#... | true |
1edcd3b9b6474bea839131948277d7540f49baaf | mrdebator/171-172 | /FileIntro.py | 1,116 | 4.34375 | 4 | # In this lab, you will experiment with opening an reading files.
#
# A file has been attached to this lab called english.txt. It contains a selection of random english words. There is one word on each line.
#
# Open the file by using the command
#
# f = open("english.txt","r")
# Ask the user for a single letter. Loop ... | true |
a7cd36032fd5b60aa3d163e0d59824addfd84c12 | orel1108/hackerrank | /practice/data_structures/linked_lists/reverse_doubly_linked_list/reverse_doubly_linked_list.py | 586 | 4.15625 | 4 | """
Reverse a doubly linked list
head could be None as well for empty list
Node is defined as
class Node(object):
def __init__(self, data=None, next_node=None, prev_node = None):
self.data = data
self.next = next_node
self.prev = prev_node
return the head node of the updated list
"""
... | true |
4d831645a79f5e033d17666419695bf3679de4e1 | tkachyshyn/move_in_json | /move_in_json.py | 1,210 | 4.25 | 4 | '''
this module helps the user to move
in the json file
'''
import json
def open_file(path):
'''
open file and convert data into
dictionary
'''
f = open(path)
data = json.load(f)
return data
lst = []
def keys(data):
'''
help the user to choose keys and to
move within them in t... | true |
f185cf0f7b3352771916dc9ab3a2a936ee6751ee | sharvarij09/LMSClub | /Find_Monday | 933 | 4.6875 | 5 | #!/usr/bin/env python3
#
#This is my code which includes a function that will check if i have "Monday" in my calender and prints it in Uppercase
#
def find_monday(mycalender1):
mycalendar1 = """Day Time Subject
Monday 9:10 AM - 10:15 AM LA
... | true |
fabe66fb9a56ea0cef30df8dc94fa5d05ebf2274 | erlaarnalds/TileTraveller | /int_seq.py | 660 | 4.34375 | 4 | num=int(input('Enter an integer: '))
cumsum=0
maxnum=0
odd=0
even=0
while num>0:
cumsum=cumsum+num
print('Cumulative total: ', cumsum)
#finding the maximum number
if num>maxnum:
maxnum=num
#counting odd and even numbers
if num%2==0:
even+=1
else:
odd+=1
... | true |
e9c6dcf015e432639e1a23cf06fa24968b1336ca | krailis/hackerrank-solutions | /Python/Strings/capitalize.py | 577 | 4.28125 | 4 | def capitalize(string):
words = string.split(" ")
upper = []
for item in words:
if (item.isalnum()):
if (item[0].isalpha()):
str_list = list(item)
str_list[0] = str_list[0].upper()
item_new = "".join(str_list)
upper.append(i... | false |
fcc48fbf44c772f1a894bc4a79afbb21f90eff89 | Pav-lik/Maturita-CS | /Programy/06 - Eratosthenovo síto/sieve.py | 533 | 4.28125 | 4 | limit = int(input("The limit under which to look for primes: "))
# create a boolean array
sieve_list = [True] * limit
primes = []
for i in range(2, limit):
# if the number hasn't been crossed out, cross out all its multiplicands and add it to the list
if sieve_list[i]:
primes.append(i)
... | true |
9f90c56bc44c827e75a879f8e343865dc3a7fc7f | amberheilman/info636 | /3BHeilmanCODE.py | 2,655 | 4.125 | 4 | """
Name: Assignment 2B
Purpose:
- read out one number at a time from a file
- User may (A) Accept (R) Replace (I) Insert or (D) Delete the number shown
- User may (S) Save file with remainder of numbers unchanged
- User may (W) Rename file and leave original file undisturbed
Error Conditions:
-Reach end of file
-Impr... | true |
b5cfe70801789f94d65dc8fb1e4bde1068edc486 | ndanielsen/intro-python | /class_two/01_data_types.py | 504 | 4.25 | 4 | ## Learn More Python with Automate the Boring Stuff:
## https://automatetheboringstuff.com/chapter1/
# Your First Program
#
# print('hello world')
#
# # Comments in python use a '#'
## WARM UP QUIZ
# PART I
a = 5
b = 5.0
c = a / 2
d = b / 2
# What is type(a)?
# What is type(b)?
# What is c?
# What is d?
# ... | false |
a8e42771a2f2a89fd53f18b05c19f9de68ad1108 | ndanielsen/intro-python | /class_two/04_exercise.py | 1,136 | 4.59375 | 5 | """
Extracting city names from a list of addresses
Exercise: Modify `extract_city_name()` to get the city name out of the address_string
"""
list_of_addresses = [
"Austin, TX 78701",
"Washington, DC 20001",
"Whittier, CA 90602",
"Woodland Hills, CA 91371",
"North Hollywood, CA 91601"
"Baltim... | true |
4e0a986a6af063585625103bfb54940e483610e0 | faisalsetiawan14/praktikum-apd | /konversi suhu.py | 565 | 4.25 | 4 | print("cara konversi suhu")
print("konversi suhu celcius ke fahrenheit, kelvin, dan reamur")
print(" berikut hasilnya")
suhu = ("fahrenheit", "kelvin", "reamur")
suhu_celcius = float(input("masukan suhu dalam celcius"))
suhu_fahrenheit = (9./5) * suhu_celcius+32
suhu_kelvin = suhu_celcius + 273
suhu_reamur = (4.... | false |
64bd846c948d790a2870d7a84465b090730a8abf | datazuvay/python_assignments | /assignment_1_if_statements.py | 249 | 4.125 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[ ]:
name = input("Please enter your name: ")
user_name = "Joseph"
if name == user_name:
print("Hello, {}! The password is: W@12".format(name))
else:
print(f"Hello {name}! See you later!")
| true |
b324e1c6fc51aa01ce6567a7ef9cc60dfaae23be | RajanIsBack/Python_Codes | /Bank_ATM_simulation.py | 941 | 4.28125 | 4 | '''ATM Simulation
Check Balance Make a Withdrawal Pay In Return Card
'''
bank_pin =5267
entered_pin = int(input("Enter your bank pin"))
if(entered_pin != bank_pin):
print("Wrong pin.Exiting and returning card")
else:
print("WELCOME USER !!. Choose from below options")
print("1.Check Balance")
pri... | true |
52aba9b05d89481b5ef529a911c7e4e1bb7d8e78 | davkandi/MITx-6.00.1x | /ps6/test.py | 1,582 | 4.71875 | 5 | import string
def build_shift_dict(shift):
'''
Creates a dictionary that can be used to apply a cipher to a letter.
The dictionary maps every uppercase and lowercase letter to a
character shifted down the alphabet by the input shift. The dictionary
should have 52 keys of all the uppercase letters a... | true |
95c22214e2e788540f942e9bf8380852fa33d23e | anikahussen/algorithmic_excercises | /functions/check_answer.py | 506 | 4.25 | 4 |
def check_answer(number1,number2,answer,operator):
'''processing: determines if the supplied expression is correct.'''
expression = True
if operator == "+":
a = number1 + number2
if answer == a:
expression = True
elif answer != a:
expression = False
... | true |
ee8969f29c4e9f16093c5b50bee0ad0d38f4ed94 | thphan/Nitrogen-Ice-cream-Shop-Monte_Carlo_Simulation | /Distribution.py | 2,450 | 4.40625 | 4 | # Distribution needed in simulation
import random
class RandomDist:
# RandomDist is a base abstract class to build a Random distribution.
# This class contains an abstract method for building a random generator
# Inherited class must implement this method
def __init__(self, name):
self._name ... | true |
e7c3d7830475a09f733725e064046f2fa72c2a0a | menezesfelipee/exercicios-python | /Aula12/dicionarios_ex03.py | 628 | 4.1875 | 4 | '''3. Faça um programa que leia nome e média de um aluno, guardando também a situação em um dicionário. No final, mostre o conteúdo da estrutura na tela. A média para aprovação é 7. Se o aluno tirar entre 5 e 6.9 está de recuperação, caso contrário é reprovado.'''
aluno = dict()
aluno['nome'] = input('Digite o nome d... | false |
d985f4eca97864fbd75db0654c0120564b339e2c | menezesfelipee/exercicios-python | /Aula14/funcoes_ex06.py | 590 | 4.25 | 4 | '''Escreva uma função que, dado um número nota representando a nota de um estudante, converte o valor de nota para um conceito (A, B, C, D, E e F).
Nota Conceito
>=9.0 A
>=8.0 B
>=7.0 C
>=6.0 D
>=5.0 E
<=4.0 F '''
def conceito(nota):
if nota >= 9:
return 'A'
elif nota >= 8:
ret... | false |
0d1c478f529b2ec27f98f77c0b03e799c12e0479 | trejp404/FileWritingProgram | /week10program.py | 2,831 | 4.21875 | 4 | # Prepedigna Trejo
# Assignment 10.1
import os #imports OS library
import time #imports time
# print() for cleaner output
print()
# welcome message
print("---Welcome---")
# print() for cleaner output
print()
# sleep for 2 seconds
time.sleep(2)
print("---To create and store a new file, follow the directions below.---"... | true |
291638d0af06b1379f39c69a86a9290d0607607d | sapnajayavel/FakeReview-Detector | /features/edit_distance.py | 2,264 | 4.15625 | 4 | #!/usr/bin/env python2.7
#encoding=utf-8
"""
Code about implementing calculate min edit distance using Dynamic Programming. Although the method is used for compare similariy of two strings,it can also be used to compare two vectors
Code from http://blog.csdn.net/kongying168/article/details/6909959
"""
class EditDista... | true |
37791833300839c3b45d050783b9f00db6be3ded | JuanRojasC/Python-Mision-TIC-2021 | /Lambda Functions/Ejercicio 0 - Experimentacion.py | 874 | 4.125 | 4 | # FUNCIONES LAMBDA O ANONIMAS
funcion = lambda parametro : parametro
funcionSuma = lambda parametro1,parametro2 : parametro1 + parametro2
funcionResta = lambda parametro1,parametro2 : parametro1 - parametro2
funcionMultiplicacion = lambda parametro1,parametro2 : parametro1 * parametro2
funcionDivision = lambda paramet... | false |
fc46624c8d57c289ea99c4efdb5cc0de0c6d8e71 | namnhatpham1995/HackerRank | /findthepositionofnumberinlist.py | 559 | 4.28125 | 4 | #Given the participants' score sheet for your University Sports Day,
#you are required to find the runner-up score. You are given scores.
#Store them in a list and find the score of the runner-up.
# in put n=5, arr= 2 3 6 6 5 => output 5
if __name__ == '__main__':
n = int(input())
arr = map(int, input(... | true |
64234ee7f6d0b26f6a512e3da1526a4a82835b77 | dyrroth-11/Information-Technology-Workshop-I | /Python Programming Assignments/Assignemt2/18.py | 633 | 4.15625 | 4 | #!/usr/bin/env python3
"""
Created on Thu Apr 2 10:49:02 2020
@author: Ashish Patel
"""
"""
Define a function reverse() that computes the reversal of a string.
For example, reverse(“I am testing”) should return the string ”gnitset ma I”.
LOGIC:In this we take a string as input and define a empty string rev_string
... | true |
0a3fdbe0b48cedd0c706d38fd17273080ef34e43 | dyrroth-11/Information-Technology-Workshop-I | /Python Programming Assignments/Assignemt1/7.py | 884 | 4.21875 | 4 | #!/usr/bin/env python3
"""
Created on Wed Mar 25 07:34:41 2020
@author: Ashish Patel
"""
"""
# Write a Python function that prints out the first ‘n’ rows of Pascal's triangle. ‘n’ is user input.
LOGIC:1)As we know pascals triange consist of the binomial coefficient of (1+x)^(n-1) for nth row.
2)Therefore we com... | true |
1c36f2fee1cdbb19c9a4bc35467bb10216776c70 | dyrroth-11/Information-Technology-Workshop-I | /Python Programming Assignments/Assignemt4/13.py | 642 | 4.1875 | 4 | #!/usr/bin/env python3
"""
Created on Thu Apr 16 09:46:08 2020
@author: Ashish Patel
"""
"""
Write a NumPy program to find the number of elements of a given array, length of one array element in bytes,
and the total bytes consumed by the elements of the given array.
Example: Array = [1,2,3]
Size of the array... | true |
3f4871250a9a6d56f16f5ada8afd808db44b83c8 | tanjased/design_patterns | /04. prototype/prototype.py | 896 | 4.34375 | 4 | import copy
class Address:
def __init__(self, street_address, city, country):
self.street_address = street_address
self.city = city
self.country = country
def __str__(self):
return f'{self.street_address}, {self.city}, {self.country}'
class Person:
def __init__(self, name... | true |
a18155b85b4e0e3c27707d4c6691c57d3070277e | mkatkar96/python-basic-program | /all python code/file handing.py | 832 | 4.1875 | 4 | '''file handling -1.file handing is very important for accessing other data.
2.there are three modes in file hanling as read , write and append.
3.in read you can red only
4.in write you can write a data but when you write new line old one gets deletd
... | true |
fc428bc197e2fd2d8f7312d5c3f5255278fd09ee | gamladz/LPTHW | /ex16.py | 1,208 | 4.53125 | 5 | from sys import argv
script, filename = argv
# Takes the filename arguments and tells user its is liable to deletion
print "We're going to erase %r." % filename
print "if you don't want that, hit CTRL-C (^C)."
print "If you do want that, hit RETURN."
raw_input("?")
#Takes input of RETURN or CTRL-C to determine the u... | true |
a0b89a3cd0583036d7a6bbf23c8db205b77df95c | Astrolopithecus/SearchingAndSorting | /Searching & Sorting/binarySearch2.py | 1,219 | 4.34375 | 4 | #Program to search through a sorted list using a binary search algorithm
#Iterative version returns the index of the item if found, otherwise returns -1
def binarySearch(value, mylist):
low = 0
high = len(mylist)-1
while (low <= high):
mid = (low + high) // 2
if (mylist[mid] == valu... | true |
2d4c8c7933257b9cc535082659548d04061bbe6d | GBoshnakov/SoftUni-OOP | /Polymorphism and Abstraction/vehicles.py | 1,265 | 4.125 | 4 | from abc import ABC, abstractmethod
class Vehicle(ABC):
def __init__(self, fuel_quantity, fuel_consumption):
self.fuel_quantity = fuel_quantity
self.fuel_consumption = fuel_consumption
@abstractmethod
def drive(self, distance):
if distance * self.fuel_consumption <= self.fuel_quan... | true |
d3e7620455bf6813e1d7ad372f114f9196c9a0f8 | Tong-Wuu/Technical-Questions | /simple-dp-fib-example.py | 739 | 4.21875 | 4 | # find the nth fib number using dynamic programming
# Solution 1: Memoization with top down approach
def memoi(n):
memo = [None] * (n + 1)
return fib(n, memo)
def fib(i, memo):
if memo[i] is not None:
return memo[i]
if i == 1 or i == 2:
result = 1
else:
result = fib(i - 1... | false |
bc4c750579fbe676caa0b2360af236cff60f0d73 | rogeriog/dfttoolkit | /structure_editing/rotate.py | 2,081 | 4.28125 | 4 | #####################################################
### THIS PROGRAM PERFORMS SUCCESSIVE ROTATIONS IN A GIVEN VECTOR
### FOR EXAMPLE:
### USE $> python rotate.py [vx,vy,vz] x=30 y=90
### TO ROTATE VECTOR V=[vx,vy,vz] 30 degrees in X and 90 degrees in Y
#####################################################
import nu... | true |
d4d730739527523f773b5a69b26792bc503215e4 | Akshaya-Dhelaria-au7/coding-challenges | /coding-challenges/week03/day5/counting_sort.py | 465 | 4.15625 | 4 | '''Counting Sort'''
def countingSort(array):
n = len(array)
output = [0] * n
count = [0] * 100
for i in range(0, n):
count[array[i]] += 1
for i in range(1, 100):
count[i] += count[i - 1]
i = n - 1
while i >= 0:
output[count[array[i]] - 1] = array[i]
count[array[i]] -= 1
i -= 1
for... | false |
6456b274762f583c97fa7862acd1afc27ceaf9af | Akshaya-Dhelaria-au7/coding-challenges | /coding-challenges/week03/day5/index.py | 602 | 4.28125 | 4 | '''Given a sorted array and a target value, return the index if the target is found.
If not, return the index where it would be if it were inserted in order.'''
element=7
list=[1,3,5,6,8]
n=len(list)
#Index is used to find the position of the value within the list
index=list.index(6)
print("Position of index in list... | true |
7d9b01e16bdf914a9727fa6d7899fe8df96e5800 | dawidpacia/python-selenium | /python_tests/src/fibonacci_primary.py | 888 | 4.125 | 4 | def fibonacci(n_element):
"""
Calculating fibbonacci value
:param n_element: number of fibbonacci sequence
:return:
"""
a_1, a_2 = 0, 1
try:
if n_element == 1:
return a_1
if n_element == 2:
return a_2
if n_element <= 0:
return False... | false |
d9aabbc9a3e63ec8d48091ab8f49ce9a49f1f799 | Ashish-Surve/Learn_Python | /Training/Day5/Functional Programming/1_map_demo_in_python3.py | 1,232 | 4.21875 | 4 |
nums = [1,2,3]
squareelemnts = [i**2 for i in nums if i<3] #list comprehension
print("Original nums list = ", nums)
print("List of square elemnts = ", squareelemnts) #[1, 4]
def sq_elem(x):
return x**2
squareelemnts2 = [sq_elem(i)for i in nums]
print("List of square elemnts = ", squareelemnts2)#[1, 4, 9]
print(... | true |
9489322aa60c348a7da1c9d6f2b10fe94533578a | sarahmarie1976/CS_Sprint_Challenges | /src/Sprint_1/01_csReverseString.py | 838 | 4.4375 | 4 | """
Given a string (the input will be in the form of an array of characters), write a function that returns the reverse of the given string.
Examples:
csReverseString(["l", "a", "m", "b", "d", "a"]) -> ["a", "d", "b", "m", "a", "l"]
csReverseString(["I", "'", "m", " ", "a", "w", "e", "s", "o", "m", "e"]) -> ["e", "m"... | true |
e4379a3d7a2b92cc140decd99c5568c960f504b3 | ruancs/Python | /ordenacao.py | 237 | 4.125 | 4 | num1 = int(input("digite o primeiro número: "))
num2 = int(input("digite o segundo número: "))
num3 = int(input("digite o terceiro número: "))
if num1 < num2 < num3 :
print("crescente")
else:
print("não está em ordem crescente")
| false |
7eb2d3d1f9dec31542a2ff7c1c948c73f5394b31 | nishant-sethi/HackerRank | /DataStructuresInPython/sorting/MergeSort.py | 919 | 4.21875 | 4 | '''
Created on Jun 4, 2018
@author: nishant.sethi
'''
def merge_sort(unsorted_list):
if len(unsorted_list) <= 1:
return unsorted_list
# Find the middle point and devide it
middle = len(unsorted_list) // 2
left_list = unsorted_list[:middle]
right_list = unsorted_list[middle:]
... | true |
491560323401dca9ab3d8e5af49e516842bc5f1b | EduardoPNK/atividadesdiversas | /9.py | 584 | 4.1875 | 4 | #Crie um programa que declare uma matriz de dimensão 3x3
#e preencha com valores lidos pelo teclado.
#No final, mostre a matriz na tela, com a formatação correta.
matriz = [
[0, 0, 0],
[0, 0, 0],
[0, 0, 0]
]
for i, valor in enumerate(matriz):
for j , valor in enumerate(matriz[i]):
... | false |
855da4aad48c1bdcef773f0b768a6469fe90e948 | gtr25/python-basic | /Favorite Character Line Formation.py | 1,340 | 4.21875 | 4 | # This code gets a Maximum Characters per line, Favorite Character and words separated by commas
# From all the possible combinations of the words,
# After excluding the "Favorite Character" and white space,
# if the total number of characters is less than the "Maximum Characters" given by the user,
# That specific... | true |
bc3987ef3958064f976a273c125b83f9f03f51a9 | Dirtytrii/data-visualization | /randomWalk/randomWalk.py | 834 | 4.125 | 4 | from random import choice
class RandomWalk:
"""一个可以生成随机步数的类"""
def __init__(self, num_points=5000):
"""初始化随机漫步的属性。 """
self.num_points = num_points
self.x_values = [0]
self.y_values = [0]
def fill_walk(self):
"""实现随机漫步"""
# 不断漫步直到列表达到指定长度
while l... | false |
5e06d754b4b7553f56d4a2350eba508fc50c8de4 | ponka07/pythoncalc | /calculator.py | 865 | 4.21875 | 4 | print("this will only work with 2 numbers")
print('what do you want to calculate?')
print("1: add")
print("2: subtract")
print('3: multiply')
print('4: divide')
while True:
choice = input('add:1, subtract:2, multiply:3, divide:4, which one do you want? ')
if choice in ('1', '2', '3', '4'):
num1 = f... | true |
c18d0e7c99f628c2c5503881b86eac33473c5502 | frankhinek/Deep-Learning-Examples | /tf-max-pool.py | 1,450 | 4.15625 | 4 | '''
A simple max pooling example using TensorFlow library tf.nn.max_pool.
tf.nn.max_pool performs max pooling on the input in the form (value, ksize,
strides, padding).
- value is of shape [batch, height, width, channels] and type tf.float32
- ksize is the filter/window size for each dimension of the input tensor
- s... | true |
4a1e8de9890faa7ab037b47ff1dc503fea90e772 | goremd/Password-Generator | /pswd_gen.py | 846 | 4.25 | 4 | # Generate pseudo-random numbers
import secrets
# Common string operations
import string
# Defines what characters to use in generated passwords.
# String of ASCII characters which are considered printable.
# This is a combination of digits, ascii_letters, punctuation, and whitespace.
characters = string.asc... | true |
dc7d96836d73a18a2b1fe086b92f525889675762 | EduardoPessanha/Git-Python | /exercicios/utilidades/numero/__init__.py | 2,620 | 4.21875 | 4 | # from utilidades import cor
from Exercícios.utilidades.cor import corletra
def leiaint(texto):
"""
-> Lê um valor de entrada e faz a validação
para aceitar apenas um valor numérico.
:param texto: recebe o valor a ser validada.
:return: retorna um valor Inteiro.
"""
while True:
try... | false |
6787874265e6425437fb1a2b47c9843eef4fe587 | EduardoPessanha/Git-Python | /exercicios/ex113.py | 830 | 4.1875 | 4 | from utilitarios import titulo
from utilidades.numero import leiaint, leiafloat
# ************************ Desafio 113 ************************* #
# Funções aprofundadas em Python #
# Reescreva a função leiaInt() que fizemos no desafio 104, #
# incluindo agora a possibilidade da d... | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.