blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
af3d3e798e2d845a7024b3a3acf949f24e87b447 | DAVMARROS/AndroidPython | /CRUD.py | 1,950 | 4.25 | 4 | """
Nombre: CRUD.py
Objetivo: muestra la operacion de la estructura de datos llamada lista
Autor:
Fecha: 07/11/2019
"""
lista = []
def insetarItem():
item = str(input("Ingrese el elemento a insertar: "))
lista.append(item)
pausa()
def buscarItem():
item = str(input("Ingrese el elemento a buscar: "))
if item in ... |
272acbf2c87c73f0eee2243c6a12978cdb28a53f | tinghaoMa/python | /demo/base/lesson_10.py | 2,118 | 4.28125 | 4 | #!/user/bin/python
# -*- coding: utf-8 -*-
"""
迭代器
可以直接作用于for循环的数据类型有以下几种:
一类是集合数据类型,如list、tuple、dict、set、str等;
一类是generator,包括生成器和带yield的generator function。
这些可以直接作用于for循环的对象统称为可迭代对象:Iterable。
"""
from collections import Iterable, Iterator
# 可以使用isinstance()判断一个对象是否是Iterable对象:
print(isinsta... |
7b1199ca5d2309e5afec6865719c7aed17e8d129 | flacogabrielc/Selenium_Python | /Clase 2/entrada.py | 238 | 3.78125 | 4 | edad = input("Ingrese una edad: ")
print('su edad es ' +edad)
edad = int(edad)
print("su edad es " + str(edad))
print(edad + 5)
#print(edad +5) -> esto da error por tipo de datos debo castearla a int
print('hola mundo ' + 'hola planeta')
|
1126a543151da9ae36e32de62f0cd902e4bfcaf0 | MichaelJWest/Project-Euler | /problem5.py | 390 | 3.59375 | 4 | #2520 is the smallest number that can be divided by each of the numbers from 1 to
#10 without any remainder.
#What is the smallest positive number that is evenly divisible by all of the numbers
#from 1 to 20?
def gcd(a, b):
return b and gcd(b, a % b) or a
def lcm(a, b):
return a * b / gcd(a, b)
multiple = 20
fo... |
14a287cb0d0731cfd0587877c694c73430254269 | manmeet-22/Python-Questions | /Questions/Q21.py | 491 | 3.546875 | 4 | class abc:
class_var = 0
sal=0
name=""
dept=0
def disp(self):
print(self.name ,self.sal, self.dept )
def total(self): return abc.class_var
def __init__(self,name,sal,dept):
abc.class_var+=1
self.name = name
self.sal = sal
self.dept = dept
obj1=abc("A",... |
2cc454a67f43689d3131d30aa52f264bdf2d1b2b | kg55555/pypractice | /Part 1/Chapter 10/exercise_10.5.py | 211 | 3.84375 | 4 | while True:
answer = input("Why do you like programming? Enter 'q' to quit\n")
if answer == 'q':
break
with open('r_programming', 'a') as file_object:
file_object.write(answer + "\n") |
75568dfd7d28c9d53fb36385235ef32e2cc3a0c8 | bytoola/python2 | /m4 flow contral/basic if else.py | 400 | 3.734375 | 4 | '''
num = eval(input("Input number: "))
if num >= 60 :
print('passed!')
if num <80:
print("so so!!")
else:
print("good!")
else:
print('failed')
'''
'''
coverage,area = eval(input('please input two number'))
count = area // coverage
count += 0 if area % coverage == 0 else 1
unit = 'can' ... |
d2d111e80881166194cc0f67fda999f3758f0e18 | gabriellaec/desoft-analise-exercicios | /backup/user_259/ch150_2020_04_13_20_22_24_375515.py | 130 | 3.671875 | 4 | def calcula_pi(n):
radicando = 0
for i in range(1,n+1):
radicando+=6/(i**2)
pi = radicando**0.5
return pi |
947c5e9e0f7b784ae37e6d218cb6b083ad7b4c0f | mjvelota/OPS435-Lab3 | /lab3a.py | 441 | 3.609375 | 4 | #!/usr/bin/env python3
# return_text_value() function
#Author ID: mjvelota
def return_text_value():
name = 'Terry'
greeting = 'Good Morning ' + name
return greeting
# return_number_value()
def return_number_value():
num1 = 10
num2 = 5
num3 = num1 + num2
return num3
# Main Program
if __name__ == '__main... |
9299be647b657196ed1bef9b9c35a1967d35f340 | y2sman/algorithm_solve | /baekjoon/[2] silver/1541_잃어버린 괄호/1541_잃어버린 괄호.py | 848 | 3.515625 | 4 | import re
tmp = input()
result = re.split('[+-]',tmp)
locate = 1
for i in range(len(tmp)):
if tmp[i] == "+":
result.insert(locate,tmp[i])
locate += 2
elif tmp[i] == "-":
result.insert(locate,tmp[i])
locate += 2
locate = 0
while "+" in result:
if result[locate] == "+":
tmp = int(result[loca... |
191ced8c7883f926988b1d3eb0e96380fb28dea9 | AnushaPalla/python-ICP1 | /Firstprogram.py | 329 | 4.03125 | 4 | a=int(input("enter first number"))
b=int(input("enter second number"))
print("addition of 2 numbers is:",a+b)
print("hello world")
print("subtraction of 2 numbers is:", a-b)
print("multiplication:",a*b)
print("divison", a/b)
print("modulous", a%b)
string1=input("enter a string")
len=0
for i in string1:
len=len+1
pr... |
d90888975f2b30ffceebe385514b6a69d5ffbcc5 | svonme/python | /basis/sorted.py | 377 | 3.90625 | 4 | # -*- coding: utf-8 -*-
#
# @Time : 2018/4/8 18:13
# @Author : svon.me@gmail.com
#
# sorted 数据排序
def sort(value):
return abs(value)
if __name__ == '__main__':
arr = [1, 2, 3, 1, 6, 9, 10]
# 默认排序
arr2 = sorted(arr)
# 数组倒序
arr2.reverse()
# 指定排序方式
arr3 = sorted(arr, reverse=True)
... |
bd82cd284a8764760ad2a5b291aeeaf3e9ea5478 | theissn/py-tic-tac-toe | /main.py | 1,795 | 3.8125 | 4 | class Board():
def __init__(self):
self.list = {}
self.board = []
self.turn = 'x'
self.win_combs = [[0,1,2], [3,4,5], [6,7,8], [0,3,6], [1,4,7], [2,5,8], [0,4,8], [2,4,6]]
self.create()
def create(self):
num = 0;
for i in range(3):
... |
1c1af8ca3380f957c2aa8e2c1bbbe7a00998f230 | annabelflook/mr_calculator | /calculator_utils.py | 1,437 | 3.5625 | 4 | import re
from mendeleev import element
from collections import Counter
def split_into_brackets(molecule):
split_by_brackets = re.findall(r"(\(([^()]+)\)*)([0-9]*)|([A-Z][a-z]*)(\d*)", molecule)
return split_by_brackets
def stoichiometry(molecule):
counted = Counter()
split = split_into_brackets(mol... |
da8a5b72ef2dfd117c532d6e19a2a2c5bc9ce986 | smazhuvan/repl-works | /main.py | 230 | 3.921875 | 4 | listA = [24, 56, 89, 0, 15, -4, 25, -8, 125, -98]
def small_num(numbers):
smallest_num = numbers[0]
for num in numbers:
if num < smallest_num:
smallest_num = num
return(smallest_num)
print(small_num(listA))
|
3d2189b436a12d220fd330bb393f8565d6629e1c | aditjain588/Leet-Code-problems | /Remove Duplicates from Sorted Array.py | 265 | 3.59375 | 4 | class Solution:
def removeDuplicates(self, nums: List[int]) -> int:
n = 0
while n <= len(nums)-3:
if nums[n] == nums[n+2]:
nums.remove(nums[n])
else:
n += 1
return len(nums) |
8a0cfbf7618f11a32ab007843c0ea28c0ac2671e | tanyafish/my-first-blog | /myfirstthings.py | 151 | 3.765625 | 4 | def hi(name):
print("hallo " + str(name) + "!")
girls = ["Alice", "Barb", "Callie", "Dave"]
for name in girls:
hi(name)
print("next girl")
|
4b1ad65dcda0f9fff7987bceabca33a8ffe7e8cf | rskarp/cs251proj9 | /data.py | 7,567 | 3.84375 | 4 | # Riley Karp
# data.py
# 2/20/2017
import sys
import csv
import numpy as np
#class that can read a csv data file and provide information about it
class Data:
def __init__(self, filename = None):
#creates a Data object by initializing the fields and reading the given csv file
#create and initialize fields
s... |
91b646ec88ed305b5155948d456b728545760a11 | k-harada/AtCoder | /ARC/ARC105/A.py | 632 | 3.6875 | 4 | def solve(a, b, c, d):
s = a + b + c + d
if s % 2 == 1:
return "No"
h = s // 2
if a == h:
return "Yes"
elif b == h:
return "Yes"
elif c == h:
return "Yes"
elif d == h:
return "Yes"
elif a + b == h:
return "Yes"
elif a + c == h:
... |
fde0936bc20ee946da14f13de151a66d164db1db | udaybhaskar578/Hacker-Rank-Challenges | /Code 30/CandyFillingBot.py | 889 | 3.765625 | 4 | # Question : https://www.hackerrank.com/contests/w30/challenges/candy-replenishing-robot
#!/bin/python3
import sys
def isShortOfCandies(candies):
if candies < 5:
return True
return False
def refillCandies(x):
global candies
candies = candies+x
def noOfCandiesRefilled(left,total,curr... |
4e6ade4462505f32531c458fbf3fee6052a57e5a | edwinevans/HarryPotterTerminalQuest | /Pigwarts/Review/numbers_fiz_hundred.py | 108 | 3.9375 | 4 | for number in range(1, 101):
if number % 3 == 0:
print "Fiz"
else:
print number
number = number + 1
|
c7b19216e5f6ca6b542b5edd4dfb8b816ab3ef5a | DivyaJyotiDas/Hackerrank | /counting-valleys.py | 1,125 | 3.640625 | 4 |
# Complete the countingValleys function below.
def countingValleys(str):
bal_factor = 0
start = ''
mountain = 0
valley = 0
for i in str:
if bal_factor == 0:
start = i
if start.lower() == 'u':
bal_factor += 1
mountain += 1
... |
de7a3d9295a0fe974b8c8c90bd52c7ae8e78d604 | MalAnna/geekbrains-homework | /algorithms python/lesson1/task1.py | 298 | 3.734375 | 4 | a = int(input('Введите трехзначное число: '))
b = a // 100 + a % 100 // 10 + a % 10
c = (a // 100) * (a % 100 // 10) * (a % 10)
print(f'Сумма цифр трехзначного числа: {b}, произведение цифр трехзначного числа: {c}')
|
3ffaeadc6a0651974a6df33f382e4b85a100da44 | lordjavac/6-Nimt | /nimt6/tests/test_card.py | 1,962 | 4.03125 | 4 | import unittest
from ..card import Card
class TestCard(unittest.TestCase):
""" Test the Card class to verify that it functions properly. """
def test_rank(self):
''' Verify that we can create a card with a rank from 1 to 104. '''
for r in range(1, 105):
with self.subTest(msg=None):... |
590d2bf17751f4bc312308293d69d0c3259436e0 | erjan/coding_exercises | /difference_between_maximum_and_minimum_price_sum.py | 2,177 | 3.84375 | 4 | '''
There exists an undirected and initially unrooted tree with n nodes indexed from 0 to n - 1. You are given the integer n and a 2D integer array edges of length n - 1, where edges[i] = [ai, bi] indicates that there is an edge between nodes ai and bi in the tree.
Each node has an associated price. You are given an i... |
2c5af649506e4beddf9ea6cbb81c0df2498e5ce4 | progh2/highschool-python | /VI. 클래스/02. 클래스와 객체/05. 연산자 오버로딩/VI. 02. 05. OperatorOverloading.py | 632 | 3.921875 | 4 | class MyNumber:
def __init__(self, val):
self.val = val
def __add__(self, other):
print("__add__")
return MyNumber(self.val + other.val)
def __sub__(self, other):
print("__sub__")
return MyNumber(self.val - other.val)
def __mul__(self, other):
print("__... |
45e225b315b5e181669c4c29db107c24f0a2a55a | suthirakprom/Python_BootcampKIT | /week02/ex/ex/54_matrix_addtion.py | 825 | 3.796875 | 4 | def matrix_addition(m1,m2):
k = l = m = 1
res = [[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]]
print("MATRIX 1:")
for i in range(4):
for j in range(4):
print(m1[i][j], end=' ')
if l % 4 == 0:
print("")
l += 1
print("")
print("MATRIX 2:")
... |
fb781a51e2f3add46ab504d797f0a21981a5295a | cheol-95/Algorithm | /Python/018. 네트워크/Network.py | 320 | 3.640625 | 4 | def solution(n, computers):
answer = 0
for i in range(len(computers)):
if answer < computers[i].count(0):
answer = computers[i].count(0)
return answer
n, computers = 3, [[1, 1, 0], [1, 1, 0], [0, 0, 1]]
# n, computers = 3, [[1, 1, 0], [1, 1, 1], [0, 1, 1]]
print(solution(n, computers)) |
176892863743bf66cf09446d35d2d04f472b395b | nyeo2/Nand2Tetris-Assembler | /binConverter.py | 396 | 3.609375 | 4 | def dectobin(dec):
if type(dec) != int:
dec = int(dec)
final = ''
while dec != 0:
final = str(dec % 2) + final
dec //= 2
return final
def bintodec(bina):
binal = []
final = 0
for char in bina:
binal.append(int(char))
expt = 0
while binal:
... |
84b522e4ce3f5d9486693bb97122dc3a35a41c34 | erba994/ftyers.github.io | /2018-komp-ling/practicals/tokenization/dictionary_extractor.py | 506 | 3.53125 | 4 | def dict_extract(filename):
with open(filename, "r", encoding="utf-8") as f:
l = f.readlines()
dict = []
for line in l:
if line[0].isdigit():
s = line.split("\t")
dict.append(s[1])
dict = set(dict)
return dict
if __nam... |
860424cb9d44326930bd2a91325e626556be209a | Ahnseungwan/Phython_practice | /2021.01/1.2/1.2 세트.py | 690 | 3.609375 | 4 | # 세트 (집합)
# 중복 안됨, 순서 없음
my_set = {1,2,3,3,3}
print(my_set)
java = {"유재석", "김태호", "양세형"}
python = set(["유재석", " 박명수"])
# 교집합 (java 와 phyton 을 모두 할 수 있는 개발자)
print(java & python)
print(java.intersection(python))
# 합집합 (java 도 할 수 있거나 python 할 수 있는 개발자)
print(java | python)
print(java.union(python))
# 차집합 (java 할 수 ... |
d4a4f0d31e0ab45f9df48d71e1729ac8bb872655 | zhang435/Database | /assignment8/shortestCompletingWord.py | 1,676 | 3.609375 | 4 | import collections
class Solution:
# def shortestCompletingWord(self, licensePlate, words):
# """
# :type licensePlate: str
# :type words: List[str]
# :rtype: str
# """
# res = ""
# dic = collections.Counter(
# [i.lower() for i in licensePlate if... |
2115a8b09b09e5dbc3973af954568ce4f8337ee0 | mbhushan/python | /fn_local.py | 140 | 3.625 | 4 | x = 50
def func(x):
print 'current value of x: ', x
x=5
print 'value changed to: ', x
func(x)
print 'value of x is still: ',x
|
a0cbb2ca10dad0e5626a9bed52b9f070130d9ddd | kapc/problems | /Arrays/maximum_swap.py | 1,279 | 4.25 | 4 | #! /usr/env/python
"""
Maximum Swap
Difficulty:Medium
Given a non-negative integer, you could swap two digits at most once to get the maximum valued number. Return the maximum valued number you could get.
Example 1:
Input: 2736
Output: 7236
Explanation: Swap the number 2 and the number 7.
Example 2:
Input: 9973
Outp... |
dea14f927da89441fabe3800f7d674adcc65420e | giometry/Data-Analysis-Snippets | /Obfuscation/obfuscation.py | 1,336 | 4.25 | 4 | # -*- coding: utf-8 -*-
"""
Code to obfuscate dataframe
- Obfuscates numeric columns based on key
- Obfuscates column names
- Changes specified dataframe with obfuscated values
Created on 3/30/2021
@author: Giovanni R Budi
"""
from string import ascii_lowercase
import itertools
def obfuscate_numeric_values(dataframe... |
afee872e50b3918d15d0d542180bf36175564ef0 | RejaneCosta/Recuperacao02 | /soma/soma.py | 263 | 3.5625 | 4 | class Soma:
@staticmethod
def soma_numeros(numeros):
resultado = 0
for numero in numeros:
resultado = resultado + numero
return resultado
numeros = [1, 2 ,3, 4]
resultado = Soma.soma_numeros(numeros)
print(resultado)
|
f2f4d7e9c81141b3c5a1d053bc31f0c03787d546 | cafecinqsens/PY | /Chapter11_176_1.py | 600 | 3.96875 | 4 | import pandas as pd
data = {
'age': [23, 43, 12, 45],
'name':['민준', '현우', '서연', '동현'],
'height':[175.3, 180.3, 165.8, 172.7]
}
#사전형에 대해서는 학습하지 않았는데 리스트형과 거의 비슷함
# 따옴표에 있는 스트링은 일반적으로 'key'라고 하고 콜론(:) 다음에 나오는 리스트형의 데이터를 'value' 라고 함
x = pd.DataFrame(data, columns=['name', 'age', 'height'])
print(x)
'''
... |
baa7658ff220a20239c55c7157ff792b9c88eeb1 | aminhp93/python_fundamental | /names_part2.py | 749 | 3.53125 | 4 | def names(users):
j = 0
while j < len(users.values()):
arr1 = users.values()[j]
arr2 = users.keys()[j]
print arr2
k = 0
while k < len(arr1):
name = " ".join(arr1[k].values())
count = 0
for i in name:
if i != " ":
count += 1
print str(k+1) + " - " + name + " - " + str... |
95c8eb90a5c30642bb1ad30fadc6e78e8ddac566 | vickispark/pyBasics | /app5.py | 469 | 4.15625 | 4 | is_male = True
is_tall = False
if is_male:
print("you are a male")
else:
print("not a male")
if is_male and is_tall:
print("male or tall")
if is_tall:
print("tall")
if is_male:
print("male")
if is_male and is_tall:
print("both")
else:
print("either one")
el... |
4eab69d9842dde85982e3d7c110934773594acf4 | pkhanna104/beta_single_unit | /un2key.py | 210 | 3.65625 | 4 |
def convert(unit):
if len(unit) == 2:
key = 'sig00'+unit
elif len(unit) == 3:
key = 'sig0'+unit
elif len(unit) == 4:
key = 'sig'+unit
else:
raise
return key |
2f89765e2046b8611441fc8a601c0b7a669c8eb5 | jimmybae/sw-expert-academy-python-code-problem | /Beginner/6220.py | 135 | 3.8125 | 4 | a = input()
if a.islower():
print("%s 는 소문자 입니다." % a)
elif a.isupper():
print("%s 는 대문자 입니다." % a) |
963b073fa116b599020ebd5d1dd2c4a7dea7683e | jsw13/Magical-Maze-Madness | /controllers/game_controller.py | 2,784 | 3.828125 | 4 | """ This module contains the GameController class """
import pygame
import pygame.locals
from views.game_view import GameView
class GameController:
""" Controller to handle the movement of the player. """
def __init__(self, maze, window, time):
""" Initializes private attributes.
Arg... |
47fba521c87123d31d1ce695f5353848c9ac4365 | euzin4/gex003_algprog | /material/respostas_exercicios/lista3/exe7.py | 294 | 4.0625 | 4 | n1 = int(input("Digite o número 1: "))
maior = n1
menor = n1
n2 = int(input("Digite o número 2: "))
if n2 > maior:
maior = n2
if n2 < menor:
menor = n2
n3 = int(input("Digite o número 3: "))
if n3 > maior:
maior = n3
if n3 < menor:
menor = n3
print("Maior:", maior, "| Menor:", menor) |
b0ecc9803eb1a0f693530d10021f58425fbdd279 | lixiang2017/leetcode | /leetcode-cn/2331.0_Evaluate_Boolean_Binary_Tree.py | 673 | 4.03125 | 4 | '''
执行用时:56 ms, 在所有 Python3 提交中击败了79.52% 的用户
内存消耗:15.8 MB, 在所有 Python3 提交中击败了36.15% 的用户
通过测试用例:75 / 75
'''
# 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 Solu... |
d873c597bcdeaa09f6e26e7202c0f3d6da884ebb | ursstaud/PCC-Basics | /album.py | 563 | 4 | 4 | def make_album(artist_name, album_title, track_count = None):
"""Returns a dictionary describing an album"""
album = {'artist name': artist_name.title(), 'title': album_title.title()}
if track_count:
album['track_count'] = track_count
return album
beatles_info = make_album('the beatles', 'the white album'... |
c6503086d33d1d99122ed3fd6df2eaa06e7f934c | shuxiaokai/favv | /streamlit/app/app_car_accidents/app.py | 3,508 | 3.609375 | 4 | import streamlit as st
import pandas as pd
import numpy as np
import pydeck as pdk
import plotly.express as px
DATA_URL = "./app_car_accidents/Motor_Vehicle_Collisions_-_Crashes.csv"
@st.cache(persist=True)
def load_data(nrows):
data = pd.read_csv(DATA_URL, nrows=nrows, parse_dates=[['CRASH_DATE', 'CRASH_TIME']])... |
a71ad4149596f6cafcf29bcf06dffbea10d7bbe2 | orangeduice/cubesat_orbit | /cubsat3.py | 3,798 | 3.734375 | 4 | import sqlite3
from sqlite3 import Error
import requests
html = 'https://www.celestrak.com/NORAD/elements/cubesat.txt'
name = input("Enter Name: ")
DATA = ["","","","","","","","","","","","","","","","","","",""]
TLESIZE = [[0,23],[26,30],31,[33,34],[35,37],[38,40],[42,43],[44,55],[57,66],[68,75],[78,84],[88,... |
b5d6e17221eb7f62196a18fdbe0f92839c253a8b | symbolr/python | /demo/6.py | 101 | 3.5 | 4 | def fact(n):
if n==1:
return 1
return n*fact(n-1)
print(fact(1))
print(fact(5))
print(fact(100)) |
36af890a5e42ca1bfb1d165f02e8f2ede632f871 | J-Weaver0405/PingRequest | /exercise.py | 1,384 | 4.0625 | 4 | import random
import string
# uchars = uppercase
# lchars = lowercase
# dchars = digits
# schars = punctuation or special
def get_random_string(uchars = 2, lchars = 6, dchars = 1, schars = 1):
# Generates a 10 characters long random string
# with 3 upper case, 3 lowe case, 2 digits and 2 special character... |
cc88b6a7b933aad1ae236bb3db78a6d51083d31f | Clair-s-Personal-REPL/GraphImplementation | /main.py | 9,471 | 4.34375 | 4 | # The main purpose of this application is to take in a graph, and to find a shortest path from one node to another node
# This program uses the pseudocode from this video: https://www.youtube.com/watch?v=oDqjPvD54Ss
# Had to make a few changes from the pseudocode since I am using an object here to implement the graph
... |
cd79c28aaacf20d34a3c164ac1b7e471025f7a0f | 1huangjiehua/ArithmeticPracticalTraining | /201826404105黄杰华算法实训/任务一(二分查找(递归)).py | 716 | 3.578125 | 4 | def erfenfa(lis, left, right, num):
if left > right:#递归结束条件
return -1
mid = (left + right) // 2
if num < lis[mid]:
right = mid -1
elif num > lis[mid]:
left = mid + 1
else:
return mid
return erfenfa(lis, left, right, num)
#这里之所以会有return是因为必须要接收值,不然返回None
#回溯到最后一层... |
1c3758e6667396d7c9cf1814bfa313eebbf91e95 | ahtornado/study-python | /day11/class1.py | 1,140 | 4.375 | 4 | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author :Alvin.Xie
# @Time :2017/11/6 22:41
# @File :class1.py
# 类定义
class People:
name = ''
age = 0
_weight = 0
_grade = 0
def __init__(self, n, a, w, g):
self.name = n
self.age = a
self._weight = w
self._grade... |
a1793eec903a01aede99aba88db21680268661d1 | kishoraen1/kishore-python | /Coditional.py | 276 | 4.03125 | 4 | a = input("Enter First Number: ")
b = input("Enter Second Number: ")
while a is int and b is int:
if a == b:
print('Same Number')
elif a > b:
print ("Greater")
elif a < b:
print ("Smaller")
else:
print ("Something Wrong")
|
434416a3e86d7f1bd1a64f7d7716c26b9d3f585e | RamiJaloudi/Python-Scripts | /Good_Examples/Interest/scrape_read_csv_lines_str_object.py | 3,501 | 3.5625 | 4 | # Python_Page_Spider_Web_Crawler_Tutorial
# from https://www.youtube.com/watch?v=SFas42HBtMg&list=PLa1r6wjZwq-Bc6FFb9roP7AZgzDzIeI8D&index=3
# Spider algorithm.
# You need to EXECUTE the file in Shell, e.g. execfile("nytimes/scrape.py")
# First open cmd. Then cd C:\Users\Joh\Documents\Python Scripts\Web Crawler Proje... |
d194fde701f467e04018b42b607a16765ab04df7 | philhoel/MiniGames | /Python/rps.py | 1,272 | 3.9375 | 4 | import random
c = "sad"
print(c.capitalize())
def cpu():
a = random.randint(1,4)
if a == 1:
return "Rock"
elif a == 2:
return "Paper"
else:
return "Scissors"
def player():
b = input("Enter Rock, Paper or Scissors: ")
#print(b.capitalize())
if (b.capitalize() != "R... |
cbc74d74d852d3eb35f90075180374acb092aa4f | it-college-n1915/cheatseat | /script/time.py | 427 | 3.890625 | 4 | #!/usr/bin/python
import time
seconds = int(input("何秒測りますか?分で測りたいときは:0 "))
if seconds == 0:
minute = int(input("何分測りますか? "))
count = minute * 60
for i in range(count):
print(count)
count -= 1
time.sleep(1)
else:
for i in range(seconds):
print(seconds)
seconds -=... |
7a7b0044722db4ed830bd82877d2d068c1ce2f65 | fm75/performance | /cpu.py | 537 | 3.625 | 4 | #! /usr/bin/python3
import timeit
def wrapper(func, *args, **kwargs):
def wrapped():
return func(*args, **kwargs)
return wrapped
def doitn(n):
t = 0
for i in range(n + 1):
t += i
return t
def doit():
experiments = [1000, 10000, 100000, 1000000]
funcs = list()
for ... |
e22aeffb0dcfbb95a00468eda8f664c9aab79bc3 | Farzana0627/Python-Practice | /Array_List/array1.py | 409 | 3.90625 | 4 | from array import *
print("Insertion")
array1 = array('i', [10,20,30,40,50])
array1.insert(2,60)
for x in array1:
print(x)
print("Deletion")
array1 = array('i', [10,20,30,40,50])
array1.remove(40)
for x in array1:
print(x)
print("Search")
array1 = array('i', [10,20,30,40,50])
print (array1.index(40))
print("... |
67be17d583975e2ea74c0205b66ebf7593243cfd | DRTeam35/HereWeGo | /2019-2020/Tests/Motors and Camera/Camera_VideoStream_Image_Save.py | 1,669 | 3.71875 | 4 | # Python program to save a
# video using Test-OpenCV
import cv2
import os
# Create an object to read
# from camera
video = cv2.VideoCapture(0)
# We need to check if camera
# is opened previously or not
if (video.isOpened() == False):
print("Error reading video file")
# We need to set resolutions.
# so, convert t... |
07e3a3644aa3f1de90e913b8171aea6af3b156ef | DeanHe/Practice | /LeetCodePython/AddTwoNumbersII.py | 1,632 | 4.03125 | 4 | """
You are given two non-empty linked lists representing two non-negative integers. The most significant digit comes first and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.
You may assume the two numbers do not contain any leading zero, except the number 0 itself... |
8998a671e75cd11d0063e4285f0b980411132128 | ryanpennings/workshop_swinburne_2021 | /examples/118_euler_angles.py | 699 | 4 | 4 | """Example: Rotations from euler angles, rotate an object based on 3 euler angles.
"""
from compas.geometry import Rotation
# euler angles
alpha, beta, gamma = -0.156, -0.274, 0.785
static, axes = True, 'xyz'
# Version 1: Create Rotation from angles
R1 = Rotation.from_euler_angles([alpha, beta, gamma], static, axes)
... |
b27c9aafd48cc36d2e40359e79b3dc0f953bca06 | georgeallbert/git-projetos | /Programas python ~ George Albert/078.py | 574 | 3.84375 | 4 | from time import sleep
print('\033[1;32m='*50)
print(f'{"NÚMEROS DIGITADOS":^50}')
print('='*50)
overflow = list()
for c in range(0,5):
overflow.append(int(input('\nDigite um número: ')))
sleep(1)
print('\033[1;33m='*50)
print(f'{"POSICÕESE E VALORES":^50}')
print('='*50)
for p, n in enumerate(overflow):
pr... |
f33495a88704ae07b8bce6cb4c8447aa24c65115 | viiicky/Problem-Solving | /LeetCode/1688.Count_of_Matches_in_Tournament.py | 584 | 3.6875 | 4 | import unittest
class Solution:
def numberOfMatches(self, n: int) -> int:
total_matches_played = 0
teams_advanced = n
while teams_advanced > 1:
matches_played = teams_advanced // 2
total_matches_played += matches_played
teams_advanced = matches_played +... |
fb55d0661eecf4d2f1d773a83f8751a2b85f9cdb | Nora-Wang/Leetcode_python3 | /None Algorithm/415. Add Strings.py | 1,017 | 3.71875 | 4 | Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2.
Note:
The length of both num1 and num2 is < 5100.
Both num1 and num2 contains only digits 0-9.
Both num1 and num2 does not contain any leading zero.
You must not use any built-in BigInteger library or convert the inp... |
afcf06341e131c94cbb2f90bcfbb33f6b9b718a4 | brijesh-989/ITW-lab-1 | /Assignment 4/10.py | 265 | 4 | 4 | user_in=input("enter a string : ")
count=0
cint=0
for i in user_in:
if i.isupper() == True:
count+=1
elif i.islower() == True:
cint+=1
print(f"No of upper case characters are : {count}")
print(f"No of upper lower characters are : {cint}") |
f3c96c97e12fc5526394ab01220ec152e0406839 | ArunRamachandran/ThinkPython-Solutions | /Chapter5/simple_recursion.py | 149 | 3.78125 | 4 | # attempt to implement a simple recursion fn
def count_down(n):
if n <= 0:
print "Blastoff !"
else:
print n
count_down(n-1)
count_down(5)
|
4275d941634a6254ab7579a07920dbb5c3ed5eef | mohanalearncoding/Leetcodepython | /basball.py | 505 | 3.5625 | 4 | from typing import List
def calPoints( ops: List[str]) -> int:
arr=[]
s1=0
for i in range(len(ops)):
if ops[i]=='C':
arr.pop()
elif ops[i]=='D':
s1=int(arr[-1])*2
#print(s1,"s1")
arr.append(s1)
elif ops[i]=='+':
... |
04f2430b75a0d7cfac88f04997bbcf34a4b38044 | sftth/portfolio | /language/python/path/5_get_file_extesion.py | 235 | 3.84375 | 4 | # reference: https://www.geeksforgeeks.org/how-to-get-file-extension-in-python/
import pathlib
# function to return the file extension
file_extension = pathlib.Path('my_file.txt').suffix
print("File Extension: ", file_extension) |
6e33df1d99ff6b74ea342e0d0441e2b6ccc2f4d8 | Benji-Huang/midnight-rider | /main.py | 7,439 | 3.5 | 4 | # main.py
# Midnight Rider
# A text-based adventure game
import random
import sys
import textwrap
import time
INTRODUCTION = """
WELCOME TO MIDNIGHT RIDER.
WE'VE STOLEN A CAR, WE NEED TO GET IT HOME.
THE CAR IS SPECIAL.
WE CAN'T LET THEM HAVE IT.
ONE GOAL: SURVIVAL... AND THE CAR.
REACH THE END BEFORE THE MEN GON ... |
bbbaa7c0d8dd42ec802f72c2a07b7fdd908815ba | MANISH762000/Hacktoberfest-2021 | /Python Library/Pandas/indexing,selecting.py | 1,211 | 4.25 | 4 | import pandas as pd
Data = pd.read_csv('train.csv')
# The Native way
#it actually offers quite simple ways
#like if want to select a column(Fare)
print(Data.Fare.head()) # or Data["Fare"]
#if i want to be more specific
print(Data.Fare[0]) # or Data["Fare"][0]
#### INDEXING IN PANDAS ####
#1- Index Based Selecti... |
21f3daa1b4b2f773c98e6b3912e2fef91fc7882c | jeremytrindade/python-brothers | /PyCharm/CursoemVideo/desafio004.py | 244 | 3.734375 | 4 | n = input('digite algo: ')
print(type(n))
print('é um valor numerico? ', n.isnumeric())
print('é um valor alphanumerico? ', n.isalnum())
print('é um valor alpha? ', n.isalpha())
print('é um valor alpha em letras maiusculas? ', n.isupper())
|
d7f97fbffe64b6b7fd9d5304e22f23e8c0ce52ba | dermoth/AdventOfCode2017 | /Day3/Day3.py | 2,204 | 4.09375 | 4 | #!/usr/bin/env python3
import math
# Given an array of height n:
# 1. For odd n, the distance from 1 for n**2 can be calculated
# as (n/2, -n/2)
# 2. For even n, the distance from 2 for n**2 can be calculated
# as (-n/2, n/2)
#100 91
# 64 63 62 61 60 59 58 57
# 37 36 35 34 33 32 31... |
98f10244cd39f97e3257d05a09a39e49ece0bc7e | letrout/music | /lib/scale.py | 6,827 | 3.78125 | 4 | """
scale.py
A class to hold a collection of tones defined as a scale
(ie all tones within an octave range).
The scale is defined by relative distances between each of the tones and the
root.
The base structure of the scale is provided by degree_tones. This is a
dictionary of degree: tone, where 'degree' is the degree... |
b053eb9dade4350e346c3c3198bd3708a62fb0e3 | page2me/Advent-of-Code-2021 | /Day-5/binary_boarding.py | 1,003 | 3.75 | 4 | #!/usr/bin/env python3
# Advent of Code 2020 Solution - Python
def seat_id_from_boarding_pass(boarding_pass):
row = 0
pass_row = boarding_pass[:7]
for char in pass_row:
row *= 2
if char == 'B':
row += 1
column = 0
pass_column = boarding_pass[7:]
for char in pass_col... |
a8dfc870c4334eb65a35eb9c52a215b031ab361c | GirlCoder99/Dice-Simulator | /dice.py | 667 | 3.78125 | 4 | import tkinter
import random
root = tkinter.Tk() #Accessing TK
root.geometry("700x450") #Creating Interface of Size 700 * 450
root.title("Roll Dice")
label = tkinter.Label(root, font=("times", 200)) #increases the size of the GUI Elements
def roll():
dice = ['\u2680', '\u2681', '\u2682', '\u2683', '\u268... |
2bbf8aa278c38a358ce9ac8b82b74941cdbc71ff | deblina23/BasicPython | /scripts/exercise40.py | 298 | 4.03125 | 4 | #!/usr/bin/env python3
print("Problem:")
print(" Write a Python program to compute the distance between the points (x1, y1) and (x2, y2). ")
print("Solution:")
import math
def calculateDistance(x1,y1,x2,y2):
return math.sqrt((abs(x2-x1)**2)+(abs(y2-y1)**2))
print(calculateDistance(4,0,6,6))
|
b3e62ef93d22b3d4427ed865cfccbb0b617ebe02 | abbenteprizer/updating-graph | /updating_graph.py | 3,520 | 3.71875 | 4 | import csv
import argparse
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
'''
This programs reads messages from a file and displays filtered data in graph.
Can automatically update graph depending on the graph-mode chosen as input
'''
### add argument to program ###
parse... |
f2196d413be060b43aecfaab025ef92cc9ad855d | bjk17/AoC_2019 | /03/Part_one.py | 1,053 | 3.6875 | 4 | #!/usr/bin/env python
def wpath_to_vset(wpath):
# wire path to "visited positions" set
vset = set()
pos = [0, 0]
for steps in wpath.split(","):
direction, length = steps[0], int(steps[1:])
if direction == 'U':
vset.update([(pos[0], pos[1] + step) for step in range(1, length... |
021e9e0bfe226c359b8fb50d2760187c8c6d8259 | 19272/python-chessgame | /board.py | 2,480 | 3.609375 | 4 | from pieces import *
class ChessBoard:
def __init__(self):
self.selected = None
self.legal_moves = []
self.turn = "white"
self.board = {}
for row in range(8):
for column in range(8):
self.board[(row, column)] = None
for column in range(8):
self.board[(column, 1)] = Paw... |
c924fe5e7cc149faaa6f6a10b6bc19e17a5b8499 | nikhilgajam/Python-Programs | /Gcd program in python.py | 329 | 3.625 | 4 | def gcdp(num1, num2):
i = gcd = 1
while i <= num1 and i <= num2:
if num1 % i == 0 and num2 % i == 0:
gcd = i
i += 1
return gcd
def gcd_rec(num1, num2):
if num2 != 0:
return gcd_rec(num2, num1 % num2)
else:
return num1
print(gcdp(1... |
52d25c434579b983c042aad5864dabb51a0c6086 | llcawthorne/old-python-learning-play | /Algorithms/make_tree.py | 1,684 | 3.78125 | 4 | #!/usr/bin/env python3
# Make tree from inorder and postorder traversal
# Implemented this for fun
# Follows the Problem 4.4.7 Algorithm and seems to work
class SimpleNode:
def __init__(self,value):
self.value = value
self.left = None
self.right = None
def printVal(self):
p... |
72961f138b75ff5c6212fbbd020884c9679da024 | lgc13/LucasCosta_portfolio | /python/RingOfFire_project/data.py | 2,410 | 3.59375 | 4 | import itertools
def Rules():
CARD_ACTIONS = [
{
'rank':'Ace',
'rule': "Waterfall..Everyone Drinks"
},
{
'rank':'2',
'rule': "F**k you: Tell someone to drink"
},
{
'rank':'3',
'rule': "F**c me: You drink... |
0d5afa45678e380a1b74a535d5e9848686edb301 | AppoPi/Projects | /Python/shuffling a list.py | 1,266 | 4.03125 | 4 | import random
from random import shuffle
def library(list):
# Slice list so that function doesn't alter parameter list
newlist = list[:]
# Call random library shuffle to randomize list order
shuffle(newlist)
return newlist
# Perfectly alternate from each half of the list
def faro(list):
r = []
# Divide list in... |
7fc957f0622c6486adbd6230d15aca2eafc42368 | raselkarim7/Coursera-DS-Algorithm-Specialization- | /Algorithmic-Toolbox/week2/gcd.py | 484 | 3.578125 | 4 | # Uses python3
import sys
def gcd_naive(a, b):
if (b > a):
a, b = b, a
if (b == 0 or a == 0):
return 1
while (a % b !=0 ):
c = a%b
a,b = b, c
current_gcd = b
return current_gcd
if __name__ == "__main__":
# input = sys.stdin.read()
inputData = input()
# ... |
1ba3d48d2f53723bef5f35676822dd643d4f915f | AmirOfir/SPOJ | /FENCE1.py | 320 | 3.671875 | 4 | # we have a wall, and we are connecting a fence to it on two points to get the max area
# considering the wall as a rod, the fence as a string. we have a semicircle
# The area of semicircle: (r^2)/(2PI)
# 1/(PI*2) = ~0.15915494309
while True:
l = int(input())
if l == 0: break
print("%.2f" % (l*l*0.15915494309))
|
1ebc827b1859b7149d49094d63cabfb759abfe77 | justinkhado/tides-ai | /tides/montecarlo/mcts_node.py | 2,886 | 3.671875 | 4 | from abc import ABC, abstractmethod
import math
import random
class MCTSNode(ABC):
'''
Abstract Monte Carlo Tree Search Node
'''
@abstractmethod
def __init__(self, state, parent=None, action=None):
'''
Params:
state: GameState corresponding to this node
actio... |
634cb17db22dc8179ede64f3ecd5e9f735c07287 | RomansWorks/CarND-Vehicle-Detection | /common_geometry.py | 3,265 | 3.5 | 4 |
class Point():
def __init__(self, x, y):
self.x = int(x)
self.y = int(y)
def scale(self, factor):
return Point(self.x*factor, self.y*factor)
def shift(self, dx, dy):
return Point(self.x+dx, self.y+dy)
def get_distance(self, other):
return ((sel... |
83344aa7fe907f101b97bc5b8e76a12f48abb02a | laycom/educational_projects | /less_1/less_1_task_4.py | 886 | 4.28125 | 4 | # 4. Пользователь вводит две буквы.
# Определить, на каких местах алфавита они стоят,
# и сколько между ними находится букв.
letter_1 = ord(input('Введите первую букву от "a" до "z": '))
letter_2 = ord(input('Введите вторую букву от "a" до "z": '))
first_letter = ord('a')
letter_1_position = letter_1 - first_lett... |
d14dedeb2a5bc2d6cd953f17d4e6fe26a7d3a7bf | sasha-n17/python_homeworks | /homework_5/task_5.py | 552 | 3.515625 | 4 | with open('task_5.txt', 'w+', encoding='utf-8') as f:
f.write(input('Введите набор чисел, разделённых пробелом: '))
with open('task_5.txt', 'r+', encoding='utf-8') as f:
numbers = f.readline()
try:
if len(numbers) > 0:
print(f'Сумма чисел в файле: {sum([float(el) for el in numbers.split... |
1853291fdc7e3d9621d5daa771d1910e3f7bb065 | jedzej/tietopythontraining-basic | /students/skowronski_rafal/lesson_01_basics/lesson_02/problem_03.py | 329 | 4.15625 | 4 | # Solves problem 03 - Sum of digits
import math
def print_sum_of_digits():
number = abs(int(input('Enter integer number: ')))
sum = 0
while number != 0:
sum += number % 10
number = number // 10
print('\nSum of digits is: {0}'.format(sum))
if __name__ == '__main__':
print_sum_of_... |
3fe5e2c56b16f04f26b5ca57cc426eb1da6df306 | Zahidsqldba07/PythonExamples-1 | /functions/intervalo.py | 245 | 3.5 | 4 | # coding: utf-8
# Aluno: Héricles Emanuel
# Matrícula: 117110647
# Atividade: Soma Intervalo
def soma_intervalo(a,b):
soma = 0
for i in range(a, b + 1):
soma += i
return soma
assert soma_intervalo(5,15) == 110
assert soma_intervalo(10,10) == 10
|
9dcaf7eee9a4fc2b969aa6711033fa62a4826dc2 | palash27/ASE-Group7-HW | /src/Sym.py | 908 | 3.59375 | 4 | import math
class Sym:
"""
Summarize a stream of symbols.
"""
def __init__(self) -> None:
self.n = 0
self.has = {}
self. most = 0
self.mode = None
def add(self, x):
"""
update counts of things seen so far
"""
if x != '?':
... |
90f59ae08ad947a12369726aae28975b12da2c5f | ricardoifc/RepoProgram | /Python/2do ciclo/04 while cadena +/practica200519-ricardoifc-master/ejercicio1.py | 313 | 3.625 | 4 | """
file: ejercicio1.py
@ricardoifc
"""
nombre = input("ingrese su nombre\t")
nota = input("ingrese una nota\t")
nota2 = input("ingrese una nota2\t")
nota = float(nota)
nota2 = float(nota2)
promedio = (nota + nota2)/2
cadena = "Estudiante con %s, tiene un promedio de %f" % \
(nombre, promedio)
print(cadena) |
799ad44f6a265668733b149e9f311ac82287eaa9 | vladder47/tasks | /caesar.py | 947 | 3.953125 | 4 | def encrypt_caesar(plaintext, shift):
alpha = 'abcdefghijklmnopqrstuvwxyz'
alpha_big = alpha.upper()
ciphertext = ''
for i in plaintext:
if i in alpha:
ciphertext += alpha[(alpha.index(i) + shift) % len(alpha)]
elif i in alpha_big:
ciphertext += alpha_big[... |
680d0c59b1b415e302185021064eae261730bead | TawfikW/Portfolio | /Python/EvenOrOdd Game/EvenOrOdd Game.py | 1,324 | 3.625 | 4 | from tkinter import *
from tkinter import ttk
import random
root=Tk()
root.geometry('275x250+350+200')
root.title('EvenOrOdd')
button1 = ttk.Button(root, text='Play')
button1.grid(row=0, column=0, columnspan=2, padx=10, pady=10)
button2 = ttk.Button(root, text='Even')
button2.grid(row=3, column=0, padx=10, pady=20)... |
5f8ab90d58e4b02f96b2747c3ebc8ea66516342a | mcculleydj/rosetta-code | /python/strings/strings_7.py | 398 | 4.0625 | 4 | # O(n)
def is_rotation(s1, s2):
if len(s1) != len(s2):
return False
# let AB represent s1
# where A is the first part of the string and B is the second
# s2 is a rotation <=> s2 == BA (necessary and sufficient)
# let s2 concatenated be represented by BABA
# if s1 can be represented by A... |
3b3af0b3c40636cfc4e43deb3694334907e020bb | hjalmarlindstrom/msudke-d | /hänga gubbe.py | 1,243 | 3.65625 | 4 |
import random
ordlista = ["hund", "mus", "dator", "stol", "bord", "skor", "ben"]
gissade_bokstäver = []
gissade_bokstäver_2 = []
gissningar = 0
ordet = ordlista[random.randrange(0, len(ordlista)-1)]
def gissning():
global gissade_bokstäver
global gissade_bokstäver_2
global gissningar
glo... |
df5a4d9f630bb35fab976c3b1127c79dc4c88c5d | MTrajK/coding-problems | /Strings/reverse_vowels.py | 1,967 | 4.15625 | 4 | '''
Reverse Vowels
Given a text string, create and return a new string constructed by finding all its vowels (for
simplicity, in this problem vowels are the letters in the string 'aeiouAEIOU') and reversing their
order, while keeping all non-vowel characters exactly as they were in their original positions.
Input: 'H... |
95f636049c0b2c012946d0b98c8f9991bfa73f19 | g147/exercism-solutions | /python/difference-of-squares/difference_of_squares.py | 227 | 3.859375 | 4 | def sum_of_squares(limit):
return sum(n**2 for n in range(limit+1))
def square_of_sum(limit):
return sum(range(limit+1)) ** 2
def difference_of_squares(limit):
return square_of_sum(limit) - sum_of_squares(limit) |
278fd23b6c54340a92a987ea66f53f51a7ee8501 | ericzhai918/Python | /LXF_Python/Function_test/func_namingKeyword_para.py | 576 | 3.71875 | 4 |
#关键字参数什么都能传,这点我很不爽,要限制它传进去的东西怎么办?
#命名关键字参数,以*分隔
def person(name,age,*,city,job):
print(name,age,city,job)
person('Jack',24,city='Shanghai',job="OA")
person('Jack',24,job="OA",city='Shanghai')
#有可变参数,省略*
def person(name,age,*args,city,job):
print(name,age,args,city,job)
person('Jack',24,'Beijing','Engineer'... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.