blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
033c9ed0e4ab5985ede13b265cbff90dd494e8ab
Abdullah99044/forever-young
/tafelmanieren/uren.py
111
3.640625
4
for x in range (-1, 13): print(x , str("am")) for y in range(11,24): print(y , str("pm"))
4439f08b7b33f738eaedeee3f305db4601c26205
mzuleta4/PythonExercism
/python/grains/grains.py
284
3.8125
4
def square(number): if not valid_number(number): raise ValueError("The number isn't between 1 and 64 and should be greater 0") return 2**(number - 1) def valid_number(number): return 0 < number < 65 def total(): return sum(square(x) for x in range(1, 65))
02865c0ff34a718081bb0d4c150b3522dc17ca70
MohnishVS/Guvi-Tasks
/uberbilling.py
1,608
4
4
flg=True while(flg): print("\n\nSelect a Service\n 1.auto\n 2.bike\n 3.car\n 4.exit\n") ch=int(input("enter your choice")) if(ch==1): kms=int(input("enter the distance covered:")) if(kms<=1): price=20 print("the bill amount is",price) elif(kms<=4): ...
b89612c53e36acc983470f2e7aa4856934cea115
BrianFoxDougherty/LabelSum.py
/LabelSum.py
2,417
3.921875
4
import argparse import sys import json from pprint import pprint """ LabelSum.py Author: Brian Fox Dougherty Operation: Given a JSON string which describes a menu, calculate the SUM of the IDs of all "items", as long as a "label" exists for that item. """ debug = 0 # default debug value. if set to 1 we will out...
12e3f51785f6012fbdb1ca3926eedb877a325140
ntkawasaki/python-tutorial
/7_input_and_output.py
8,071
4.65625
5
""" 7. Input and Output """ """ 7.1. Fancier Output Formatting Convert values to string format with str() and repr(). The str() function is meant to return representations of values which are fairly human-readable, while repr() is meant to generate representations which can be read by the interpreter (or will force...
1452d70d1b1eb0e6f0e791e0d2a3ec0aec3b9e9e
vijaykumar150/homework2
/part- 2.py
116
3.71875
4
a = "Hello" l = list(a) print(l) j=''.join(l) print(j) j1 = ' '.join(l) print(j1) j2 = '_'.join(l) print(j2)
0c5db9c1de0d5f1bfb922d9b4d2d4cda02c0006c
hanbee1123/algo
/DataStructures/Graph/topological_sort.py
1,353
3.90625
4
""" There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1. You are given an array prerequisites where prerequisites[i] = [ai, bi] indicates that you must take course bi first if you want to take course ai. For example, the pair [0, 1], indicates that to take course 0 you have t...
59794a8b2c9134ae0d5cf381e306fdbae3273c41
hanbee1123/algo
/DataStructures/Priority_Queue_and_HEAP/network_delay_time.py
1,185
3.9375
4
""" You are given a network of n nodes, labeled from 1 to n. You are also given times, a list of travel times as directed edges times[i] = (ui,vi,wi) ui is the source node, vi is the target node wi is the time it takes for a signal to travel from source to target We will send a signal from a given node k. Return the...
13d1c807328218001d5809ac701f25c96e1a9681
hanbee1123/algo
/Algo/Dynamic_programming/coin_change.py
2,144
3.59375
4
""" You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money. Return the fewest number of coins that you need to make up that amount. If that amount of money cannot be made up by any combination of the coins, return -1. You may assum...
1f9966b35de87fb864390ebe817850b2a036959b
hanbee1123/algo
/Algo/Dynamic_programming/climbing_stairs.py
1,032
3.875
4
""" 계단을 올라가고 있다. 이 계단의 꼭대기에 도착하려면 n개의 steps만큼 올라가야 한다. 한번 올라갈 때 마다 1step 또는 2steps 올라갈 수 있다. 꼭대기에 도달하는 방법의 갯수는 총 몇가지 일까요? input: n=2 output = 2 1. 1+1 2. 2 input: n=3, output =3 1. 1+1+1 2. 1+2 3. 2+1 DP using topdown memo = {} def dp_topdown(n): if n == 1: return 1 if n == 2: return 2 ...
dd57ec22b1e3db12ae7b2b3ac169edb235f32998
hanbee1123/algo
/DataStructures/Hash_Table/longest_consecutive_sequence.py
1,704
3.53125
4
""" 문제: 정렬되어 있지 않은 정수현 배열 nums가 주어졌다. nums원소를 가지고 만들 수 있는 가장 긴 연속된 수의 갯수는 몇개인지 반환하시오 input: nums =[100,4,200,1,3,2] output: 4 (가장 긴 연속된 수 1,2,3,4) 문제 해결: O(nlogn) method: #1. sort the nums #2. then from beginning consecutive sequence. O(n) method using hash table: #1. 100,4,200,1,3,2 [101:T, 5:T, 201:T, 2:T, 4:T,...
6ec5322284408552c82b522299977415ee57c9e2
MonikaSophin/python_base
/2.4 tuple.py
422
4
4
""" 2.4 基本数据类型 -- tuple(元组) """ ## 用法与list基本一致,不同的是 # tuple用(), list用[] # tuple不可修改序列元素, list可修改序列元素 # 创建元组 tuple1 = (1, "a", "ss", 1+2j) print(id(tuple1)) tuple1 = 2, "b", "ss1", 2+2j ## 不需要括号也可以 print(id(tuple1)) a = (50) print(type(a)) # 不加逗号,为整型 a = (50,) print(type(a)) # 加上逗号,为元组
ab2a728ab214b390f5e83f460cfe4a85c1a9edc2
serdaraltin/Freelance-Works-2021
/202101161937 - mstfyr (Python - Quiz)/01_source-code/05_project/final_exam-test.py
9,307
3.65625
4
# -*- coding: utf-8 -*- """ EXAM RULES - You are strictly forbidden to share answers with your course mates. - You are not allowed to search for answers on the Internet. You are not allowed to ask for answers in forums or other online communication systems. - Note that, when you find an answer on the web,...
881fa732e96e88c04ad2fb0622af7aa627e6f93b
andylws/SNU_Lecture_Computing-for-Data-Science
/HW5/P4.py
1,272
3.875
4
""" **Instruction** Write P4 function that reads a file and creates another file with different delimeter. - Assume the input file is delimited with blank(' '). - Output file has comma(',') as a delimeter - Assume there is no consecutive blanks in input file. i.e. ' ', ' ', ' ',... does not appear in the input f...
fe3b764e6d704aa111a91b292966f2d3b60b5eb3
andylws/SNU_Lecture_Computing-for-Data-Science
/Proj2/P3.py
2,273
3.984375
4
""" **Instruction** Please see instruction document. """ from linked_list_helper import ListNode, create_linked_list, print_linked_list def P3(head: ListNode) -> ListNode: if head is None: return None if head.next is None: return head ''' # Find the number of nodes cnt = 0 cu...
656d28880463fdd9742a9e2c6c33c2c247f01fbf
andylws/SNU_Lecture_Computing-for-Data-Science
/HW3/P3.py
590
4.15625
4
""" #Practical programming Chapter 9 Exercise 3 **Instruction** Write a function that uses for loop to add 1 to all the values from input list and return the new list. The input list shouldn’t be modified. Assume each element of input list is always number. Complete P3 function P3([5, 4, 7, 3, 2, 3, 2, 6, 4, 2, 1, ...
a2fa443482a145cb7d6d75e7b3a99e37c2aa0c9d
andylws/SNU_Lecture_Computing-for-Data-Science
/Proj2/P2.py
777
3.921875
4
""" **Instruction** Please see instruction document. """ def P2(parentheses: str) -> bool: ##### Write your Code Here ##### par_list = ['.'] for i in parentheses: if i == '(' or i == '{' or i == '[': par_list.append(i) elif i == ')': if par_list[-1] == '(': ...
2396c3f164d68a2fe00bef5aee8689254ff072bc
andylws/SNU_Lecture_Computing-for-Data-Science
/HW4/P1.py
444
3.875
4
""" Implement a function that takes a list of integers as its input argument and returns a set of those integers occurring two or more times in the list. >>> P1([1,2,3,1]) {1} >>> P1([1,2,3,4]) set() >>> P1([]) set() >>> P1([1,2,3,1,4,2]) set({1,2}) """ def P1(lst): result = set() noDup = set(lst) ...
fe84b61fe62bf5056bd2d91c2070753ebf22c339
barmi/CodingClub_python
/LV4/Chapter4/start/myArtApp.py
1,737
3.75
4
# myArtApp.py # based on the code from myEtchASketch.py in Python Basics. # 『코딩 클럽 LV1. 모두를 위한 파이썬 기초』의 myEtchASketch.py from tkinter import * #### Set variables. 변수를 정합니다. canvas_height = 400 canvas_width = 600 canvas_colour = "black" x_coord = canvas_width/2 y_coord = canvas_height line_colour = "red" line_width = ...
51dd14daadc02e7518fef366d94ea9df1edecdfd
barmi/CodingClub_python
/LV3/SourceCode/보너스장/MyBreakout/main.py
2,335
3.609375
4
# MyPong의 주된 파일을 만듭니다. from tkinter import * import table, ball, bat, random window = Tk() window.title("MyBreakout") my_table = table.Table(window) # 전역 변수 초기화 x_velocity = 4 y_velocity = 10 first_serve = True # Ball 공장으로부터 볼을 주문합니다 my_ball = ball.Ball(table = my_table, x_speed=x_velocity, y_speed=y_velocity, ...
0eda42b293a5816c846e25cba58e006b19ef3770
barmi/CodingClub_python
/LV2/SourceCode/ch1/myMagic8Ball.py
1,125
3.65625
4
# My Magic 8 Ball import random # 답변을 입력해봅시다. ans1="자! 해보세요!" ans2="됐네요, 이 사람아" ans3="뭐라고? 다시 생각해보세요." ans4="모르니 두려운 것입니다." ans5="칠푼인가요?? 제 정신이 아니군요!" ans6="당신이라면 할 수 있어요!" ans7="해도 그만, 안 해도 그만, 아니겠어요?" ans8="맞아요, 당신은 올바른 선택을 했어요." print("MyMagic8Ball에 오신 것을 환영합니다.") # 사용자의 질문을 입력 받습니다. question = input("조언을 구하고 싶으...
650e11ce5d2d7d32f12a3f22d7a5dc9cecf846e4
jungaSeo/python
/Python02/cal/mathTest.py
756
3.796875
4
''' # 여러 줄 인식 : """ data = """ 안녕하세요. 하하하.. 히히히히힣 """ print(data) print("안녕하세요\n\n하하하..\n\n하하하핳") ''' ''' # 실습 1 # 계산기 a = int(input("숫자 1: ")) b = int(input("숫자 2: ")) print(a,"+",b,"=",a+b) print(a,"-", b,"=",a-b) print(a,"*", b,"=",a*b) print(a,"/", b,"=",a/b) ''' ''' # ...
672a19db7cda79d1d3e3c935385020439cff276f
marauderlabs/leetcode
/easy/897-increasing-order-search-tree.py
811
3.84375
4
# https://leetcode.com/problems/increasing-order-search-tree # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def increasingBST(self, root: TreeNode) -> TreeNode: def inOrder(r...
d8df108ecad24419cb1f61b344eb42d38529c7b6
Aragami1408/competitive-programming
/codeforces/A/cf791A.py
113
3.53125
4
a,b = tuple(int(x) for x in input("").split(" ")) y = 0 while a <= b: a *= 3 b *= 2 y += 1 print(y)
957430eed1546f073ecaac7e45fd8382b43bdbb1
Givonaldo/POP_URI-JUDGE
/POP_EXEMPLOS/nivel1/Salario.py
990
3.890625
4
''' Created on 5 de dez de 2015 URI Online Judge Salário - 1008 Escreva um programa que leia o número de um funcionário, seu número de horas trabalhadas, o valor que recebe por hora e calcula o salário desse funcionário. A seguir, mostre o número e o salário do funcionário, com duas casas decimais. Entrada ...
50be8229b9dbf1c1820e654b12a9bb1224a0dd40
moretanjames/Grav_Sim
/Grav_Sim/movement.py
275
3.5625
4
class Velocity(): ''' Velocity for objects ''' def __init__(self,xspeed = 0, yspeed = 0): self.xspeed = xspeed self.yspeed = yspeed class Coord(): ''' Coordinates for objects ''' def __init__(self, xpos, ypos): self.xpos = xpos self.ypos = ypos
26d257726f861c581e2b50e899efd25e8b1068ff
wwwser11/study_tasks-
/tasks/task7.py
527
3.734375
4
# 7. В функцию передается список списков. Нужно вернуть максимум. который достигает выражение # (a1*a1 + a2*a2 + an*an). Где ai -- максимальный элемент из iго списка. from functools import reduce from itertools import starmap def func(big_list): return reduce(lambda x, y: x + y**2, [0] + list(starmap(max, bi...
b4baa75a31b415e4e08e24d866b4469288bacbee
amagrabi/ds-preprocess
/dir.py
608
3.75
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Helper functions to process directories and files. @author: amagrabi """ import os import shutil import magic def delete_path(path): shutil.rmtree(path) def create_folders(folder_list, path): for folder in folder_list: folder_path = os.path.joi...
8df63ced2463425561006248e766d2a6cb8f8be5
ScaredTuna/Python
/Tesco.py
332
3.6875
4
Product = "Pepsi" Quantity = 10 Unit_Price = 1.25 Amount = Quantity * Unit_Price VAT = Amount * 11 / 100 print("Product:", Product) print("Quantity Purchased:", Quantity) print("Unit Price:", Unit_Price) print("----------------------------------") print("Total Bill:", Amount) print("VAT:", VAT) print("Net Amount:", (Am...
96bb253cbcac7168c009a01e2b1ebb56f1e537b3
ScaredTuna/Python
/Lists2.py
700
4.0625
4
names = [] choice = "" longest = "" second = "" print("------------------------------------------") while choice != "exit": choice = input("Enter name (exit to quit):") if choice != "exit": names.append(choice) if len(choice) > len(longest): second = longest longest = cho...
1e49e98b5f63ff14120531c952868f6841ef56ba
ScaredTuna/Python
/Salary.py
562
3.953125
4
name = input("Enter Name:") salary = int(input("Enter Salary:")) if salary >= 35000: VAT = salary * 21 / 100 if salary < 35000: VAT = salary * 17 / 100 print("----------------------------------------------") print("Name:", name) print("Salary:", salary) print("----------------------------------------------") pr...
b4a85cfa138df5113411b2ce9f52360a3066342d
ScaredTuna/Python
/Results2.py
455
4.125
4
name = input("Enter Name:") phy = int(input("Enter Physics Marks:")) che = int(input("Enter Chemistry Marks:")) mat = int(input("Enter Mathematics Marks:")) tot = phy + che + mat per = tot * 100 / 450 print("-------------------------------------") print("Name:", name) print("Total Marks:", tot) print("Percentage:", per...
38643b407ca00ff786cc993b12b11fd3a7668656
ScaredTuna/Python
/NestedIf.py
276
3.796875
4
no = int(input("Enter Number:")) print("-----------------------------------") if no > 1000: print("A") if no > 5000: print("C") else: print("E") else: print("B") if no > 500: print("D") print("-----------------------------------")
89db5cdc6027908c848eb4b27f0b54c3774ab387
ianaquino47/Daily-Coding-Problems
/Problem_109.py
376
4
4
# This problem was asked by Cisco. # Given an unsigned 8-bit integer, swap its even and odd bits. The 1st and 2nd bit should be swapped, the 3rd and 4th bit should be swapped, and so on. # For example, 10101010 should be 01010101. 11100010 should be 11010001. # Bonus: Can you do this in one line? def swap_bits(x): ...
c96d92aa08169e386366b7f6798f4460e92dfe32
ianaquino47/Daily-Coding-Problems
/Problem_68.py
1,295
4.03125
4
# This problem was asked by Google. # On our special chessboard, two bishops attack each other if they share the same diagonal. This includes bishops that have another bishop located between them, i.e. bishops can attack through pieces. # You are given N bishops, represented as (row, column) tuples on a M by M chessb...
e2472ed715c6a86dd43db8df6e38e0faa314c9fd
ianaquino47/Daily-Coding-Problems
/Problem_45.py
498
3.796875
4
# This problem was asked by Two Sigma. # Using a function rand5() that returns an integer from 1 to 5 (inclusive) with uniform probability, implement a function rand7() that returns an integer from 1 to 7 (inclusive). def rand7(): r1, r2 = rand5(), rand5() if r2 <= 3: return r1 elif r2 == 4: ...
0d2e64fe59a76cdf62779241733dd96e1ea5ae0d
ianaquino47/Daily-Coding-Problems
/Problem_73.py
297
4.03125
4
# This problem was asked by Google. # Given the head of a singly linked list, reverse it in-place. def reverse(head): prev, current = None, head while current is not None: tmp = current.next current.next = prev prev = current current = tmp return prev
da7b63be1bd15d4a098be19875876505f7f82f4a
ianaquino47/Daily-Coding-Problems
/Problem_90.py
578
4.03125
4
# This question was asked by Google. # Given an integer n and a list of integers l, write a function that randomly generates a number from 0 to n-1 that isn't in l (uniform). from random import randrange def process_list(n, l): all_nums_set = set() for i in range(n): all_nums_set.add(i) l_set = ...
328710868aa68a29a7383e18f75727655aeb8076
ianaquino47/Daily-Coding-Problems
/Problem_58.py
1,400
3.875
4
# This problem was asked by Amazon. # An sorted array of integers was rotated an unknown number of times. # Given such an array, find the index of the element in the array in faster than linear time. If the element doesn't exist in the array, return null. # For example, given the array [13, 18, 25, 2, 8, 10] and the...
6cebbce8244a78c5a4c28f8ebe28b8064ea6dce1
firas3333/Artificial-Intelegence-Lab
/assignment2/reinforcmentL.py
13,128
3.671875
4
from vehicle import Vehicle import learningUtils # goal vihcle (4,2) means its out # 2 arrays to set the length of a vehicle GOAL_VEHICLE = Vehicle('X', 4, 2, 'H') smallcars = {'X', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K'} largecars = {'O', 'P', 'Q', 'R'} # class RushHour has all the moethods a...
34d1d4c7e3e16b4cb08fa7f398f89174a30afae8
firas3333/Artificial-Intelegence-Lab
/assignment2/learningUtils.py
1,851
3.671875
4
import random class Move(object): # constructor to initiate vehicles, board, move, depth of the state , and its value (heuristic) def __init__(self,car, direction): """Create a new Rush Hour board. Arguments: vehicles: a set of Vehicle objects. """ self.ca...
9b54d192cad797d0121cca02a5bb72cd7f1517fd
tlively/distributed-lightcycle
/game_utils.py
10,672
3.90625
4
""" game_utils.py This contains utility functions and classes necessary for running the game. The three classes defined in the file are Direction, Message and Game State. Direction defines the cardinal directions and allows a player to extrapolate in a given direction given a location. Message encapsulates the inter-c...
69e6a29d952a0a5faaceed45e30bf78c5120c070
TommyWongww/killingCodes
/Daily Temperatures.py
1,025
4.25
4
# @Time : 2019/4/22 22:54 # @Author : shakespere # @FileName: Daily Temperatures.py ''' 739. Daily Temperatures Medium Given a list of daily temperatures T, return a list such that, for each day in the input, tells you how many days you would have to wait until a warmer temperature. If there is no future da...
1ae82daf01b528df650bd7e72a69107cdf686a82
TommyWongww/killingCodes
/Invert Binary Tree.py
1,251
4.125
4
# @Time : 2019/4/25 23:51 # @Author : shakespere # @FileName: Invert Binary Tree.py ''' 226. Invert Binary Tree Easy Invert a binary tree. Example: Input: 4 / \ 2 7 / \ / \ 1 3 6 9 Output: 4 / \ 7 2 / \ / \ 9 6 3 1 Trivia: This problem was i...
9befa8049cd7c31fd959b6ad7ca652c4e1435d00
jillgower/pyapi
/sqldb/db_challeng.py
2,819
4.21875
4
#!/usr/bin/env python3 import sqlite3 def create_table(): conn = sqlite3.connect('test.db') conn.execute('''CREATE TABLE IF NOT EXISTS EMPLOYEES (ID INT PRIMARY KEY NOT NULL, NAME TEXT NOT NULL, AGE INT NOT NULL, ADDRESS CHAR(50), SALARY REAL);''') print(...
1dcf3d4b3a383247a907379bf32ec77174667fd8
sslaia/belajar_python
/latihan/toko_hider.py
8,906
3.515625
4
import json import datetime import os def menginput_menu(): # mendeklarasikan berbagai variable daftar_menu = [] # fungsi loop memasukkan data menu makanan keluar = False while keluar == False: # menampilkan formulir isian nama_makanan = input("Masukkan nama makanan : ") ...
028fd4df6d1d0722e4e2209bf1ae2159567fcd25
lazyboy8000/algorithms
/binarysearch.py
677
4.0625
4
mylist = [1, 2, 3, 4, 5, 6] def binarySearch(mylist, item): lowIndex = 0 highIndex = len(mylist) - 1 while lowIndex <= highIndex: middleIndex = (lowIndex + highIndex) / 2 print middleIndex # 2, if item == mylist[middleIndex]: return '%d found at position %d' % (it...
837f5b80b8fe013676c41c9184b877a1add378b0
lazyboy8000/algorithms
/mergesort2.py
2,634
4
4
# ********************************************************************************** # This function merges leftList & rightList together into finalList. These lists are already sorted. def merge(leftList, rightList): finalList = [] # The final list to hold the sorted list, reset to = [] each time this function is...
048cc584eda064b0d148fea8d69843bb26051ed1
thalessahd/udemy-tasks
/python/ListaExercicios1/ex5.py
637
4.15625
4
# -*- coding: utf-8 -*- """ Escreva um programa que receba dois números e um sinal, e faça a operação matemática definida pelo sinal. """ print("Digite o primeiro número:") num1 = float(input()) print("Digite o segundo número:") num2 = float(input()) print("Digite o sinal:") sinal = input() if sinal=="+": resu = ...
c1f7a2b84099c8c382495cd026cdddd258f18c23
peternara/DELF-local-descriptor-train-pytorch
/test.py
326
3.765625
4
a = [i for i in range(10)] def get(a): while True: for i in range(0, 10, 3): try: if i+3 < 10: yield a[i:i+3] else : raise Exception except: break; b = get(a) for i in range(20): print(next...
2ee7f50b026d65adf22a95d9a92c4e0d7cf2d94e
Param3103/IMDB-movie-scrapper
/tests/tests.py
1,226
3.625
4
import unittest import csv import re data = [] with open('IMDBmovies.csv', 'r') as file: csv_reader = csv.reader(file) for line in csv_reader: if len(line) != 0: data.append(line) class Testing_Project(unittest.TestCase): #tests if all movies have been deposited into csv file def te...
202bd0898352102599f6e4addccaec7a60b46a8f
amymhaddad/exercises_for_programmers_2019
/flask_product_search/products.py
1,454
4.15625
4
import json #convert json file into python object def convert_json_data(file): """Read in the data from a json file and convert it to a Python object""" with open (file, mode='r') as json_object: data = json_object.read() return json.loads(data) #set json data that's now a python object to pro...
8ec2a87f98be3111440db36b81aaa3051064eecb
amymhaddad/exercises_for_programmers_2019
/product_search/user_input.py
184
3.71875
4
"""Get user input for product item to search""" def get_item_name_from_user(): """Get a name of a product from the user""" return input("What is the product name? ").title()
53fc3227a9c2537217e950a2c85dc57f3d812b2f
VladBe1/Learn_Python
/ex2.py
456
4
4
# numbers = ['3','5','7','9', '10.5'] # print(numbers) # numbers.append("Python") # print(len(numbers)) # print(numbers[0]) # print(numbers[-1]) # print(numbers[1:4]) # numbers.remove("Python") # print(numbers) Weather = { "city": "Moscow", "temperature": "20" } Weather['temperature'] = int(Weather['temperature...
6d3c6b5362c47d16b3916607be2896033e321e71
disha111/Python_Beginners
/Assignment 3.9/que2.py
552
4.1875
4
import pandas as pd from pandas.core.indexes.base import Index student = { 'name': ['DJ', 'RJ', 'YP'], 'eno': ['19SOECE13021', '18SOECE11001', '19SOECE11011'], 'email': ['dvaghela001@rku.ac.in', 'xyz@email.com', 'pqr@email.com'], 'year':[2019,2018,2019] } df = pd.DataFrame(student,index=[10,23,13]) p...
a3bb747fcef01e7c5f885a303d4c0055b1337cd0
disha111/Python_Beginners
/Python Quiz Solution/Q46.py
72
3.5
4
import numpy as np ary = np.array([1,2,3,5,8]) ary = ary+1 print(ary[1])
6ef4e9543d7c7c20bdbb1ffa4976b8c3b6e9b0f5
disha111/Python_Beginners
/extra/scope.py
672
4.15625
4
#global variable a = 10 b = 9 c = 11 print("Global Variables A =",a,", B =",b,", C =",c) print("ID of var B :",id(b)) def something(): global a a = 15 b = 5 #local variable globals()['c'] = 16 #changing the global value. x = globals()['b'] print("\nLocal Variables A =",a,", B =",b,", C =",c,",...
a7455bef1e99b4c247b6cc082dc2889542497607
disha111/Python_Beginners
/chapters/ch 2/july22.py
1,132
3.875
4
import re search = ''' abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890 @#$%^&(*((^&))) 123-456-7896 563-658-7566 456*254&2454 ''' print(r"\tRKU")#Row String to print special command like \n \t etc.... a=r"\tabc"#Row String print(a) ########################## REGULAR EXPRATATION ########################...
0e15bc4ef67886f7a066341f6487fa450eb3f94b
disha111/Python_Beginners
/Assignment 3.11/HighestValueFind.py
304
3.59375
4
import pandas as pd df = pd.read_csv('ETH.csv') filt1 = df['Date'].str.contains('2019') filt2 = df['Date'].str.contains('2020') print("highest value of column 'Open' for the year 2019 : ",df.loc[filt1,'Open'].max()) print("highest value of column 'Open' for the year 2020 : ",df.loc[filt2,'Open'].max())
190212bfde32271246fa0e383ccf20f2a78330f3
disha111/Python_Beginners
/chapters/ch 1/july15.py
1,430
3.96875
4
############################ PUBLIC PRIVATE AND PROTECTED EXAMPLE ############################################ class student: _name = None _roll = None __college = None myvar = "RKU1" def __init__(self,name,roll,college): self._name = name self._roll = roll self.__college = c...
e4dde5c7d3495bf7adcaf74b9701cb69042c4d6b
disha111/Python_Beginners
/Assignment 1.2/A1.4.py
202
4
4
def showNumbers(limit): for i in range(0,limit+1): if(i%2 == 0): print(i,"EVEN") else: print(i,"ODD") limit = int(input("Enter Limit : ")) showNumbers(limit)
c69e79ced4ab46520eb7e2851edfb53343863015
disha111/Python_Beginners
/Assignment 3.1/que2.py
243
3.953125
4
import numpy as np ls =[] print("Enter Element in Matrix : ") for i in range(0,9): ls.append(int(input())) def display(ls): array = np.array(ls).reshape(3,3) #two-dimensional NumPy array. return array dim = display(ls) print(dim)
a1d9f3efbfe2da86945024de8c87acf6fba5a61b
tonnekarlos/aula-pec-2021
/Semana-5-Ex02-Q01-runcodes.py
416
3.65625
4
def main(): nome = input('') estado_civil = int(input('')) n1 = [] n2 = [] if estado_civil == 2: n1.append(nome) for i in n1: print(len(i)) elif estado_civil == 1: nome2 = input('') n1.append(nome) n2.append(nome2) for i in n1: ...
5e5be5dc017ed6d0837d9eb608ac812fcdeebbd5
tonnekarlos/aula-pec-2021
/Semana-5-Ex02-Q03.py
705
3.734375
4
def verifica_numero(n): d = n // 10 u = n % 10 return d, u def main(): # Entrada de dados n = int(input('digite um número entre 10 e 99: ').strip()) # Processamento x = 0 d, u = verifica_numero(n) if 10 <= n <= 99: if d % 2 != 0: x += 1 if u % 2 != 0: ...
2cfc741cea7bec22ae64cd7b8194636eacedbaeb
tonnekarlos/aula-pec-2021
/Semana-5-Ex01-Q04-runcodes.py
724
3.71875
4
def media(n1, n2, n3, n4, n5): return(n1+n2+n3+n4+n5) / 5 def main(): n1 = float(input("".strip())) n2 = float(input("".strip())) n3 = float(input("".strip())) n4 = float(input("".strip())) n5 = float(input("".strip())) maior = [] if n1 > media(n1, n2, n3, n4, n5): maior.append...
e323a0fe8e50ad7df9ecf1ce4ffe5ccd5aa5aa9b
tonnekarlos/aula-pec-2021
/T1-Ex04.py
249
4.28125
4
def verifica(caractere): # ord retorna um número inteiro representa o código Unicode desse caractere. digito = ord(caractere) # 0 é 48 e 9 é 57 return 48 <= digito <= 57 print(verifica(input("Digite um caractere: ".strip())))
574b931268a7d7cdf6dd172bfa85068bc6c4364b
sesorov/phonebook_lab
/main.py
1,488
3.796875
4
import sys from interface import BookInterface from additional import Text, GColor PhoneBook = BookInterface() GREEN = GColor.RGB(15, 155, 43) def main_menu(): print(GREEN + Text.BOLD + '*' * 18 + " MAIN MENU " + '*' * 18 + Text.END) print("Please, select an action by choosing its index.\nOperations:") p...
358cfe68d16aeb8794f21c5e60acfe334f0d6436
svmeehan/FuelEfficiencyCalc
/testSuite.py
614
3.53125
4
import unittest from DistanceTable import * class TestDistanceTable(unittest.TestCase): def test_not_a_valid_file(self): '''Test to make sure an IOError is raised for an invalid file name''' with self.assertRaises(FileNotFoundError): DistanceTable.readCSV(self, 'does-not-exist.csv') #self.assertRaises(IOEr...
a2a4b44f5e4c0ec04d8ede72e715936ea6aefc1c
dpudovkin84/py-study
/tests/TestExcept_2.py
293
3.890625
4
while True: a=input('Enter number a:') b=input('Enter number b:') try: result= int(a)/int(b) except ZeroDivisionError: print("Zerro division") except ValueError: print("Not a digit") else: print('Square Resutl:',result**2) break
35fa9f1acf78fe291cb15f6c46203cd6768bbc3b
DS-ALGO-S30/Two-Pointers-2
/1_removeDuplicates.py
971
3.671875
4
def solution(nums): ''' Approach: 1. using 3 pointers, slow pointer indicates all values before it are traversed. 2. fast pointer quickly moves to new values and prev=fast and slow moves one step and fast moves to nex and flag=0 3. if flag ==0 then only move make nums[slow]=nums[fast] 4. slow po...
bfe570477d001c7cb5b7e2e9e1e1aa8522e8db47
shubhamrocks888/python_oops
/Polymorphism.py
3,348
4.625
5
## Polymorphism in Python '''Example of inbuilt polymorphic functions :''' # len() being used for a string print(len("geeks")) # len() being used for a list print(len([10, 20, 30])) '''Examples of used defined polymorphic functions :''' def add(x, y, z = 0): return x+y+z print(ad...
6a225c527bf763828225ead494d4beaa3aebfcad
Smirt1/Clase-Python-Abril
/Funciones.py
609
3.78125
4
# suma = 7 + 8 + 9 # media = suma / 3 # print ("La puntuacion de la clase es: ", media) # def puntuacion (alum1, alum2, alum3): # suma = alum1 + alum2 + alum3 # return suma / 3 # media = puntuacion(7,8,9) # print ("La puntuacion de esta clase es: ", media) # media = puntuacion(10,15,9) # print ("La puntuaci...
42fab2e2b67d33b344ee1e19fdc2ce537f62f195
Smirt1/Clase-Python-Abril
/Tarea1.py
2,008
4.0625
4
#Escriba en pantalla el tipo de dato que retorna la expresión 4 < 2: # print (4 < 2) #Almacene en una variable el nombre de una persona y al final muestre en la consola el me nsaje: “Bienvenido [nombrePersona]” # usuario = input("Escriba el nombre del usuario: ") # print ("Bienvenido : " + usuario) #Evalúe si un n...
9c0cd7be7ad5ad32f43d66d7ccceb2ddfe673a12
Smirt1/Clase-Python-Abril
/IfElifElse.py
611
4.15625
4
#if elif else tienes_llave = input ("Tienes una llave?: ") if tienes_llave == "si": forma = input ("Que forma tiene la llave?: ") color = input ("Que color tiene la llave?: ") if tienes_llave != "si": print ("Si no tienes llaves no entras") if forma == "cuadrada" and color =="roja":...
cda697bb9039180d04863b553d60092dd24a2f6b
Georgie88/Python-Challenge
/1. PyBank/main.py
3,399
4.1875
4
#dependencies import csv #set file name file_name = 'budget_data_1.csv' #open a file with open(file_name, newline='') as csvfile: #read the file with csv budget_data = csv.reader(csvfile, delimiter=',') #skip the header row next(budget_data) #setting up the variables for the number of months...
cb3eda57daa9030fb7d3f4ca6bd842fd06d7033c
yzy1995215/Python
/本科科研/8-03/问题2.py
1,625
4
4
""" 定义一个列表的操作类:Listinfo 包括的方法: 1 列表元素添加: add_key(keyname) [keyname:字符串或者整数类型] 2 列表元素取值:get_key(num) [num:整数类型] 3 列表合并:update_list(list) [list:列表类型] 4 删除并且返回最后一个元素:del_key() """ class Listinfo(object): # 列表操作类 def __init__(self,list1): self.list = list1 def add_key(self,keyname): # 列表元素添加: a...
5ef3862b7db12c4010253c4b76cc7913dcac190b
yzy1995215/Python
/本科科研/7-13/问题1.py
273
3.5625
4
""" 编写一个函数,调用函数返回四位不含0的随机数. """ import random def random_number(figure): num = 0 for i in range(1,figure+1): num = num*10 + random.randint(1,9) return num if __name__ == '__main__': print(random_number(4))
f7561710a33183178c180fc6809c4bbf49df4a37
aldwinhs/Tubes-Daspro
/F07.py
3,067
3.65625
4
# KAMUS # id_ubah : string # ketemu : boolean # nama : integer # jumlah : integer # banyakubah : integer def ubahjumlah(datas2, datas3): # F07-Mengubah Jumlah Gadget atau Consumable pada Inventory ketemu = False while not(ketemu): id_ubah= input("Masukan ID: ") ID = 0 nama = 1 ...
d3aec4132ad1f894861652559d9f1ab936bfb6d8
LakshayLakhani/my_learnings
/programs/arrays/left_rotate.py
1,388
3.859375
4
# arr = [1,2,3,4,5] # op = [2,3,4,5,1] # # first = arr[0] # for i in range(len(arr)-1): # arr[i] = arr[i+1] # # arr[-1]=first # # print(arr) # O(nd) -> # arr = [1,2,3,4,5] # # d = 3 # # for i in range(d): # first = arr[0] # for i in range(len(arr)-1): # arr[i] = arr[i+1] # # arr[-1]=first # # p...
ab06ae955363b0ac7fcdfd22f35e9ea6e698d5c3
LakshayLakhani/my_learnings
/programs/binary_search/bs1.py
484
4.125
4
# given a sorted arrray with repititions, find left most index of an element. arr = [2, 3, 3, 3, 3] l = 0 h = len(arr) search = 3 def binary_search(arr, l, h, search): mid = l+h//2 if search == arr[mid] and (mid == 0 or arr[mid-1] != search): return mid elif search <= arr[mid]: return bina...
5857c3f71274a55944187eef5781c0c459ed4db4
LakshayLakhani/my_learnings
/programs/palindrom.py
253
3.9375
4
#recursive way string = "l" l = 0 r = len(string)-1 def check_palindrom(l, r, string): if string[r] != string[l]: return False if l < r: check_palindrom(l+1, r-1, string) return True print(check_palindrom(l, r, string))
e528e6c095c2116ca53d99c34109cc5d09ff56a0
luphord/imgwrench
/imgwrench/commands/frame.py
1,165
3.546875
4
"""Put a monocolor frame around images.""" import click from PIL import Image from ..param import COLOR def frame(image, width, color): """Put a monocolor frame around images.""" frame_pixels = round(width * max(image.size)) new_size = (image.size[0] + 2 * frame_pixels, image.size[1] + 2 * frame_pixels)...
7b3649f5efa47990921e1447c9f1ab3755d9a3a0
dolefeast/Simulation_Intro
/failed/freefall_euler.py
877
3.5
4
import numpy as np import matplotlib.pyplot as plt #Physical variables F = 600 #G * M, abreviated. #Position r0 = 4#Starting distance r_y = r0 #Updatable starting distance r_x = 0 #Horizontal position r_t = r_y - 35 #Earth's radius r = np.array([r_x, r0]) r_norm = np.linalg.norm(r) #Speed v_x = 7 #Horizontal speed ...
03354fb7eafde52270044aeb96d7b9735907652a
kylesadler/Zn-Polynomial-Factorizer
/factorizer.py
3,792
3.671875
4
from itertools import product from pprint import pformat import sys def main(): coefficients = [1,4,3,0,1,2] run(*coefficients) def run(*coefficients): for p in [2,3,5]: print(f'\n{p}:\n') results = factor(p, coefficients) for result in results: print(list(result[0]),...
cca327c9bb2b6f5bcaaeaf09b09c80b07fe15e32
younes-m/Utilitary-Python-Scripts
/spaces_to_under.py
993
3.671875
4
import sys import os """ replaces the spaces in file names by underscores ('_') works with any number of files/folders dragged and dropped on the script""" def newname(path): #returns the path with spaces in the file name replaced with '_' if spaces in the file name, else false output = path.split('\\') ...
72a911716ddb5155762d944e69c8ca518297d68b
SAmelekhin/algorithms-1
/search_in_broken_array.py
768
3.75
4
from typing import Any, List, Tuple, Union def broken_search(elements: Union[List[Any], Tuple[Any]], target: Any) -> Any: left, right = 0, len(elements) - 1 while left <= right: mid = (left + right) // 2 if target == elements[mid]: return mid if elements[mid] <= elements[ri...
52624832b010752d12893ac8b7044e6ac1c0bad9
chenp0088/git
/cars_4.py
91
3.671875
4
#!/usr/bin/python3 # coding=utf-8 cars = ['bmw','audi','toyota','subaru'] print(len(cars))
99f8aed5acd78c31b9885eba4b830807459383be
chenp0088/git
/number.py
288
4.375
4
#!/usr/bin/env python # coding=utf-8 number = input("If you input a number ,I will tell you if the number is multiplier of ten! Please input the number: ") number = int(number) if number%10 == 0: print("It`s the multiplier of ten!") else: print("It`s not the multiplier of ten!")
2c72bc803695eda04d7faeecfbb8830c3353e23e
chenp0088/git
/age.py
272
4
4
age=40 if age<2: print("He is a baby.") elif 2<=age<4: print("He is a child.") elif 4<=age<13: print("He is a children.") elif 13<=age<20: print("He is a teenager.") elif 20<=age<65: print("He is an adult. ") elif age>65: print("He is an old man")
05ec60a24844022ebc0b28c9b17c13c7b4d2487f
chenp0088/git
/users.py
258
3.734375
4
users=['admin','root','peter','psla','seare'] for user in users: print("Hello "+user+'.') if user=='admin': print("Hello "+user+','"would you like to see a status report?") else: print("Hello Eric,thank you for logging in again")
f2970ec63018d4b56a8a71fe495e726ad5f09bfd
chenp0088/git
/p99-6-11.py
610
3.71875
4
#!/usr/bin/env python # coding=utf-8 cities={ 'taizhou':{ 'country':'china', 'population':'1000 million', 'fact':'水乡,好吃的多', }, 'dongjin':{ 'country':'japan', 'population':'20000 million', 'fact':'鬼子多', }, 'new york':{ 'country':'america', ...
d4ecd2f89f348afd4823274945057ace57de464c
chenp0088/git
/cars_5.py
175
4.03125
4
#!/usr/bin/python3 # coding=utf-8 cars = ['bmw','audi','toyota','subaru'] for car in cars: if car =='bmw': print(car.upper()) else: print(car.title())
3de21f3820b9d9ea0fe8b02b7c7b6893b63ebddb
margomalfait/Informatica5
/07b-Iteraties-While-lus/Blackjack.py
373
3.609375
4
# invoer kaart = int(input('kaart is: ')) totaal = 0 # berekening while totaal < 21 and kaart > 0: totaal += kaart if totaal < 21: kaart = int(input('kaart is: ')) if totaal > 21: antw = 'Verbrand ({})'.format(totaal) if totaal == 21: antw = 'Gewonnen!' if kaart == 0: antw = 'Voorzichtig...
a887131116e866ff21d8711061fee32e7117ea97
margomalfait/Informatica5
/Toets/IrrationaleFuncties.py
230
3.796875
4
from math import sqrt # invoer a = float(input('Geef x: ')) # berekening if a < 2: if x == 2: mes = '{:.2f} ∉ dom(f)'.format(a) else: mes = '' elif x < 2: mes = 'x ∉ dom(f)' # uitvoer print(mes)
dd318131a8b9d8e68380bf13ce9a02d0c4b6784f
shashankgupta12/valuefy
/scraper/valuefy.py
884
3.734375
4
# valuefy/valuefy.py URL = 'https://medium.com/' def write_to_file(file_name, url): """This function writes the received url to the received file name.""" with open(file_name, 'a') as myfile: myfile.write('{}\n'.format(url)) def format_internal_url(url): """This function formats an internal ...
2e64de10c2dc00984708a0e917423883ecb26bad
kulshrestha97/PythonPractice
/gradingstudent.py
322
3.65625
4
n = int(raw_input()) marks = [] newmarks = [] for i in xrange(0,n): m = int(raw_input()) marks.append(m) for i in marks: a = i//5 multiple = (a+1)*5 if ((multiple - i)<3 and i>=38): newmarks.append(multiple) else: newmarks.append(i) print "\n".join(map(str,newmarks...
89454ce7d16599c6e309ea06df4fb4f4d7eb02c6
franloza/hackerrank
/hash_maps/ransom_note.py
822
3.5625
4
#!/bin/python3 import os from collections import Counter # Complete the checkMagazine function below. def checkMagazine(magazine, note): c = Counter(magazine.split(' ')) for word in note.split(' '): count = c.get(word, 0) if count == 0: return "No" else: c[word] ...
a89a3d8ea0047d3445add9e48c2d77f7458268b2
marcellinamichie291/crypto_simulator
/strategy/moving_average_double.py
939
3.515625
4
import numpy as np class MovingAverageDoubleStrategy: """ Double moving average strategy. """ def __init__(self, period_1=9, period_2=21, trade_fee=0): if period_1 > period_2: self.period_max = period_1 self.period_min = period_2 else: self.period_max = per...
6bcf17d04fad2916b1ab737e706cb032c4c46381
HenrryAraujo/file-processing-poc
/process_csv_files.py
2,106
3.5
4
#---------------------------------------------------- # Python program to process csv files: # -> Below program is intended to showcase some # Python functionalities to process data # from csv files. # # The program will process any new incoming file and # set its ip detils identifies by file name prefix ...
a01c02e5227267010b7bf6ddb54c2502797bb3c6
Akshay7591/Caesar-Cipher-and-Types
/ROT13/ROT13encrypt.py
270
4.1875
4
a=str(input("Enter text to encrypt:")) key=13 enc="" for i in range (len(a)): char=a[i] if(char.isupper()): enc += chr((ord(char) + key-65) % 26 + 65) else: enc += chr((ord(char) + key-97) % 26 + 97) print("Encrypted Text is:") print(enc)