blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
487268a86646814033a1964b9bd0b5c9f2ab7e07 | swjjxyxty/study-python | /base/set.py | 223 | 3.765625 | 4 | s = {1, 2, 3}
print(s)
# can't save same value
s = {1, 1, 2, 3, 4, 4}
print(s)
# add element
s.add(5)
print(s)
# remove element
s.remove(5)
print(s)
s1 = {1, 2, 3, 4}
s2 = {1, 5, 6, 7, 8}
print(s1 & s2)
print(s1 | s2)
|
200d1aca926a6d8901c5b79d2f461e292f076104 | shankar7791/MI-10-DevOps | /Personel/Avdhoot/Python/Mar 4/ex3.py | 456 | 4.25 | 4 | #Write a Python function that accepts a string and
#calculate the number of upper case letters and lower case letters
def string(str1):
uc, lc = 0, 0
for i in str1 :
if i.isupper() :
uc += 1
elif i.islower():
lc += 1
else :
pass
print("Original... |
1b325e6dbb36101ba58df0ef0fbd6a677a7caf1a | bindurathod/Assignment6 | /2empsal.py | 971 | 3.859375 | 4 | import pandas as pd
df = pd.read_csv (r'D:PythonProjects\assignment6\players.csv')
# block 1 - simple stats
mean1 = df['Salary'].mean()
sum1 = df['Salary'].sum()
max1 = df['Salary'].max()
min1 = df['Salary'].min()
count1 = df['Salary'].count()
median1 = df['Salary'].median()
std1 = df['Salary'].std()
var... |
9b65b62e523f971293653656c9ca68c5156a3041 | phenderson123/python2 | /dice.py | 300 | 3.953125 | 4 | import random
min = 1
max = 6
roll_again = "yes"
while roll_again == "yes" or roll_again == "y":
print "Roll them dices man..."
print "The numbers are...."
print random.randint(min, max)
print random.randint(min, max)
roll_again = raw_input("Roll em again dude?")
|
faf16edd9486e888597a41d446d9dfad160fbdc7 | Nilcelso/exercicios-python | /ex008.py | 291 | 4 | 4 | medida = float(input('Digite uma distancia em metros: '))
dm = medida * 10
cm = medida * 100
mm = medida * 1000
dam = medida / 10
hm = medida / 100
km = medida / 1000
print('A medida de {}m, corresponde a: \n{}km \n{}hm \n{}dam \n{}dm \n{}cm \n{}mm'.format(medida, km, hm, dam, dm, cm, mm))
|
aa6c04fac0cb6a749797ca6e8d4a087855cf77c2 | DrunkenPrimape/learning-python | /python/week-3/descending.py | 317 | 3.8125 | 4 | # def descending(numbers):
# size = range(len(numbers) - 1)
# for current in size:
# next = current + 1
# if(numbers[current] < numbers[next]):
# return False
# return True
# descending([])
# #True
# descending([4,4,3])
# #True
# descending([19,17,18,7])
# #False
|
cfba4b93b38c64a6cf66b42056f9586917acf1a2 | 1769778682/python_day02_code | /hm05_逻辑运算符.py | 260 | 3.953125 | 4 | # 逻辑运算: 主要指事物或条件的两面性, 要么成立True, 要么不成立False
# 案例:
x = False
y = True
print('左右条件是否同时满足:', x and y)
print('左右条件是否任意满足一个:', x or y)
print('对目标取反:', not x)
|
2c81394f33f05de8a6d76fbd9e76ad4008d636e0 | evemorgan5/100-days-of-code | /pycharm_projects/day18/main.py | 849 | 3.875 | 4 | # from turtle import Turtle, Screen
# # module^ class^ Screen class
# # import turtle module and get hold of the turtle class (Turtle)
# timmy_the_turtle = Turtle()
# ^ new turtle object ^ from Turtle class
# # when from turtle: import Turtle, tim = Turtle()
# else if import module have to call class Turtle... |
bb91c482e21a07f11f3b3fd57456b18dda38b0e9 | ApurvaJogal/python_Assignments | /Assignment4/Assignment4_2.py | 336 | 4.125 | 4 | #Write a program which contains one lambda function which accepts two parameters and return its multiplication.
#Input : 4 3 Output : 12
#Input : 6 3 Output : 18
# Author : Apurva Anil Jogal
# Date : 20th March 2019
result = lambda a,b: a*b;
no1=input("Enter first number:");
no2=input("Enter second number:");... |
8966c109441a5fd8b0ca869ebb5d8d8ccb0fdaa8 | MrColinHan/Haim-Lab-Projects | /HCV/Find_accession_inAAsequence(inFasta).py | 4,992 | 3.546875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 5 23:38:36 2019
@author: Han
"""
from re import compile
'''
FOR HCV project
This script finds all Accession numbers that contain special characters in a AA Sequence fasta file.
INPUTS:
AADir: the directory AA sequen... |
bf771140a6a88a6a01733c8ef9d2efd8a8256942 | Raigridas/Secure_Communications | /RSA/Level3.py | 223 | 3.59375 | 4 | from Crypto.PublicKey import RSA
#private key is given in the exercise
key = """-----BEGIN RSA PRIVATE KEY-----
MIIEpQIBAAKCAQEAzGm6Ogrmlf4OSPDQ5nUIiDAJeR9wHdhce7m3NprE3QQqggdr
K/itQlqfRxqTP8uFDzuvLCHkiBIkWXiB9uYx4nVP+y5Db0p8cA453Xc2wvpYO8m/
6n3VFkAQyzIs7vSr77KqVyPvRzSn9OAjn9FEg1Z7TEmcbkfTo39S1urTBaTTvffw
ULIaEu/QWcV... |
662a5409e94359070bdda8b57e080a397190e248 | sanchitmahajann/pong | /pong.py | 3,381 | 3.6875 | 4 | #Simple pong game
import turtle
import winsound
win = turtle.Screen() #the actual window
win.title('Pong by Sanchit')
win.bgcolor('Black')
win.setup(width=800, height=600)
win.tracer(0) #prevents auto-update
#Score A
score_a = 0
score_b = 0
#Paddle L
paddle_l = turt... |
60dbbfa4e1f72fd3842fd59e8e6d86a44a54d714 | Leevan48/Leevan-Advanced-Python | /Games Sales/GameSales.py | 638 | 3.515625 | 4 | import pandas as pd
import matplotlib.pyplot as plt
df = pd.read_csv('dato.csv')
print("No. of games per publisher :")
print(df['Publisher'].value_counts())
print("Game with maximum sales in Europe: ")
maximum_eu = df['EU_Sales'].max()
grouped1_df = df.groupby('EU_Sales')['Platform']
for key, item in grouped1_... |
b2f666be0a1879fc9c5bf5a976b13b2d1e1b1202 | michaelyzq/Python-Algorithm-Challenges | /038countAndSay.py | 1,156 | 3.78125 | 4 | """
https://leetcode.com/problems/count-and-say/hints/
The count-and-say sequence is the sequence of integers with the first five terms as following:
1. 1
2. 11
3. 21
4. 1211
5. 111221
1 is read off as "one 1" or 11.
11 is read off as "two 1s" or 21.
21 is read off as "one 2, then one 1" or 1211.
... |
a7677d1daaf6a4e5aee85c1f3ec0844b5c01bca7 | pallotron/quiz | /fb_puzzles/usrbincrash/userbincrash | 2,370 | 3.765625 | 4 | #!/usr/bin/python
import sys
import getopt
import re
debug = False
def log(msg):
if debug == True:
print msg
def pprint(obj):
if debug:
import pprint
pp = pprint.PrettyPrinter(indent=1)
pp.pprint(obj)
def load_input(file):
c = []
w = []
try:
f = ope... |
f38c96c083a7193c66fbfa822c48d0da4df9081d | shinespark/code | /c/C019.py | 632 | 3.546875 | 4 | # coding: utf-8
import sys
lines = [x.strip() for x in sys.stdin.readlines()]
num_count = int(lines[0])
target_lines = lines[1: 1 + num_count]
def getDivisior(num):
l = [1]
for i in range(2, num + 1 // 2):
if num % i == 0:
l.append(i)
return l
def checkPerfectNumber(num):
divis... |
114f1d4aada5aa259c622e28b71bad51fa628211 | ANkurNagila/My-Code | /Code76.py | 731 | 3.640625 | 4 | Month=["January","February","March","April","May","June","July","August","September","October","November","December"]
x=28
Days=[31,x,31,30,31,30,31,31,30,31,30,31]
Res=""
for _ in range(int(input())):
Test=input().split(" ")
if (int(Test[2])%4==0 and int(Test[2])%100!=0) or (int(Test[2])%4==0 and int(Test[2])... |
0fcaa59ca60bc457881b861352c6fd23e80a6ce9 | IvanWoo/coding-interview-questions | /puzzles/word_ladder_ii.py | 2,453 | 3.953125 | 4 | # https://leetcode.com/problems/word-ladder-ii/
"""
Given two words (beginWord and endWord), and a dictionary's word list, find all shortest transformation sequence(s) from beginWord to endWord, such that:
Only one letter can be changed at a time
Each transformed word must exist in the word list. Note that beginWord i... |
ace5a2735304926ccb6f6695e336ad7ed661cd5a | KenedyMwendwa/Python | /Lists.py | 1,015 | 4.34375 | 4 | #create a list of my favorite people
favorite= ["Big5", "uncle", "family", "business"]
creditNumbers= [2,3,4,5,6,7,8,9]
#to print all the subjects in my list
print(favorite)
#printing one favorite, we use the index values of the lists
print(favorite[0])
#to print a range of values, for instance beyond index 1
p... |
a15582af746339e5302fa7325009eecbc1782d02 | bethke/hermes | /src/utils/code_etl/user_to_file_mapper.py | 5,894 | 3.5 | 4 | #!/usr/bin/env python
"""Provides functions to convert `git log` information for a repository to JSON
suitable to read in with Spark.
Attributes:
JSON_LINE (dict): A dictionary that stores information from `git log`. Each
entry corresponds to the information from one line in the source file.
The v... |
5518f9d0d9805549440196a517400b938501ffef | subodhss23/python_small_problems | /easy_probelms/return_sum_of_two_smaller_nums.py | 618 | 4.09375 | 4 | '''Create a function that takes a list of numbers and returns the sum
of the two lowest positive numbers.'''
def sum_two_smallest_nums(lst):
sorted_lst = sorted(lst)
new_lst = []
for i in sorted_lst:
if i > 0:
new_lst.append(i)
return new_lst[0] + new_lst[1]
print(sum_two_sma... |
b3d8c23535eb0f33c41a3d966088842e32c228e7 | Fuerfenf/Basic_things_of_the_Python_language | /functions/closure_function.py | 1,307 | 4.625 | 5 | import logging
# When and why to use Closures:
# - As closures are used as callback functions, they provide some sort of data hiding.
# This helps us to reduce the use of global variables.
# - When we have few functions in our code, closures prove to be efficient way.
# But if we need to have many functions, then g... |
2185cd32af281d3c82628de09e81ddb0c09bd6fb | jdogg6ms/project_euler | /p038/p38b.py | 1,322 | 4.125 | 4 | #!/usr/bin/env python
# Project Euler Problem #38
"""
Take the number 192 and multiply it by each of 1, 2, and 3:
192 * 1 = 192
192 * 2 = 384
192 * 3 = 576
By concatenating each product we get the 1 to 9 pandigital, 192384576. We will call 192384576 the concatenated product of 192 and (1,2,3)
The same can be ... |
dadec3c0db680da0e3551d95b1e9dcb7e527be1c | carlosaugus1o/Python-Exercicios | /ex074 - Maior e menor valores em tupla.py | 524 | 3.8125 | 4 | from random import randint
print('-' * 30 + f'\n{"SORTEIO DE VALORES": ^30}\n' + '-' * 30)
# Atribuindo valores sorteados a uma tupla
valorSorteado = ()
for cont in range(0, 5):
valorSorteado += randint(1, 10), # Pode-se utilizar uma
# Listando valores sorteados formatados sem Aspas e Parênteses
print('... |
6ce737e2c6c92806f4636f182c0ddc0614d7981a | Srishti14/ex_06_01_coursera_py4e | /ex_06_01.py | 116 | 3.875 | 4 | word = "srishti"
length = len(word)
index = -1
while index >= -length:
print(word[index])
index = index - 1
|
706924533fa536d80303e5e1c4f72c5612e313f4 | Vishnuprasad-Panapparambil/Luminar-Python | /functions/marklist.py | 367 | 3.96875 | 4 | n=input("enter the name of student")
s1=int(input("enter the marks of science"))
m1=int(input("enter the marks of maths"))
e1=int(input("enter the marks of english"))
total=s1+m1+e1
print(m1)
print(total)
if(total>145):
print("a+")
elif(total>=140):
print("a")
elif(total>=135):
print("b+")
elif (total >= 13... |
6d4cc043cf0b0c8ab921b3849be1ba4ec2e34109 | mialskywalker/PythonAdvanced | /File Handling/Exercises/line_numbers.py | 452 | 3.765625 | 4 | import re
text_regex = r"[a-zA-Z]"
symbols_regex = r"['-.\!?,]"
def count_stuff(line, pattern):
return len(re.findall(pattern, line))
counter = 1
with open("text.txt", "r") as file:
text = file.readlines()
for sentence in text:
text_num = count_stuff(sentence, text_regex)
symb_num = co... |
61a47efe29f1ac090dc037ac1d0983c9146944e5 | omigirish/Academic-Coding | /Python /Semester codes/tuple.py | 887 | 4.4375 | 4 | height=() #CREATING EMPTY TUPLE
c=0
while(c==0):
print("1 for adding new height\n2 for displaying maximum and minimum height\n3 for dislaying average height\n4 for dislaying height of students in ascending order")
n = int(input("Enter value:"))
if (n == 1):
a = input("Enter height:")
... |
218aacce95f3e96080a2a54e2744bf412e80e6a9 | tanaostaf/python | /lab7_3_1.py | 442 | 3.953125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
def checkio(expression):
s = ''.join(c for c in expression if c in '([{<>}])')
while s:
s0, s = s, s.replace('()', '').replace('[]', '').replace('{}', '').replace('<>','')
if s == s0:
return False
return True
print (chec... |
063b211e3c4e8064399581efc7580cb00ba3cb48 | KANDERKJ/learning_python | /Day_5_Mission.py | 1,267 | 3.984375 | 4 | # Day 5 Mission
# 1) integers and float points (int and float)
# 2) integer
# 3)
pi = 3.14
r = 2
print(type(pi))
print(type(r))
print(pi * r ** 2)
# 4)
name = 'Kyle'
surname = 'Kander'
print(type(name))
# i) string
# ii)
print('Kyle ' + 'Kander')
# iii)
print([name.lower() ] + [surname.upper... |
7713b861590fe3dbf8662eb97049526a8df354ff | kuangyl0212/PAAA | /src/test/resources/py-source-a/045py_source_file1.py | 402 | 4.34375 | 4 | """
1.(5分)编写Python程序,使用循环语句在屏幕上显示如下图形。注:(1)不使用循环语句不得分;(2)第五行第一个数字之前不能有空格;(3)行与行之间不能有空行。(4)编程题中的过程代码要同时写在纸质试卷上。
"""
for i in range (1,6):
for j in range (i,i+1):
print (j)
print (i)
|
1a4924dff009c609f7b4a7d05c4fbe75f12c9ce0 | aash/opencv_chessboard | /azoft/img_utils/img_utils.py | 2,879 | 3.6875 | 4 |
from numpy.linalg import norm
import numpy as np
import cv2
def _line(p1, p2):
A = (p1[1] - p2[1])
B = (p2[0] - p1[0])
C = (p2[0]*p1[1] - p1[0]*p2[1])
return A, B, C
def _segment_intersect(L1, L2):
D = L1[0] * L2[1] - L1[1] * L2[0]
Dx = L1[2] * L2[1] - L1[1] * L2[2]
Dy = L1[0] * L2[2] -... |
8c066d8195e2623f42ce3366c6fb11890b899d0e | yigitkarabiyik/python_crash_course_answers | /chapter10_files/4_storing_data/Ex_12.py | 352 | 3.65625 | 4 |
import json
filename='favorite_number.json'
try:
with open(filename) as f_obj:
favorite_number=json.load(f_obj)
except FileNotFoundError:
favorite_number=input("What is your favorite number? ")
with open(filename,'w') as f_obj:
json.dump(favorite_number, f_obj)
else:
print("I know your favorite number is "... |
4253dd83f19b2bf2bba0ecc8a8c3e3ad95af149a | dr-dos-ok/Code_Jam_Webscraper | /solutions_python/Problem_96/874.py | 719 | 3.609375 | 4 | #!/usr/bin/env python
def best_triple_part(n):
if n == 0:
return 0
elif n < 3:
return 1
else:
if score%3 == 0:
return score//3
return score//3+1
def best_surprise_part(n):
if n == 0:
return 0
elif n == 1:
return 1
elif n==2:
return 2
else:
if score%3 == 2:
ret... |
fadebbd4f7b98c739675fb61be66247ad99c10d8 | bobur554396/udacity | /my_folder/test.py | 303 | 3.546875 | 4 | import matplotlib.pyplot as plt
import numpy as np
N = 20
x = np.random.rand(N)
y = np.random.rand(N)
colors = np.random.rand(N)
area = np.pi * (45 * np.random.rand(N))**2
plt.scatter (x, y, s=area, c=colors, alpha=0.4, label="Test label")
plt.legend()
plt.xlabel("X")
plt.ylabel("Y")
plt.show()
|
12503b6ecada0b3bc490d33c49bab42c3bb62bc4 | kieran-nichols/gym_tracker | /Old/write_to_file.py | 416 | 3.734375 | 4 | #!/usr/bin/env python3
import tkinter
def write_File (text_File):
file = open("users.txt", "a+")
user_Input = text_File.get()
file.write(user_Input)
file.close()
screen = tkinter.Tk()
the_input = tkinter.Entry(screen)
the_input.grid(row=1, column=1)
button_Write = tkinter.Button(screen, text = "Se... |
f5c2de05816bea9b94ac6f8513abf6d3204534af | Allegheny-Computer-Science-102-F2018/cs102f2018-lab03-starter | /src/myTalkingHeads.py | 927 | 3.96875 | 4 | #!/usr/bin/env python3
# Date = 18 Sept 2018
# Version = i
# OriginalAuthor =
# Description: A program to model two speakers who exchange a "meaningful" conversation between each other.
stopWords_list =["I", "have","know", "like", "love", " to ", " a "]
# we remove stop words as they do not add specificity to the ... |
e520fb56cc8db1e081fb7b5dd94e89936d0aa043 | Ochieng424/Data-Structures-and-Algorithms | /missing_number.py | 246 | 3.953125 | 4 | # How do you find the missing number in a given integer array of 1 to n?
num = [1, 2, 3, 4, 6, 7, 8, 9]
def findMissingNum(A):
n = len(A)
total = (n + 1) * (n + 2) / 2
sumOfA = sum(A)
print(total-sumOfA)
findMissingNum(num)
|
0a70fdf40f8ba2fcd2d26930183d4958827451fb | PaulVirally/Abstract-Genetic-Algorithm | /examples/word.py | 1,332 | 3.828125 | 4 | """
This example will have a Genetic Algorithm converge on a word.
Each gene of a Chromosome is a letter (represented in ASCII in binary).
The fitness of a Chromosome is negative the distance each letter has to the chosen word.
"""
import sys
sys.path.insert(0, './GA')
from Chromosome import Chromosome
from GA import... |
05d7ece7b6fb4ea9e43c9d07ec58746b9aff51de | JakubKazimierski/PythonPortfolio | /Coderbyte_algorithms/Hard/WeightedPath/test_WeightedPath.py | 683 | 3.59375 | 4 | '''
Unittestst for WeightedPath.py
January 2021 Jakub Kazimierski
'''
import unittest
import WeightedPath
class test_WeightedPath(unittest.TestCase):
'''
Class with unittests for WeightedPath.py
'''
# region Unittests
def test_ExpectedOutput(self):
'''
Checks i... |
d9c9d2e9da6dd751dcbe3af9ab44928cd1fceaa0 | khimanshu/Vinegre_cipher | /program1.py | 3,534 | 4.3125 | 4 | #!/usr/bin/python
import string #for string operations
import os #for calling the operating system calls from within the program
# Himanshu Koyalkar
# Date : 03-07-2016
# Class : cs 524- 02
# The program takes key and then gives the user the options to encrypt or decrypt the files of users choice
while (1):
prin... |
05d78cc05e96235e514690ba8971c3a8cd02e0eb | lukedemi/advent-of-code-2019 | /day1/run.py | 421 | 3.671875 | 4 | import pathlib
input_file = pathlib.Path(__file__).resolve().parent / 'input.txt'
content = [int(line) for line in input_file.open()]
def fuel_cost(mass):
return int(mass / 3) - 2
total = 0
initial_fuel = 0
for mass in content:
fuel = fuel_cost(mass)
initial_fuel += fuel
while fuel > 0:
tota... |
20690daf0c5a32efecccde3bdcc988697597d541 | Pranjal6172/Hangman-game-using-Python | /hangman.py | 4,852 | 3.9375 | 4 | # -*- coding: utf-8 -*-
import random
# for all the available letters after gussing each letter
def availableletters(gussed_letter,wrong_gussed_letters):
alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
... |
54db32c945e85081eeb6d10bf02f3cbffe0d3f9c | gastonq/decart_linear_algebra_2019 | /myla/myla/bec2vectors.py | 4,581 | 4.53125 | 5 | #!/usr/bin/env python
# coding: utf-8
# In[72]:
get_ipython().run_line_magic('matplotlib', 'inline')
# # Vectors (Column Vectors)
#
# A vector is a column of numbers. Vectors are related to a **point** but have an essential geometric meaning.
#
# Think of the vector $v$ as an arrow pointing from the origin to th... |
465a970d2ca212a63a13930893a389e21554e260 | AdarshKoppManjunath/Image-Processing | /assignment3/assignment3/a3q4.py | 4,677 | 3.5 | 4 | """This program is written in python3 and can execute using visual studio code.
Prerequisites are-
Input image path, destination folder, input image width and image column
Command to execute this program-
python a3q4.py "<original image path> <original image row> <original image columns> <destination path>"""
... |
41553c5a8fd78e9809df4a68cecaa21f7bf6a147 | NoeNeira/practicaPython | /Guia_1/Ejercicio13.py | 494 | 4.1875 | 4 | """
Crear un programa que guarde en una variable el diccionario {'Euro':'€', 'Dollar':'$', 'Yen':'¥'},
pregunte al usuario por una divisa y muestre su símbolo o un mensaje de aviso si la divisa no está en el diccionario.
"""
miDicc = {
'Euro':'€',
'Dollar':'$',
'Yen':'¥'
}
divisaEligida = input("Qué... |
af832c52837eea53d79b1fcfa84c2b398013017d | wmemon/python_playground | /24_days/Day 9/Question29.py | 268 | 4.15625 | 4 | """
Define a function that can accept two strings as input and concatenate
them and then print it in console.
"""
concat = lambda x,y : str(x)+str(y)
string1 = input("Please enter string 1: ")
string2 = input("Please enter string 2: ")
print(concat(string1,string2)) |
09a682c9fb65dfcb15859ac137a753560d7313e6 | avdata99/programacion-para-no-programadores | /ejercicios/ejercicio-047/ejercicio.py | 3,373 | 4.40625 | 4 | """
La funcion "detectar_escaleras" funciona bastante bien.
Toma una lista de numeros y busca escaleras ascendentes
dentro de la secuencia de numeros.
Esta funcion detecta casi todas las secuencias pero no todas
Tarea:
- Arreglar la funcion para que pase los tests y encuentre
todas las escaleras existentes
Nota: pr... |
6bdcddc628168f004d920f5c7f73eebc78f07357 | SungHyunShin/Programming-Challenges-Contest-II | /challengeIIC/program.py | 444 | 3.546875 | 4 | #!/usr/bin/env python3
# Sung Hyun Shin (sshin1) & Luke Song (csong1)
import sys
def longestPerm(word1,word2):
perm = []
word2 = [x for x in word2]
for char in word1:
if char in word2:
word2.remove(char)
perm += char
if perm:
perm.sort()
print("".join(perm))
else:
print()
#main
if __name__ == '__m... |
de409eef8178d9e55cbf4e15b8db83b5359fd89a | nhanduong288/HomePractice | /Algorithms/CamelCase.py | 140 | 3.578125 | 4 | '''
Source: Big-O
'''
# input string
s = input()
result = 1
for letter in s:
if letter.isupper():
result += 1
print(result)
|
9f7cb15eee0419ed5562f55687330d36b392c7f0 | exploring-curiosity/DesignAndAnalysisOfAlgorithms | /Assignment1/q3_5inssort.py | 369 | 3.890625 | 4 | def ins_sort(a,n):
if n == 0:
return
else:
ins_sort(a,n-1)
ordered_insert(a,n)
def ordered_insert(a, n):
if n == 0:
return
elif a[n - 1] < a[n]:
return
else:
a[n - 1], a[n] = a[n], a[n - 1]
ordered_insert(a, n - 1)
a = input("> ").split()
i... |
62c1116a0a5d2ef0d09af33c2f1a41237a733f60 | butterflow/butterflow | /12b.py | 1,020 | 3.546875 | 4 | def predecessor():
global jobs,n
cur=n
chosen=cur-1
while cur>1:
if chosen<=0:
p[cur]=0
cur-=1
chosen=cur-1
else:
if jobs[cur][0]>=jobs[chosen][1]:
p[cur]=chosen
cur-=1
chosen=cur-1
else:
chosen-=1
def find_sol(j):
global Schedule
if j>0:
if jobs[j][2]+M[p... |
c2ffbe80746baea45ae3e847cd3d6bb5c4d9f29b | plisek1986/workshop_module2 | /Konfiguracja bazy danych/models.py | 5,818 | 3.796875 | 4 | from utils import hash_password
from psycopg2 import connect
class User:
"""
This class defines actions for user and password management
"""
# define the connection with database
con = connect(user='postgres', host='localhost', password='coderslab',
database='workshops_module2')
... |
70c145a9180b41e21171e766b078e77a86f0dcda | ZacharyRSmith/exercism | /python/sandbox.py | 431 | 3.640625 | 4 | def danny_bub2(list):
for i in range(len(list)//2):
# 0 -
for j in range(i, (len(list) - 1) - i):
if list[j] > list[j + 1]: # if lt > rt, swap
list[j], list[j + 1] = list[j + 1], list[j]
for k in range((len(list) - 2) - i, i, -1):
if list[k] ... |
24c20bf1a9fc2026ebd7c06d57324dfd740507b5 | JustKode/python-algorithm | /2.Sort/selection_sort.py | 308 | 3.6875 | 4 | def selection_sort(list_var):
for i in range(len(list_var) - 1):
min_value_index = i
for j in range(i + 1, len(list_var)):
if list_var[i] > list_var[j]:
min_value_index = j
list_var[i], list_var[min_value_index] = list_var[min_value_index], list_var[i] |
c6034bdc7cfbdcfdcb7c18c78aaebf89ee0ef02b | pananer02/project_game | /project_game.py | 6,438 | 3.5625 | 4 | #Example 10-2
import pgzrun
from random import randint
#function for display
def draw():
screen.fill((100,200,200))
if StatusGame == 0:
message = "Are you ready, press Enter key to play."
screen.draw.text(message,topleft=(20,350),fontsize=40,color='blue')
elif StatusGame == 1:
scre... |
e30e11c1c6b09915235a9a390f517892d045391c | ElkinAMG/holbertonschool-higher_level_programming | /0x03-python-data_structures/6-print_matrix_integer.py | 230 | 3.8125 | 4 | #!/usr/bin/python3
def print_matrix_integer(matrix=[[]]):
for x in matrix:
for y in range(len(x)):
cend = " " if y != (len(x) - 1) else ""
print("{:d}".format(x[y]), end=cend)
print()
|
97170e4852c74fb8d8ef5567449e29377f650908 | 7honarias/holbertonschool-higher_level_programming | /0x0A-python-inheritance/100-my_int.py | 323 | 3.578125 | 4 | #!/usr/bin/python3
"""Modulo int"""
class MyInt(int):
"""class MyInt"""
def __init__(self, size):
"""instantiation"""
self._size = size
def __ne__(self, other):
"""negative"""
return int.__eq__(self, other)
def __eq__(self, other):
return int.__ne__(self, othe... |
a5e2ad8f7619e749b216ba1a484455a6228bc2ac | KAA-sign/stepik | /python_1/decoder.py | 955 | 3.90625 | 4 | original_alphabet = list(input('Enter original alphadet: '))
# original_alphabet = list('abcd')
finite_alphabet = list(input('Enter finite alphabet: '))
# finite_alphabet = list('*d%#')
not_encrypted = list(input('Enter not_encrypted string: '))
# not_encrypted = list('abacabadaba')
not_encrypted = list(input('Enter en... |
b3fbe9484d4f0c6d69a78c456adda787ac46ecc1 | amymhaddad/version_2_exercises_for_programmers | /example_problem.py | 432 | 3.78125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu May 10 15:34:22 2018
@author: amyhaddad
"""
def tip_calculator(bill_amount, tip_rate):
"""Determine the tip for a bill"""
tip_as_decimal = tip_rate / 100
total_tip_amount = bill_amount * tip_as_decimal
return total_tip_amount
def cal... |
d8ccc4e425ca456962e05cecea11cc399e8e9b18 | anishLearnsToCode/python-training-1 | /solution-bank/pattern/solution_3.py | 171 | 3.765625 | 4 | rows = int(input())
print('*' * (rows + 1))
for i in range(rows - 1):
print(end='*')
print(' ' * (rows - i - 2), end='')
print('' if i == rows - 2 else '*')
|
7fe2c49f7edbd64a8d1179e0ce9e8f717194f422 | bringsyrup/CircuitsLabs | /1/graphII.py | 640 | 3.640625 | 4 | #! /bin/env python
import matplotlib.pyplot as plt
import csv
import sys
def makeGraph(CSV):
f = open(CSV, 'rt')
try:
reader = csv.reader(f)
Iin = []
Iout = []
for row in reader:
Iin.append(row[0])
Iout.append(row[1])
finally:
f.close()
... |
de70dd28bca94cc9c60933fe1f0dea764aaead8d | Disha5harma/Data-Structures | /Binary Tree/Level order traversal.py | 2,161 | 4.125 | 4 | # Level order traversal
# Send Feedback
# Given a binary tree, print the level order traversal. Make sure each level start in new line.
# Input format :
# Elements in level order form (separated by space). If any node does not have left or right child, take -1 in its place.
# Output Format :
# Elements are printed l... |
7d1d3d042d19da853de7e920387507c588b57556 | Ayush456/pythonExamples | /stringCapitalize.py | 603 | 4.3125 | 4 | str = "this is a demo string"
print(str.capitalize())
print(str)
print(str.upper())
print(str.lower())
print(str.upper().center(50,"*"))
sub='i'
print("Counting the no of alphabets 'i' : ",str.count(sub))
sub2='string'
#whether the string will end with "string"
print("",str.endswith(sub2))
#Does the string contains ... |
ef1afa1f3acc2d61551558b29824fad8315fdbe0 | Alumasa/Python-Basics-Class | /functions.py | 335 | 3.84375 | 4 | """"
A function is a block of code/statements that perform a certain task and returns a result.
"""
def addTwoNumbers():
sum = 34 + 56
return sum
print(type(addTwoNumbers()))
def addNumber(x, y):
sum = x + y
return sum
print(addNumber(67, 99))
def my_function():
print("Hello from a function!")... |
3fec5cf0225eaaa241dbbe57b60e1449195c4106 | diegofregolente/30-Days-Of-Python | /10_Day_Loops/9.py | 84 | 3.703125 | 4 | tot = 0
for n in range(101):
tot += n
print(f'The sum of all numbers is {tot}')
|
b5d92e3d8466bd612fefc00825414f12b965ea47 | abhinavsharma629/Data-Structures-And-Algorithms-Udacity-Nanodegree | /Level 2/Huffman.py | 4,460 | 3.65625 | 4 | import sys
class MinHeap:
root=None
nodeArr=[]
def __init__(self, frequency=0, char=None):
self.data=frequency
self.character=char
self.left=None
self.right=None
# add new node to the heap -> takes O(log N) time
def addNewNode(self,node):
if(self.root==Non... |
d4d7372a3e1b00f98d2dfcfe89efe0ede471dab2 | ding-co/baekjoon-python | /Stage_50/stage_07/pb02_11720.py | 429 | 3.5625 | 4 | # 2. 숫자의 합 (11720)
# 정수를 문자열로 입력받는 문제.
# Python처럼 정수 크기에 제한이 없다면 상관 없으나,
# 예제 3은 일반적인 정수 자료형에 담기에 너무 크다는 점에 주목합시다.
# github: ding-co
# Constraint
# 0. input: 1 <= N <= 100
# 1. input: N numbers
n = int(input())
input_data = input()
sum = 0
for data in input_data:
sum += int(data)
print(sum) |
83674578476c9335bec312be2c37f9b5a3ba45bf | beraa/I590-Projects-BigData-Software | /fizzbuzz.py | 677 | 4.34375 | 4 | import sys
def fizzbuzz(n):
"""
fizzbuzz.py python program accepts an integer n from the command line.
Pass this integer to a function called fizzbuzz. The fizzbuzz function should then iterate from 1 to n.
ith number is a multiple of two, print “fizz”,
ith number is a multiple of three print “b... |
99e337531b54df2c0d0dc75663850a13b2bcd400 | Hassan-Farid/PyTech-Review | /Computer Vision/GUI Handling OpenCV/Handling Images/Reading Images with Different Colors.py | 994 | 3.8125 | 4 | import cv2
import sys
#Reading image from the Images folder in Grayscale Format
grey_img = cv2.imread("./Images/image1.jpg", cv2.IMREAD_GRAYSCALE) #Alternatively use 0
#Reading image from Image folder neglecting transparency value (Converts RGBA/BGRA to RGB/BGR)
color_img = cv2.imread("./Images/image1.jpg", cv2.IMREA... |
08e65f4eb49ddb3423dc577a1104d6729df1391b | 99rockets/algorithms | /sorting/bogo_sort/bogo_sort.py | 810 | 4.09375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
from sys import argv
from random import randint, shuffle
"""
Example usage:
>> time python3 bogo_sort.py 5
user 0.04s
system 0.01s
cpu 86%
total 0.050
>> time python3 bogo_sort.py 10
user 77.95s
system 0.27s
cpu 99%
total 1:18.74
"""
try:
k = ... |
47f175d804bb6d13917f5d3f5a187e24191bae91 | ZachtimusPrime/exercism | /python/say/say.py | 318 | 3.59375 | 4 | from num2words import num2words
def say(number: int) -> str:
if number < 0 or number > 999999999999:
raise ValueError("Must enter a number between 0 and 999,999,999,999")
return num2words(number, lang='en').replace('thousand,','thousand').replace('million,','million').replace('billion,','billion')
|
88381307e66d31872ec0f8388d02b653759d1ce1 | hieplt1018/AI_for_everyone | /W1/function.py | 415 | 3.5 | 4 | # define and call function
def point():
print("Physics: 4.0")
print("Math: 4.0")
print("English: 4.0")
point()
#pass argument
def get_name(name):
print("Your name: " + name)
get_name("Hiep")
#default argument
def say_oh_year(name = "Sky"):
print(name + " say OH, YEAH!")
say_oh_year()
say_oh_year("... |
43a68d9e8ead8faaa34d3cda62a30b4e1b2c4eec | IvanAlexandrov/HackBulgaria-Tasks | /week_0/1-Python-simple-problem-set/matrx_bomb.py | 1,630 | 3.5625 | 4 | from sum_matrix import sum_matrix
def matrix_bombing_plan(matrix):
result = {}
for i, row in enumerate(matrix):
for j, col in enumerate(row):
# print(new_matrix)
new_matrix = [x[:] for x in matrix]
key = (i, j)
subtraction = matrix[i][j]
# up... |
655ea0008d32f959a67896163e3832e3ff829062 | linjunyi22/datastructures | /插入排序.py | 679 | 3.890625 | 4 | """
插入排序
"""
l = [2,6,5,4,1,7,8,9,0]
def insert_sort(lists):
for i in range(1, len(lists)): # 插入排序一定要有一个已经排好序的,一般选下标为零那个
temp = lists[i] # 记住当前还没排序的元素
j = i - 1 # 从i-1到0是已经排好序的,待会要比较
while j >= 0: # 从 i-1到0开始遍历
if lists[j] > temp: # 如果已经排好序的元素里有比当前待排序的元素大,那么把元素往后移动一个位置
... |
a1ffff1093053d83c877840e9ab0c1d8024b43e8 | M42-Orion/python-data-structure | /归并算法.py | 1,482 | 3.65625 | 4 | #!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@File : 归并算法.py
@Time : 2020/03/27 13:49:22
@Author : 望
@Version : 1.0
@Contact : 2521664384@qq.com
@Desc : None
'''
# here put the import lib
'''
归并排序是采用分治法的一个非常典型的应用,另一个可以采用分治法的是快速排序,归并算法比快速排序速度稍低。归并排序的思想就是先递归分解数组,再合并数组。
将数组分解最小之后,然后合并两个有序数组... |
bb7711869b83f35eb1bc5934c736f705f1a3a929 | Vith-MCB/Phyton---Curso-em-Video | /Cursoemvideo/Códigos/aula06 - Calculando média.py | 161 | 3.984375 | 4 | n1 = int(input('Digite o primeiro número: '))
n2 = int(input('Digite o segundo número: '))
m = (n1+n2)/2
print('A média entre {} e {} é: {}'.format(n1,n2,m)) |
5e9dbb30ed1f829b2be79c31f04c9a82aebdae34 | aishwaryan14/sllab | /part_a_11.py | 351 | 3.71875 | 4 | li = ["The2","darkest1","ho6ur","200a9"]
for i in range(0,len(li)):
if i%2==0:
print(li[i])
print("\n")
for i in range(0,len(li)):
if i%3==0:
li[i]=li[i].upper()
print(li)
print("\n")
for i in range(0,len(li)):
li[i]=li[i][::-1]
print(li)
print("\n")
num_li=[]
for l in li:
for i in l:
if i.isdigit():
... |
0ab2f6a63e711dda19c5b1452d7066f8046284e5 | Sergi-Simon/INTRODUCTION-TO-PYTHON-PROGRAMMING | /Courseworks/Coursework 3/Solutions/functions.py | 579 | 3.75 | 4 | """ functions.py
Solution to the coursework
Author: Sergi Simon
Latest update: October 31, 2020
"""
import math
import numpy as np
fx0 = 0
fx1 = 2
def f1 ( x ):
return math.cos( x )
def df1 ( x ):
return -math.sin( x )
def f2 ( x ):
return math.exp( -x ) - x
def df2 ( x ):
return -math.exp( -x ) - x
... |
79f5308265ffe30641afc0d1e5a4050bb9d4188a | psemchyshyn/Flights-analysis | /modules/data_dashapps/cities_processing.py | 896 | 3.703125 | 4 | '''
FligthsDetector
Pavlo Semchyshyn
'''
import json
import pandas as pd
import requests
def get_cities_json():
'''
Writes data about the cities that have
iata code in the "iata_cites.json" file
'''
url = "https://api.travelpayouts.com/data/en/cities.json"
headers = {'x-access-token': 'a9664... |
b4e76cde009496ede9999e06a3f43f0e3e1101c0 | bencouser/electronics | /motor_step.py | 921 | 3.515625 | 4 | import RPi.GPIO as GPIO
from time import sleep
GPIO.setmode(GPIO.BOARD)
# time module to add delay between turning on and off control pins
ControlPins = [7, 11, 13, 15]
for pin in ControlPins:
GPIO.setup(pin, GPIO.OUT)
GPIO.output(pin, 0)
# Make an array for 8 set sequence for half stepping
half_step = [[... |
b8addbaf31dce94cbf9e67adfeee954a02ca3942 | KaloyankerR/python-advanced-repository | /Assignments/Exam Preparation/Python Advanced Retake Exam - 08 April 2020/03. Find the Eggs.py | 1,464 | 3.765625 | 4 | def find_strongest_eggs(elements: list, sub_list):
sub_listed_elements = [[] for x in range(sub_list)]
ind = 0
while elements:
if ind == sub_list:
ind = 0
element = elements.pop(0)
sub_listed_elements[ind].append(element)
ind += 1
valid = []
for sub_lis... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.