blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
a957213cad27ef8e8fcb5fcad84e18a9ff3ffa33 | Arun-9399/Simple-Program | /binarySearch.py | 550 | 4.15625 | 4 | #Binary Search Algorithm
def binarySearch(alist, item):
first=0
last= len(alist)-1
found= False
while first<= last and not found:
midpoint= (first+last)//2
if alist[midpoint]== item:
found= True
else:
if item<alist[midpoint]:
last= mid... | true |
342ddc75e963daefe5348880baeaee70eb1d58f1 | nikita-sh/CSC148 | /Lab 3/queue_client.py | 1,219 | 4.375 | 4 | """
Queue lab function.
"""
from csc148_queue import Queue
def list_queue(lst: list, q: Queue):
"""
Takes all elements of a given list and adds them to the queue. Then, checks
the queue for items that are not lists and prints them. If the item being
checked is a list, it is added to the queue. This p... | true |
1ec3e20f2743feadef75547e7c94d15bebe47939 | RuanNunes/Logica-de-Programa-o-com-Python | /WebProject1/listaEtuple.py | 962 | 4.25 | 4 | class listaEtuple(object):
#Tuple é um conjunto de dados na mes variavel definido com "()" e separado cada valor por virgula, as tuples não podem ser modificadas depois de instanciasdas
meses = ('janeiro','fevereiro','março','abril')
#listas também é um conjunto de dados porem separados por "[]", as listas pod... | false |
f86a9c4575fc01964b15d16df211d5881daf9a25 | educa2ucv/Material-Apoyo-Python-Intermedio | /Codigo/1-ProfundizandoEnFunciones/Ejercicio-1.py | 876 | 4.1875 | 4 | """
Ejercicio #01:
Desarrolle una función que reciba una lista
de asignaturas (Matemáticas, Fisica, Quimica, Historia y Lenguaje)
pregunta al usuario la nota que ha sacado en cada una y elimine de la lista
las asignaturas aprobadas. Al final, el programa debe mostrar
por pant... | false |
b4f9216dde63230dad5f5c85948151dbdd3119db | hicaro/practice-python | /sorting/mergesort.py | 1,417 | 4.28125 | 4 | class MergeSort(object):
'''
__merge Sort sorting algorithm implementation
- Best case: O(n log(n))
- Average case: O(n log(n))
- Worst case: O(n log(n))
'''
@staticmethod
def __merge(array, aux, lo, mid, hi):
for k in range(lo, hi + 1):
aux[k] = array[k... | false |
677822cf2d9796a31de51f13477c5f31d097da76 | hicaro/practice-python | /sorting/insertionsort.py | 502 | 4.125 | 4 | class InsertionSort(object):
'''
Insertion Sort sorting algorithm implementation
- Best case: O(n)
- Average case: O(n^2)
- Worst case: O(n^2)
'''
@staticmethod
def sort(numbers=None):
_len = len(numbers)
for i in range(1, _len):
to_insert = numbe... | true |
7df9e746b8e11f1e8d3dee1f840275f5e9763d68 | ruchitiwari20012/PythonTraining- | /operators.py | 693 | 4.53125 | 5 | # Arithmetic Operators
print(" 5+ 6 is ", 5+6)
print(" 5- 6 is ", 5-6)
print(" 5* 6 is ", 5*6)
print(" 5/6 is ", 5/6)
print(" 5//6 is ", 5//6)
# Assignment Operator
x=5
print(x)
x+=7
print(x)
x-=7
print(x)
x/=7
print(x)
#Comparison Operator
i=8
print(i==5)
print(i!=5)# i not equal to 5
print(i>=5... | true |
f2121f4abcd95f8f5a98aaee6103f703cd5aa357 | danismgomes/Beginning_Algorithms | /isPalindromeInt.py | 603 | 4.15625 | 4 | # isPalindrome
# It verifies if a integer number is Palindrome or not
answer = int(input("Type a integer number: "))
answer_list = []
while answer != 0: # putting every digit of the number in a list
answer_list.append(answer % 10) # get the first digit
answer = answer // 10 # remove the first digit
def ... | true |
a55db03c2d0ccfe6c86920ea4c26131ec980d539 | fahimnis/CS303_Computer_Programming_Projects | /Reverse.py | 505 | 4.21875 | 4 | # File: Reverse.py
# Description: Homework_4
# Student's Name: Fahim N Islam
# Student's UT EID: fni66
# Course Name: CS 303E
# Unique Number: 50180
#
# Date Created: 2/6/20
# Date Last Modified: 2/10/20
def Reverse():
x = int(input("Enter an integer: "))
a = int(x/100)
b = int(... | false |
f542b03e60b159f12efa105551ea0bce8d205aea | Emerson-O/PythonBasicoE_Gerber | /HT3.py | 806 | 4.15625 | 4 | #Ejercicio1
print("EJERCICIO 1")
con1 = input("Ingrese la contraseña a almacenar por favor: ")
print("")
contraseña = input("Introduce tu contraseña para ingresar: ")
print("")
if con1.lower() == contraseña.lower():
print("Contraseña correcta, Bienvenido")
else:
print("La contraseña incorrecta")
print... | false |
d257b52336940b64bc32956911164029f56c5f22 | maxz1996/mpcs50101-2021-summer-assignment-2-maxz1996 | /problem3.py | 1,587 | 4.40625 | 4 | # Problem 3
# Max Zinski
def is_strong(user_input):
if len(user_input) < 12:
return False
else:
# iterate through once and verify all criteria are met
number = False
letter = False
contains_special = False
uppercase_letter = False
lowercase_letter = False... | true |
7e52333c372dac152d046fb6d2f6ff763b9cf019 | rajila/courserapython | /enfoqueoopI.py | 1,132 | 4.125 | 4 | class SupA:
varA = 1
def __init__(self):
pass
def funA(self):
return 'A'
def funC(self):
return 'CA'
class SupB:
varB = 2
def __init__(self):
pass
def funB(self):
return 'B'
def funC(self):
return 'CB'
def do(self):
'''
... | false |
56c94622c6852985b723bf52b0c2f20d2617f6c8 | kaozdl/property-based-testing | /vector_field.py | 2,082 | 4.125 | 4 | from __future__ import annotations
from typing import Optional
import math
class Vector:
"""
representation of a vector in the cartesian plane
"""
def __init__(self, start: Optional[tuple]=(0,0), end: Optional[tuple]=(0,0)):
self.start = start
self.end = end
def __str__(self) ... | true |
033813da0698f0fbfee6e4925b9117b8faee476f | Jose-Humberto-07/pythonFaculdade | /funcoes/exe01.py | 376 | 4.21875 | 4 | def inverter(texto):
return texto[::-1]
pessoas = []
for p in range(3):
perguntas = {"Qual o seu nome?":"",
"Em que cidade você mora?":"",}
print((p+1),"° entrevistado")
for pe in perguntas:
print(pe)
perguntas[pe] = input()
print()
pessoas.ap... | false |
d629fb9d9ce965a27267cbc7db6a33662e0ff1d1 | vusalhasanli/python-tutorial | /problem_solving/up_runner.py | 403 | 4.21875 | 4 | #finding runner-up score ---> second place
if __name__ == '__main__':
n = int(input("Please enter number of runners: "))
arr = map(int, input("Please enter runners' scores separated by space: ").split())
arr = list(arr)
first_runner = max(arr)
s = first_runner
while s == max(arr):
arr.r... | true |
4a50cdce034f5fc9fe4367c141aa77af9379f2e2 | lariodiniz/Udemy-Python-Kivy | /app-comerciais-kivy/aulas/operacao_matematica.py | 719 | 4.21875 | 4 | #print(10+10)
#print(10(50.50))
'''
print(10-10)
print(1000-80)
print(10/5)
print(10/6)
print(10//6) # devolve a divisão sem os pontos flutuantes
print(10*800)
print(55*5)
#Módulo de Divisão
6 % 2 #Resultado da divisão entre dois numeros
print(3 % 2)
print(4 % 2)
print(5 % 2)
print(7 % 3.1)
num1 = float(input("D... | false |
d4ed2875ee9e98891d885e415d31ad470c268195 | lariodiniz/Udemy-Python-Kivy | /app-comerciais-kivy/aulas/interacao.py | 1,211 | 4.125 | 4 | # -*- coding: utf-8
#Enquanto
"""
x = 0
while( x <= 10):
print(x)
x += 1
#Enquanto com Else
x = 0
print("while")
while(x<10):
print(x)
x+= 1
else:
print("else")
print("fim")
#Laço For
#For em python sempre trabalha com lista
for c in "python":
print(c)
#range
range(0,10,2) # devolve um obje... | false |
0844afed653ec7311aa6e269867e2723f131deca | atg-abhijay/Fujitsu_2019_Challenge | /EReport.py | 1,374 | 4.34375 | 4 | import pandas as pd
def main():
"""
main function that deals with the file input and
running the program.
"""
df = pd.DataFrame()
with open('employees.dat') as infile:
"""
1. only reading the non-commented lines.
2. separating the record by ',' or ' ' into 3
... | true |
02d453b80c142ad4b130fd5c3f9748a588e4c49d | hansen487/CS-UY1114 | /Fall 2016/CS-UY 1114/HW/HW6/hc1941_hw6_q4.py | 460 | 4.25 | 4 | """
Name: Hansen Chen
Section: EXB3
netID: hc1941
Description: Read and evaluate a mathematical expression.
"""
expression=input("Enter a mathematical expression: ")
array=expression.split()
operand1=int(array[0])
op=array[1]
operand2=int(array[2])
output=0
if (op=='+'):
output=operand1+operand2
elif (op=='-'):
... | false |
c3e6a8a88cce32769e8fe867b8e0c166255a8105 | hansen487/CS-UY1114 | /Fall 2016/CS-UY 1114/HW/HW6/hofai/q6.py | 488 | 4.25 | 4 | password=input("Enter a password: ")
upper=0
lower=0
digit=0
special=0
for letter in password:
if (letter.isdigit()==True):
digit+=1
elif (letter.islower()==True):
lower+=1
elif (letter.isupper()==True):
upper+=1
elif (letter=='!' or letter=='@' or letter=='#' or letter=='$'):
... | true |
d82eafc8998a0a3930ee2d868158da93fca0329b | hansen487/CS-UY1114 | /Fall 2016/CS-UY 1114/HW/HW2/hc1941_hw2_q5.py | 844 | 4.15625 | 4 | """
Name: Hansen Chen
Section: EXB3
netID: hc1941
Description: Calculates how long John and Bill have worked.
"""
john_days=int(input("Please enter the number of days John has worked: "))
john_hours=int(input("Please enter the number of hours John has worked: "))
john_minutes=int(input("Please enter the number of minu... | true |
252e629263ab4295b2bb5cfaf34efd5998df2274 | syasky/python | /day03/03_python元组-tuple.py | 998 | 4.25 | 4 | #tuple 不可更改的数据类型
#语法 xxx=(1,2,3)
tuple1=(1,2,3)
print(tuple1)
#而且可以省略括号
tuple2=4,5,6
print(tuple2)
#注意: 单元素的元组创建时要注意,加一个逗号
tuple3=('aa',)
print(type(tuple3))
tuple4='bb',
print(type(tuple4))
#元组可以放多种数据
tuple5=('a',1,True,None,[1,2,3],tuple4)
print(tuple5)
#元组可以多变量一次赋值
a,b,c=100,200,300
pr... | false |
a7e9f749651d491f1c84f088ea128cbeaf18d9a5 | lindsaymarkward/cp1404_2018_2 | /week_05/dictionaries.py | 505 | 4.125 | 4 | """CP1404 2018-2 Week 05 Dictionaries demos."""
def main():
"""Opening walk-through example."""
names = ["Bill", "Jane", "Sven"]
ages = [21, 34, 56]
print(find_oldest(names, ages))
def find_oldest(names, ages):
"""Find oldest in names/ages parallel lists."""
highest_age = -1
highest_age_... | true |
96df163a93ed47fc84ed50b65857d9efa23d69ab | lhmisho/Data-Structure---Python-3 | /insertionSort.py | 341 | 4.15625 | 4 | def insertion_sort(L):
n = len(L)
for i in range(1, n):
item = L[i]
j = i - 1
while j >= 0 and L[j] > item:
L[j+1] = L[j]
j = j-1
L[j+1] = item
if __name__=="__main__":
L = [6,1,4,9,2]
print("Before sort: ", L)
insertion_sort(L)
pri... | false |
d0b18dd59833733b72f5ef43a9b3d53ea0d1d429 | Abarna13/Floxus-Python-Bootcamp | /ASSIGNMENT 1/Inverted Pattern.py | 278 | 4.21875 | 4 | '''
Write a python program to print the inverted pyramid?
* * * * *
* * * *
* * *
* *
*
'''
#Program
rows = 5
for i in range(rows,0,-1):
for j in range(0,rows-1):
print(end="")
for j in range(0,i):
print("*",end= " ")
print()
| true |
d9918e166dc1f669bed7f96b01cce30470f0a85a | nealsabin/CIT228 | /Chapter5/hello_admin.py | 599 | 4.21875 | 4 | usernames = ["admin","nsabin","jbrown","arodgers","haaron"]
print("------------Exercise 5-8------------")
for name in usernames:
if name == "admin":
print("Hello, admin. Would you like to change any settings?")
else:
print(f"Hello, {name}. Hope you're well.")
print("------------Exercise 5-9---... | true |
31d8a9230ed12e4d4cb35b2802a9c721c1d23d15 | nealsabin/CIT228 | /Chapter9/restaurant_inheritance.py | 1,049 | 4.21875 | 4 | #Hands on 2
#Exercise 9-2
print("\n----------------------------------------------------------")
print("-----Exercise 9-6-----\n")
class Restaurant:
def __init__(self, restaurant_name, cuisine_type):
self.restaurant_name = restaurant_name
self.cuisine_type = cuisine_type
self.number_served =... | true |
5e2463436e602ab6a8764adee0e48605f50a7241 | Jay07/CP2404 | /billCalc.py | 252 | 4.125 | 4 | print("Electricity Bill Estimator")
Cost = float(input("Enter cents per kWh: "))
Usage = float(input("Enter daily use in kWh: "))
Period = float(input("Enter number of billing days: "))
Bill = (Cost*Usage*Period)/100
print("Estimated Bill: $", Bill) | true |
c7dfa455c559c0e9c0379f03bd985908c6a3342f | Plain-ST/python_practice_55knock | /29.py | 668 | 4.3125 | 4 | """
29. 辞書(キーの存在確認)
今,以下のように辞書が作成済みです.
d = {'apple':10, 'grape':20, 'orange':30}
この辞書に対して,'apple'というキーが存在するかを確認し,存在しなければ,'apple'というキーに対して-1という値を追加してください.
また,同様のことを'pineapple'でも行なってください.その後,最終的な辞書を出力してください.
期待する出力:{'apple': 10, 'grape': 20, 'orange': 30, 'pineapple': -1}
"""
d = {'apple':10, 'grape':20, 'orange':30}
... | false |
42c4caab27c4cdd3afc59c6270f372c6e388edb3 | mvanneutigem/cs_theory_practice | /algorithms/quick_sort.py | 1,936 | 4.40625 | 4 |
def quick_sort(arr, start=None, end=None):
"""Sort a list of integers in ascending order.
This algorithm makes use of "partitioning", it recursively divides the
array in groups based on a value selected from the array. Values
below the selected value are on one side of it, the ones above it on the
... | true |
1c7605d505ea2a2176883eaba72cfc04ff2fb582 | knowledgewarrior/adventofcode | /2021/day1/day1-p1.py | 1,590 | 4.40625 | 4 | '''
As the submarine drops below the surface of the ocean, it automatically performs a sonar sweep of the nearby sea floor. On a small screen, the sonar sweep report (your puzzle input) appears: each line is a measurement of the sea floor depth as the sweep looks further and further away from the submarine.
For exampl... | true |
2c05503575eccf27161b3217d13da4027c91affb | dharunsri/Python_Journey | /Inheritance.py | 738 | 4.3125 | 4 | # Inheritance
# Accessing another classes is calles inheritance
class Songs: # Parent class / super class
def name(self):
print("People you know")
def name2(self):
print("Safe and sound")
class selena(Songs): # Child class/ sub class - ... | true |
aabb79dc9eb7d394bf9a87cd51d9dacde5eabf3e | dharunsri/Python_Journey | /Python - Swapping of 2 nums.py | 1,286 | 4.3125 | 4 | # Swapping of two numbers
a = 10 # 1010
b = 20 # 10100
# Method 1
temp = a
a = b
b = temp
print(" Swapping using a temporary variable is : " ,'\n',a, '\n',b)
# Method 2
a = a+b # 10 + 20 = 30
b = a-b # 30 - 20 = 10
a = a-b # 30 - 10 = 20
pr... | true |
2dd468406342dc6e8f767ba6d469613b19eed0ad | samanthamirae/Journey | /Python/OrderCostTracking.py | 2,862 | 4.25 | 4 | import sys
totalOrders = 0 #tracks number of orders in the batch
batchCost = 0 #tracks the total cost across all orders in this batch
# our functions
def orderprice(wA,wB,wC):
#calculates the cost total of the order
cTotal = 2.67 * wA + 1.49 * wB + 0.67 * wC
if cTotal > 100:
cTotal = cTota... | true |
788e78bede5679bcb0f93f4642602520baead921 | shirisha24/function | /global scope.py | 372 | 4.1875 | 4 | # global scope:-if we use global keyword,variable belongs to global scope(local)
x="siri"
def fun():
global x
x="is a sensitive girl"
fun()
print("chinni",x)
# works on(everyone) outside and inside(global)
x=2
def fun():
global x
x=x+x
print(x)
fun()
print(x)
# another example
x=9
def fun() :
... | true |
9332d185e61447e08fc1209f52ae41cecdc90132 | mchoimis/Python-Practice | /classroom3.py | 701 | 4.3125 | 4 | print "This is the grade calculator."
last = raw_input("Student's last name: ")
first = raw_input("Student's first name: ")
tests = []
test = 0 #Why test = 0 ?
while True:
test = input("Test grade: ")
if test < 0:
break
tests.append(test)
total = 0 ... | true |
7fb16ee09b9eb2c283b6e6cd2b2cabab06396a58 | mchoimis/Python-Practice | /20130813_2322_len-int_NOTWORKING.py | 1,302 | 4.1875 | 4 | """ input() takes values
raw_input() takes strings
"""
# Asking names with 4-8 letters
name = raw_input("Choose your username.: ")
if len(name) < 4:
print "Can you think of something longer?"
if len(name) > 8:
print "Uhh... our system doesn't like such a long name."
else:
print 'How are you, ', nam... | true |
85009ecac2bcdaeaf0b4ccf8cc715151574d28bd | rom4ikrom/Practical-session-5 | /last4.py | 417 | 4.25 | 4 | import math
print ("x^1 \t x^2 \t x^3")
print ("----------------------")
for num in range(1,6):
for power1 in range(1,2):
for power2 in range(2,3):
for power3 in range(3,4):
result1 = math.pow(num, power1)
result2 = math.pow(num, power2)
r... | false |
f91a713fff27f167f0c6e9924a2f8b39b5d99cd3 | Manuferu/pands-problems | /collatz.py | 919 | 4.40625 | 4 | # Manuel Fernandez
#program that asks the user to input any positive integer and outputs the successive values of the following calculation.
# At each step calculate the next value by taking the current value and, if it is even, divide it by two, but if it is odd,
# multiply it by three and add one. Have the program... | true |
5a388d39dbab1a59a8bf51df96b26eb51192e70e | manojkumarpaladugu/LearningPython | /Practice Programs/largest_num.py | 358 | 4.53125 | 5 | #Python Program to Find the Largest Number in a List
num_list = []
n = input("Enter no. of elements:")
print("Enter elements")
for i in range(n):
num = input()
num_list.append(num)
print("Input list is: {}".format(num_list))
big = 0
for i in num_list:
if i > big:
big = i
print("Largest num... | true |
0e1dfa0c61334091f7f6bbc09e8e72d3c1e7365b | manojkumarpaladugu/LearningPython | /Practice Programs/GeeksforGeeks Archive/vowel_string.py | 720 | 4.5 | 4 | # Program to accept the strings which contains all vowels
'''
#method1
def is_string_vowel(string):
vowels = {'a','e','i','o','u','A','E','I','O','U'}
for char in string:
if not (char=='a' or char=='e' or char=='i' or char=='o' or char=='u'):
if not (char=='A' or char=='E' or char=='I' or char=='O'... | false |
4655d4a9c07fdc83d990068507bb7a614bee7321 | manojkumarpaladugu/LearningPython | /Practice Programs/print_numbers.py | 310 | 4.34375 | 4 | #Python Program to Print all Numbers in a Range Divisible by a Given Number
print("Please input minimum and maximum ranges")
mini = input("Enter minimum:")
maxi = input("Enter maximum:")
divisor = input("Enter divisor:")
for i in range(mini,maxi+1,1):
if i % divisor == 0:
print("%d" %(i))
| true |
35b61f8813afb1b2f2fcbed2f6f0e9cb97097503 | manojkumarpaladugu/LearningPython | /Practice Programs/second_largest.py | 377 | 4.4375 | 4 | #Python Program to Find the Second Largest Number in a List
num_list = []
n = input("Enter no. of elements:")
print("Enter elements:")
for i in range(n):
num_list.append(input())
print("Input list is: {}".format(num_list))
num_list.sort(reverse=True)
print("The reversed list is: {}".format(num_list))
p... | true |
2a4a24cc323bc98d2cc0d4f007daec09b8a762ec | manojkumarpaladugu/LearningPython | /Practice Programs/GeeksforGeeks Archive/large_prime_factor.py | 440 | 4.40625 | 4 | # Python Program for to Find largest prime factor of a number
def is_prime(num):
for i in range(2, (num / 2) + 1, 1):
if num % i == 0:
return 0
return 1
def find_largest_prime_factor(num):
maxi = 0
for i in range(1, (num / 2) + 1, 1):
if num % i == 0:
if is_prime(i):
i... | false |
6fb77fed8433ef037ebbd70be628f2d0d462d480 | manojkumarpaladugu/LearningPython | /Practice Programs/GeeksforGeeks Archive/binary_palindrome.py | 460 | 4.15625 | 4 | # Python | Check if binary representation is palindrome
def check_binary_palindrome(binary):
reverse_binary = ""
i = len(binary) - 1
while i >= 0:
reverse_binary += binary[i]
i -= 1
if reverse_binary == binary:
return 1
else:
return 0
binary = str(input("Enter a binary umber:"... | false |
56b022638dff063eefcda1b732613b1441b0bde3 | vinromarin/practice | /python/coursera-programming-for-everbd/Exercise_6-3.py | 402 | 4.125 | 4 | # Exercise 6.3 Encapsulate this code in a function named count, and generalize it
# so that it accepts the string and the letter as arguments.
def count(str, symbol):
count = 0
for letter in str:
if letter == symbol:
count = count + 1
return count
str_inp = raw_input("Enter string:")
smb... | true |
e70a3ca8aeb66c993ba550fa3261f51f5c4ea845 | PurneswarPrasad/Good-python-code-samples | /collections.py | 2,017 | 4.125 | 4 | #Collections is a module that gives container functionality. We'll discuss their libraries below.
#Counter
from collections import Counter
#Counter is a container that stores the elemnts as dictionary keys and their counts as dictionary values
a="aaaaaabbbbcc"
my_counter=Counter(a) #makes a dictionary of a
print(my_c... | true |
3798ed579d458994394902e490bd4afb781c843d | petr-jilek/neurons | /models/separationFunctions.py | 1,055 | 4.25 | 4 | import math
"""
Separation and boundary function for dataGenerator and separators.
Separation function (x, y): Return either 1 or 0 in which region output is.
Boundary function (x): Return value of f(x) which describing decision boundary for learning neural network.
"""
# Circle separation and boundary functions.
# ... | true |
dc11626d5790450752c98f192d4ddee383b21aae | teebee09/holbertonschool-higher_level_programming | /0x03-python-data_structures/3-print_reversed_list_integer.py | 227 | 4.59375 | 5 | #!/usr/bin/python3
def print_reversed_list_integer(my_list=[]):
"prints all integers of a list, in reverse order"
if my_list:
for n in range(0, len(my_list)):
print("{:d}".format(my_list[(-n) - 1]))
| true |
5fdf358cac32bc7fea9d0d862a9613d742675043 | sanjay-chahar/100days | /pizza-order.py | 668 | 4.21875 | 4 | pizza = input("What size pizza you want to order? S,M and L = ")
pepperoni = input("Do you want to add pepperoni ? Y or N = ")
cheese = input("Do you want add extra cheese? Y or N = ")
price = 0
if pizza == "S":
price += 15
if pepperoni == "Y":
price += 2
# print(f"Pizza price is £{price}")
eli... | false |
4a4c9eb5d19396aa917b6ea5e9e74ab168b7287d | jramos2153/pythonsprint1 | /main.py | 2,176 | 4.40625 | 4 | """My Sweet Integration Program"""
__author__ = "Jesus Ramos"
#Jesus Ramos
# In this program, users will be able to solve elementary mathematical equations and graph.
name = input("Please enter your name: ")
print("Welcome", name, "!")
gender = input("Before we start, tell us a bit about your self. Are you male or fe... | true |
614dcefde41a4b7d064f8248fceb4a7d3204e60e | fernandosergio/Documentacoes | /Python/Praticando/Utilização da linguagem/while encaixado desafio.py | 675 | 4.3125 | 4 | #usuario vai digita uma sequencia de numeros
#imprimi o fatorial do numero digitado
#while sem função
#entrada = 1
#while entrada => 0:
# entrada = int(input("Digite um número natural ou 0 para parar: "))
# i = 1
# anterior = 1
# while i <= entrada:
# mult = anterior * i
# anterior = mult
# ... | false |
06f51bde337c4f60bae678ada677654c4bab7afd | ramjilal/python-List-Key-concept | /shallow_and_deep_copy_list.py | 1,400 | 4.53125 | 5 | #use python 2
#first simple copy of a list, List is mutable so it can be change by its copy.
x = [1,2,3]
y = x # here list 'y' and list 'x' point to same content [1,2,3].
y[0]=5 # so whenever we will change list 'y' than list 'x' would be change.
print x #print -> [5,2,3]
print y #print -> [5,2,3]
#... | true |
00c319cb96b7c226943266109c4e48c723fc4ff5 | bhargavpydimalla/100-Days-of-Python | /Day 1/band_generator.py | 487 | 4.5 | 4 | #1. Create a greeting for your program.
print("Hello there! Welcome to Band Generator.")
#2. Ask the user for the city that they grew up in.
city = input("Please tell us your city name. \n")
#3. Ask the user for the name of a pet.
pet = input("Please tell us your pet's name. \n")
#4. Combine the name of their city a... | true |
67dcf2f90962af4a64ae3e0907e051f558755771 | realme1st/Data-structurePython | /linkedlist3.py | 720 | 4.28125 | 4 | # 파이썬 객체지향 프로그래밍으로 링크드 리스트 구현
class Node:
def __init__(self,data,next=None):
self.data=data
self.next = next
class NodeMgmt:
def __init__(self,data):
self.head = Node(data)
def add(self,data):
if self.head == "":
self.head =Node(data)
else:
... | false |
7a183fdbe4e63ee69c2c204bfaa69be6e7e29933 | demelziraptor/misc-puzzles | /monsters/monsters.py | 2,634 | 4.125 | 4 | import argparse
from random import randint
"""
Assumptions:
- Two monsters can start in the same place
- If two monsters start in the same place, they ignore eachother and start by moving!
- All monsters move at each iteration
- For some reason, the monsters always move in the same order...
- This monster world runs p... | true |
349cb6b10ae1affa50838b3d88d634101c5553c0 | kwohl/python-multiple-inheritance | /flower-shop.py | 2,628 | 4.125 | 4 | class Arrangement:
def __init__(self):
self.flowers = []
def enhance(self, flower):
self.flowers.append(flower)
class MothersDay(Arrangement):
def __init__(self):
super().__init__()
def enhance(self, flower):
if isinstance(flower, IOrganic):
self.flowers... | false |
d927fecd196dab0383f022b4a5669a47e7f9fb37 | Oyelowo/GEO-PYTHON-2017 | /assignment4/functions.py | 2,671 | 4.40625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Sep 27 11:15:48 2017
@author: oyeda
"""
##You should do following (also criteria for grading):
#Create a function called fahrToCelsius in functions.py
#The function should have one input parameter called tempFahrenheit
#Inside the function, create a variable called converte... | true |
ca0d0d446cbc2a2cbf3f0f99a4ce6358cb913ccf | PiaNgg/t08.chunga_huatay | /iteracion.chunga.py | 1,211 | 4.15625 | 4 | #EJERCIOIO 1
fruta="Pera"
for i in fruta:
print(i)
print("-----")
#EJERCIOIO 2
fruta="Manzana"
for i in fruta:
print(i)
print("-----")
#EJERCIOIO 3
fruta="platano"
for i in fruta:
print(i)
print("-----")
#EJERCIOIO 4
fruta="Mango"
for i in fruta:
print(i)
print("-----")
... | false |
14265fcb05c67d2b45d8bfe5ccb5f97c8b28295d | Dartnimus/for-Andersen | /name_Vyacheslav.py | 420 | 4.375 | 4 | '''
Составить алгоритм: если введенное имя совпадает с Вячеслав,
то вывести “Привет, Вячеслав”, если нет, то вывести "Нет такого имени"
'''
name = input("Введите имя ")
if name == 'Вячеслав':
print("Привет, {}".format(name))
else:
print("Нет такого имени") | false |
8913aa3c08840276a068ebe6b6d6d69afe519167 | AndrewKalil/holbertonschool-machine_learning | /unsupervised_learning/0x02-hmm/1-regular.py | 2,114 | 4.28125 | 4 | #!/usr/bin/env python3
""" Regular Markov chain """
import numpy as np
def markov_chain(P, s, t=1):
"""determines the probability of a markov chain being in a
particular state after a specified number of iterations
Args:
P is a square 2D numpy.ndarray of shape (n, n)
represent... | true |
d9d934e204e8a0503d96f17fc16433cc2ba42a2e | oscarhscc/algorithm-with-python | /LeetCode/538. 把二叉搜索树转换为累加树.py | 984 | 4.125 | 4 | '''
给定一个二叉搜索树(Binary Search Tree),把它转换成为累加树(Greater Tree),使得每个节点的值是原来的节点值加上所有大于它的节点值之和。
例如:
输入: 原始二叉搜索树:
5
/ \
2 13
输出: 转换为累加树:
18
/ \
20 13
'''
# Definition for a binary tree node.
# class TreeNode(object):
#... | false |
26144b4784b9602b473a8d1da19fe8b568fdc662 | blackdragonbonu/ctcisolutions | /ArrayStringQ3.py | 948 | 4.4375 | 4 | '''
The third question is as follows
Write a method to decide if two strings are anagrams or not.
We solve this by maintaining counts of letters in both strings and checking if they are equal, if they are they are anagrams. This can be implemented using a dictionary of byte array of size 26
'''
from collections impor... | true |
6aa56313f436099121db045261afc16dbcac9595 | Adrianbaldonado/learn_python_the_hard_way | /exercises/exercise_11.py | 304 | 4.25 | 4 | """Asking Qestions
The purpose of this exercise is to utilize all ive learned so far
"""
print("How old are you?", end=' ')
age = (' 22 ')
print("How tall are you?", end=' ')
height = ( 5 )
print("How do you weigh?", end=' ')
weight = ('160')
print(f"So, you're{age} old, {height} tall and {weight}") | true |
18b210811e067834d980f7b80b886d36e060d65b | deepikaasharma/unpacking-list | /main.py | 310 | 4.34375 | 4 | # Create a list
some_list = ['man', 'bear', 'pig']
# Unpack the list
man, bear, pig = some_list
'''
The statement above is equivalent to:
man = some_list[0]
bear = some_list[1]
pig = some_list[2]
'''
# Show that the variables represent the values of the original list
print(man, bear, pig)
print(some_list) | true |
1a6dfa2fb7db6a3d0d4c349afc09c7868dc3af5e | micha-wirth/Lecturio | /loops.py | 422 | 4.15625 | 4 | # for x in list
for x in [1, 2, 3]:
print(x)
# for c in string
for c in 'abc':
print(c)
# for i in range(0, 3, 1):
for i in range(3):
print(i)
print(list(range(3)))
# while-loop
x = 0
while x < 3:
print(x)
x += 1
# break-statement
while True:
if x == 3:
print('End of while-loop')
... | false |
eb0ba706baa251c56bbaaaafa25110ae5b7d18db | micha-wirth/Lecturio | /sequences.py | 248 | 4.1875 | 4 | text = 'abcdefghiklm'
print('a' in text)
print('x' in text)
t = tuple(range(3))
print(0 in t)
print(3 in t)
# Last element of a sequence.
print(text[len(text) - 1])
print(text[-1])
print(max(text))
print(t[len(t)-1])
print(t[-1])
print(max(t))
| false |
9ee2d6ea090f939e7da651d7a44b204ff648168a | ShumbaBrown/CSCI-100 | /Programming Assignment 3/guess_the_number.py | 874 | 4.21875 | 4 | def GuessTheNumber(mystery_num):
# Continually ask the user for guesses until they guess correctly.
# Variable to store the number of guesses
guesses = 0
# loop continually ask the user for a guess until it is correct
while (True):
# Prompt the user of a guess
guess = int(input('En... | true |
d02467d8e5ec22b8daf6e51b007280d3f4c8a245 | malav-parikh/python_programming | /string_formatting.py | 474 | 4.4375 | 4 | # leaning python the hard way
# learnt the basics
# string formatting using f
first_name = 'Malav'
last_name = 'Parikh'
middle_name = 'Arunkumar'
print(f"My first name is {first_name}")
print(f"My last name is {last_name}")
print(f"My middle name is {middle_name}")
print(f"My full name is {first_name} {middle_name}... | true |
e4e80522ce19e03c1c6bceee954741d324d79b44 | ffabiorj/desafio_fullstack | /desafio_parte_1/question_1.py | 504 | 4.1875 | 4 | def sum_two_numbers(arr, target):
"""
The function receives two parameters, a list and a target.
it goes through the list and checks if the sum of two numbers
is equal to the target and returns their index.
"""
number_list = []
for index1, i in enumerate(arr):
for index2, k... | true |
836b0ef11b1e389e78b91511b9fcbfe167b3d420 | AnhVuH/vuhonganh-fundamental-c4e16 | /session05/homework/ex3.py | 258 | 4.15625 | 4 | bacterias = int(input('How many B bacterias arer there? '))
minutes = int(input('How much time in minutes will we wait? '))
for time in range(1,minutes,2):
bacterias *= 2
print("After {} minutes, we would have {} bacterias".format(minutes, bacterias))
| false |
e3c20aa1677c13d4c0ccf63d2f7180e717a39cb4 | AnhVuH/vuhonganh-fundamental-c4e16 | /session02/yob.py | 259 | 4.125 | 4 | yob = int(input("Your year of birth: \n"))
age = 2018 - yob
print("Your age: ",age)
if age < 10: #conditional statement
print("Baby")
elif age <= 18:
print("teenager")
elif age ==24:
print("asfsdfsdf")
else:
print("Not baby")
print("Bye")
| false |
58f0290c093677400c5a85267b1b563140feda85 | FrancescoSRende/Year10Design-PythonFR | /FileInputOutput1.py | 1,512 | 4.53125 | 5 | # Here is a program that shows how to open a file and WRITE information TO it.
# FileIO Example 3
# Author: Francesco Rende
# Upper Canada College
# Tell the user what the program will do...
print ("This program will open a file and write information to it")
print ("It will then print the contents to the screen for y... | true |
2306ffb05eecd0dc048f36c8359b7684178f0634 | MuhammadRehmanRabbani/Python | /Average of 2D Array python/average.py | 1,260 | 4.28125 | 4 |
# defining the average function
def average(matrix,matrix_size):
my_sum = 0 # declaring variable to store sum
count = 0 # declaring variable to count total elements of 2D array
# this for loop is calculating the sum
for i in range(0, matrix_size):
for j in range(0, matrix_size):
... | true |
356a8c8ecc88afd964c5a83dc438890a3326b483 | girishsj11/Python_Programs_Storehouse | /Daily_coding_problems/daily_coding_2.py | 737 | 4.125 | 4 | '''
Given an array of integers, return a new array such that each element at index i of the new array is the product of all the numbers in the original array except the one at i.
For example, if our input was [1, 2, 3, 4, 5], the expected output would be [120, 60, 40, 30, 24]. If our input was [3, 2, 1], the expect... | true |
9d3dad6f365a6e73d00d90411f80a1a6e165f0cf | girishsj11/Python_Programs_Storehouse | /codesignal/strstr.py | 1,378 | 4.125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Jan 26 12:33:18 2021
@author: giri
"""
'''
Avoid using built-in functions to solve this challenge. Implement them yourself, since this is what you would be asked to do during a real interview.
Implement a function that takes two strings, s and x, as a... | true |
1f75ec5d58684cd63a770bd63c7aab3ee7b26de6 | girishsj11/Python_Programs_Storehouse | /codesignal/largestNumber.py | 569 | 4.21875 | 4 | '''
For n = 2, the output should be
largestNumber(n) = 99.
Input/Output
[execution time limit] 4 seconds (py3)
[input] integer n
Guaranteed constraints:
1 ≤ n ≤ 9.
[output] integer
The largest integer of length n.
'''
def largestNumber(n):
reference = '9'
if(n==1):
return int(reference)
eli... | true |
478ed1b0685ac4fda3e3630472b2c05155986d50 | girishsj11/Python_Programs_Storehouse | /codesignal/Miss_Rosy.py | 2,510 | 4.15625 | 4 | '''
Miss Rosy teaches Mathematics in the college FALTU and is noticing for last few lectures that the turn around in class is not equal to the number of attendance.
The fest is going on in college and the students are not interested in attending classes.
The friendship is at its peak and students are taking turns fo... | true |
b986d60ff29d4cf7ff66d898b5f0f17a29a168cb | girishsj11/Python_Programs_Storehouse | /prime_numbers_generations.py | 577 | 4.1875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Jan 14 16:00:24 2021
@author: giri
"""
def is_prime(num):
"""Returns True if the number is prime
else False."""
if num == 0 or num == 1:
return False
for x in range(2, num):
if num % x == 0:
return False
... | true |
8b6aad04e70312c2323d1a8392cef1bc10587b2e | Stone1231/py-sample | /loop_ex.py | 413 | 4.125 | 4 | for i in [0, 1, 2, 3, 4]:
print(i)
for i in range(5):
print(i)
for x in range(1, 6):
print(x)
for i in range(3):
print(i)
else:
print('done')
#A simple while loop
current_value = 1
while current_value <= 5:
print(current_value)
current_value += 1
#Letting the user choose when to qu... | true |
ded47265e7eda94698d63b24bd4665b2e8afb16e | mikvikpik/Project_Training | /whitespace.py | 308 | 4.1875 | 4 | """Used in console in book"""
# Print string
print("Python")
# Print string with whitespace tab: \t
print("\tPython")
# Print multiple whitespaces and strings
print("Languages:\nPython\nC\nJavaScript")
# variable set to string and call variable without print
favorite_language = "python"
favorite_language
| true |
7791023ad7a3561d91401b22faeff3fce3a1c7c8 | EoinMcKeever/Test | /doublyLinkedListImplemention.py | 1,028 | 4.4375 | 4 | class Node:
def __init__(self, data):
self.data = data
self.next = None
self.previous = None
class DoublyLinkedList:
def __init__(self):
self.head = None
self.tail = None
#insert at tail(end) of linked list
def insert(self, data):
new_node = Node(data)
if self.head is None:
self.head = new_node
... | true |
d795bad87b7b902d05ee026e5f280a131aa15a89 | trajeshmca21/rajesht | /assignent/assignment4/usecase2.py | 279 | 4.15625 | 4 | even = [ x for x in range(20) if x % 2 == 0]
odd= [ x for x in range(20) if x %2 != 0]
square=[x*x for x in range(20) ]
cube=[x*x*x for x in range(20)
print("print square of list",square)
print"odd numbers",(odd)
print("print even numbers",even)
print("print cube",cube) | false |
1da86b9c0e953787d0ae33850015e6f3aea85f7b | rekhinnvs/learnPython | /HackerRank/codes/Conditional.py | 435 | 4.40625 | 4 | # Given an integer, , perform the following conditional actions:
#
# If n is odd, print Weird
# If n is even and in the inclusive range of 2 to 5, print Not Weird
# If n is even and in the inclusive range of 6 to 20, print Weird
# If n is even and greater than 20, print Not Weird
N = int(raw_input().strip())
if N%2 !=... | false |
5edf8cb2a9e0e25df4d2ce8e76c143b7b43e4f91 | scheffeltravis/Python | /Fractals/Tree.py | 761 | 4.25 | 4 | """
Tree.py
Simple fractal program which draws a tree based on bifurcation in terms
of 'branch' length.
"""
import turtle
# Draw a tree recursively
def drawTree (ttl, length):
if length > 5:
ttl.forward (length)
ttl.right (20)
drawTree (ttl, length - 15)
ttl.left (40)
drawTree (ttl,... | false |
6eb48816205257b528b1aefd8f03fa8206716aa9 | sayee2288/python-mini-projects | /blackjack/src/Deck.py | 1,401 | 4.1875 | 4 | '''
The deck class simulates a deck of cards and
returns one card back to the player or the dealer randomly.
'''
import random
class Deck:
'''
The deck class creates the cards
and has functions to return a card or shuffle all cards
'''
def __init__(self):
print('Deck is ready for the game'... | true |
0240991d2a500c398cfd17ea1ac3616d00dd09dd | Spandan-Madan/python-tutorial | /8_while_loops.py | 2,147 | 4.40625 | 4 | import random
# ** While Loops **
# What if you want your code to do something over and over again until some
# condition is met?
# For instance, maybe you're writing code for a timer
# and you want to keep checking how much time has passed until you have waited
# the correct amount of time.
# Then you should us... | true |
e6bed67b87876e59d12ad8a0e2776649b169f3bf | Spandan-Madan/python-tutorial | /5_booleans.py | 1,334 | 4.40625 | 4 | # ** Boolean Comparisons **
print("Examples of boolean comparisons")
# Python also supports logical operations on booleans. Logical operations take
# booleans as their operands and produce boolean outputs. Keep reading to learn
# what boolean operations Python supports.
# And
# The statement `a and b` evaluates t... | true |
b6965d0d5ebe028780d4ba63d10d1c159fab97c7 | jasonwee/asus-rt-n14uhp-mrtg | /src/lesson_text/re_groups_individual.py | 407 | 4.1875 | 4 | import re
text = 'This is some text -- with punctuation.'
print('Input text :', text)
# word starting with 't' then another word
regex = re.compile(r'(\bt\w+)\W+(\w+)')
print('Pattern :', regex.pattern)
match = regex.search(text)
print('Entire match :', match.group(0))
print('Word ... | true |
8025c47447a18c0f93b4c59c6c1191c6b0c6454a | shail0804/Shail-Project | /word_series.py | 2,137 | 4.125 | 4 | def Character_to_number():
""" This function converts a given (User Defined) Character to Number\
as per the given Pattern (2*(Previous Character) + counter) """
nb = input('please enter the character: ')
nb = nb.upper()
count = 1
sum = 0
for s in range(65,ord(nb)+1):
sum = sum*2... | true |
e8596535535979655079184dbf2d61899b8610b3 | diptaraj23/TextStrength | /TextStrength.py | 324 | 4.25 | 4 | #Calculating strength of a text by summing all the ASCII values of its characters
def strength (text):
List=[char for char in text] # storing each character in a list
sum=0
for x in List:
sum=sum+ord(x) #Extracting ASCII values using ord() function and then adding it in a loop
return... | true |
1775f4ecf0c6270b6209dd68358899fa92c8387c | jasonchuang/python_coding | /27_remove_element.py | 897 | 4.40625 | 4 | '''
Example 1:
Given nums = [3,2,2,3], val = 3,
Your function should return length = 2, with the first two elements of nums being 2.
It doesn't matter what you leave beyond the returned length.
Example 2:
Given nums = [0,1,2,2,3,0,4,2], val = 2,
Your function should return length = 5, with the first five elements of n... | true |
ce6f6114512ae2682c8902999118c08474da92fd | alanamckenzie/advent-of-code | /advent2017/code/utils.py | 403 | 4.15625 | 4 | def read_file(filename, line_delimiter='\n'):
"""Read the contents of a file
:param str filename: full path to the text file to open
:param line_delimiter: line delimiter used in the file
:return: contents of the file, with one list item per line
:rtype: list
"""
with open(filename, 'r... | true |
36ac8905679118a796c0ea1e073b8f4c035f3246 | campbellerickson/CollatzConjecture | /Collatz.py | 540 | 4.25 | 4 | print "Type '123' to start the program::",
check = input()
if check == 123:
print "To what number would you like to prove the Collatz Conejecture?::"
limit = input()
int(limit)
for x in xrange(1,limit+1):
num=x
original=x
iterations=0
while num > 1:
if (num % 2 == 0):
num = num/2
iteration... | true |
a3ce178e270557e7711aa92a860f2d6820531dcc | KSSwimmy/python-problems | /csSumOfPostitive/main.py | 776 | 4.125 | 4 | # Given an array of integers, return the sum of all positive integers in an array
def csSumOfPositive(input_arr):
# Solution 1
sum = 0
for key, value in enumerate(input_arr):
if value <= 0:
continue
else:
sum += value
return sum
# Solution 2
'''
... | true |
8c99e5d3a112f865f0d8c90f98be43ce6c1e7e01 | moorea4870/CTI110 | /P5HW2_GuessingGame_AvaMoore.py | 817 | 4.28125 | 4 | # Using random to create simple computer guessing game
# July 5, 2018
# CTI-110 P5HW2 - Random Number Guessing Game
# Ava Moore
# use random module
import random
# set minimum and maximum values (1-100)
MIN = 1
MAX = 100
def main():
#variable to control loop
again = 'y'
#until the user i... | true |
444179e90b2b2cffdf645e97c8e48cd9c86d2923 | dmunozbarras/Practica-6-Python | /ej6-6.py | 649 | 4.21875 | 4 | # -*- coding: cp1252 -*-
"""DAVID MUÑOZ BARRAS - 1º DAW - PRACTICA 6 - EJERCICIO 6
Escribe un programa que permita crear una lista de palabras y que, a continuación,
cree una segunda lista igual a la primera, pero al revés (no se trata de escribir
la lista al revés, sino de crear una lista distinta).
"""
num=inpu... | false |
c565083b6d11e6bb8403b0e4c3083ea695a4f5fa | Hanjyy/python_practice | /conditional2.py | 1,677 | 4.1875 | 4 | '''
purchase_price = int(input("What is the purchase price: "))
discount_price_10 = (10 /100 )* (purchase_price)
final_price_10 = purchase_price - discount_price_10
discount_price_20 = (20/100) * (purchase_price)
final_price_20 = purchase_price - discount_price_20
if purchase_price < 10:
print("10%", final_price_... | true |
20a497f0e1df4edff5d710df5b8fa4839998ca18 | hihasan/Design-Patterns | /Python In these Days/practice_windows/com/hihasan/ListPractice.py | 786 | 4.25 | 4 | number=[1,2,3,4]
#print list
print(number)
#Accessing Elements In A List
print(number[0])
print(number[-1])
print(number[-2])
print(number[0]+number[2])
#changing, adding & removing elements
names=["Hasan","Mamun","Al","Nadim"]
names.append("Tasmiah") #When we append an item in the list, it will store in last
prin... | true |
fe0a64036e5a1317c0dcaaded3a332a6d33594a7 | axecopfire/Pthw | /Exercises/Ex15_Reading_FIles/Reading_Files.py | 1,392 | 4.5625 | 5 | # Importing argv from the system module
from sys import argv
# argv takes two variables named filename and script
script, filename = argv
# The variable txt opens filename, which is an argv variable
txt = open(filename)
# filename is entered after this prompt, which is then assigned to the variable txt. At the same ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.