blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
61b1845941446d8168c4d8831b1dc68d2e96306f | smallbombbomb/CodingTest | /CT/ShuffleSeq.py | 435 | 3.53125 | 4 | #N = 6 , numlist = [3, 2, 5, 6, 1, 4]
#1 2 3 4 5 6 // 그대로 들어가고
#3 2 5 6 1 4
#5 -> 1
#2 -> 2
#6 -> 4
#3 -> 5
#1 -> 3
#4 -> 6
#5 2 1 4 3 6
# N, K 공백으로 입력받음
n = map(int, input())
k = input().split()
numlist = [3, 2, 5, 6, 1, 4]
count = 0
for i in k:
for j in range(len(numlist)):
#if i == numlist[j]:
... |
f0dc4a93592f8d7af51e6f14cf39fbdc0ffa65a5 | win-t/meetup_docker_27_mar | /demo/hello/hello_3 | 180 | 3.734375 | 4 | #!/usr/bin/env python3
import sys
print("Hello ", end="")
if len(sys.argv) < 2:
print("World")
else:
print(sys.argv[1])
data = input()
print("Your input: %s" % data)
exit(0)
|
f198b071d92c515309474c669137e0f5b1594af1 | gzummo/algorithms | /Sorting Algorithms/insertion-sort.py | 362 | 4.125 | 4 | #!/usr/bin/env python3
def insertion_sort(list):
for i in range(1, len(list)):
current_item = list[i]
j = i - 1
while j >= 0 and list[j] > current_item:
list[j+1] = list[j]
j -= 1
list[j+1] = current_item
return list
list = [4, 1, 4, 20, ... |
edb00c2ef9669e575b20e1042f53e4680f426757 | Amit32624/Python | /Python_codes/DemoComparisionOperators.py | 211 | 4.09375 | 4 | '''
Created on 19-Jun-2017
@author: mohan.chinnaiah
'''
x = 10
y = 12
print('x > y is',x>y)
print('x < y is',x<y)
print('x == y is',x==y)
print('x != y is',x!=y)
print('x >= y is',x>=y)
print('x <= y is',x<=y) |
8b1b753f3cfe7149203c3113721cce14918110bd | msaei/think-n-guess | /guss-letter.py | 1,241 | 3.875 | 4 | # this is a python program for a gusing game named under curtain.
# there is a combination of four different letters that picked from 6 letters.
# every time player guse the combination will get a score that shows how close was.
# 10 points for every correct letter in correct position and 1 point for any correct
# let... |
c9ccae6a6aaabe2d19cd724eae5bef4fae219a95 | heysushil/python-practice-set-three-with-3.8 | /8.tupel.py | 596 | 4.15625 | 4 | # Tuple
mytuple = ('10',10,29,9)
print('\nmytuple: ', type(mytuple))
# mytuple[0] = 11
data = (1,2,3,['Ram','Shyam',['Ram','Shyam']])
print('\nMYtuple: ', mytuple[0])
print('\nSingle Name: ', data[-1][-1][0])
'''
Question:
1. Ek tupe creat karna hai then uske index positions ko find karna hai, positive and negati... |
6d0676b9eb9cad4ef2376057bf17bc650c8f8eb3 | yangjinke1118/trainpython100 | /train002.py | 2,481 | 3.671875 | 4 | """
题目:企业发放的奖金根据利润提成。利润(I)低于或等于10万元时,奖金可提10%;利润高于10万元,
低于20万元时,低于10万元的部分按10%提成,高于10万元的部分,可提成7.5%;20万到40万之间时,
高于20万元的部分,可提成5%;40万到60万之间时高于40万元的部分,可提成3%;60万到100万之间时,
高于60万元的部分,可提成1.5%,高于100万元时,超过100万元的部分按1%提成,从键盘输入当月利润I,
求应发放奖金总数?
程序分析:请利用数轴来分界,定位。注意定义时需把奖金定义成长整型。
程序源代码:
实例(Python 2.0+)
#!/usr/bin/python
# -*- coding: U... |
6bddc82a8e2e13e363d7e90b1aa84ad2b85ce712 | KarimnC/Mision_04 | /Software.py | 1,146 | 4.15625 | 4 | #Karimn Daniel Hernández Castorena
#Programa que calcula el descuento de una compra y el pago total de la misma.
#Funciión que calcula el descuento a realizar.
def calcularDescuento(p):
if p>=1 and p<=9:
d=0
elif p>=10 and p<=19:
d=.15
elif p>=20 and p<=49:
d=.22
elif... |
52948c3e114f34095bbf811e24123cdb702b7299 | zfu1316/leetcode-maxed_out | /algorithm/python/prob501-1000/prob917_easy_Reverse-Only-Letters.py | 494 | 3.5 | 4 | class Solution:
def reverseOnlyLetters(self, s: str) -> str:
n = len(s)
result = list(s)
left = 0
right = n - 1
while left < right:
if not result[left].isalpha():
left += 1
elif not result[right].isalpha():
right -= 1
... |
af3934947aca77e03b85e9b391ba893a40a6e8c0 | santoshr1016/OpenCV | /HRank/lists.py | 795 | 3.53125 | 4 | l = []
N = int(input().strip())
for i in range(N):
cmdArray = input().split(" ")
# print(cmdArray)
# if cmdArray[0] in dir(l):
if cmdArray[0] == "insert":
l.insert(int(cmdArray[1]), int(cmdArray[2]))
elif cmdArray[0] == "remove":
l.remove(int(cmdArray[1]))
elif cmdArray[0] == "ap... |
d8d3092c8698b017936c5b21e5127fe16268e19d | jkaeuffer/Coursera-Python | /Pong_final_Coursera.py | 4,897 | 3.6875 | 4 | # Implementation of classic arcade game Pong
import simplegui
import random
# initialize globals - pos and vel encode vertical info for paddles
WIDTH = 600
HEIGHT = 400
BALL_RADIUS = 20
PAD_WIDTH = 8
PAD_HEIGHT = 80
HALF_PAD_WIDTH = PAD_WIDTH / 2
HALF_PAD_HEIGHT = PAD_HEIGHT / 2
LEFT = False
RIGHT = True
ball_... |
c9068b42c4151dd5b833b409508fd7c29e9c8b13 | manastole03/Programming-practice-2 | /python1/DAY6_PROGRAMS/conversions.py | 660 | 4.28125 | 4 | # Python function that convert feet into inches.
def ft_to_inch(ft):
inches = ('{:.2f}'.format(ft*12))
print(f'{ft} feet = {inches} inches')
ft = float(input("Feet: "))
ft_to_inch(ft)
# Python function to convert miles to kilimeter.
def miles_to_km(miles):
km = ('{:.2f}'.format(miles/0.6214))
... |
d9a1d27c731869f709f5815a8b410cc81da150fb | sonurounier/PythonPrograming | /S0AQ03.py | 688 | 3.953125 | 4 | '''
You invite home 10 of your closest friends and play a simple game of luck.
Each of your friend picks up a card from a stack of cards numbered from 300 to 325.
The person with the highest number winsSimulate this simple game using Python
[ Hint : Make sure that no 2 friends get the same numbered card ]
'''
from ra... |
fa6613b78fe1df6ac8aa9eb4849b2feb045870dd | Dyr-El/advent_of_code_2017 | /Airwide-python/day3part1.py | 1,611 | 3.859375 | 4 | import sys
import math
def print_2d_array(array):
for line in array:
print(line)
def main(puzzle_input):
# Special case for input == 1
if puzzle_input == 1:
return 0
array_dim = math.ceil(math.sqrt(puzzle_input))
if array_dim % 2 == 0:
array_dim += 1
# Create array
... |
23ef26e3b4b52d26a1880b8fb9f1c0ef331962d1 | VVKot/coding-competitions | /leetcode/python/986_interval_list_intersections.py | 885 | 3.65625 | 4 | """
T: O(A + B)
S: O(C), where C = min(A, B)
Walk through both of the lists and check if two current intervals intersect.
If so - add them to the result. Move the pointer in the list which interval
ends earlier.
"""
from typing import List
class Solution:
def intervalIntersection(self, A: List[List[int]],
... |
462ab4714e906718244b1e1f0b0505aefd782534 | MrFMach/Python-CursoEmVideo | /challenge019to020.py | 435 | 3.8125 | 4 | from random import choice, sample, shuffle
s1 = input("Enter a studend #1: ")
s2 = input("Enter a studend #2: ")
s3 = input("Enter a studend #3: ")
s4 = input("Enter a studend #4: ")
student = [s1, s2, s3, s4]
# challenge 19
print("The chosen student is {}".format(choice(student)))
print("The two chosen students are ... |
472753b6ed3f54811850aa5e9b9d8a968a3c02bb | uisandeep/ML-Journey | /python/dictionary.py | 1,363 | 4.09375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun May 3 09:20:53 2020
@author: sandeepthakur
"""
thisdict = {
"brand": "ford",
"model": "Mustang",
"year": 1980}
print(thisdict)
#access using key
print(thisdict["model"])
print(thisdict.get("model"))
thisdict["year"] = 2000
#print(thisd... |
414cc6277fb86818f81f8408b73cb3746b59d1fa | SeanStew21/Array-example | /ArrayExample.py | 552 | 4.0625 | 4 | #An Array (python calls it a list)
aryList = ['cherries', 'apples', 'plums', 'bells', 'melons', 'bars']
#print(aryList[0]) picks the first fruit in aryList
'''for i in range(6): #called hardcoding when limiting to 6 instead of unlimited
print(i, aryList[i])'''
aryLength = len(aryList) #assigns aryList to variab... |
9742c3f83fcf47c9a388a29914cca96312f29bda | Kraay89/AoC2018 | /Day1/Day1.py | 1,027 | 3.796875 | 4 | ###############################################################################
# ADVENT OF CODE 2018 #
# DAY 1 #
###############################################################################
... |
6770fbf6864972792853d7ac1e7ec12f4df569a4 | Supermac30/CTF-Stuff | /Mystery Twister/Autokey_Cipher/Autokey Key Finder.py | 447 | 4.09375 | 4 | """
This script finds the key when given the ciphertext and plaintext with the AutoKey Cipher
"""
plaintext = input("input plaintext ")
ciphertext = input("input ciphertext ")
key = ""
for i in range(len(plaintext)):
key += chr((ord(ciphertext[i]) - ord(plaintext[i]))%26 + ord("A"))
for i in range(len... |
12f72272bc55c666104e8aa3af8ea83a93766f9b | gabrielcarlosama/FrameWorks_8A | /scripts_python/Race.py | 698 | 3.640625 | 4 | '''
Se requiere un Scrip en Python que se permita simular el juego de
carrera numerica con dos Players.
La carrera inicia en la posicion CERO y finaliza en la posicion 100.
El juego se realiza por default con 2 jugadores
El jugador que llegue primero a la meta (posicion 100 sera el ganador)
Si un jugador generara 3 pa... |
17bdbe39b02d914a07618c3614baa45ddb07f3de | MichaelGavin16/Python | /MichaelGavinMod9.py | 651 | 3.9375 | 4 | import random
guesses = 0
number = random.randint(-100, 100)
print("I am thinking of a number between -100 and 100. Can you guess in 7 attempts?")
while guesses < 7:
print("Answer:")
g = input()
g = int(g)
guesses = guesses + 1
if g > number:
print("Too High")
if ... |
bc793ac0bd0c127aba373472c634d0e0cd145cad | liusska/Python-Fundamentals-Jan-2021 | /mid_exams_solutions/04.mid_exam/03.Numbers.py | 299 | 3.96875 | 4 | numbers = [int(x) for x in input().split()]
average_num = sum(numbers) / len(numbers)
numbers = [num for num in numbers if num > average_num]
sorted_numbers = sorted(numbers, reverse=True)
if sorted_numbers:
print(' '. join(str(x) for x in sorted_numbers[:5]))
else:
print("No") |
1ae45a7daf72afb638d200e918cbfd57e24f48e1 | Granafmini/python10 | /bit.py | 290 | 3.671875 | 4 | def max():
a=int(input())
b=int (input())
c=int(input())
if (a>b):
if(a>c):
print (a);
else :
print(c);
elif (b>c):
print (b);
else:
print (c);
def main():
try:
max()
except ValueError:
print('invalid');
main()
|
36fa19fc0ee095bfabc4503c13d99f08530986ea | MDobrinski/TrainingNeeds | /TrainingNeedsDF.py | 7,427 | 3.59375 | 4 | import csv
import datetime
import os
import xlsxwriter
import tkinter as tk
from tkinter import filedialog
from tkinter import ttk
from tkinter import Menu
from tkinter import messagebox
import pandas as pd
def get_file():
global filename
filename = filedialog.askopenfilename(initialdir="/Users/mdobrinski/d... |
dd12771b78ed4690e1675318ff03170ad59f2459 | rashidkhalid1212/Blend_with_python | /Sourav Assignment/Sourav_q1.py | 538 | 4.125 | 4 | """this calculator performs following functions
Addition
Subtraction
Multiplication
Division
"""
#Let x and y be the two numbers
x=float(input("Enter your first number here"))
y=float(input("Enter your second number here"))
sum=float(x+y)
print("Addition of the two number gives=")
print(sum)
sub=float(x... |
bcc947b7ff462d20f1dff2a738c1335bbf7c5a97 | petronius/minotaur | /__init__.py | 7,844 | 3.671875 | 4 | """
But of all the games, I prefer the one about
the other Asterion. I pretend that he comes to visit me and that I show him my
house. With great obeisance I say to him "Now we shall return to the first
intersection" or "Now we shall come out into another courtyard" Or "I knew you
would like the drain" or "Now you ... |
d3f02c5c309108ea641636a8375411505e7a4723 | AdamZhouSE/pythonHomework | /Code/CodeRecords/2542/60671/246230.py | 326 | 3.5625 | 4 | str0=input()
strr1=str0[1:-1]
str1=strr1.split(",")
str1.sort()
numl=[]
for o in str1:
numl.append(int(o))
numl.sort()
length=len(numl)
count=0
temp=0
for i in range(length-1):
if(numl[i]+1==numl[i+1]):
temp+=1
else:
if((temp+1)>count):
count=temp+1
temp=0
print(count)
... |
c2484c92c5d6747efe397f9df042b869b194ff7a | ahmedmdl/pdptw | /customers.py | 13,041 | 3.90625 | 4 | from collections import namedtuple
import numpy as np
from datetime import datetime, timedelta
import spatial as spatial
class Customers():
"""
A class that generates and holds customers information.
Randomly normally distribute a number of customers and locations within
a region described... |
c2aba18ec71cf5f47cfeac598dc477dd738c4178 | angel-sarmiento/python-ML | /ML-Models/LinRegression.py | 2,378 | 3.625 | 4 | #%%
#%%
"Preamble for importing libraries"
import numpy as np
from numpy.random import randn
import pandas as pd
from pandas import Series, DataFrame
from scipy import stats
import seaborn as sns
import matplotlib as mlib
import matplotlib.pyplot as plt
import sklearn
from sklearn.linear_model import LinearRegr... |
cff01f6f3109ff5b868c05b81e21372af8bc76ef | Nafiuli131/Python-Coding | /Python_coding/modules.py | 248 | 3.765625 | 4 | '''import datetime
import time
today=datetime.date.today()
timetoday=time.time()
print(today)
print(timetoday)'''
from camelcase import CamelCase
c=CamelCase()
print(c.hump('hello nafiul'))#this module make the uppercase of the first letter here
|
b313a63d3e984bfd5a48af52c44c1a37a1bb284a | naylorc/cti110 | /P5T1_KilometerConverter_NaylorConnor.py | 292 | 4.0625 | 4 | #CTI - 110
#P5T1 - Kilometer Converter
#Connor Naylor
#7/17/18
#miles=kilometers*0.6214
def main():
kilometers=int(input("How many kilometers were traveled? "))
miles=kilometers*0.6214
show_miles(miles)
def show_miles(miles):
print(miles,"miles were traveled.")
main()
|
18f3eb009d7996c4016e81b42f9a7dc3c39fb692 | fossifus/FoCS | /Competitions/BattleshipMatch/Rules.py | 1,860 | 4.125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Mar 21 11:55:12 2020
@author: Kyle
"""
"""
The class that contains the rules for placing your pieces you may use this to check your piece placement
But do not change this code
"""
class Rules:
def checkPieces(self, pieces):
for p in pieces:
... |
835319ccdfe0ef61d024efc651b7399edd694fd8 | Kyeongrok/python_crawler | /com/chapter08_json/02_python_json/06_retrieve_data_using_for2.py | 173 | 3.671875 | 4 | import json
json_str = '[{"name":"kyeongrok", "age":"32"}, {"name":"bomi", "age":"25"}]'
json_obj = json.loads(json_str)
for student in json_obj:
print(student['name']) |
b48d720d2ea5165718aa5eb4d1a1d4860523b8c3 | adinath10/Python-Apps | /Unit-1 Basic Data Types/Letter_Counter_App.py | 634 | 4.28125 | 4 | #Python Challenge 1 Letter Counter App
print("Welcome to the Letter Counter App")
#Get User Input
name = input("\nWhat is your name: ").title().strip()
print("Hello, " + name.title() + "!")
print("I will count the number of times that a specific letter occurs in a message.")
msg = input("\nPlease enter a message: ")... |
6acf34ef1a19711406133b35be2039db0673d9be | rafaelperazzo/programacao-web | /moodledata/vpl_data/152/usersdata/267/65901/submittedfiles/swamee.py | 521 | 3.640625 | 4 | # -*- coding: utf-8 -*-
import math
#COMECE SEU CÓDIGO AQUI
g = 9.81
E = 0.000002
f = float(input('Insira o fator de atrito f: '))
L = float(input('Insira o comprimento da tubulação em metros: '))
Q = float(input('Insira o valor da vazão em m3/s: '))
Hf = float(input('Insira a perda de carga: '))
v = float(input('Insir... |
775092e7d5ae9650f3f83eb4a181c2ef2a1baf46 | maxdinech/car-crash | /tutos/tuto_pytorch.py | 6,434 | 3.6875 | 4 | """
Tutoriel d'utilisation de Pytorch
=================================
Sommaire:
---------
1. Manipulation des tenseurs ------------------------------------- 16
2. Variables et gradients --------------------------------------- 69
3. Définition d'un MLP sim... |
2c2d93a67e213b473523c4ad14afbf7aaac8ea37 | Djamal1/PythonProg | /Python1/l11/O_O_P.py | 268 | 3.515625 | 4 | class Auto:
def __init__(self, wheels, body):
self.wheels = wheels
self.body = body
def drive(self):
print("Не поеду!!")
tesla = Auto(2, True)
print(tesla.wheels)
print(tesla.body)
tesla.drive()
tesla.wheels += 2
oka = Auto(10, False) |
373a5e3d2e14fc77a5358846430c9a02c73f439d | github4n/stock-magic | /utils/common_utils.py | 440 | 3.875 | 4 | # -*- coding: utf-8 -*
import datetime
def today():
today = datetime.date.today()
return today.strftime('%Y%m%d')
def last_tradeday():
'''
正确的作法是返回上一个交易日的日期
'''
return yesterday()
def yesterday():
yesterday = datetime.date.today() - datetime.timedelta(days=1)
return yesterday.strf... |
ace32c45afedb31c2a21883ab018ff22787be710 | Deniska10K/stepik | /2.3-sep_and_end_parameters/2.custom_separator.py | 660 | 4.375 | 4 | """
Напишите программу, которая считывает строку-разделитель и три строки, а затем выводит указанные строки через
разделитель.
Формат входных данных
На вход программе подаётся строка-разделитель и три строки, каждая на отдельной строке.
Формат выходных данных
Программа должна вывести введённые три строки через раздел... |
d8924d548d219f3dfb552742dc76085ef2d3f831 | ellinx/LC-python | /BinaryTreeLongestConsecutiveSequenceII.py | 2,118 | 4.125 | 4 | """
Given a binary tree, you need to find the length of Longest Consecutive Path in Binary Tree.
Especially, this path can be either increasing or decreasing.
For example, [1,2,3,4] and [4,3,2,1] are both considered valid, but the path [1,2,4,3] is not valid.
On the other hand, the path can be in the child-Parent-chil... |
82de1455f60d8a35b7cb52aae5799f973f6e3816 | Nordenbox/Nordenbox_Python_Fundmental | /.history/sortAlgorithm_20201120222047.py | 800 | 3.765625 | 4 | import random
import time
def findMin(L): # find a minist element in a certain list
min = L[0] # surppose the first element in the list is the minist element
for i in L: # map every element of the list
if i < min: # if some element is less than surpposed minist, it replace the minist
... |
03f37e5e4ca95c4aa498371eda0a4b4b5907fe4e | Randle9000/pythonCheatSheet | /pythonCourseEu/3_NumericalPython/python_course_eu/03_numpy_array/Exercises.py | 828 | 4.21875 | 4 | import numpy as np
#1) create an arbitrary one dimensional array called v
v = np.array([1, 2, 3, 4, 5, 66, 12, 167, -5])
print(v)
#2) create a new array which consists of the odd indeces of previously created array 'v'
x = v[1::2]
print(x)
#3) create a new array in backwards ordering from v
z = v[::-1]
p... |
006328c6fa629fe7656cb29948979aeccc2c0e16 | android156/python_basics | /Les2/task6.py | 2,429 | 3.515625 | 4 | storage = [
(1, {"name":"desktop", "price":"2000", "quantity":20, "measure":"unit"}),
(2, {"name":"printer", "price":"300", "quantity":10, "measure":"unit"}),
(3, {"name":"scaner", "price":"500", "quantity":17, "measure":"unit"})
]
empty_dict = {"name":"", "price":"", "quantity":0, "measure":""}
print(f'Се... |
b2e29bc74323612639b603dec3eabb34a0fa214b | Gitaparup/demo-testing | /args_check.py | 450 | 3.796875 | 4 | def myfunc(a,b, *args):
# print(a)
# print(b)
# print("---------- C --------------")
# print(c)
#
# print("---------- D --------------")
# print(d)
for ar in args:
if ar == c:
print(c)
# elif ar == d:
# print(d)
else:
... |
8d4979500b27b9ccc0f89389ab2c43c4a533f625 | JoTaijiquan/Python | /Python101-New130519/1-7-7.py | 244 | 3.609375 | 4 | #Python 3.9.5
#Example 1-7-7
def func_1_7_7(x,y,z):
'return ค่าหลายๆ ตัวเป็น tuple'
return(x,y,z)
if __name__ == "__main__":
print(func_1_7_7(1,10,20))
print(func_1_7_7((1,2),[3,4],"hello"))
|
1898febed6287acb604c826d26b376ef5f5f6f9c | kyle-mccarthy/ds-baby-names | /income_names.py | 1,549 | 3.8125 | 4 | import pandas as pd
income = pd.read_csv('data/TopMedianIncomeByYear.csv')
income_low = pd.read_csv('data/LowMedianIncomeByYear.csv')
names = pd.read_csv('data/StateNames.csv')
top_names = pd.DataFrame(columns=names.columns)
top_low_names = pd.DataFrame(columns=names.columns)
# we are essentially going to iterate ov... |
270811a739b4cb7904eafaaf9d597a3ddabdfbc2 | yangrencong/pythonstudy | /1.0/1.0.py | 331 | 3.828125 | 4 | print('-------我的第一个小游戏--------')
temp = input('不妨猜一下我想的什么数字:')
guess = int(temp)
if guess == 8:
print('你猜对了')
print('猜对也没奖励')
else:
print('猜错啦')
print('游戏结束,不玩啦^-^')
|
ef911b45524bef91705335d4cb93b8e381567c68 | weihan1107/python_programs | /practice/ch03/uniquewords2_ans.py | 629 | 3.609375 | 4 | #!/usr/bin/env python
import collections
import string
import sys
words = collections.defaultdict(int)
strip = string.whitespace + string.punctuation + string.digits + "\"'"
for filename in sys.argv[1:]:
for line in open(filename):
for word in line.lower().split():
word = word.strip(strip)
... |
dee8b7518ddea252251bdb040b528a2ed770c25b | bannavarapu/Competetive_Programming | /competetive_programming/week3/day1/rand5.py | 224 | 3.78125 | 4 | import random
def rand7():
return random.randint(1, 7)
def rand5():
# Implement rand5() using rand7()
x = rand7()
if x<6:
return x
return rand5()
print 'Rolling 5-sided die...'
print rand5()
|
90938b58aeb634ee479ea1fc76d0526f2b4033cc | ikhwan1366/Datacamp | /Data Engineer with Python Track/03. Streamlined Data Ingestion with Pandas/Chapter/04. Importing JSON Data and Working with APIs/07-Handle deeply nested data.py | 1,950 | 3.78125 | 4 | '''
Handle deeply nested data
Last exercise, you flattened data nested down one level. Here, you'll unpack more deeply nested data.
The categories attribute in the Yelp API response contains lists of objects. To flatten this data, you'll employ json_normalize() arguments to specify the path to categories and pick ot... |
b13a31f9ff56d3ea5ac1b8a1a3755585de61439b | apurvjain9999/Python-Lab | /apj2/sudeep/area2.py | 1,091 | 4.125 | 4 | import mymodule
choice = 0
while choice != 5:
print("\n\n1.Rectangle")
print("2.Circle")
print("3.Triangle")
print("4.Sphere")
print("5.Exit")
choice = int(input("\nEnter your choice "))
if choice == 1:
a = int(input("Enter side 1 of rectangle "))
b = int(input("Enter sid... |
57588f5e36779916cc6165f6c5b9b9d0fdd503a7 | pierrebeaucamp/Exercism-Python | /meetup/meetup.py | 748 | 3.890625 | 4 | import calendar
import datetime
import regex
def meetup_day(year, month, day, label):
week = list(calendar.day_name)
try: delta = int(regex.findall(r'\d', label)[0])
except IndexError: delta = -1 if label == "last" else 1
# itermonthdays will return 0's if a day isn't present in a month. We need
... |
0c094a1af400e29ff0988aa09602a4ae1ee0563a | testingy12345/SQATools2021 | /DataType/Conditions/ConditionalStatement.py | 3,751 | 4.25 | 4 | """
num= 21
if num%2 == 0:
print("Even Number")
else:
print("Odd Number")
"""
a=60
b=87
c=53
# # Find out bigger number
"""
if a > b and a >c :
print("A is bigger Number :" , a)
if b > a and b > c:
print("B is bigger Number : ",b)
if c > a and c >b :
print("C is bigger Number : ", c)
"""
"""
if... |
d7af36e190324dcb6a896a8c46715467b244a97c | michalwols/citemachine | /citemachine/util.py | 1,070 | 3.84375 | 4 | from collections import defaultdict
def filter_dict(func, dictionary):
"""Filter a dictionary *in place* based on filter function
Args:
func: func(key, value), returns ture if item should be retained,
false otherwise
dictionary: dict to be filtered
"""
for key in dictionary... |
20c6fa220b6ea6526bf713e2eb67976a3f3009a3 | Nahida-Jannat/testgit | /nahida_insertion_sort.py | 525 | 4.15625 | 4 | # Descending Order Insertion Sort Implementation
# index = [ 0 1 2 3 4]
# number_list = [15, 5, 25, 1, 10]
def insertion_sort(number_list):
n = len(number_list)
for i in range(1, n):
item = number_list[i]
j = i - 1
while j>=0 and number_list[j] < item:
... |
abccb80197b7aa1ef3024a31853c2e0724c8a63a | Jeetendranani/yaamnotes | /ds/binary_tree/binary_tree_traversal_solution.py | 1,944 | 3.859375 | 4 | """
binary tree traversal solution
in this article, we will provide the recursive solution for the tree traversal methods we have mentioned. And talk about
the implementation of the iterative solution. finally, we will discuss the difference between them.
Iterative solution
There are several iterative solutions for t... |
fa9f903752e599c591042a642cf15f76c58a6ed8 | prabhakar267/youtube | /043/chess/board.py | 5,026 | 3.546875 | 4 | """
This module contains functions relating to the creation and access
of the game board.
"""
import pieces
from square import Square
import globVar
import utils
grid = []
def populate():
place = 0
global grid
# fill grid with empty Squares
for i in range(16):
grid.append([... |
4d691205a4bb3a1438093d9a425ed33b88396d13 | artemiev86/polochka | /contr_2.py | 2,463 | 3.5625 | 4 | # C_1 = (35, 78, 21, 37, 2, 98, 6, 100, 231)
# C_2 = (45, 21, 124, 76, 5, 23, 91, 234)
# if sum(C_1) > sum(C_2):
# print("сумма больше в кортеже", C_1)
# elif sum(C_1) == sum(C_2):
# print("сумма чисел кортежа равна")
# else:
# print("сумма больше в кортеже", C_2)
# print(C_1.index(min(C_1)), C_1.index(ma... |
b500270d24233852a88fed9f85955caea7a78928 | JMorris1575/CryptogramSolver02 | /src/file_handler.py | 4,444 | 3.59375 | 4 | import gzip, struct, os, sys
import data_structures
"""
The ideas, and parts of the program, are taken from Mark Summerfield's very good book:
Programming in Python 3 - A Complete Introduction to the Python Language
"""
MAGIC = b"CS\x00\x00"
FORMAT_VERSION = b"\x00"
GZIP_MAGIC = b"\x1F\x8B"
def clean(text):
"""
... |
b6774a7f8db1a6be831564aeadf4878d8fc1a4f7 | YuduDu/cracking-the-coding-interview | /quickSort.py | 348 | 3.875 | 4 | #!/usr/bin/python
def quickSort(list):
if(len(list)<=1):
return list
pivot = list[0]
less = []
greater = []
for i in list[1:]:
if i<=pivot:
less.append(i)
else:
greater.append(i)
less = quickSort(less)
greater = quickSort(greater)
return less+[pivot]+greater
alist = [54,26,93,17,77,31,44,5... |
b1d2bab0776f7f4a4415a54d68d0e3c249dba0d4 | spenceslx/code_dump | /pythonsnippets/piproximate/piproximate.py | 1,873 | 3.984375 | 4 | #######################################
#Little program used to approximate Pi#
#using probability. Simply drawing an #
#equivalent quarter cirlce within a #
#square and plotting random points #
#######################################
import numpy
import random
import math
import decimal
#decimal precision
decim... |
4cfb7447e792f59f1d61694b14eea3c2be4e7781 | 7german7/python_comands | /practicas/tipos_datos.py | 1,934 | 3.59375 | 4 | #********************************************************TIPOS DE DATOS********************************************************
# Python maneja diferentes tipos de datos y por ser un lenguaje de programacion con tipado dimamico no es obligatorio declarar
# el tipo de dato como los lenguajes de programacion con tipado ... |
0adba0ec65b55baf3cde6be8636334ec9755171e | rafaelperazzo/programacao-web | /moodledata/vpl_data/5/usersdata/80/1291/submittedfiles/atm.py | 381 | 3.9375 | 4 | # -*- coding: utf-8 -*-
from __future__ import division
import math
x=int(input('digite o valor:'))
a=x//20
b=(x%20)//10
c=(b%10)//5
d=(c%5)//2
e=(d%2)
print('o numero de cedulas de 20 é: %.d' %a)
print('o numero de cedulas de 10 é: %.d' %b)
print('o numero de cedulas de 5 é: %.d' %c)
print('o numero de cedulas de 2 é... |
7a6f1539e53e5e6c0feb9b3d86cc843bd67034fa | teoluna/thinkcspy | /10.3.py | 260 | 3.640625 | 4 | myList = [76, 92.3, 'hello', True, 4, 76]
myList.append('apple')
myList.append(76)
myList.insert(3, 'cat')
myList.insert(0, 99)
print(myList)
print(myList.index('hello'))
print(myList.count(76))
myList.remove(76)
myList.pop(myList.index(True))
print(myList) |
44030767ee985c4970a66cf7114284557cde1ae3 | Sewar-web/data-structures-and-algorithms1 | /multi-bracket-validation/multi_bracket_validation/multi_bracket_validation/multi_bracket_validation.py | 797 | 3.546875 | 4 | def multi_bracket_validation(strings):
open = tuple('({[')
close = tuple(')}]')
map = dict(zip(open, close))
# print(map)
arr_multi = []
for i in strings:
if i in open:
arr_multi.append(map[i])
elif i in close:
if not arr_multi or i != arr_multi.... |
0f8fdaa7e1175a1d03019a278ec6d90c1baa8d0e | shcqupc/hankPylib | /leetcode/tst2.py | 438 | 3.546875 | 4 | d1 = {'a': 2, 't': 1, 'c': 1, 'h': 1}
d2 = {'c': 1, 'a': 1, 't': 1}
# {'c': 1, 'a': 1, 't': 2, 'b': 1}
# {'c': 1, 'a': 2, 't': 3, 'b': 1, 'h': 1}
# {'c': 1, 'a': 2, 't': 4, 'b': 1, 'h': 1, 'r': 1, 'e': 2}
diff = d1.keys() & d2.keys()
print(type(diff))
print(set(d2))
# print(d1.keys() - d2.keys())
# print(d1.keys() - d2... |
85890466b2cad52d2271b3da8d2db6ccd6b33f16 | MonaGupta2301/Python-Basics | /function.py | 378 | 3.859375 | 4 | def percent(marks):
p=(sum(marks)/500)*100
return p
s1=int(input(" Enter The Marsks In Sub1 :"))
s2=int(input(" Enter The Marsks In Sub2 :"))
s3=int(input(" Enter The Marsks In Sub3 :"))
s4=int(input(" Enter The Marsks In Sub4 :"))
s5=int(input(" Enter The Marsks In Sub5 :"))
marks=[s1,s2,s3,s4,s5]
per1=percent... |
de4099dc0f313a04c53c6b4dd31053991ea3ae62 | joeandersen/CSSE7030 | /CSSE1001Answers/A_Point_Class_Definition.py | 674 | 3.78125 | 4 | import math
epsilon = 0.000001
class Point:
def __init__(self, x, y):
self._x = x
self._y = y
def dist_to_point(self,p):
x1 = self._x
y1 = self._y
x2 = p._x
y2 = p._y
distance = math.sqrt((x1-x2)**2 + (y1-y2)**2)
return distance
def is_near(... |
86cdf378df42bc89390df9e7e525d669d029700a | tcolley-cutco/python-training | /src/hello.py | 1,872 | 4 | 4 | import sys
def find_age(age_string):
age = ''
for char in age_string:
if char.isnumeric():
age = age + char
return age
def main():
print("Hello world!")
# Step 2
calculated_number = 11 * 2
# Step 3
float_number = 1.618
# Step 4
my_string = "My age is "... |
4da60bd6281a44c3ffb3d1782df8925ea6df33e0 | NiteshTyagi/leetcode | /solutions/1636. Sort Array by Increasing Frequency.py | 491 | 3.53125 | 4 | class Solution:
def frequencySort(self, nums: List[int]) -> List[int]:
d = dict()
result = []
for i in nums:
count = nums.count(i)
if count not in d:
d[count]=[i]
else:
d[count].append(i)
for key,value in sorted(d.it... |
52c796d20477c313c66b3f34bbacde558cb37190 | runemal-ops/automation_with_python | /wardrobe.py | 170 | 3.703125 | 4 | wardrobe = {"shirt":["red","blue","white"], "jeans":["blue","black"]}
for elements in wardrobe:
for color in wardrobe[elements]:
print("{} {}".format(color, elements)) |
081eeb7dc4b47649303d93b01ba451e28e3a9c6a | yo16/tips_python | /for/listに対するfor.py | 208 | 3.53125 | 4 | # -*- coding: utf-8 -*-
# listに対するfor
# 2017/3/21 (c) yo16
elements = ['aa','bb','cc']
# 0から始まるindexと値を同時に取れる
for i, elm in enumerate(elements):
print(str(i)+":"+elm)
|
6bab310ec4a460f382a37aa470ec391f8a6603ba | sandra-biology/python | /str_replace.py | 310 | 4.09375 | 4 | def str_replace(int_list, index):
if int_list[index] < 5:
int_list[index] = "small"
else:
int_list[index] = "large"
return int_list
int_list = [2, 7, 8]
index = 0
print("int_list before:", int_list, "index =", index)
str_replace(int_list, index)
print("int_list after:", int_list) |
a090cb678d02312a7886f3bdb8c4c5874f7710cf | wendful/hello-world | /my python/datetime1.py | 232 | 3.65625 | 4 | #datetime模块
#提供日期和时间的运算和表示,提供day,month,year属性
import datetime
print(datetime.date(2018,10,25))
dt = datetime.date(2018,10,25)
print(dt)
print(dt.day)
print(dt.month)
print(dt.year) |
4bdb8e51d6df3557433a64e8d0f5c14c35e52c57 | andreykutsenko/python-selenium-automation | /hw_alg_4/hw_alg_4_3.py | 356 | 3.6875 | 4 | def str_decompression(string):
new_string = ''
for i in range(len(string)):
if string[i].isdigit():
counter = int(string[i])
new_string = new_string + string[i-1] * counter
elif i == len(string)-1:
new_string = new_string + string[i]
return new_string
pri... |
39ce4efff1efe77cbcd9bf805ba11a6393fba2c2 | juegodynamics/interlang | /src/scripts/essentials/functions/functions.py | 109 | 3.78125 | 4 | def add(a, b):
return a+b
a = 2
b = 2
print(str(a) + " plus " + str(b) + " equals " + str(add(a, b)))
|
f462d9d0123cbf30fa398792afa983b528868573 | DIAfuad/classwork | /lesson5a.py | 241 | 3.8125 | 4 | #python loop
#==============
"""
Syntax of for loop
for variable in sequence:
Body of for
"""
for x in [7,33,5,22]:
print(x,end="\t")
for x in range(0,99):
print(x,end="\t")
print(x)
print(x,end=" ")
|
d657bd66774d3c72892452475363eef7c6fd1c87 | maximilian-drach/Image-Detection-Encryption- | /Team07_Project_1/key_generator.py | 3,062 | 3.609375 | 4 | """
===============================================================================
ENGR 13300 Fall 2021
Program Description
Creates user functions that handle generating encryption key and using the encryption key to encrypt or decrypt an image.
Assignment Information
Assignment: Group Project
Author... |
803f7a84200c731de59ff557d583fac3e247e684 | webdott/DSA-concepts-and-problem-solutions | /bubble_sort.py | 1,064 | 4.3125 | 4 | """
========================= BUBBLE SORT METHOD USING A COMPARISON ARRAY ================================
"""
def bubble_sort(input_array):
array_is_sorted = False
while not array_is_sorted:
comp_array = input_array[:]
for i in range(1, len(input_array)):
if input_array[i] < input... |
da40757d300c14cd015ce718cc27ec724fb7283c | TalatWaheed/100-days-code | /code/python/Day-45/Del.py | 264 | 3.875 | 4 | class Coordinate:
x = 10
y = -5
z = 0
point1 = Coordinate()
print('x = ',point1.x)
print('y = ',point1.y)
print('z = ',point1.z)
del Coordinate.z
print('--After deleting z attribute--')
print('x = ',point1.x)
print('y = ',point1.y)
print('z = ',point1.z)
|
d3ef147b9862e1379b58e2665b74c9a41d1edcea | saurabhsisodia/CodeforcesRound-550-DIV3 | /two_merged_sequence.py | 1,349 | 4.28125 | 4 | # Function to print strictly Increasing and
# Strictly Decreasing sequence if possible
def Find_Sequence(array,n):
# Arrays to store strictly Increasing and
# Decreasing sequence
inc_arr,dec_arr=[],[]
# Initializing last element of both sequence
inc, dec = -1, 1e7
# Iterating through the array
fo... |
85321e72b17598f9a55939125106f600103a52da | DiegoMaraujo/100-exerc-cios-em-Python- | /100Exercicios em Python/ex94.py | 1,106 | 3.546875 | 4 | galera = list()
pessoa = dict()
soma = media = 0
while True:
pessoa.clear()
pessoa['nome'] = str(input('Nome: '))
while True:
pessoa['sexo'] = str(input('Sexo F/M ')).upper()[0]
if pessoa['sexo'] in 'FM':
break
print('Erro ! por favor digite M ou F ')
pesso... |
6237c31bde891e2db79cf89854b552928c6c3db8 | fernaper/cv2-tools | /cv2_tools/Selection.py | 14,877 | 3.828125 | 4 | # MIT License
# Copyright (c) 2019 Fernando Perez
import cv2
from cv2_tools.Utils import *
class SelectorCV2():
""" SelectorCV2 helps to select information in frames.
This is the original idea of the library, being capable to select multiple
zones with enough intelligence to decide how to show as much i... |
fe083f376777d4bfdf2d44f02cac9cd46fbd0605 | jstremme/clustering | /2D_clustering.py | 1,021 | 3.890625 | 4 | import numpy as np
from scipy import cluster
from matplotlib import pyplot
def plot_variance_explained(initial):
pyplot.plot([var for (cent,var) in initial])
pyplot.xlabel('Num Clusters K', fontsize=14)
pyplot.ylabel('Unexplained Variance', fontsize=14)
pyplot.title('Variance as a function of Clusters K')
pyplot... |
e00c0c1e10d7e26a3e689867b26ad981f09e7593 | rzats/python-assignments | /src/04_2d_arrays.py | 656 | 4.3125 | 4 | matrix = [[1, 2, 3, 4],
[5, 6, 7, 8],
[9, 10, 11, 12],
[13, 14, 15, 16]]
print (matrix)
# Find the smallest element of each row and column in a matrix (i.e. 2d array / list of lists).
min_rows = [min(row) for row in matrix]
print (min_rows)
min_cols = [min(col) for col in zip(*matrix)]
p... |
33c54cb8a64a9867300c8b2d7f94ef8593f66310 | ecstasyquail/p4e | /elevatorfloor.py | 736 | 4.21875 | 4 | # What floor are you on in the United States vs the rest of the world?
# gets user input
floornum = input("What floor number are you on? ")
# FINDS OUT WHERE USER IS AT
while True:
country = input("Are you in the United States? Y/N ")
if country == 'Y' or country == 'N':
break
else:
print(... |
6f9c0d622227e7499a6043b1660bf9a2cfcd64f0 | swheatley/python-crash-course | /lists.py | 874 | 4.15625 | 4 | #3.1 Names
friends_list = ['Sophia', 'Elizabeth', 'Sean', 'Sarah', 'Alex']
print(friends_list[0])
print(friends_list[1])
print(friends_list[2])
print(friends_list[3])
print(friends_list[-1])
#
#
# 3.2 Greetings
print(friends_list[0] + " " + "you are my Russian friend")
print(friends_list[1] + " " + "you are my coding b... |
43afd21fa0d9c4e0849d7e1f1c104751a9c7fc5c | SumitVashist/100patterns | /52.py | 330 | 3.765625 | 4 | """
Enter a number:5
I I I I I I I I I
G G G G G G G
E E E E E
C C C
A
"""
num=int(input("Enter a number:"))
for i in range(1,num+1):
print(" "*(i-1),end="")
for j in range(0,num+1-i):
print(chr(64+2*num+1-2*i),end=" ")
for k in range(1,num+1-i):
print(chr(64+2*num+1-2*i),end=" ")
... |
a853e865e637f748ae07ca1e524d62efc7bf93e8 | jyseo628/w200 | /W200_Week6/score_word.py | 94 | 3.640625 | 4 | x = input("Enter letters: ")
score = 0
for char in x:
score += scores[char]
print(score)
|
5630a1f755bcb97d80903c68d63d85f599297cb6 | git-mih/Learning | /python/04_OOP/descriptor/08property_and_descriptors.py | 7,747 | 4.15625 | 4 | # Properties and decorators
from numbers import Integral
# __________________________________________________________________________________________________
# property object: using decorator syntax:
class Person:
@property
def age(self):
return getattr(self, '_age')
@age.setter
def age(self... |
d61c923be247454e02e67f60bf6cf8532cad8066 | Akash006/Apy_snipets | /flush_magic.py | 477 | 3.90625 | 4 | import sys
import time
print(f'{"="*10} Output without Flush {"="*10}')
# It will take 10 sec to print the output as print
# takes the data into buffer and then when the buffer gets
# full it prints the data.
for i in range(10):
print(i, end=' ')
time.sleep(1)
print("\n")
print(f'{"="*10} Output with Flush ... |
ed5a0f28015fd05509ab3ee880af3b6a05b613af | jenihuang/Coding_problems | /Codewars/scramblies_extra.py | 574 | 3.859375 | 4 | def scramble(str1, str2):
''' returns True if str2 can be created using letters in str1, else False'''
#9267 ms failed 7
if len(str1) < len(str2):
return False
s1 = set(str1)
s2 = set(str2)
extra = list(s1.difference(s2))
missing = list(s2.difference(s1))
if missing:
... |
7ed9a8130fc661c4d705a38768dae942fbfd10a6 | wxnacy/study | /python/leetcode/2-add-two-numbers.py | 3,615 | 4.1875 | 4 | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: wxnacy(wxnacy@gmail.com)
# Description: 两数相加
'''
难度:中等
知识点:链表、数学
地址: [https://leetcode-cn.com/problems/add-two-numbers/](https://leetcode-cn.com/problems/add-two-numbers/)
```
给出两个 非空 的链表用来表示两个非负的整数。其中,它们各自的位数是按照 逆序 的方式存储的,并且它们的每个节点只能存储 一位 数字。
如果,我们将这两个数相加起来,则... |
b61ce9a92ad6748c155fa88ac69be5c7a4f47d18 | lennox-davidlevy/python_works | /user_input_and_while_loops/multiple_of_ten.py | 676 | 4.3125 | 4 | def is_multiple_of_ten(n):
return n % 10 == 0
def is_a_number(n):
return n.isnumeric()
prompt = "Please enter a number that is a multiple of ten: "
number_provided = input(prompt)
while (
is_a_number(number_provided) is not True
or is_multiple_of_ten(int(number_provided)) is not True
):
if is_... |
ffa10595ea557ece1fd7d9b9045d954bf5c5f99c | rustamovilyos/python_lessons | /py_lessons_for_github/dars_7/Vazifa-3.py | 471 | 3.984375 | 4 | # 3 Kiritilgan raqamni kvadratini ekranga chiqarish dasturini tuzing. Dastur to'xtovsiz ishlashi kerak.
# Har safar yangi raqam kiritilganda uni kvadranini ekranga chiqarsin
n = int(input('Raqamni kvadratini xisoblash uchun istalgan raqam kiriting: '))
# print(pow(n,2))
print(n**2)
while n != 0:
x = int(input('Na... |
7e1de796501f9bb9e647529881e91b38a02bd694 | sohammehta96/Leetcode | /Sort in a Wave.py | 1,033 | 4.59375 | 5 | """
Sort an array in wave form
Difficulty Level: Medium
• Last Updated : 18 May, 2021
Given an unsorted array of integers, sort the array into a wave like array. An array'arr[0..n-1]' is
sorted in wave form if arr[0] >= arr[1] <= arr[2] >= arr[3] <= arr[4] >=
"""
def quicksort(seq):
if len(seq) <= 1:
... |
2b5eaa34b17cfaf19b8bfc569cec1b42411cff27 | Oscar-Oliveira/Python-3 | /18_Exercises/A_Exercises/Solutions/Ex10.py | 315 | 4.09375 | 4 | """
Exercise 10
"""
import sys
def print_file(filename):
with open(filename, "r") as file:
print(file.read())
try:
filename = input("File: ")
print_file(filename)
except FileNotFoundError:
print("The file does not exist!!")
except:
print("ERROR:", sys.exc_info()[0])
|
9a52418b2e355103a61c87eea9e3e799511f2120 | aliattar83/python | /Code/Chapter 5/Algorithm Workbench/question7.py | 130 | 3.515625 | 4 | # Algorithm Workbench
# Question 7
def main():
for r in range(10):
for c in range(15):
print('#', end='')
print()
main()
|
335c7b7793fe44f9cbf52e2402064114d3bf045a | fwparkercode/IntroProgrammingNotes | /Notes/Fall2019/Ch7C.py | 3,912 | 4.1875 | 4 | # Chapter 7 - Lists (Arrays)
for i in range(10):
my_list.append(i)
# Data Types
import random
my_int = 3478 # counting numbers (pos and neg)
my_float = 4.9843 # decimal numbers
my_string = "Hello" # text
my_bool = False # True or False only
my_list = [11, 12, 13, "Hi", False]
my_tuple = (11, 12, 13)
# W... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.