blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
ea7b254cac5d2fce96496f8a6fa49d573ef83078 | seema1711/My100DaysOfCode | /Day 5/AddEleQueue.py | 984 | 4.21875 | 4 | <<<<<<< HEAD
### ADDING ELEMENTS TO A QUEUE ###
class Queue:
def __init__(self):
self.queue = list()
def add(self,dataval):
# Insert method to add element
if dataval not in self.queue:
self.queue.insert(0,dataval)
return True
return False
def size(self):
... | true |
44b0f6ad8977686865b8eb3fc78b6215533715d1 | KlimentiyFrolov/-pythontutor | /Занятие 8. Функции и рекурсия/задача 2.PY | 243 | 4.1875 | 4 | #http://pythontutor.ru/lessons/functions/problems/negative_power/
def power(a, n):
b = 1
for i in range(abs(n)):
b *= a
if n >= 0:
return b
else:
return 1 / b
print(power(float(input()), int(input()))) | true |
49f4af3bb658ec31944b69a42b1745300aa849b0 | HenFaibishProjects/Python | /mine/The-Basic/If-Else.py | 485 | 4.21875 | 4 | # Simple if condition:
num1 =5
if num1 > 4:
print num1
# Using and,or,not
num2 =5
if num2 > 4 and num2 < 3:
print num2
num3 =5
if num3 > 4 or num3 < 3:
print num3
num4 =5
if not num4 == 4:
print num4
# Add Elese:
num5 = 10
if num5 > 5:
print 'Num5 is bigger then 5'
else:
print 'Num5 is smaller the... | false |
1197b645af240babf6cefa4be8af88f32149ed3e | jthiruveedula/PythonProgramming | /Regex/patternStar.py | 512 | 4.21875 | 4 | #asterisk is used to find patterns based on left or right position from asterisk
pattern='swi*g'
import re
string = '''I am black!
I am swinging in the sky,
I am wringing worlds awry;'''
match =re.match(pattern,string)
search =re.search(pattern,string)
findall =re.findall(pattern,string)
print("Match Method: " ,matc... | true |
d2382eb19ffc091fedcc333b0d3c96a010804127 | jthiruveedula/PythonProgramming | /DataEngineering/sets.py | 1,133 | 4.25 | 4 | #Branch of Mathematics applied to collection of objects
#i.e., sets
#Python has built in set datatype with accompanying methods
# instersection (all elements that are in both sides)
#difference(elements in one set but not in other set)
#symmetric_difference(all elements in exactly one set)
#union ( all elements that a... | true |
df5f166e5011a902893c503e8c9237a309f0e293 | HeroRacerNiko/lesson_5_hw | /count_odds_and_evens.py | 2,141 | 4.28125 | 4 | # Function check only WHOLE number
# Function doesn't check for digits duplication in the parameter number input
# For example 44411 would return 3 even digits and 2 odds
# Function does NOT skip count with duplicate digit and will count and add to list of evens or odds
def count_odds_and_evens(num):
while not num... | true |
6c1456aa803cfe446a9b9df5c17d2d4c2e430fe7 | OMerkel/Fractals | /Hilbert/Howto/hilbert-howto-3.py | 1,632 | 4.375 | 4 | #!/usr/bin/env python3
"""
How to draw a Hilbert Curve - Step 3
In step 2 the turtle drew a hilbert curve in iteration n=0
"""
import turtle
COLOR = [ 'blue' ]
def hilbert( turtle, length, depth ):
"""
hilbert shall recursively call itself
The function holds a parameter depth that is decre... | true |
0ba643609336a3ffed063e32526fc246e14e2e5c | cinthiatengan/Basic-Python | /Ex_Files_Python_EssT/Exercise Files/Chap04/conditional.py | 222 | 4.15625 | 4 | #!/usr/bin/env python3
# Copyright 2009-2017 BHG http://bw.org/
x = 1
if x>= 5:
print('verdadeiro porque {} >= 5'.format(x))
elif x == 3:
print('{} == 3'.format(x))
else:
print('{} é menor que 5'.format(x))
| false |
371a13b27ba338050a1e885cb53f1d426f9fede1 | pedrottoni/Studies-Python | /Cursoemvideo/Mundo2/exercise036.py | 799 | 4.375 | 4 | '''
Escreva um programa para aprovar o empréstimo bancário para a compra de uma casa. Pergunte o valor da casa, o salário do comprador e em quantos anos ele vai pagar. A prestação mensal não pode exceder 30% do salário ou então o empréstimo será negado.
'''
house_price = float(input('Qual o valor da casa? '))
buyer_sal... | false |
fe131b33f35efa66510e7543b46f636fe1a07eca | pedrottoni/Studies-Python | /Cursoemvideo/Mundo2/exercise059.py | 1,189 | 4.34375 | 4 | '''
Crie um programa que leia dois valores e mostre um menu na tela:
[ 1 ] somar
[ 2 ] multiplicar
[ 3 ] maior
[ 4 ] novos números
[ 5 ] sair do programa
Seu programa deverá realizar a operação solicitada em cada caso.
'''
first_value = int(input('Digite o primeiro valor: '))
second_value = int(input('Digite o segundo... | false |
d8515e68643e393c81df9f0c86a836cae800c0f4 | pedrottoni/Studies-Python | /Cursoemvideo/Mundo1/exercise031.py | 689 | 4.15625 | 4 | '''
Desenvolva um programa que pergunte a distância de uma viagem em Km. Calcule o preço da passagem, cobrando R$0,50 por Km para viagens de até 200Km e R$0,45 parta viagens mais longas.
'''
distance = float(input('Qual é a distância da viagem? '))
print(f'Você está prestes a iniciar uma viagem de {distance}Km')
if ... | false |
0b481af4a03fe47d7e40c2647b278bb89f8a19c0 | pedrottoni/Studies-Python | /Pessoais/Jogo da Forca.py | 661 | 4.125 | 4 | '''
V Receber 3 palavras
V Agrupar as 3 palavras
V Sortear uma das 3 palavras
- Receber uma letra
- Verificar se é uma letra
- Verificar se a letra é repetida
- Verificar se a letra pertence a palávra escolhida
- Verificar quantas letras faltam
-
-
-
'''
import random
# Receber 3 palavras
first_word = str(input('Digit... | false |
16b21fa84cb8b02f3aa8afd9ce4eafa3156520bf | OtsoValo/UTSC-Works | /CSCA08/ex0.py | 1,895 | 4.21875 | 4 | def multiply(x,y):
return x+y
def auto_email_address(x,y):
return x + "." +y + "@mail.utoronto,ca"
x = float(input("please input a number:"))
y = float(input("please input another number:"))
print(multiply(x,y))
a = input("please enter your first name:")
b = input("please enter your last name:")
address =... | true |
5bf93ada1ebcc70d6243e0a5bf352e6526722ff0 | OtsoValo/UTSC-Works | /CSCA08/week9/week9_my_stack2.py | 1,690 | 4.125 | 4 | class Stack():
'''A last-in, first-out (LIFO) stack of items'''
def __init__(self):
'''(Stack) -> NoneType
Create a new, empty Stack.
'''
# this time, let's represent our stack with a list such that the top
# of the stack is at the 0th element of the list
self._c... | true |
ce24642c0b9a675bc6402dfb9f00e191a86a3aa6 | kalsotra2001/practice | /ctci/linked-lists/4-partition-by-x.py | 895 | 4.125 | 4 | class LinkedList(object):
def __init__(self):
self.head = None
def insert(self, data):
new_node = Node(data, self.head)
self.head = new_node
return self.head
def print_list(self):
cur = self.head
while cur:
print cur.data
cur = cur.n... | false |
9ba37e0ec412a97a1341545f89772823bbaa8ded | kalsotra2001/practice | /hackerrank/algorithms/warmups/sherlock-and-the-beast.py | 589 | 4.1875 | 4 | def get_decent(digits):
target = digits
threes = 0
fives = 0
max = 0
while digits > 0:
if digits % 3 == 0:
fives = digits
break
digits -= 5
threes = target - digits
if digits < 0 or threes % 5 != 0:
return "-1"
number = ""
while fives >... | true |
5b1cb7b7e1e1c695b4a0a703bf647c3ee2da5abf | Sinha123456/Simple_code_python | /factorial_while.py | 312 | 4.46875 | 4 | number = 6
product = 1
current = 1
while current<=number:
product*=current
current += 1
print(product)
#Running same thing using for loop
# calculate factorial of number with a for loop
for num in range(1, number + 1):
product *= num
# print the factorial of number
print(product)
| true |
c96ec0dd3f7be02edb2cb90ee747eb395be69792 | libus1204/bigdata2019 | /01. Jump to python/chap05/174_class_calculator.py | 652 | 4.125 | 4 | class Calculator: # 사용자 정의 클래스
def __init__(self): # 생성자(Constructor) 객체 생성시 최초로 수행되는 함수
self.result = 0 # Class 의 멤버 변수
def adder(self, num): # 멤버 함수(Member Function)
print("[%d]값을 입력 받았습니다." % num)
self.num1 = 100 # 멤버변수로 등록은 가능하나, 가독성은 떨어진다.
self.result += num
re... | false |
dc7311f672b80ddf847eac14a1ad81bee065cd66 | bala4rtraining/python_programming | /python-programming-workshop/test/namedtuple/namedtuplecreationexpone.py | 1,449 | 4.125 | 4 |
# the code below shows a simple tuple - 1st part of excercise
from math import sqrt
pt1 = (1.0, 5.0)
pt2 = (2.5, 1.5)
line_length = sqrt((pt1[0]-pt2[0])**2 + (pt1[1]-pt2[1])**2)
print(line_length)
# the code below shows a simple named tuple - 2nd part of our excercise
from collections import namedtuple
Point = na... | true |
1b852fc0dd98132bc8590ca978654de519bca513 | bala4rtraining/python_programming | /python-programming-workshop/youtube_python_videos/dictionary/dictionaryfromkeysthree.py | 807 | 4.375 | 4 |
# create a dictionary from mutable object list
# vowels keys
keys = {'a', 'e', 'i', 'o', 'u' }
value = [1]
vowels = dict.fromkeys(keys, value)
print(vowels)
# updating the value
value.append(2)
print(vowels)
#If the provided value is a mutable object (whose value can be modified) like list, dictionary, etc., whe... | true |
315a09868d5ccdd2c29900f3e5df8148b09f3524 | bala4rtraining/python_programming | /python-programming-workshop/string/ljust_and_rjust.py | 424 | 4.5 | 4 |
#Ljust, rjust. These pad strings. They accept one or two arguments. The first argument
#is the total length of the result string. The second is the padding character.
#Tip: If you specify a number that is too small, ljust and rjust do nothing.
#They return the original string.
#Python that uses ljust, rjust
s = "... | true |
40f9fbb5bfd6cdcd6c5ab29d2b109f76b3548167 | bala4rtraining/python_programming | /python-programming-workshop/interesting_programs/decimal_to_binary_in_bits.py | 206 | 4.25 | 4 |
# Python 3 implementation of above approach
# Function to convert decimal to
# binary number
def bin(n):
if (n > 1):
bin(n >> 1)
print(n&1,end=" ")
# Driver code
bin(131)
print()
bin(3)
| true |
6b99a93f0c58c2ab9ac3ded9483a65ad45e69fa6 | bala4rtraining/python_programming | /python-programming-workshop/pythondatastructures/class/issubclass.py | 758 | 4.34375 | 4 |
#Issubclass. This determines if one class is derived from another. With this
#built-in method, we pass two class names (not instances).
#Return:If the first class inherits from the second, issubclass returns true.
#Otherwise it returns false.
#Tip:This is rarely useful to know: a class is considered a subclass o... | true |
f06d4ab6301792efe152f6e31b879e8af446677f | bala4rtraining/python_programming | /python-programming-workshop/data_structures/named_tuple/namedtupletwo.py | 563 | 4.53125 | 5 |
#namedtuple is a factory function for making a tuple class. With that class
#we can create tuples that are callable by name also.
import collections
#Create a namedtuple class with names "a" "b" "c"
Row = collections.namedtuple("Row", ["a", "b", "c"], verbose=False, rename=False)
row = Row(a=1,b=2,c=3) #Make a ... | true |
59e8e3a092bb160de2b3216f99f3cb7e6cde6709 | bala4rtraining/python_programming | /python-programming-workshop/pythondatastructures/regular_expression/search.py | 747 | 4.40625 | 4 |
#Search. This method is different from match. Both apply a pattern. But search attempts this
#at all possible starting points in the string. Match just tries the first starting point.
#So:Search scans through the input string and tries to match at any location. In this
#example, search succeeds but match fails.
... | true |
1f528a9f016ab29739e09549db415d98b11af0be | bala4rtraining/python_programming | /python-programming-workshop/test/dictionary/listto_dict.py | 230 | 4.15625 | 4 |
original = {"box": 1, "cat": 2, "apple": 5}
# Create copy of dictionary.
modified = original.copy()
# Change copy only.
modified["cat"] = 200
modified["apple"] = 9
# Original is still the same.
print(original)
print(modified)
| true |
13c4357d79ee16af405cb6a745a64e7e6b19318b | bala4rtraining/python_programming | /python-programming-workshop/test/pythondatastructures/built_in_functions/lambda/functionsinsidelist.py | 529 | 4.34375 | 4 |
#In the example above, a list of three functions was built up by embedding
#lambda expressions inside a list. A def won't work inside a list literal
#like this because it is a statement, not an expression.
#If we really want to use def for the same result, we need temporary function
#names and definitions outside... | true |
6e3d3063dee1ed723883124085c093ccee478401 | bala4rtraining/python_programming | /python-programming-workshop/test/pythondatastructures/none/none_usage_in_dictionary.py | 209 | 4.1875 | 4 |
#Python program that uses dictionary, None
items = {"cat" : 1, "dog" : 2, "piranha" : 3}
# Get an element that does not exist.
v = items.get("giraffe")
# Test for it.
if v == None:
print("Not found")
| true |
83eee1932f9a1c411deaeed876fd83d788dc31ba | bala4rtraining/python_programming | /python-programming-workshop/test/pythondatastructures/file/parse_csv.py | 222 | 4.125 | 4 |
import csv
#Open CSV file.
with open("input.csv", newline="") as f:
# Specify delimiter for reader.
r = csv.reader(f, delimiter=",")
# Loop over rows and display them.
for row in r:
print(row)
| true |
6056539afef034b1d222ac3436e7c2ff6c68e55d | bala4rtraining/python_programming | /python-programming-workshop/test/pythondatastructures/fibonacci/fibonacci_two.py | 294 | 4.40625 | 4 |
#Python program that displays Fibonacci sequence
def fibonacci2(n):
a = 0
b = 1
for i in range(0, n):
# Display the current Fibonacci number.
print(a)
temp = a
a = b
b = temp + b
return a
# Directly display the numbers.
fibonacci2(15)
| true |
978adb0fd9c937fc09cd5f5d0594476f9fbab251 | bala4rtraining/python_programming | /python-programming-workshop/test/HomeWorkProblems/16.greaterandlesser-than-given-number.py | 435 | 4.3125 | 4 |
# Count the number of elements in a list that are greater
# than or equal to some minimum number and less that or equal
# to some maximum number for example, the list of numbers can
# be 12, 5, 23, 79, 63, 11, 7, 6, 115, 129
# minimum is 10 and maximum is 100]
newlist = [12, 5, 23, 79, 63, 11, 7, 6, 115, 129]
mini... | true |
16f0449bfb7dec9a11cb561cfa8cbaf1cabd8b60 | bala4rtraining/python_programming | /python-programming-workshop/HomeWorkProblems/8.anagrams-ofeachother.py | 464 | 4.34375 | 4 |
## python program to find whether the given words are anagrams of each other ##
# find if two strings are anagrams of each other and
# report the answer as "yes" or "no"
first_string = input(" Give first string : ")
second_string = input(" Give second string : ")
first_string = sorted(first_string)
second_string =... | true |
89589bd79a5ee51df2033ce8dc9e7e069688cf0f | bala4rtraining/python_programming | /python-programming-workshop/solutions/new.py | 458 | 4.1875 | 4 |
# this is the basic method
number = int(input("Give a number"))
for val in range(2,number):
if number % val == 0:
print(val,end=" ")
print("\n\n")
# this is using list comprehension
factors = [val for val in range(2,number) if number % val == 0]
print(factors)
# this is using a function
def find_facto... | true |
5ee5ebe06d9c49bff31c0e598f1f44acef452cd1 | bala4rtraining/python_programming | /python-programming-workshop/HomeWorkProblems/17.tupletakeinput.py | 589 | 4.625 | 5 |
## python program to create a tuple by getting input from the user ##
# write a program create a tuple by taking input from the user
mylist = []
for count in range(5):
name=input(" Give any name : ")
mylist.append(name)
tupletwo = (mylist[0],mylist[1],mylist[2],mylist[3],mylist[4])
print(" The elements in tu... | true |
e17c340151134585011263499a8dda6c200373f7 | bala4rtraining/python_programming | /python-programming-workshop/iterators_and_generators_new/class_03-08-2020/6.infinite_generators.py | 349 | 4.125 | 4 |
def infinite_sequence():
num = 0
while True:
yield num
num += 1
gen=infinite_sequence()
print(next(gen))
print(next(gen))
print(next(gen))
print(next(gen))
# def infinite_sequence():
# num = 0
# while True:
# print(num)
# num = num + 1
#for i in infinite_sequence():
# ... | false |
b589cf5c1d286d01d3986160bb4c8d890791ff6c | bala4rtraining/python_programming | /python-programming-workshop/iterators_and_generators_new/12.newiteratorpattercreation.py | 317 | 4.40625 | 4 |
def frange(start, stop, increment):
x = start
while x < stop:
yield x
x += increment
#To use such a function, you iterate over it using a for loop or use it with some other
#function that consumes an iterable (e.g., sum(), list(), etc.). For example:
for n in frange(0, 9, 0.5):
print(n)
| true |
dccc689f10f200088286a7f8b33fe67e06afdf66 | bala4rtraining/python_programming | /database/secondone.py | 1,225 | 4.3125 | 4 | ## Connecting to the database
## importing 'mysql.connector' as mysql for convenient
import mysql.connector as mysql
## connecting to the database using 'connect()' method
## it takes 3 required parameters 'host', 'user', 'passwd'
db = mysql.connect(
host = "localhost",
user = "root",
passwd = "Superpa@99... | true |
2c40f802dbf405ea79d5e792626f74011df1969e | bala4rtraining/python_programming | /python-programming-workshop/builit-in-functions/find/find_one.py | 251 | 4.25 | 4 |
#Python program that uses string find
value = "cat picture is cat picture"
# Find first index of this string.
i = value.find("picture")
print(i)
# Find first index (of this string) after previous index.
b = value.find("picture", i + 1)
print(b)
| true |
f261c999b95e455d7c5832ebeb11139aeb5a792c | ishandas387/DbsStuff | /PrgAnalytics/Problem2.py | 777 | 4.15625 | 4 | '''
Validates the user input and returns the splitted result.
If after split the list doesm't have 2 values, the input doesn't
satisfy the domain/username format.
'''
def validate_and_return(message):
while True:
user_name = input(message)
#splits with '\'
data = str(user_name).split("\\")
... | true |
52653ebdcb26a69d87b19f6f2259ca447f1e51fd | oraloni/python-little-games | /which_hand.py | 1,371 | 4.28125 | 4 | '''Which Hand - in Pythom Basic Games Project
Or Aloni 13/06/2020 v/1/0'''
print(" Which hand?\n")
print('''RULES: Pick up a dime in one hand and a penny in the other. I'll guess which hand holds
which coin if you answer a couple of questions for me.
... | true |
a85bbe7cf2198eb26c99a1f3f60e73c463d26305 | thirdcaptain/holbertonschool-higher_level_programming | /0x0B-python-input_output/1-number_of_lines.py | 355 | 4.21875 | 4 | #!/usr/bin/python3
"""
module defines number_of_lines function
"""
def number_of_lines(filename=""):
""" returns the number of lines of a text file
args:
filename (file): file to read
"""
linenumber = 0
with open(filename, 'r', encoding='utf-8') as f:
for line in f:
lin... | true |
fd5f77e150f73ee65cc191d4f8fdd666470c5394 | Hyperx837/Bits2020 | /chat bot/chatbot.py | 1,342 | 4.15625 | 4 |
ques_ans = {
'What is your name? ': 'Alpha',
'How old are you? ': '7 years',
'What is your School? ': 'I never went to school',
'What is your father\'s name? ': 'I do not have a father but I '
'was created by Anupama',
'What is your mother\'s name? ': 'I don\'t ... | true |
ad6e7846181a1db91a9ed7e9d44ae373903bbf9f | Min-Guo/coursera-learn-to-program-foundamentals | /assignment-2/a2.py | 2,670 | 4.3125 | 4 | import math
def get_length(dna):
""" (str) -> int
Return the length of the DNA sequence dna.
>>> get_length('ATCGAT')
6
>>> get_length('ATCG')
4
"""
return len(dna)
def is_longer(dna1, dna2):
""" (str, str) -> bool
Return True if and only if DNA sequence dna1 is longer than ... | false |
475b3a1300525aac00cca14b41742c99d3612ea7 | Ena-Sharma/list-in-python | /newlist.py | 216 | 4.15625 | 4 | list=[1,2,3,4,5,6]
print("Initial list:")
print(list)
slicing=list[3:6]
print(slicing)
slicing_list=list[:-5]
print(slicing_list)
list.pop()
print(list)
for i in range(len(list)):
print(i, end=" ")
print("\r") | true |
62248d30fa1bd73b9d4436e03f0e42cf7e14305f | tilsies/CP1404 | /cp1404practicals/prac_02/acsii_table.py | 490 | 4.15625 | 4 | LOWER_LIMIT = 33
UPPER_LIMIT = 127
character = input("Enter a Character: ")
print("The ACSII code for {0} is {1}".format(character, ord(character)))
number = int(input("Enter a number between {0} and {1}: ".format(LOWER_LIMIT, UPPER_LIMIT)))
while number < LOWER_LIMIT or number > UPPER_LIMIT:
print("Invalid cho... | true |
2c08dac1a7cad63382d69082c608d3fe02a75b6d | ChengHsinHan/myOwnPrograms | /CodeWars/Python/8 kyu/#112 Grasshopper - Debug.py | 967 | 4.46875 | 4 | # Debug celsius converter
# Your friend is traveling abroad to the United States so he wrote a program to
# convert fahrenheit to celsius. Unfortunately his code has some bugs.
#
# Find the errors in the code to get the celsius converter working properly.
#
# To convert fahrenheit to celsius:
#
# celsius = (fahrenheit ... | true |
d4abedb8cc12fb365e1309d49b0d8ef7e8005379 | ChengHsinHan/myOwnPrograms | /CodeWars/Python/7 kyu/#04 Sum of odd numbers.py | 366 | 4.15625 | 4 | # Given the triangle of consecutive odd numbers:
#
# 1
# 3 5
# 7 9 11
# 13 15 17 19
# 21 23 25 27 29
# ...
# Calculate the sum of the numbers in the nth row of this triangle (starting at
# index 1) e.g.: (Input --> Output)
#
# 1 --> 1
# 2 --> 3 + 5 = 8
... | true |
97caf558aa471cc7bcfcab2921028f6ffa998e44 | ChengHsinHan/myOwnPrograms | /CodeWars/Python/8 kyu/#227 Area of a Square.py | 338 | 4.125 | 4 | # Complete the function that calculates the area of the red square, when the
# length of the circular arc A is given as the input. Return the result rounded
# to two decimals.
#
# Note: use the π value provided in your language (Math::PI, M_PI, math.pi, etc)
import math
def square_area(A):
return round((2 * A / m... | true |
d087d676cc95399719f79ce1968b9471297b7b9d | ChengHsinHan/myOwnPrograms | /CodeWars/Python/8 kyu/#152 How old will I be in 2099.py | 1,442 | 4.25 | 4 | # Philip's just turned four and he wants to know how old he will be in various
# years in the future such as 2090 or 3044. His parents can't keep up
# calculating this so they've begged you to help them out by writing a programme
# that can answer Philip's endless questions.
#
# Your task is to write a function that ta... | true |
a467834a82132a92cd105ef74bd73ad708a73e4c | ChengHsinHan/myOwnPrograms | /CodeWars/Python/8 kyu/#122 L1 Bartender, drinks!.py | 1,206 | 4.125 | 4 | # Complete the function that receives as input a string, and produces outputs
# according to the following table:
#
# Input Output
# "Jabroni" "Patron Tequila"
# "School Counselor" "Anything with Alcohol"
# "Programmer" "Hipster Craft Beer"
# "Bike Gang Member" "Moonshine"
# "Politician" "... | true |
a4f4d1ee2a78ce0ad7b827643a098a580bd07d7f | ChengHsinHan/myOwnPrograms | /CodeWars/Python/8 kyu/#022 Regex count lowercase letters.py | 494 | 4.28125 | 4 | # Your task is simply to count the total number of lowercase letters in a
# string.
#
# Examples
# lowercaseCount("abc"); ===> 3
#
# lowercaseCount("abcABC123"); ===> 3
#
# lowercaseCount("abcABC123!@€£#$%^&*()_-+=}{[]|\':;?/>.<,~"); ===> 3
#
# lowercaseCount(""); ===> 0;
#
# lowercaseCount("ABC123!@€£#$%^&*()_-+=}{[]|... | false |
c7be302d35c6a6ff9f9e2363219c69bc45d4b245 | ChengHsinHan/myOwnPrograms | /CodeWars/Python/8 kyu/#054 Add Length.py | 573 | 4.28125 | 4 | # What if we need the length of the words separated by a space to be added at
# the end of that same word and have it returned as an array?
#
# Example(Input --> Output)
#
# "apple ban" --> ["apple 5", "ban 3"]
# "you will win" -->["you 3", "will 4", "win 3"]
# Your task is to write a function that takes a String and r... | true |
6acbf3dc4f5c25598f811880121a6d2cbcb72b9c | ChengHsinHan/myOwnPrograms | /CodeWars/Python/8 kyu/#157 Are You Playing Banjo.py | 470 | 4.21875 | 4 | # Create a function which answers the question "Are you playing banjo?".
# If your name starts with the letter "R" or lower case "r", you are playing
# banjo!
#
# The function takes a name as its only argument, and returns one of the
# following strings:
#
# name + " plays banjo"
# name + " does not play banjo"
# Names... | true |
2575f9bcb23571369a0fa7cf5832fc1399a26008 | ChengHsinHan/myOwnPrograms | /CodeWars/Python/8 kyu/#235 Will you make it.py | 546 | 4.125 | 4 | # You were camping with your friends far away from home, but when it's time to
# go back, you realize that your fuel is running out and the nearest pump is 50
# miles away! You know that on average, your car runs on about 25 miles per
# gallon. There are 2 gallons left.
#
# Considering these factors, write a function t... | true |
9e38100a28ecac4ecb6a6d67e5a600371bb8658a | ChengHsinHan/myOwnPrograms | /CodeWars/Python/8 kyu/#048 Simple Fun #261 Whose Move.py | 1,022 | 4.15625 | 4 | # Task
# Two players - "black" and "white" are playing a game. The game consists of
# several rounds. If a player wins in a round, he is to move again during the
# next round. If a player loses a round, it's the other player who moves on the
# next round. Given whose turn it was on the previous round and whether he won... | true |
6685082c37a723957d9439431f42bd51a1ef0f4a | cinker/karanProjects | /Classes/Product_Inventory.py | 1,242 | 4.15625 | 4 | #!/usr/bin/python3
# Product Inventory Project - Create an application which manages an inventory
# of products. Create a product class which has a price, id, and quantity on
# hand.
# Then create an inventory class which keeps track of various products and can
# sum up the inventory value.
class Product:
def __... | true |
d2cd63e30ab801cfcb2186987d069525340f6f6b | abhishekrd760/BasicPythonPrograms | /quadratic.py | 460 | 4.21875 | 4 | import cmath
a = float(input("Enter the value of a in quadratic equation"))
b =float(input("Enter the value of b in quadratic equation"))
c = float(input("Enter the value of c in quadratic equation"))
x1 = (-b + cmath.sqrt((b**2)-(4*a*c)))/(2*a)
x2 = (-b - cmath.sqrt((b**2)-(4*a*c)))/(2*a)
d = (b**2)-(4*a*c)
print("Th... | true |
659d1521ecdd0cfd143b222364c0e8889a952263 | Mohit1299/Python | /A3Q3.py | 481 | 4.15625 | 4 | input_time = input("Enter the time : ")
time = input_time.split(":")
minute_angle = int(time[1])*6
print(minute_angle)
hour_angle = int(time[0])*30 + (minute_angle/12)
print(hour_angle)
if(hour_angle > minute_angle):
res_angle = hour_angle - minute_angle
else:
res_angle = minute_angle - hour_angle
if(res_angle... | true |
d8838575fd3f49c16694f11bf788ad4c7ec1cf39 | Mohit1299/Python | /A5Q9.py | 472 | 4.1875 | 4 | def is_prime(no):
if(no < 2):
print("Prime numbers are always greater than 2")
return False
count = 0
for i in range(1,no):
if(no%i==0):
count += 1
else:
continue
if(count == 1):
return True
else:
return False
user_inp... | true |
28d8b70dcfed4461d22dcfb7919e79c702091ff3 | permCoding/algopro20 | /part2/01-func-coding/04.py | 683 | 4.21875 | 4 | # генераторы и итераторы
# итераторы
lst = list(range(10))
print(lst) # объект-итератор
lst = [smb for smb in '012345']
print(lst) # объект-итератор
lst = (smb for smb in '012345')
print(lst) # объект-генератор
print(', '.join(lst))
print('= = = = = = = = =')
tpl = (x for x in [0, 1, 2, 3]) # из итератора в генер... | false |
33e073a5a1bf85fc0e4b20d7bfd9bae96adfefeb | calendij9862/CTI110 | /P1HW2_BasicMath_CalendineJoseph.py | 658 | 4.25 | 4 | # This program adds and multiplies 2 numbers
# 9/13/2020
# CTI-110 P1HW2 - Basic Math
# Joseph Calendine
#
print('Please enter your first number:')
Integer1 = int(input())
print( 'Please enter your second number:')
Integer2 = int(input())
print( 'First number entered: ' , Integer1 )
print( 'Second number entered: ' , ... | true |
9c0f21efca20bb54f6f6aee834adb755f8a65e9f | HBashanaE/algorithms | /basic-concepts/binary_search/a_binary_search.py | 2,734 | 4.375 | 4 | def binary_search_recur(arr, find, start, end):
"""Recursive algorithm. Halves search"""
if start == end:
return False
mid = (start + end) // 2
if arr[mid] == find:
return True
elif arr[mid] > find:
return binary_search_recur(arr, find, start, mid)
else:
return bi... | false |
e8e7be052d4014a42d2ad8b74ee3eeabc6f89f16 | absingh-hub/Python_practise | /iterators2.py | 280 | 4.21875 | 4 | nums = [1, 2, 3]
#for num in nums:
# print(num)
#this for loop is equivalent to following working in background
i_num = iter(nums)
while True:
try:
num = next(i_num)
print(num)
except StopIteration:
break
#Iterators can only go forward through __next__ method | true |
ce00f60549ffd503e99682e1649a94a160a7eb19 | arbonap/interview-practice | /LL.py | 1,303 | 4.125 | 4 | class Node(object):
def __init__(self):
self.value = value
self.next = None
class Linkedlist(object):
def __init__(self):
self.head = None
def append_node(self, value):
new_node = Node(value)
if self.head is None:
self.head = new_node
else:
... | true |
82e6e225af956d7b7d6fa0aad4d208a4f4ddb157 | arbonap/interview-practice | /remove-odds.py | 216 | 4.28125 | 4 | def remove_odd_nums(array):
""" Remove odd numbers from a given array"""
for num in array:
if num % 2 != 0:
array.remove(num)
return array
print remove_odd_nums([1, 2, 3, 4, 5, 6, 7])
| true |
39b2468242a054fdd8442ac7d348861dc391704b | arbonap/interview-practice | /pig-latin.py | 459 | 4.1875 | 4 | def pig_latin(text):
"""Create Pig Latin generator. If a word begins with a vowel, add '-ay' to the end of the word. If a word begins with a consonant, slice the first letter to the end and add '-ay' to the end of the string."""
pyg = '-ay'
text = text.lower()
if len(text) > 0 and text.isalpha():
if text[0]... | true |
30e251b989128d2745451b5f34999f65ee3f1d8b | gkulk007/Hacktoberfest2021 | /Programs/Aman_Ahmed_Siddiqui/Evil Number.py | 1,539 | 4.28125 | 4 | '''
An Evil number is a positive whole number which has even number of 1's in its binary equivalent. Example: Binary equivalent of 9 is 1001, which contains even number of 1's. A few evil numbers are 3, 5, 6, 9…. Design a program to accept a positive whole number and find the binary equivalent of the number and count t... | true |
12a6ad4283868e04e2913c3639fd8e7cbfdea215 | gkulk007/Hacktoberfest2021 | /Programs/Aman_Ahmed_Siddiqui/Smith Number.py | 1,513 | 4.34375 | 4 | '''
A Smith number is a composite number, whose sum of the digits is equal to the sum of its prime factors. For example:
4, 22, 27, 58, 85, 94, 121 ………. are Smith numbers.
Write a program in Python to enter a number and check whether it is a Smith number or not.
Sample Input: 666
Sum of the digits: 6 + 6 + 6 = 18
Pri... | true |
d9fb509e83bc948c3566f0f714fa1096212f4431 | irene1811/Everything | /Shapes.py | 556 | 4.15625 | 4 | from turtle import *
import math
# Name your Turtle
t = Turtle()
#Set Up your screen and starting position
setup (500,300)
x_pos = (0)
y_pos = (0)
t.setposition(x_pos,y_pos)
for i in range (3):
forward(50)
left(120)
for i in range (5):
left (-60)
for i in range (3):
forward(50)
left (12... | false |
f2c2a749c967baf45396e85dcd0d6e5cc097e374 | LayllaRodrigues/Head_First_LearntoCode | /ch6/pseudocodigo_loop.py | 1,359 | 4.15625 | 4 | # O loop externo representa cada passagem no algoritmo.
# O loop interno passa por cada item da lista e executa as comparações (e qualquer troca necessária).
# Com isso em mente, vamos dar uma olhada:
# PSEUDOCODIGO - classifica a lista em ordem crescente:
# # define a function
# def bubble_sort(list):
# # dec... | false |
450fff7c3c0e11a77a0601387ad6c73c48a67cb3 | vijaynchakole/Python-Code | /MyParallelProgramming.py | 886 | 4.125 | 4 |
#below program which uses serial processing approach
def square(n):
return(n*n)
if __name__ == "__main__":
#input list
arr = [1,2,3,4,5]
#empty list to store result
result = []
for num in arr :
result.append(square(num))
print(result)
####################... | true |
6d1cd1d5e5be293ca71d3b8b9f4e5e0df4b96726 | Audrey-me/CGPA-CALCULATOR | /second.py | 1,301 | 4.15625 | 4 | def degree_checker(grade):
degree = 'Pass'
y = ['first class honours', 'second class honours (upper division)', 'second class honours (lower division)',
'third class honours']
about = '''ABOUT
The function takes in strings
UOP students should include % while MAU students include gpa when en... | false |
875605683c59e5cacd6b7cbe69c182c45318aa76 | haifeng94/Python-Algorithm | /剑指offer/面试中的各项能力/发散思维能力/Sum.py | 631 | 4.1875 | 4 | # coding=utf-8
'''
题目:求1+2+3+...+n,要求不能使用乘除法、for、while、if、else、switch、case等关键字及条件判断语句(A?B:C)。
'''
'''
思路一:利用了python的特性, range和sum
'''
class Solution:
def Sum_Solution(self, n):
return sum(range(1, n+1))
s = Solution()
res = s.Sum_Solution(5)
print(res)
'''
思路二:其实跟思路一差不多
'''
class S... | false |
ed1200ad70c5924d2b556a263be368679482b7f8 | MerhuBerahu/Python3-DnD5e-CharacterCreator- | /Races.py | 1,909 | 4.1875 | 4 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
"""Display race information and select a race
"""
#TODO stuff
import json
from Systems import check_input
with open("Jsons\\races.json", encoding="utf8") as test: #Open races.json as test
race_list = json.load(test)
def race_info():
"""Pull in race information... | true |
e4d83836f27a7cd3d1719661f6a8a963dc3b735f | byui-cs/cs241-course | /week01/ta01-solution.py | 1,168 | 4.28125 | 4 | # Team Activity 01
# Author: Br. Burton
# Part 1: Ask the user for their DNA sequence, count the number of A's
dna = input("Please enter your DNA sequence: ")
# This will keep track of our matches
match_count = 0
# Go through the string letter by letter, and count the matches
for letter in dna:
if letter == 'A'... | true |
1bbff88e227879dd98c15b0ffe6a78554378caa1 | myfriendprawin/Praveen-Kumar-Vattikunta | /Weekend Day2.py | 671 | 4.34375 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[6]:
#Data Types:
#Numbers: Number data types are immutables.
#Integers:
A=1
B=3
A+B
# In[7]:
#Float: Declaring values in decimal is called as float.
X=1.
Y=2.0
X+Y
# In[8]:
#Advance assignment of values to variables.
K,L,M,N=5,6,9,1
print(M)
# In[19]:
#List Dat... | true |
023a9c620470e17c50842ee0b078960cb3b2d88d | ivyldewitt/python-review | /practice/interactive.py | 698 | 4.53125 | 5 | ### PRACTICE ###
user_prompt = input("Please enter a whole number (no decimals): ")
user_int = int(user_prompt)
## Write a program that requests a number from the user.
# Have the program print "Even" or "Odd" depending on whether
# they entered an even or odd number.
while user_int != 0:
if user_int % 2 == ... | true |
ae7b0936d7d7a56203adc0d7fc63db4466ab2229 | tristan-neateworks/AIArena | /AIArena/AI.py | 1,963 | 4.125 | 4 | class Player:
"""This forms an interface for a generic game "player." It is extended by the AI class and can be used to represent any kind of entity that makes moves in a given game.
:param name: The human-readable reported name for the player (ex. LilBuddy for our Connect 4 playing AI)
:param game: Th... | true |
0d8908216a9d7ce6f1419118b6f88db5f8fd1672 | natasharivers/python-exercises | /python_warmup.py | 1,984 | 4.75 | 5 | ##WARM UP EXERCISES
#write the code that takes a single string string containing the make and model of a vehicle.
#first part of te string before the space is the make
#the last part of the string after the space is a model
#we can assume that the strings will only have one space
#assume the input string is completely ... | true |
2920e6e3ec24466f9e284bc5ec0bd200359c037a | jashidsany/Learning-Python | /LCodecademy Lesson 11 Function Arguments/L11.3_Default_Arguments.py | 1,015 | 4.15625 | 4 | # Function arguments are required in Python. So a standard function definition that defines two parameters requires two arguments passed into the function.
# Not all function arguments in Python need to be required. If we give a default argument to a Python function that argument won’t be required when we call the fun... | true |
956cd4948879564ec6b2d19ade61a1bf5ef76885 | jashidsany/Learning-Python | /Codecademy Lesson 8 Dictionaries/LA8.11_Try_And_Except_To_Get_A_Key.py | 585 | 4.34375 | 4 | # We saw that we can avoid KeyErrors by checking if a key is in a dictionary first. Another method we could use is a try/except:
# key_to_check = "Landmark 81"
# try:
# print(building_heights[key_to_check])
# except KeyError:
# print("That key doesn't exist!")
# When we try to access a key that doesn’t exist, t... | true |
6bb3631eed8bdebd296f4054d1c84d272f44ff1f | jashidsany/Learning-Python | /Codecademy Lesson 9 Files/L9.0_Reading_A_File.py | 1,191 | 4.5625 | 5 | # Computers use file systems to store and retrieve data.
# Each file is an individual container of related information.
# If you’ve ever saved a document, downloaded a song, or even sent an email you’ve created a file on some computer somewhere.
# Even script.py, the Python program you’re editing in the learning env... | true |
ba45301804c28d062503ca306c6ea393b7da0394 | jashidsany/Learning-Python | /Codecademy Lesson 6 Strings/LA6.16_Joining_Strings_1.py | 511 | 4.375 | 4 | # Now that you’ve learned to break strings apart using .split(), let’s learn to put them back together using .join(). .join() is essentially the opposite of .split(), it joins a list of strings together with a given delimiter. The syntax of .join() is:
# 'delimiter'.join(list_you_want_to_join)
# Delimiters are spaces... | true |
022fc7d62f80194c39334f22d8e48e8826f01a07 | jashidsany/Learning-Python | /Codecademy Lesson 6 Strings/LA6.28_X_Length.py | 560 | 4.1875 | 4 | # Write your x_length_words function here:
def x_length_words(sentence, x):
words = sentence.split(" ")
# creates a variable words that stores the words split in the string sentence
for word in words:
# iterates through the words
if len(word) < x:
# if the length of the word is less than the ... | true |
b93ee019f4b0714aec476258771ad849ddb70c95 | SSamiKocaaga/python-project | /Assignment 007_003.py | 693 | 4.1875 | 4 |
# Variables
armvalue = 0
condition = False
# Receives input from the user until he/she enters data in the expected format
while not condition:
number = input('Write a number: ')
if number.isdigit():
condition = True
else:
print(" It is an invalid entry. Don't use non-numeric, float, or negat... | true |
e6385076df5131c0df3330896536fb40edbfa250 | fuston05/Computer-Architecture | /OLD_ls8/util.py | 1,512 | 4.46875 | 4 | # In general, the `.format` method is considered more modern than the printf `%`
# operator.
# num = 123
#
# # Printing a value as decimal
#
# print(num) # 123
# print("%d" % num) # 123
# print("{:d}".format(num)) # 123
#
# # Printing a value as hex
#
# print(hex(num)) ... | true |
81fb3be1743672abd6f93a65aa4892ed28901eaf | jcellomarcano/Willy | /myStack.py | 1,904 | 4.125 | 4 | DEBUG_MODE = True
import sys
"""
Estructura de Pila para verificacion del interprete
Primera fase del proyecto
Traductores e Interpretadores (CI-3725)
Maria Fernanda Magallanes (13-10787)
Jesus Marcano (12-10359)
E-M 2020
Simulacion de una Pila que se encarga de verificar contextos den... | false |
8263cd6c0f37eb66061219be0d314bb12cb2564d | vvdnanilkumargoud/Python | /search.py | 548 | 4.21875 | 4 | #a is list
a = [1,2,3,4,5]
#It will search entire list whthere value is there or not
check = raw_input("Enter which you want to search in a list : ")
if check not in a:
a.append(check)
print "%s is not in the list we are adding into list" %check
print "This is the latest list : %s" %a
else:
print a
#b ... | true |
54e81046a418fc4c8fbfa60d0ce83bdb15e4f8d3 | nvyasir/Python-Assignments | /exception_regform.py | 604 | 4.3125 | 4 | # Registration System
#
#
# You are making a registration form for a website.
# The form has a name field, which should be more than 3 characters long.
# Any name that has less than 4 characters is invalid.
# Complete the code to take the name as input, and raise an exception if the name is invalid, outputting "Invalid... | true |
1a1e048c7e1e5c2a367b0c5e75f5f2bef4e38506 | nvyasir/Python-Assignments | /tuples.py | 714 | 4.28125 | 4 | # Tuples
#
# You are given a list of contacts, where each contact is represented by a tuple, with the name and age of the contact.
# Complete the program to get a string as input, search for the name in the list of contacts and output the age of the contact in the format presented below:
#
# Sample Input
# John
#
# Sam... | true |
b9f60c435d858ede41449fff6c05f4a0de3e5343 | volllyy/python_basic_HW | /HW/HW_3/Task_5.py | 1,734 | 4.1875 | 4 | # HW3 - Task № 5
def sum_func() -> int:
"""
The program asks the user for a string of numbers separated by a space.
When you press Enter, the sum of the numbers should be displayed.
The user can continue to enter numbers separated by a space and press Enter again.
The sum of the newly entered number... | true |
b1314d7f4195ed997d446cb084b59a45f24f8623 | volllyy/python_basic_HW | /HW/HW_1/Task_1.py | 695 | 4.1875 | 4 | #HW1 - Task № 1
year = 2020
temperature = 10.5
month = 'April'
print(year,'/', temperature,'Cº /', month)
name = input('What`s your name?\n')
surname = input('What`s your surname?\n')
age = input('How old are you?\n')
number = input('What is your phone number? (Wright down without + and spaces, '
'just c... | true |
34328ab0d637668b489d976640218293d219691a | developeruche/python_threading_module | /demo_one/app.py | 756 | 4.1875 | 4 | import threading
""" Thread is a mean by which a program of app can excectue various function simutanously """
def thread_one_function(test_arg_one, test_arg_two):
for i in range(0, 20):
print(f'I am Tread one ----- {test_arg_one}, {test_arg_two}')
def thread_two_function(test_agr):
for i in range(0... | true |
1b4c62b21246c21f184138a31135ee333ac13510 | mummyli/python_practice | /data_structure/concat_str.py | 253 | 4.125 | 4 | # join()连接可迭代对象
parts = ['Is', 'Chicago', 'Not', 'Chicago?']
print("-".join(parts))
a = 'Is Chicago'
b = 'Not Chicago?'
# format 拼接
print('{} {}'.format(a, b))
# 简单拼接两个字符串
c = "hello" "world"
print(c) | false |
3f84c7f6030299449c5513201fedc08b0fb07332 | darshanjain033/darshjain | /largest number.py | 382 | 4.40625 | 4 | # Python program to find the largest number among the three input numbers...
num_1 = float(input("Enter Number_1 :"))
num_2 = float(input("Enter Number_2 :"))
num_3 = float(input("Enter Number_3 :"))
if (num_1 >= num_2 and num_1 >= num_3):
print("Number_1 is large")
elif (num_2 >= num_1 and num_2 >= num_3):
pri... | true |
3956a24fe0603b39e0658763b0f8757733f018ae | ebrudalkir/Pythondersnotlar- | /ders4.py | 330 | 4.125 | 4 |
'''for i in range(1,10):
print(i*"*")'''
factoriyel=1
while True:
sayi=int(input("enter of numbers:"))
if(sayi<=0):
print("please enter positive number!!")
else :
for i in range(1,sayi+1):
factoriyel=factoriyel*i
print("factoriyel",factoriyel)
b... | false |
5c75c95c28a0e6f541d8dce1f38f5e61bf77e91f | RitRa/multi-paradigm-programming-exercises | /Week3_exercises/q8_primenumber.py | 424 | 4.1875 | 4 | # Write a program that prints all prime numbers. (Note: if your programming language does not support arbitrary size numbers, printing all primes up to the largest number you can easily represent is fine too.)
number = input("Pick a number")
#convert to a number
number = int(number)
for i in range(number):
if (nu... | true |
19a4d0579ea77bd0c219ce75c467d6e650b6efae | RitRa/multi-paradigm-programming-exercises | /Week3_exercises/q3_whatisyournamemodified.py | 307 | 4.40625 | 4 | # Write a program that asks the user for their name and greets them with their name.
# Modify the previous program such that only the users Alice and Bob are greeted with their names.
name = input("what is your name?")
vip = ["Alice", "Bob"]
for i in vip:
if i == name:
print("Hello " + name) | true |
1677429d9d212b6971af7f1b7408a5aeb08b945a | xzx1kf/football_manager_project | /football_manager/elo/elo.py | 1,908 | 4.3125 | 4 | class Result(object):
"""
A Result can either be a win, lose or draw. A numerical value is
assigned to the result.
"""
WIN, LOSE, DRAW = 1, 0, 0.5
class EloFootballRating(object):
"""
A rating system based on the Elo rating system but modified to take
various football specific variable... | true |
617b9b55c1908552d1f58451a6d9b69bd0c961cf | longhao54/leetcode | /easy/88.py | 2,191 | 4.15625 | 4 | '''
给定两个有序整数数组 nums1 和 nums2,将 nums2 合并到 nums1 中,使得 num1 成为一个有序数组。
说明:
初始化 nums1 和 nums2 的元素数量分别为 m 和 n。
你可以假设 nums1 有足够的空间(空间大小大于或等于 m + n)来保存 nums2 中的元素。
示例:
输入:
nums1 = [1,2,3,0,0,0], m = 3
nums2 = [2,5,6], n = 3
输出: [1,2,2,3,5,6]
'''
class Solution:
def merge(self, nums1, m, nums2, n):
"""... | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.