blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
f0306870c55e02ef5c53a351afd6a30217acf968
samyuktahegde/Python
/datastructures/arrays/insert_element.py
314
4.21875
4
def insert(arr, element): arr.append(element) # declaring array and key to insert arr = [12, 16, 20, 40, 50, 70] key = 26 # array before inserting an element print ("Before Inserting: ") print (arr) # array after Inserting element insert(arr, key) print("After Inserting: ") print (arr)
3b78a1d564b7a0f21e46beb612a613a1738a2e02
EwaGrela/ewagrela.github.io
/little_snakes/count_vowels.py
1,249
3.953125
4
def counter(n): count = 0; vowels = [] for i in "aeiou": for l in n.lower(): if l==i: count +=1 return count; print("counting vowels in a string") to_count = "Adam Moceri" print(counter(to_count)) print("counting vowels in an input:") inp = input("Enter Text and count vowels: ") print(counte...
b88a2c42c30e2fb453e01cd9fb6b392d043ab3fc
laoshu198838/Data_Structure_and_Algrithm
/02_single_cycle_link.py
4,040
3.703125
4
# coding:utf-8 class Node(object): """节点""" def __init__(self, elem): self.elem = elem self.next = None class SingleLinkcircleList(object): """单链表""" def __init__(self, node=None): self.__head = node def is_empty(self): """链表是否为空""" return...
aec065cbf8fc1797f1bda9d5f06f10dbad291f54
18684092/AdvProg
/ProjectEuler/General-first-80-problems/problem63.py
744
3.59375
4
############### # Problem 63 # ############### """ The 5-digit number, 16807=75, is also a fifth power. Similarly, the 9-digit number, 134217728=89, is a ninth power. How many n-digit positive integers exist which are also an nth power? """ # So the easy answer is the sum over i from 2 to 9 of (int)(i/log...
ae6154d4c17695d2591912af57e2192234408ae6
chaitanya-j/python-learning
/Basics/Programs on loops/loop_missle.py
497
3.90625
4
# MISSILE DETECTION PROGRAM # import time no = int(input("How many times do i scan this area?:")) for z in range(no): print("SCANNING THE AREA.....") time.sleep(2) Detected = input("detcted or not?? yes/no:") if Detected == "yes": print("MISSILE DETECTED LAUNCHING ANTI-MISSILE BRAMHOS*****") print(3...
8f66b30156f73428d8d83b09b757ce17d179203a
gem5/gem5
/ext/ply/example/unicalc/calc.py
2,532
3.796875
4
# ----------------------------------------------------------------------------- # calc.py # # A simple calculator with variables. This is from O'Reilly's # "Lex and Yacc", p. 63. # # This example uses unicode strings for tokens, docstrings, and input. # ----------------------------------------------------------------...
871a5dcff233df3467270c90ba4bc695910ed4bb
hanlsin/udacity_DLNF
/Part2.NeuralNetworks/L9.TensorFlow/classify_nn_train.py
3,570
3.59375
4
import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets('.', one_hot=True, reshape=False) import numpy as np train_imgs = mnist.train.images print(train_imgs.shape) print(train_imgs[0].shape) import matplotlib.pyplot as plt img = (train_imgs[0] * 255).astyp...
1f521d8e9bcf0348778a656f012d9278406d2ada
oopxiajun/python
/base_grammar/isinstance_type.py
672
3.78125
4
''' Created on 2019年11月19日 @author: Administrator ''' num=1.1 print(isinstance(num, int)) #False print(isinstance(num, float)) #True print(isinstance(num, bool)) #False print(isinstance(num, complex)) #False num=2 print(isinstance(num, int)) #True a=1 b=2.2 d=2 c=a+b print (c) c=a/d...
7cda4fd0f2538a12b0c626a529ad25b0a7d6754e
shivamkaushik12007/practice
/leetCode/sumNumbersRootToLeaf.py
594
3.625
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: sum=0 def sumNumbers(self, root: TreeNode) -> int: self.checkNode(root,0) return self.su...
18908a97fdd16d6a2c5f72e3360298966c8ea5a7
snarkfog/python_learning
/lesson_7/slicing.py
281
3.953125
4
my_list = [5, 7, 9, 1, 1, 2] sub_list = my_list[:3] print(sub_list) print(my_list[2:-2]) print(my_list[4:5]) sub_list = my_list[:-1:2] print(sub_list) print(my_list[2:-2:2]) print(my_list[::-1]) print(my_list[2:]) print(my_list[2::2]) print(my_list[:-2]) print(my_list[::-2])
c48f6d7e74211baf2d1ee9a1146e3d32a233bd3e
sarthak815/MyCAP_AI
/Dictionary_deletion.py
313
4.0625
4
a = {"India":"Delhi", "France":"Paris", "United Kingdom":"London", "USA":"Washington DC"} print(a) c = "y" while c == "y": b = input("Enter country to be deleted: ") del a[b] c = input("Would you like to delete another element(y/n):") print(f"The updated dictionary is\n{a}")
71e3187b7fc1b9c263909175606b62d51d9f1f00
afelfgie/GameAndAnimation
/robot.py
3,938
3.796875
4
#! /usr/bin/python #Author : GunadiCBR & afel #Date : 30-09-2018 #Team : Mls18hckr #Github : https://github.com/afelfgie import curses from curses import KEY_RIGHT, KEY_LEFT, KEY_UP, KEY_DOWN import random from random import randrange, randint def printRobot(win, pos_x, pos_y, size): ''' Prints the Robot '''...
1bc67de90ce462d8fcfd9e8e56db985e2faa8ca3
BiggerDragon/machine-learn-demo
/bin/numpy/day02/demo04.py
369
3.71875
4
import numpy as np a = np.array([10,11,12,13,14,15,16,17]) b = a.reshape((2,2,2)) print(b) # 将轴2放在轴0前,其他轴相对位置不变 print(np.rollaxis(b, 2)) # 将轴2滚动到轴1,轴1移动到轴2原来的位置 print('\n') print(np.rollaxis(b,2,1)) # 交换数组的两个轴 a = np.arange(8).reshape(2,2,2) print(a) print(np.swapaxes(a, 2, 0))
b7a6531291bf456203e42b548d447ead7138b175
DhruvSrivastava-16/LinkedList-Practise
/sublist_reverse.py
1,124
4.03125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Jun 4 19:02:35 2021 @author: dhruv """ class listnode: def __init__(self,val = 0,next = None): self.val = val; self.next = next def reverse_sublist(List1_n1,s,f): print("Yo!") dummy_head = List1_n1 subli...
778899c766bfecf7b452001de40ec9c3fa9eea1c
150801116/python_100
/python_100/实例024:斐波那契数列II.py
306
3.84375
4
#题目 有一分数序列:2/1,3/2,5/3,8/5,13/8,21/13…求出这个数列的前20项之和。 molecule = 2 #分子 denominator = 1 #分母 sum = 0 #总和 for i in range(20): sum += molecule/denominator molecule,denominator = (molecule+denominator),molecule print("前20项和:",sum)
d517350eda72ada085900a28c1366f9dad1e5374
sanshitsharma/pySamples
/binary_search.py
653
3.875
4
#!/usr/bin/python class BinarySearch: def __binary_search(self, a, elem, l, r): if l > r: return -1 mid = (l+r)/2 if elem == a[mid]: return mid elif elem < a[mid]: return self.__binary_search(a, elem, l, mid-1) else: return se...
cd3a0cbd5117b4ae3c1b5ba208c1a977142271a7
wadoodalam/RiverCrossingPuzzles
/oldsrc/animation.py
429
3.5
4
''' Created on Oct 30, 2019 @author: sauga, wadood, and mashfik ''' class Animation: def moveBoat(self, x1, y1, x2, y2): pass def updateImage(self, charID, imageID): #Update characters pass def moveChar(self, x, y): #Taking previous x and y coor...
54427e6c259cad594b074b2738b8364e4726cecc
Chinna2002/Python-Lab
/L13-Binary Tree with Single Node.py
322
3.734375
4
print("121910313006","Kadiyala Rohit Bharadwaj") class Node: def __init__(self, data): self.left = None self.right = None self.data = data def print(self): print(self.data) n=int(input("Enter a value to add a node to Binary Tree:")) r = Node(n) print("Nodes in Binary Tr...
f24b8a204d70c2c4d1d41337b49ad9957c599d3b
josecervan/Python-Developer-EOI
/module2/bot_window/center.py
1,081
3.796875
4
from graphics import * from random import randint import sys def main(width, height, n_points): win = GraphWin("Exercise-02, Points", width, height) win.setBackground(color_rgb(0, 0, 0)) x1 = int(width / 4) x2 = int(3 * width / 4) y1 = int(height / 4) y2 = int(3 * height / 4) for i in r...
81160702cb9236bbb727761b1d94050284dde95e
denizgurzihin/PythonBasic
/main.py
5,467
4
4
import math ######################################################################################################################## # first question print(" Question 1:") array_1A = [67, 'ankara', 'istanbul', 20, 'izmir'] array_1B = ['izmir', 20, 'istanbul', 'ankara', 67] print("First array is " + str(array_1A...
87fd46bf4e9acd79d5070eaf2456e2f6da7b23a7
simona-boop/esposito
/stringa 2.py
298
3.671875
4
s=str(input("Inserisci una stringa: ")) ripetizioni=0 for i in range(0, len(s)): r=l x=s[i] for j in range(i+l, len(s)): if s[i] == s[j]: r = r + l if r > ripetizioni: carattere = x ripetizioni = r print(carattere) print(ripetizioni)
95f18fdecc5f9ff7b2130b52d7c269070f3cec9e
annarob/testing
/christopher's programming/rgn.py
2,311
3.515625
4
from tkinter import * import random import time tk = Tk() canvas = Canvas(tk, width=500, height=500) canvas.pack() def random_rectangle(width, height, fill_color): x1 = random.randrange(width) y1 = random.randrange(height) x2 = x1 + random.randrange(width) y2 = y1 + random.randrange(height) canvas.c...
b0bbf1ed0a3f9685a54be79df1db4c71929172eb
BTJEducation/ReadMyTimeTable
/6a Read My Timetable.py
314
3.625
4
#Read My Timetable #---------------------------------------- def readfile(day): filename=day+".txt" channel = open(filename,"r+") lesson=channel.readlines() channel.close() return lesson #---------------------------------------- day=input("Day of week") lesson=readfile(day) print(lesson)
d488a41ac89710f52ac27d260ff5838e88e7e033
PedroMarco/Day8
/TryingAppend.py
187
3.671875
4
__author__ = 'acpb859' list = [0,1,2,3,4] list2 = [] for x in list: list2.append(x * 0.5) print(list2) list3 = [] for x in list2: if x <1.5: list3.append(x) print(list3)
1a0b8206c49a2a63b55416cd093a709f89d7db86
heitorchang/learn-code
/checkio/scientific_expedition/completely_empty.py
1,298
3.609375
4
def completely_empty_visit(val, visited): # look for infinite loop : c = []; c.append(c) id_val = id(val) if id_val in visited: return False try: val = list(val) if isinstance(val, dict) and len(val) == 1: if list(val.keys())[0] != '': return False ...
cdd1800eb863639ad824ca90cfe285dd4f3ffba8
mrazzakov/advent-of-code-2020
/day14/day14-1.py
4,391
4.125
4
# --- Day 14: Docking Data --- # As your ferry approaches the sea port, the captain asks for your help again. The computer system that runs this port isn't compatible with the docking program on the ferry, so the docking parameters aren't being correctly initialized in the docking program's memory. # After a brief ins...
9dce3385021c8538dbd60c2f9be299931a0a8328
MaryaMohsen/pdsnd_github
/bikeshare_2.py
10,355
4.53125
5
#Import required packages import time import pandas as pd import numpy as np #dictionary of cities corresponding to their data files CITY_DATA = { 'chicago': 'chicago.csv', 'new york city': 'new_york_city.csv', 'washington': 'washington.csv' } months = {'january': 1, 'february': 2, 'march':...
507ffaef91cfc749e830b0feae13c24820111b06
szbrooks2017/holbertonschool-higher_level_programming
/0x0C-python-almost_a_circle/tests/test_models/test_square.py
3,883
3.515625
4
#!/usr/bin/python3 """ tests for the base class""" import os import io import unittest import unittest.mock from models import square from models.base import Base Square = square.Square class TestSquare(unittest.TestCase): """ tests for Square""" def test_save_to_file(self): filename = "Square.json...
f6ee7453e6fd4e465f6517f4ac7320ee31f41be6
elhamsyahrianputra/Pemrograman-Terstruktur
/Chapter 06/Chapter06_Latihan No.2_c.py
240
3.578125
4
def starFormation1(n): for star in range(1, n+1): print(star * "*") def starFormation2(n): for star in range (1, n+1): print((n+1-star) * "*") def starFormation3(n): starFormation1(n//2) starFormation2(n-(n//2)) starFormation3(7)
8eefd641993ca7aa18e9ffac1e63c67b85b8cbca
ausaki/data_structures_and_algorithms
/leetcode/generate-random-point-in-a-circle/286376927.py
812
3.859375
4
# title: generate-random-point-in-a-circle # detail: https://leetcode.com/submissions/detail/286376927/ # datetime: Mon Dec 16 21:00:13 2019 # runtime: 144 ms # memory: 23.1 MB import math import random class Solution: def __init__(self, radius: float, x_center: float, y_center: float): self.radius = radi...
04d25d91f20151bd515fad46d84b7eb7b8020bcf
Ankitmahida/Catenation
/task1.py
761
3.765625
4
# Exercise 1 a=10,;b=10.20;c='Ankit' # Exercise 2 a=complex(2,4) print(type(a)) b=15 a=b print(type(a)) #Exercise 3 a=10,b=90 Result=a a=b y=Result Print(a) Print(b) # Exercise 4 #python version 2 x=raw_input("Enter the value") print x #python version3x input1=eval(input("Enter the value")) ...
57b9602123431800b4d2bba0507716b360ddb475
edson-gonzales/SICARIOS
/src/admin_module/user_module/customer.py
2,556
3.59375
4
#customer.py __author__ = 'Roy Ortiz' from admin_module.user_module.person import Person from db.transactions.DBManager import DBManager class Customer(Person): """ Creation of an instance of customer """ def __init__(self, first_name, last_name, birth_date, address, phone, email, membership...
ca004a03ffb30d75cff01a4b323631d2db67b52a
kiranrraj/100Days_Of_Coding
/Day_48/sphere.py
1,091
4.5625
5
# Title : Sphere Calculations # Author : Kiran Raj R. # Date : 1/12/2020 PI = 3.14 print("Enter 's' to calculate volume of Sphere") print("Enter 'c' to calculate volume of Cylinder") choice = input().lower() if choice == 's' : radius = float(input('Enter the Radius of a Sphere: ')) s_area = 4 * PI * rad...
69322814507de3a13d61f3d87ebb16ac0c822362
cn5036518/xq_py
/python16/day1-21/day009 函数入门/02作业题/练习3.py
543
4.09375
4
#!/usr/bin/env python #-*- coding:utf-8 -*- ''' 3,写函数,判断用户传入的对象(字符串、列表、元组)长度是否大于5。 ''' def greater5(arg): #arg或者obj作为形参的名字 if len(arg) >5: print('实参的长度大于5') return True # return len(arg) >5 #也可以 else: print('实参的长度小于等于5') return False s1 = 'jack' greater5(s1) #实参的长度小...
6f3d23dc4cff15137b3d8fd9907f31893c6f2394
vfedoroff/interview-python
/simple-elevator/solution.py
19,320
3.796875
4
UP = 1 DOWN = 2 FLOOR_COUNT = 6 import time class Elevator(object): def __init__(self, logic_delegate, starting_floor=1): self._current_floor = starting_floor self._history = [starting_floor] print ("%s..." % starting_floor) self._motor_direction = None self._logic_delegate...
cbbf8a818af7b40a6219fe7c451f626bcb45b086
aluisq/Python
/estrutura_repeticao/ex7.py
143
3.953125
4
x = 1 soma = 0 while x <= 10: y = abs(float(input("Digite um número: "))) soma += y # soma = soma + y x += 1 print((soma / 10))
eba6e4ee462843c48e13fd910eebe845144245ef
p02e909/web_mk
/exercises/ex7_6.py
1,495
3.59375
4
#!/usr/bin/env python3 import random # NOQA import string # NOQA def your_function(length=16): '''Tạo một mật khẩu ngẫu nhiên (random password), mật khẩu này bắt buộc phải chứa ít nhất 1 chữ thường, 1 chữ hoa, 1 số, 1 ký tự punctuation (string.punctuation). ''' # Xoá dòng sau và viết code vào đ...
e31b2677f51d1174fff2c6e099483a0cf7b92c7f
Tarun17NE404/python-programs
/Factorial.py
131
4.09375
4
n = int(input("Enter the number")) output = 1 for i in range(n,0,-1): output = output*i print("Factorial of", n , "is", output)
64bad160d45e1f011a2a8da15f8bce64c5d330ac
snejy/Programming101
/week0/prime_factorization/solution.py
557
3.703125
4
def prime_factorization(n): if is_prime(n): return [(n,1)] else: result=[] for i in divisors(n): k = 0 while n % i == 0: k=k+1 if is_prime(n): result.append((n,k)) return result ...
fdef3ac657a9faa183d2defbbe1ccc88fdafaa0b
Srinjana/CC_practice
/MATH PROB/evnnum.py
525
3.921875
4
# a string has a mixture of letter, integer and special char. from here find the largest even number combination possible from the available digits after removing duplicates. If no even number, return -1. # Author @Srinjana import itertools s = input() s_unique = set() x = -1 for i in s: if i.isdigit(): s...
6b4a26baa7373f82e160778bd390b5e2d292df6d
mjoze/kurs_python
/codewars/Format_a_string_of_names.py
1,166
4.09375
4
"""Given: an array containing hashes of names Return: a string formatted as a list of names separated by commas except for the last two names, which should be separated by an ampersand. Example: namelist([ {'name': 'Bart'}, {'name': 'Lisa'}, {'name': 'Maggie'} ]) # returns 'Bart, Lisa & Maggie' namelist([ {'name': 'Bar...
7f30fd1a8f458aa067417f6a616c450242e7fcf6
LEEHyokyun/Sparta_algorithm
/week1/01_00_find_alphabet.py
368
3.953125
4
print("a".isalpha()) # 지정변수가 문자인지 확인 array = "Hello world" # 문자열의 해당 자리의 문자가 문자인지 확인 print(array[2].isalpha()) print(array[5].isalpha()) alphabet_occurence_array = [0]*26 # 해당 배열에는 원소 0이 26개로 배열되어 저장됨 ord("a") print(ord('a')) #97, 아스키코드 print(ord('a')-ord('c'))
d9d2abb6f21855a3ec27cd285bf4f8325cbfa077
TianyuDu/csc148
/lecture/mar192018_0101.py
505
3.875
4
# March 19 2018, Lecture 0101 def fib(n: int) -> int: """ Return nth fibonacci number >>> fib(0) 0 >>> fib(1) 1 >>> fib(3) 2 """ if n < 2: return n else: return fib(n - 2) + fib(n - 1) def fib_mem(n: int, seen: dict) -> int: """ return nth fibonacci nu...
334920f67ac6cafe8e47cfcff0d6859d4307c05f
NAKSEC/finance_book
/fin_scrapy/maya/string_utils.py
625
3.515625
4
import re def is_year_by_regex(string): regex_pattern = "(19|20)\d{2}" result = re.match(regex_pattern, string) return result def remove_empty_key_value_from_dictionary(dictionary_of_strings): new_dictionary = {} regex = re.compile(r'[\(*\)\n\r\t]') for elem in list(dictionary_of_strings.keys(...
56322c3258e0bbb6c2596fb776e4e9a756bf33ab
DimaDanilov/algoritm-programming
/1 Sort/heapsort.py
1,361
3.734375
4
import time arr_num = 1000 # Выбор файла filename = "generatedfiles/" + str(arr_num) + ".txt" # Считывание массива из файла file = open(filename, "r") arr = (file.read()).split(' ') # Считывание строки и разбиение её на массив for i in range(len(arr)): arr[i] = int(arr[i]) # Перевод массива строк в массив чисел ...
c0f99b18aa87f30ed6a90473bfbeb00b9e787ab4
zgle-fork/OpenCV-Python-Tutorial
/ch09-图像的基础操作/9.itemset.py
348
3.515625
4
# -*- coding: utf-8 -*- import cv2 import numpy as np img = cv2.imread('../data/messi5.jpg') # px = img[100, 100] print(px) blue = img[100, 100, 0] print(blue) # img[100, 100] = [255, 255, 255] print(img[100, 100]) # 获取像素值及修改的更好方法。 print(img.item(10, 10, 2)) img.itemset((10, 10, 2), 100) print(img.item(10, 10, 2))
e7ba3fd84f12e426cb6324261cc6fdf5acac7096
fander2468/pythoncrashcourseproblems
/chapter7/pizza_toppings.py
219
4.1875
4
pizza_toppings = '' while pizza_toppings != 'quit': pizza_toppings = input("Enter a pizza topping, enter 'quit' to quit ") if pizza_toppings == 'quit': continue print('I add ' + pizza_toppings)
818f452713e6fce3908f59df610f6a9e4dd073b9
mo2274/CS50
/pset7/houses/import.py
1,508
4.375
4
from sys import argv, exit import cs50 import csv # check if the number of arguments is correct if len(argv) != 2: print("wrong argument number") exit(1) # create database db = cs50.SQL("sqlite:///students.db") # open the input file with open(argv[1], "r") as characters: # Create Reader reader_csv ...
520454f7fc3fe0c05bdc0ee882dffb2c9d35566c
hussamh10/EvolutionaryScheduler
/xmlconverterforunitime.py
6,811
3.5625
4
import csv import xlrd import datetime def csv_from_excel(myfile,mysheet='Sheet1'): wb = xlrd.open_workbook(myfile) sh = wb.sheet_by_name(mysheet) outputfilename = "readable" + myfile + ".csv" your_csv_file = open(outputfilename, 'wb') wr = csv.writer(your_csv_file, quoting=csv.QUOTE_ALL) ...
b736d580b41f3d193b0bf835e9b58c89a39e18a2
Aasthaengg/IBMdataset
/Python_codes/p02546/s638739854.py
82
3.6875
4
i=str(input()) leng=len(i) if i[leng-1]=="s": print(i+"es") else: print(i+"s")
a6f31a90b1315fc24e851c6c1205d8423f5a78ee
whoyoung388/algos
/maximum-depth-of-binary-tree.py
963
3.75
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None // BFS import collections class Solution: def maxDepth(self, root: TreeNode) -> int: if not root: return 0 depth = 0 ...
9fbf739bb9e4b000d8f4676814dfd94476838c1d
tpagliocco/Python-Examples
/30 Day Python Challenge/Binary_Conversion.py
481
3.59375
4
#!/bin/python3 #Given a base-10integer, N , convert it to binary (base-2). Then find and print the base-10 integer #denoting the maximum number of consecutive 1's in N's binary representation. import sys n = int(input().strip()) count= 0 maxcount = 0 for i in str(bin(n)): if i == '1': count +=1 eli...
f2a115dd0f07e65f09469d754b718eb8e62db217
ANKquil/PracticeDV
/task139.py
1,070
4.28125
4
# Написать функцию special_number(number), которая определяет является ли число особенным. # Назовем число особенным, если сумма цифр числа, возведенных в степень, равную позиции цифры, равна самому числу. # # Примеры: # special_number(89) => True -> 8^1 + 9^2 = 8 + 81 = 89 import traceback def special_numb...
19e845cc29dd965df8b40ac3d7b4f67abfc825ca
viii1/Pong
/pong.py
3,340
3.890625
4
import turtle # Small "T" cause its a modular name #For windows wn = turtle.Screen() # Here the origin is at the center of the screen unlike pygame or openCV wn.title("PONG") wn.bgcolor("black") wn.setup(width=800,height=600) """ stop the windows from updating we have to update it manually And it helps in speeding...
0fa9e6ec57f9db3b9eaa7d583e974517833d594e
wimbuhTri/Kelas-Python_TRE-2021
/P4/0.py
223
3.875
4
x=float(input("Masukkan nilai X= ")) y=float(input("Masukkan nilai Y= ")) p = x + y q1 = x * y q2 = x / y print("Hasil dari P=",p) if p >= 0: print('maka Q=x*y adalah =',q1) else: print('maka Q=x/y adalah =',q2)
d0a27452e39ff7a24e6032c72dbba6688b050c1d
Bambur31/python
/Homework_8_task_7.py
469
4
4
class ComplexNum: def __init__(self, num): self.num = complex(num[0], num[1]) def __add__(self, other): return self.num + other.num def __mul__(self, other): return self.num * other.num x = [1, 2] y = [2, 3] num_1 = ComplexNum(x) num_2 = ComplexNum(y) print(f"Сум...
1a5d42c87178a51d0ca470b491694d78fb6e73d1
drestion/leetcode
/python/MergeTwoSortedLists.py
855
3.890625
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def mergeTwoLists(self, l1: ListNode, l2: ListNode) -> ListNode: # two pointer h, pl1, pl2 = ListNode(), l1, l2 oh = h ...
86bc17fe69ce36a28ae4c03979a84f548665dde3
Scrapey-Doo/Scraper
/server.py
7,364
3.59375
4
# CSCI 3800 Final Project # Group: ScrapeyDo # Group leader: Yuzhe Lu # Group members: Yuzhe Lu, David Oligney, Prinn Prinyanut, Eric Slick, Patrick Tate # first run server.py, then run client.py to connect as many different clients to the Server as you want from socket import socket, AF_INET, SOCK_STREAM # because w...
2b71e43c5b3aee49d4388e192ed5ed57054ce839
diogoandrade1999/FP-1ano
/aula04/exercicio1.py
442
4.125
4
num = float( input("Escreva o número zero: ") ) soma = 0 media = 0 elementos = 0 maximo = num minimo = num while num != 0: soma = soma + num elementos = elementos + 1 media = soma / elementos if maximo < num: maximo = num if minimo > num: minimo = num num = float( input("Escreva o número zero: ") ...
58e4d65f849dd72b7ffca2091d3ea01498c05c02
GarvenYu/Algorithm-DataStructure
/58数组中只出现一次的两个数字/findnumsappearonce.py
1,522
3.921875
4
# !usr/bin/env python # -*-coding:utf-8-*- """ 一个整型数组里除2个数字外,其他数字都出现了2次。请找出这2个只出现1次的数字。 要求:时间复杂度O(n),空间复杂度O(1)。 示例:数组{2,4,3,6,3,2,5,5},输出4和6。 思路: 1.相同数字进行异或结果为0; 2.从头到尾异或数组中每个数字,得到的结果是数组中只出现1次的两个数字的异或结果,在结果数字中 找到第一个为1的位置,记为第n位。以第n位是否为1将数组分成两部分,这样两个子数组中第n位分别为0和1, 而且每个子数组都包含一个只出现一次的数字,再进行异或输出最后结果。 """ def array_xor(ar...
fd65a27a4d5de44a223e7366cfed999c098c859a
joansekamana/FunMooc
/UpyLab_4_10.py
1,005
3.5
4
import random def bat(joueur_1, joueur_2): PIERRE = 0 FEUILLE = 1 CISEAUX = 2 if (joueur_1 == PIERRE and joueur_2 == CISEAUX) or (joueur_1 == CISEAUX and joueur_2 == FEUILLE) or ( joueur_1 == FEUILLE and joueur_2 == PIERRE): return True else: return False def main()...
f8e2f1b3f4f987f10a35bddf18318290405f8cf1
mustafaha1/python-work
/save the princess.py
3,975
4
4
# import time # used for short delay # from random import randrange # used for random number generator # print(' _____ _ _ _ _ ') # print(' / ____| | | | | (_) | |') # print(' | (___ __ __...
7283fe0c25af12327b5ccda0316f8c12a8a13506
AG-droid/Python-Projects
/unit_conv.py
13,357
4.28125
4
print('WELCOME TO THE UNIT CONVERTER') print('') print('') y = input("What do you want to measure ? :") a = input('What do you want to convert from (Full forms only) -->') b = input('What do you want to convert to -->') c = float(input('pls enter the value that you want to convert -->')) def weight(): if a == ...
745ab76c07b89b02ad45b15dee1f563d4aeeaa98
bibiksh/Python_trainging
/2.Python_basic/Chapter01/Problem01.py
212
4.1875
4
Numslist=[] num=int(input("input your number : ")) for i in range(0,num): element=int(input("input number : ")) Numslist.append(element) avg=sum(Numslist)/num F=round(avg,2) print(avg) print(f'avg = {F}')
ae569f759f0ac9765dc2df0a7d10ad97e83c6d12
wangyendt/LeetCode
/Easy/496. Next Greater Element I/Next Greater Element I.py
559
3.546875
4
# !/usr/bin/env python # -*- coding: utf-8 -*- # author: wang121ye # datetime: 2019/7/16 10:12 # software: PyCharm class Solution: def nextGreaterElement(self, nums1: list, nums2: list) -> list: ret = [] for n in nums1: i = nums2.index(n) for j in range(i + 1, len(nums2)): ...
3fbe7f33d4a50efeac427b8e85a4503e9380ebe2
Svyat33/beetroot_python
/lesson_7_functions/lesson7_task1_simple_function.py
406
4.25
4
# Task 1 # A simple function. # Create a simple function called favorite_movie, which takes # a string containing the name of your favorite movie. # The function should then print “My favorite movie is # named {name}”. def favorite_movie(film_name): print(f'My favorite movie is named "{film_name}".\n') if __nam...
415059588b98e64211aefbd028e6650b2ac229da
Joaovictoroliveira/Exercicios-Python---Hora-Extra
/calcular_salario.py
242
3.953125
4
salario_hora = int(input("Digite o salario/hora do funcionario: ")) horas_por_mes = int(input("Digite a quantidade de horas trabalhadas no mes: ")) salario_mes = salario_hora * horas_por_mes print("salario do funcionario: ", salario_mes)
adcb99912aaab699c446712a4fd3714debd669c5
ddh/leetcode
/python/maximum_average_subarray_i.py
1,525
4.0625
4
""" Given an array consisting of n integers, find the contiguous subarray of given length k that has the maximum average value. And you need to output the maximum average value. Example 1: Input: [1,12,-5,-6,50,3], k = 4 Output: 12.75 Explanation: Maximum average is (12-5-6+50)/4 = 51/4 = 12.75 Note: 1 <= k <= n <...
d8c08777006dbd9940ef6a297954b1c871273d46
ahmedzaabal/Feet-to-Meter
/main.py
1,400
3.515625
4
from tkinter import Tk, Button, Label, DoubleVar, Entry window = Tk() window.title("Feet to Meter Conversion App") window.configure(background="light green") window.geometry("320x220") window.resizable(width = False, height = False) def convert(): """ docstring """ value = float(feet_entry.get()) ...
7b1cd5af373265bb6f1d112b476a499629db984d
shapovalovdev/AlgorythmsAndDataStructures
/src/Stack/stack_linked_list_head.py
2,298
4.125
4
class Node: def __init__(self, v): self.value=v self.next=None self.prev=None class StackHead: def __init__(self): self.head=None self.tail=None def size(self): node = self.head length=0 while node is not None: ...
85afc94838f479658b4c21f0d1cbdf00d80faa5a
SamuelTeguh/UPH
/ex.inp.2.py
104
3.84375
4
age = int(input("Please enter your age:")) olderAge = age + 1 print ("Next year you will be", olderAge)
e58bcfc7605c2e099f693fefecf4a4c47542838d
cronJ/scan-rename
/main.py
2,425
3.5625
4
#!/usr/bin/env python3 import os from tkinter import * from tkinter import filedialog class App: def __init__(self, master): frame = Frame(master) frame.pack() self.directory = "" self.list_of_files = [] self.image = None self.directory_label = Label(frame, text=...
479c0af84249064d2b1833df8af57e6449fff74a
NicoR10/PythonUNSAM
/ejercicios_python/envido.py
2,401
3.640625
4
import random from collections import Counter valores = [1, 2, 3, 4, 5, 6, 7, 10, 11, 12] palos = ['oro', 'copa', 'espada', 'basto'] naipes = [(valor, palo) for valor in valores for palo in palos] def buscar_envido(): ''' Pide una mano y se fija si hay envido. Retorna el puntaje. Para mas detalle de...
52363037c0f5acdd6f929369cfe38717d73cdd79
Marceloalf/Edustation
/escola_v1/s_year.py
503
3.734375
4
def school_years(): pre_school = 2 basic_school = 9 high_school = 3 levels = [] for level in range(1, pre_school + 1): levels.append(("{}º PS".format(level), "{}º ano primário".format(level))) for level in range(1, basic_school + 1): levels.append(("{}º BS".format(level), "{}º ...
b299ad79275f5d32cdb2c4cf95d97feaa33aa37f
artbohr/codewars-algorithms-in-python
/7-kyu/sort-gift-code.py
932
3.9375
4
sort_gift_code = lambda x: ''.join(sorted(x)) ''' Happy Holidays fellow Code Warriors! Santa's senior gift organizer Elf developed a way to represent up to 26 gifts by assigning a unique alphabetical character to each gift. After each gift was assigned a character, the gift organizer Elf then joined the characters t...
bc42a3de125338c72051f85b2b6bb39c14548803
Whiteshadow-hacker/white_shadow
/assesment/QUESTION_15.py
225
4.28125
4
str=input("enter the string:") bit=list() for i in str : if i != '0' or i != '1': bit.append(i) if not bit: print("the string contains only 0 or 1") else: print("the string does not contain only 0 or 1")
55305174539fbf71b3e67151b4f402548566130d
edbeeching/ProjectEuler
/myutils.py
2,219
4.21875
4
# -*- coding: utf-8 -*- """ Created on Sun Oct 29 17:13:48 2017 @author: Edward """ class Figurate: @staticmethod def triagonal(n): return int(n*(n+1)/2) @staticmethod def square(n): return int(n**2) @staticmethod def pentagonal(n): ...
d679639d7a197b21129fb24c6dd4b4d7ef89806e
liyanhe95/basic
/python/class_02/function_1208.py
1,272
3.9375
4
#函数的定义:实现某个指定的功能 重复使用 # type() # len() # range() #函数有啥作用:可以提高代码的复用性 #函数的具体语法:关键字 def #def 函数名(参数1,参数2,参数3): #函数体:本函数要实现的功能 #return 表达式 #def 顶格写 表示这是一个函数 #函数名 小写 不同的字母与数字之间用下划线隔开 不能以数字开头 #参数的个数可以大于等于0 #函数体是函数的子代码 要有缩进 写自己想实现的功能即可 #return后面的表达式 >=0 个 #return 就是当你调用函数的时候 会返回return后面的表达式的值 #如果return后面没有表达式 写...
6f120046dd15c7de5ea92cf4e1363c2224661412
YOOOOONA/algorithm_study
/[프로그래머스]점프와순간이동.py
649
3.515625
4
# -*- coding: utf-8 -*- """ Created on Fri Mar 13 00:52:46 2020 @author: 융 """ #k칸 앞으로 이동 or 현재까지온거리*2만큼 순간이동 가능. k칸 이동은 k만큼 건전지 닳아. #N거리에 가려고 해.최대한 순간이동 많이 해서 #사용해야되는 최소건전지양 리턴 def sol(n,answer): if n==1 or n==2: return answer##### else: if n%2==1: return sol((n-1)//2,answer+1)###...
b6dc5db297cc164f84079241cd564703ab6dc0d9
moonimooni/get-random-test
/get_random.py
712
3.828125
4
import random def get_zero_or_one(): return random.randint(0,1) def get_random(max_num): num = max_num - 1 # change decimal max num to binary max_bin = "" while num >= 1: if num == 1: max_bin = "1" + max_bin break num, left_num = num // 2, num % 2 max_bin = str(left_num) + max_bin ...
e751a32549e3c35724dc0be273e7f135d5c14d56
xuyoji/MLDC
/mldc.py
4,435
3.515625
4
#written by xu yongjie 12/24/2017 class graph(): class node(): def __init__(self, k): #k is the sequence of the node self.k = k self.next = [] #contain the nodes node k point to and the weight between them #[[1, 2], [4, 5]] for example #means point to 1 and 4 with weights 2 and 5 sel...
40c2eb86b3813110b80d5a84f78d6808af68faae
karsevar/Crash_Course_Python-
/CCpython_ch3_exer1.py
1,330
4.3125
4
##3-1 friends = ["Ari Encombe", "Robert Grey", "Masanori", "Masa", "Kenji", "Jonny Phan", "Brian Miller"] print(friends) for friends in friends: print(friends)# Is is way simpler than R programming. To make a comparible #loop you need to write for(i in 1:friends){ print(friends[i])} ##3-2 friends = ["Ari Encombe"...
d08469af450ddfd3380ed4f98b625378e5fe9d65
denemorhun/Python-Problems
/AlgoExperts/Arrays/validate_subsequence.py
1,472
3.984375
4
''' Given an array of DISTINCT integers, Validate a second array is a subset Main idea here is to check matches in only 1 direction ''' # return the two numbers from array that equal to target def isValidSubsequence(array, sequence): isSub = False pos = 0 # outer loop is the sequence for i in range (le...
8398decfeb72da5adc31498fa15a9f5dc2811a22
omarSuarezRodriguez/Python
/Portafolio/programasConsola/indice.py
2,596
3.625
4
''' 1. Imprimir “Hola mundo” por pantalla. 2. Crear dos variables numéricas, sumarlas y mostrar el resultado 3. Mostrar el precio del IVA de un producto con un valor de 100 y su precio final. 4. De dos números, saber cual es el mayor. 5. Crea una variable numérica y si esta...
d4b8925bbf0644f086cc8d2a7f8ef0855bf4c483
Alm3ida/resolucaoPythonCursoEmVideo
/desafio41.py
583
4.15625
4
""" A confederação Nacional de Natação precisa de um programa que leia o ano de nascimento de um atleta e mostre sua categoria, de acordo com a idade: -Até 9 anos: MIRIM -Até 14 anos: INFANTIL: -Até 19 anos: JÚNIOR: -Até 20 anos: SÊNIOR -Acima: MASTER """ from datetime import date year = int(input('Digite o ano de se...
90f61c0aa52efe8f8e0d9eeaadc0daa8247d2bfe
emmaryd/bioinformatics-course
/assignment3/main_chain.py
3,613
3.890625
4
#EMMA RYDHOLM import numpy as np import math UPPER_DIST = 3.95 LOWER_DIST = 3.65 def read_file(filepath): """ Reads the positions from file, assuming that the atom numbers starts at 1 and is aranged in order Args: filepath: string that contains the filepath """ positions = [] with open(...
288bf39b8e205bbd42c2fbf8b66fef1368ca62e5
MaazSc/python-basics
/sortList.py
222
3.796875
4
l=[1,2] l.extend([3,4,5]) print(l) l.pop() print(l) s="maaz" abc=list(s) print(abc) s="".join(abc) print(s) lists=["abc","def","ghi","jkl"] x="nn".join(lists) print(x) T=tuple(l) print(T) T=list(T) print(T)
2ca10e31cf48801d53b05c8d14a2f8f7764e170e
rafaelperazzo/programacao-web
/moodledata/vpl_data/97/usersdata/216/56558/submittedfiles/lecker.py
784
3.515625
4
# -*- coding: utf-8 -*- n=int(input('Digite a quantidade de números na lista:')) h=[] b=[] for i in range(0,n,1): c=int(input('Digite um valor para lista h:')) h.append(c) for i in range(0,n,1): d=int(input('Digite um valor para lista b:')) b.append(d) def lecker(a): cont=0 for i in range...
fe79f8b1591f8363ef861f69c195699a444fd970
fzaman2258/In_Progress
/Games/Hangman.py
2,870
4.25
4
import random def wrong(letter): if letter not in word: return True return False def print_curr_state(word, letter, letters_remaining, list_letters_remaining): index = 0 for char in word: if char == letter: list_letters_remaining[index] = letter ...
6333a8ad89d31ec76fdb44d3cc256126050e0050
wiiaam/filehost
/auths.py
771
3.796875
4
#!/usr/bin/env python3.3 import sys import hashlib def addPass(password): with open("auths") as f: passwords = [x.strip('\n') for x in f.readlines()] hash = hashlib.sha256(password.encode('utf-8')).hexdigest() if passwords.__contains__(hash) is False: with open("auths","a") as f: ...
49c029af3c4396ebc2498257c562b9b7d41e9fe4
EachenKuang/LeetCode
/code/110#Balanced Binary Tree.py
1,331
3.75
4
# https://leetcode.com/problems/balanced-binary-tree/description/ # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): # 1 使用104中的maxDepth def isBalanced(self, root): ...
8a63b2cd7cd7d780aa3336e191d9a0b04575dbc0
gwcpdx/fall_term_backend
/Lesson4_listMethods/Lesson4_listMethods_livecode.py
524
4.4375
4
# Lesson 4 - List Methods living coding examples cities = ["Portland", "Vancouver", "Eugene", "Seattle", "Boring", "Beaverton"] # Add one item to the list one_state = 'Alaska' cities.append(one_state) print cities # Add a LIST to an existing list! states_list = ["Oregon", "Washington", "California", "New York", "Ge...
8d18ab90859dd5bf41d2a94bef862499d5ceb71a
tahadavari/ICPC
/Questions/Kth smallest element .py
406
3.671875
4
# link : https://practice.geeksforgeeks.org/problems/kth-smallest-element5635/1# # sorting class Solution: def kthSmallest(self,arr, l, r, k): ''' arr : given array l : starting index of the array i.e 0 r : ending index of the array i.e size-1 k : find kth smallest element...
93c2a1d1f22f08e4fb076b4ea1ad57d8c2af8e80
noelp2500/Principles-of-Computing-Part-1
/2048(full).py
6,217
3.859375
4
# 2048 (full) # Author - Noel Pereira # Submission - http://www.codeskulptor.org/#user47_MqRFwhG2Vy_2.py #################################################################### """ Clone of 2048 game. """ import random # Directions, DO NOT MODIFY UP = 1 DOWN = 2 LEFT = 3 RIGHT = 4 # Offsets for ...
a063a9933d3e40961211c64dbf4a7497a8feb10d
ThiagoMMonteiro/teste_vcx
/tests.py
3,906
3.640625
4
import queue import stack import unittest #======================================== #------------ queue.py ------------------ #======================================== class Test_Class_Node_queue(unittest.TestCase): def test__init__(self): n1 = queue.Node(5) self.assertEqual(n1.data, 5) se...
d08535076ba3497aa243669b11c9855cc296626b
harshithreddyr/Company-
/home.py
1,058
3.78125
4
from company import Employee,Supervisor print("welcome to company") while True: print("\n \n what would you like to see:\n1.salary\n2.disp_details\n3.check\n4.calc_tax\n5.Exit") choice=int(input("enter your choice: ")) print(choice) sup_id=[12,13,14,15,16,17] emp_name=raw_input("enter the name: ") emp_id=int(inpu...
79144aad681947a99d09b0ede9462f9d6e7f8232
abhaysinh/Data-Camp
/Data Science for Everyone Track/09-Data Manipulation with Pandas/04- Creating and Visualizing DataFrames/06-Removing missing values.py
782
4.4375
4
''' Removing missing values Now that you know there are some missing values in your DataFrame, you have a few options to deal with them. One way is to remove them from the dataset completely. In this exercise, you'll remove missing values by removing all rows that contain missing values. pandas has been imported as p...
d29ce00b99e86afa13fd1ee07124d5b5e401cf25
Aasthaengg/IBMdataset
/Python_codes/p03852/s828525601.py
146
3.828125
4
c = input() if ord(c) == 97 or ord(c) == 101 or ord(c) == 105 or ord(c) == 111 or ord(c) == 117: print("vowel") else: print("consonant")
d324a1e5851f787a636e9aa38d92b075c0f99208
nikhil33333/python
/multiply.py
123
4.03125
4
def multiply_list(items): i = 1 for x in items: i *= x return i print(multiply_list([8,2,3,-1,7]))
a862b366435a258da975ea281cb5956d21fc7522
enkhtuvshinj/Facial-keypoints
/models.py
3,149
3.625
4
## TODO: define the convolutional neural network architecture import torch import torch.nn as nn import torch.nn.functional as F # can use the below import should you choose to initialize the weights of your Net import torch.nn.init as I class Net(nn.Module): def __init__(self): super(Net, self).__init_...