blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
c14f124e703e753a3a3554f64eef1faf4de8dde7 | Kwpolska/adventofcode | /2018/task02a.py | 564 | 3.703125 | 4 | #!/usr/bin/env python3
import collections
with open("input/02.txt") as fh:
file_data = fh.read().strip()
def solve(data):
twos = threes = 0
for line in data.split('\n'):
c = collections.Counter(line)
if 2 in c.values():
twos += 1
if 3 in c.values():
threes +... |
c050dd80df0b0f2969cac927c60afa029f9c41d8 | jdescalzo/card_trick | /card_trick.py | 2,708 | 4 | 4 | from deck import *
deck = []
suits = ['♠','♥','♦','♣']
values = ['A','2','3','4','5','6','7','8','9','10','J','Q','K']
deck = shuffle_deck(build_deck(deck,suits,values))[:21]
deck_top = []
deck_middle = []
deck_bottom = []
def deck_cut():
"""Separate the deck in three parts"""
while len(deck) > 0:
fo... |
c6fd62a3919dfa4893310e5ff825850fd77fedb4 | Ankit-Kumar08/Soduku_Solver- | /Eliminate.py | 744 | 3.734375 | 4 |
from Grid_Value import *
def eliminate(values):
"""Eliminate values from peers of each box with a single value.
Go through all the boxes, and whenever there is a box with a single value,
eliminate this value from the set of values of all its peers.
Args:
values: Sudoku in dictionar... |
b3d3a96c5294c50d10cbd3fc56db3ac17b34b029 | patkry/gios | /air_data.py | 860 | 3.71875 | 4 | """ Creating DataFrame for a specific sensor from data downloaded from api. """
import json, requests
import pandas as pd
from pandas.io.json import json_normalize
def load_s(z):
""" Creates url with sensor id as function argument, downloads data from api, parse json to python dictionary, flattens it, constructs... |
5d3eec0be57361c043e60da4e1977e41b3ddbf3e | manikandan12629/Exercise | /venv/findLength.py | 400 | 3.640625 | 4 | def approach1():
global x, y, z
x='abc'
y='hello world !'
z=' h e l l o '
print('x length is {}, y length is {} and z lenth is {}'.format(len(x), len(y),len(z)))
def approach2():
a = b = c = 0
for i in x:
a+=1
for i in y:
b+=1
for i in z:
c+=1
print(... |
ec00a8cb1fa704a73ff7fc860117d99ef58dd949 | daniel199410/python | /reto2.py | 2,060 | 3.65625 | 4 | from os import system, name
def print_list(_list_):
x = 0
txt = ''
while x < len(_list_):
txt = '{} {}'.format(txt, '{}. {}'.format(x + 1, _list_[x]))
if x < len(_list_) - 1:
txt = txt + ","
else:
txt = txt + "."
x += 1
print(txt)
def clear():
... |
3c04909599fa5fdddac4ff36f325086be222fac7 | Jayakumari-27/python | /find the DOB.py | 76 | 3.609375 | 4 | x=2021
y=int(input("enter your birth year"))
z=x-y
print(f"you are {z} old") |
c2608d455c0c2d7a33f8c252cfaaf0207b42f7ca | kristinnk18/NEW | /Skipanir/forLoops/consecutiveNumbers.py | 482 | 4.3125 | 4 | # Write a Python program using for loops that, given an integer n as input, prints all consecutive sums from 1 to n.
# For example, if 5 is entered, the program will print five sums of consecutive numbers:
# 1 = 1
# 1 + 2 = 3
# 1 + 2 + 3 = 6
# 1 + 2 + 3 + 4 = 10
# 1 + 2 + 3 + 4 + 5 = 15
# Print only each sum, not the a... |
7f4815356a740c6fbf436c6489db245a81d10c27 | kylemaa/Hackerrank | /Implementation/time-conversion.py | 707 | 4.03125 | 4 | # https://www.hackerrank.com/challenges/time-conversion/problem
#!/bin/python3
import os
import sys
#
# Complete the timeConversion function below.
#
def timeConversion(s):
#
# Write your code here.
#
int_hr = int(s[0:2])
if s[8:10] == 'PM' and int_hr < 12:
int_hr += 12
if s[8:10] == '... |
fd0bca58beb0380799468b6daf8dae9aaa1a11b1 | ramyaavak/product_even | /product_even.py | 89 | 3.921875 | 4 | a=int(raw_input())
b=int(raw_input())
if((a*b)%2==0):
print("even")
else:
print("odd")
|
f6fdcfafff17cbc4d8cbf2e76ab6b93117f02bd1 | Python87-com/PythonExercise | /Code/day16_20191128/my_range_exercise.py | 990 | 4.15625 | 4 | """
练习
for i in range(10):
print(i)
"""
class MyRange:
pass
class MyRangeManager:
# 开始数字 终止数字 步长
def __init__(self, startNum=0, stopNum=0, stepNum=1):
self.startNum = 0
self.stopNum = 0
self.stepNum = 1
self.__list... |
591bd8574542c8cfa5f832274e45650bd50f075f | 207leftovers/stupidlang | /stupidlang/parser.py | 2,239 | 3.921875 | 4 | Symbol = str
# Determines the object type of the token string and returns the
# token as its corresponding type
def typer(token):
# If the token is the string 'true' or 'false', returns the
# corresponding boolean value
if token == 'true':
return True
elif token == 'false':
return Fal... |
912f5b01232564e15a96e42e4461476c6fc26eb4 | DonatasNoreika/python1lygis | /Programos/Funkcijos/1uzduotis.py | 3,628 | 3.734375 | 4 | # Sukurkite ir išsibandykite funkcijas, kurios:
# 1. Gražinti trijų paduotų skaičių sumą.
def skaiciu_suma(sk1, sk2, sk3):
return sk1 + sk2 + sk3
print(skaiciu_suma(45, 5, 6))
# 2. Gražintų paduoto sąrašo iš skaičių, sumą.
def saraso_suma(sarasas):
suma = 0
for skaicius in sarasas:
... |
8c965ac17f439bc477757d796c39d8d3586b22eb | garypush/leetcode-notes | /leetcode/727.py | 1,154 | 3.671875 | 4 | class Solution(object):
''' 难点在于dp[i][j]的定义 '''
def minWindow(self, S, T):
"""
dp[i][j] means the smallest end index of the substring in S[i:] and T[j:]
:type S: str
:type T: str
:rtype: str
"""
m,n = len(S),len(T)
dp = [[None for _ in range(n)] fo... |
74ee397b16894aec64e9a42d6db8708ebd229557 | nanthamanish/GeneCentralityLethality | /Centrality.py | 4,043 | 3.578125 | 4 | import pandas as pd
import networkx as nx
import time
import os
def get_features(G, mi=1000):
"""Function to extract features from the Graph
Built in functions from the networkx package is used to extract the
following centrality measures.
1) Degree centrality
2) Eigenvector centrality
... |
9760c341e75e7863644d6f1802bf8fab4c545cc5 | kradical/Pytris | /TetrisPieces.py | 9,964 | 3.546875 | 4 | import pygame
import random
# global properties of the instance of the application
class TetrisApp():
def __init__(self):
self.block_list = [['I', 'O', 'S', 'Z', 'J', 'L', 'T'], ['I', 'O', 'S', 'Z', 'J', 'L', 'T']]
random.shuffle(self.block_list[0])
random.shuffle(self.block_list[1])
... |
2d96d9b64b846c7f99dc65bd272480e62de2e510 | ShakilAhmmed/Problem_Solve | /CodeForces/watermelon.py | 90 | 3.90625 | 4 | number = int(input())
if number > 2 and number % 2 == 0:
print("YES")
else:
print("NO")
|
63ebc1b1ca42ceaa7583b7afbf5c28976f7929fd | r96725046/leetcode-py | /Matrix/73.set-matrix-zeroes.py | 1,051 | 3.578125 | 4 | #
# @lc app=leetcode id=73 lang=python3
#
# [73] Set Matrix Zeroes
#
# @lc code=start
class Solution:
def setZeroes(self, matrix: List[List[int]]) -> None:
"""
Do not return anything, modify matrix in-place instead.
"""
fr=False
fc=False
for j in range(len(matrix[0]... |
5cf2ac22b1ae80dbfe7d8f228729b7fc8d33e8c7 | juaopedrosilva/Python-Challenge | /EstruturaSequencial/atividade7.py | 97 | 3.59375 | 4 | l = int(17)
area = float(l * l)
dobro = 2 * float(area)
print("o dobro desta área é ", dobro) |
d24a220a50086d515edc95aa28de2786d3daa4cc | GoVed/AITicTac | /Game.py | 3,179 | 3.640625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Oct 1 19:36:59 2021
@author: vedhs
"""
import random
import numpy as np
class Game:
#For saving which player has which tile of the game
isX = np.full((3,3),False)
isO = np.full((3,3),False)
turn = False
def __init__(self):
self.turn = bool(r... |
cc9e3becff1a5d5954f0162274ed7277373f0bdd | souza10v/Exercicios-em-Python | /activities1/codes/61.py | 382 | 3.65625 | 4 | // -------------------------------------------------------------------------
// github.com/souza10v
// souza10vv@gmail.com
// -------------------------------------------------------------------------
k=soma=n=0
while n != 999:
n=int(input("Digite um número [999 para parar]: "))
if n != 999:
... |
4e31b7edc2767043bab5afe63f8c010e2a2e79aa | deanhadzi/cs-module-project-algorithms | /moving_zeroes/moving_zeroes.py | 899 | 4.375 | 4 | '''
Input: a List of integers
Returns: a List of integers
'''
def moving_zeroes(arr):
# Step 1 - create a copy of the original array.
arr_copy = arr[:]
# Step 2 - create a counter to get number of zeros in array.
counter = 0
# Step 3 - loop through the array copy and remove all zeros.
# Increase... |
ad1b03f5f0186b63b7ec1762415c35295a0f29a8 | skrishna1978/CodingChallenge-January-2019- | /1.10.2019 | binaryToDecimalArray.py | 1,123 | 4.1875 | 4 | #1.10.2019 - Shashi
#program to accept binary value as an array and return its decimal equivalent.
#Binary code can be of any length but should only comprise of 1s and 0s.
def bin_dec(binArr): #function starts here
result = 0 #variable to hold final answer
for i in range(len(binArr)): #loop through each digit ... |
b51c44618813b1d9c2033d4df445ecd5691f57b7 | i-am-Shuvro/Project-GS-4354- | /Main File.py | 8,972 | 3.96875 | 4 | def greet(str):
name1 = input("[N.B: Enter your name to start the program.] \n\t* First Name: ")
name2 = input("\t* Last Name: ")
return "Hello, " + str(name1) + " " + str(name2) + "! Welcome to this program, sir!"
print(greet(str))
print("This program helps you with some information on tax-rate on... |
61e6e62fb99f60133fb12cd377ce3e2bdf4d2b2c | chrislarry/python | /fibonacci.py | 154 | 3.5625 | 4 | #!/usr/bin/python
new = 1
count = 10
old = 0
print("\n\nFibonacci number\n\n")
for i in range(count):
new += old
old = new - old
print(new)
|
3ec148e2293bcbd29a9787c40c1dcf34de1f9aa9 | kenan666/Study | /算法总结/合并K个排序链表.py | 1,706 | 4 | 4 | '''
合并 k 个排序链表,返回合并后的排序链表。请分析和描述算法的复杂度。
示例:
输入:
[
1->4->5,
1->3->4,
2->6
]
输出: 1->1->2->3->4->4->5->6
'''
'''
解1
优先级队列
时间复杂度:O(n*log(k))O(n∗log(k)),n 是所有链表中元素的总和,k 是链表个数。
'''
class Solution:
def mergeKLists(self, lists: List[ListNode]) -> ListNode:
import heapq
dummy = ListNode(0)
... |
bb8ea7b5e9957e76a832e68f7270d5e4a4f9fb48 | tianyuemylove/yue | /p1月.py/冰淇淋.py | 246 | 3.5625 | 4 | import random
cc = random.randint(1,9)
if cc == 1 or cc == 4 or cc == 7:
print('刘美娜买棒棒糖')
elif cc == 2 or cc ==5 or cc == 8:
print('王一凡买奶喝')
elif cc == 3 or cc == 6 or cc ==9:
print('吕东泽买冰淇淋')
|
93e5d17db6aeff8758e91900f6a71e552fd22dd3 | mike1334/Project-2---build_a_soccer_league | /league_Functions.py | 2,425 | 3.875 | 4 | import csv
import copy
teams = {
'Sharks':[],
'Dragons':[],
'Raptors':[]
}
def divide_teams_experience():
# This function loops through the provided .csv file. First it finds and splits evenly the experinenced
# players between the three teams. Next it accomplishes the same task with the inexperienced playe... |
d344c3f167cc2c43e88ee123edec72ba2ad81ff0 | Khun-Cho-Lwin/Python-Files-IPND | /Print_Numbers.py | 202 | 3.859375 | 4 | def print_numbers(x):
i = 0
while i < x:
i = i + 1
print i
print_numbers(3)
def print_numbers(n):
i = 1
while i <= n:
print i
i = i + 1
print_numbers(3)
|
c77aea0a501e5274320b729e577651440fc7f82c | rabidrabbit/tropical-cryptography | /key_exchange_protocol.py | 3,039 | 3.578125 | 4 | """
Implementation of a tropical key exchange protocol.
"""
from tropical_matrix import *
import math
import random
def get_identity_matrix(n):
if n <= 1:
raise ValueError("An identity matrix must have more than a singular entry.")
identity_matrix = []
for i in range(n):
row = [math.inf] * ... |
46dd13daf20eae469285d583be1864a9dd6cc373 | aksharanigam1112/MachineLearningIITK | /packageML01/Practical30.py | 185 | 3.6875 | 4 | #Arbitrary Argument List
def disp1(*arr):
print("type(arr) = " , type(arr) , arr)
for num in arr:
print(num)
print("\n")
disp1(5,6,7,8)
disp1(2,3)
disp1()
disp1(9)
|
be0136e6fc715290143246e8f510b91df4ef6584 | taissalomao/curso_em_video | /exer_019.py | 371 | 4.09375 | 4 | # um professor quer sortear um dos seus quatro alunos para apagar o quadro. Faça um programa que ajude ele, lendo o nome deles e escreevendo o nome escolhido.
import random
a1 = input("noem do aluno ")
a2 = input("nome do aluno ")
a3 = input("nome do aluno ")
a4 = input("nome do aluno ")
lista = [a1,a2,a3,a4]
pri... |
519448917781c391a653f4218f306c6da2fba967 | sujith1919/TCS-Python | /classroom examples/2.py | 197 | 4.03125 | 4 | count = 0
while count < 10:
print(count)
if count % 2 == 0:
print("Even")
elif count % 2 == 1:
print("Odd")
else:
pass
count+=1
print("Done")
|
d6de9f8da0183a535ca750f926bead94f6a27a89 | sinayanaik/nand-and-tetris | /chapter 1/boolean_or.py | 384 | 4.09375 | 4 | # input 2 variables only 1 or 0
# output 0 only if both inputs are 0
import sys
def boolean_or(x:int,y:int)-> int:
if x and y not in [0,1]:
print("only 1 & 0 permittible as input")
sys.exit()
if x==y==0:
return 0
else:
return 1
x= int(input("operand x: "))
y= int(input("ope... |
7018ab7bc15267394035bd6ce62f07ae625c89fd | NCRivera/Python-Crash-Course | /Chapter_3/3_5_Changing_Guest_List.py | 602 | 4.09375 | 4 | #3-5. Changing Guest List
guests = ['maria', 'celia', 'sheldy']
print("You, " + guests[0].title() + " are formally invited to my dinner, tomorrow night.")
print("You, " + guests[1].title() + " are formally invited to my dinner, tomorrow night.")
print("You, " + guests[2].title() + " are formally invited to my d... |
4c0551bb1e7303a383707b79e066ff978e1b9ce5 | Saikat2019/Python3-oop | /3static_class_methods.py | 1,558 | 3.953125 | 4 | class Employee:
num_of_emps = 0
raise_amount = 1.04
def __init__(self, first, second,pay):
self.first = first
self.second = second
self.pay = pay
self.email = first + '.' + second + '@gmail.com'
Employee.num_of_emps += 1
#regular methods automatically takes the instance as first arg
def fullname(self): ... |
b9947702b74c46a84194737e12f3ad1c3d65181d | killian-mahe/the_eternal_kingdom | /characters/zombie.py | 912 | 3.671875 | 4 | # -*- coding: utf-8 -*-
# Standard imports
import time
# Package imports
from IO import Terminal
# Internal imports
from characters import Monster
class Zombie(Monster):
def __init__(self, monster_model_file, position, life=1, speed=3):
"""Create an instance of Zombie
Arguments:
... |
5577a5c54e2432f2c68fc171a11470a3108938d0 | ferreirads/uri | /uri1131.py | 936 | 3.6875 | 4 | partidas = 0
ponto_inter = 0
ponto_gremio = 0
empate = 0
while True:
inter, gremio = map(int, input().split())
partidas = partidas + 1
if inter > gremio:
ponto_inter = ponto_inter + 1
elif inter < gremio:
ponto_gremio = ponto_gremio + 1
elif gremio == inter:
empat... |
3d08317438ce08a954e020490fffd5bdd49c19fd | jonathan-wells/teamdanio-rosalind | /scripts/ini3.py | 432 | 3.96875 | 4 | #!/usr/bin/env python3
def index_string(s, a, b, c, d):
"""Return 2 strings from s corresponding to characters a-b and c-d."""
outstring1 = s[a:b+1]
outstring2 = s[c:d+1]
return outstring1, outstring2
s = 'HumptyDumptysatonawallHumptyDumptyhadagreatfallAlltheKingshorsesandalltheKingsmenCouldntputHump... |
e3d0fa0e90b28e78b8489ad11d5ea48a5b39960c | hkj9057/backjun | /05_03.py | 270 | 3.5 | 4 | import multiprocessing
import time
start_time = time.time()
def count(name):
sum = 0
for i in range(1, 5000001):
sum += i
num_list = ['a1','a2','a3','a4']
for num in num_list:
count(num)
print("--- %s seconds ---"%(time.time() - start_time)) |
88ffe20223c7c74346535197e86f7ebb21551ce7 | Weirdeeno/lab_1_python | /Lab/Lab7/Lab7.5.py | 774 | 4.4375 | 4 | """
9. Описати рекурсивну функцію Palindrome (S) логічного типу, яка повертає True,
якщо ціле S є паліндромом (Читається однаково зліва направо і справа наліво),
і False в іншому випадку. Оператор циклу в тілі функції не використовувати.
Вивести значення функції Palindrome для п'яти даних чисел.
"""
def Palindrom... |
ac552976b46c33a710fff33cb1ae61463737872d | pranavkhuranaa/DailyCodes | /Constructor/constructor.py | 447 | 4.25 | 4 | #This code implements constructors in Python 3.0
#1
class Point:
def __init__(self,x,y): #constructor
self.x=x
self.y=y
def move(self):
print('move')
def draw(self):
print('draw')
point=Point(10,20)
#point.x=11
print(point.x)
#2
class Person:
def __init__(sel... |
baefcbd2129b05dc598bb45bed1f3108126eddd6 | sandip-tiwari/IMNN | /IMNN/network/network.py | 5,864 | 3.59375 | 4 | """Simple network builder
This module provides the methods necessary to build simple networks for use in
the information maximising neural network. It is highly recommeneded to build
your own network from scratch rather than using this blindly - you will almost
certainly get better results.
"""
__version__ = "0.1rc1... |
544310f3ef050399b88087c324c314fd0333e7c5 | mhee4321/python_basic | /matplotlib_examples/group_bar_plot.py | 2,293 | 3.515625 | 4 | #Group Bar Plot In MatPlotLib
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
raw_data = {'first_name': ['Jason', 'Molly', 'Tina', 'Jake', 'Amy'],
'pre_score': [4, 24, 31, 2, 3],
'mid_score': [25, 94, 57, 62, 70],
'post_score': [5, 43, 23, 23, 51]}
df = pd.DataFr... |
5b3a4ffedae758a88f2efcdaf82383d5235c492e | AJoh96/BasicTrack_Alida_WS2021 | /Week40/4.9.5.py | 218 | 3.671875 | 4 | import turtle
window = turtle.Screen()
window.bgcolor("lightgreen")
finn = turtle.Turtle()
finn.color('blue')
for x in range(100):
finn.forward(x * 5)
finn.right(90)
#finn.right(89)
window.mainloop()
|
56f76b7644b0f770cef0bfc52c466b00efd081bb | gunjan1991/CSC-455---Assignments | /Assignment 6 - Gunjan - Part 4 Solution.py | 885 | 3.734375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Feb 17 09:53:17 2016
@author: gunjan
"""
# Assignment: 6
# Name: Gunjan Pravinchandra Pandya
# Part: 4
import sqlite3
# Open a connection to database
conn = sqlite3.connect("ChaufferDatabase.db") #Should be the database to which table belongs to
# Request a ... |
5b050974294599808516b3b1c7d173452c0424c6 | iWeslie/AlgorithmPlayground | /LeetCode/Python/141.linked-list-cycle.py | 602 | 3.71875 | 4 | #
# @lc app=leetcode id=141 lang=python
#
# [141] Linked List Cycle
#
# Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
def hasCycle(self, head):
"""
:type head: ListNode
:rty... |
e680b7e421ea2ef55c7f2aa35d8d4bc0587f3099 | euyouer/python-cev | /curso-aula_em_video/Ex 088 - Palpites para a Mega Sena.py | 619 | 3.53125 | 4 | from random import randint
from time import sleep
print('\033[1;31m*\033[m' * 25)
print('JOGA NA MEGA SENA'.center(25))
print('\033[1;31m*\033[m' * 25)
game = list()
ans = int(input('Quantos jogos você quer que eu sorteie? '))
print(f'-=-=-=- SORTEANDO {ans} JOGOS -=-=-=-')
for n in range(ans):
aux = list()
wh... |
6289aa5aed46a293aacbab300062a0f5002de8ce | PalMassimo/AdvancedProgrammingProject | /Python/reverse_module.py | 274 | 3.5625 | 4 | def reverse_dictionary(d):
rd = dict()
for elem in set([value for values_list in d.values() for value in values_list]):
rd[elem] = list(set([key for key, value in d.items()
for list_elem in value if elem == list_elem]))
return rd
|
caf0bbef0996e7a25b8def0aa19d07e1ec44cbc7 | kristenscheuber/CP1404 | /prac_02/file.py | 1,602 | 4.125 | 4 | '''
Do all of the following in a single file called files.py:
1. Write a program that asks the user for their name, then opens a file called “name.txt” and writes that
name to it.
2. Write a program that opens “name.txt” and reads the name (as above) then prints,
“Your name is Bob” (or whatever the name is in the file)... |
702d2b230f02a98258cb6cf4c820f9ee5b62dd48 | GSAUC3/turtle-graphics | /poly_kwargs.py | 509 | 3.890625 | 4 | import turtle
class poly:
def __init__(self,**k) -> None:
self.side=k['side']
self.size=k['size']
self.color=k['color']
self.interior_angles=(self.side-2)*180
self.angle=self.interior_angles/self.side
def draw(self):
turtle.color(self.color)
for i in ra... |
0df7b84dc63ddbc80f77c53ee5e55ac7072b53e7 | Aasthaengg/IBMdataset | /Python_codes/p03377/s819525040.py | 93 | 3.59375 | 4 | cat, animal, just = map(int, input().split())
print("YES" if cat<=just<=cat+animal else "NO") |
43ee1473816a78d636a04923fdca4a04da569c38 | onuryarartr/trypython | /odev1.py | 469 | 4.21875 | 4 | """Problem 1
Kullanıcıdan aldığınız 3 tane sayıyı çarparak ekrana yazdırın. Ekrana yazdırma işlemini format metoduyla yapmaya çalışın."""
print("Merhaba, lütfen istenen değerleri girin..")
s1 = int(input("Sayı 1:"))
s2 = int(input("Sayı 2:"))
s3 = int(input("Sayı 3:"))
print("İşlem yapılıyor...")
sonuc =... |
2e71ab038509eed47cec6f27e0b90af17ede36b8 | penguin138/ctc_convolutions | /prettify_syllables.py | 2,194 | 3.703125 | 4 | #! /usr/bin/env python3
"""Wiktionary syllables prettifier."""
import re
import sys
import pandas as pd
def check_ru(x, axis):
"""Check whether string contains only russian alphabetic characters."""
alphabet = 'АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ'
alphabet = alphabet + alphabet.lower() + 'и́о́а́ы́я́е́у́ю́э́... |
aaeefc6b7013002144d92522faf7da514d1bcc7a | arslanaarslan/Hangman | /Topics/Loop control statements/Prime number/main.py | 386 | 4.1875 | 4 | number = int(input())
is_prime = False
divider = 2
while divider <= number:
if number == divider:
is_prime = True
break
if number == 2:
is_prime = True
break
if number % divider == 0:
break
divider += 1
if is_prime:
print("T... |
d6d7a8b6fbae97ccbde88f81d388beb02408a368 | SergioKuk/sk-repo | /Proj_1/stepik_2020-09.py | 5,837 | 3.84375 | 4 |
#==================================================================================================================
# 2.5 Списки
#==================================================================================================================
'''
Напишите программу, на вхо... |
ca4f3b12a43c4e2916704d59982c6cd091590b19 | janvanzeghbroeck/zombie_dice | /game_bits.py | 2,514 | 3.6875 | 4 | import numpy as np
## constants
n_green_dice = 6
n_yellow_dice = 4
n_red_dice = 3
# the distibution of the sides on each colored die
green_dice = ['brain','brain','brain','feet','feet','shot']
yellow_dice = ['brain','brain','feet','feet','shot','shot']
red_dice = ['brain','feet','feet','shot','shot','shot']
class ... |
20198d30d02238a019306c693f741d4e545fa58c | MFTECH-code/checkpoint02-cpt | /ZenGroup.py | 3,408 | 3.828125 | 4 | # CHECKPOINT 2 CPT
#quantidade de Pratos Principais
pratosPrincipais = int(input("Quantos pratos principais: "))
while (pratosPrincipais <= 0):
print("Número de pratos principais inválido. Digite novamente.")
pratosPrincipais = int(input("Quantos pratos principais: "))
if (pratosPrincipais > 3):
descontoP... |
be3afe48729bb126c0730e8c3dc6dbd743868283 | Praveen-bbps/python_basic_examples | /mutable_demo.py | 470 | 3.671875 | 4 | # Strings are immutable
a="bbps"
print(a[2])
# make the below line comment to remove the error
a[2]="q"
# lists are mutable
months=["jan","feb","mar"]
print(months[2])
months[2]="apr"
print(months[2])
myscore=[20,15,80,25,90]
myname=["bbps", "school",25]
# ascending order
print(sorted(myscore))
# decend... |
3fa696abaaa3db0b3241f4c52c6807d394ad6d17 | QuantumKane/statistics-exercises | /probability_distributions.py | 4,853 | 4.0625 | 4 |
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from scipy import stats
from env import host, user, password
# 1 A bank found that the average number of cars waiting during the noon hour at a drive-up window follows a Poisson distribution with a mean of 2 cars. What is the probability that no c... |
d6d48b86ee1f3203e6a9e16291a0d0925635e1dd | CastleWhite/LeetCodeProblems | /92.py | 636 | 3.8125 | 4 | # Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
def reverseBetween(self, head: ListNode, left: int, right: int) -> ListNode:
dummy = ListNode(0, head)
newbegin = dummy
... |
5d3cda86ae06ab1c5926bd0e4459e22e12e5b11b | Pradeepsuthar/pythonCode | /BasicPrograms/binary_search.py | 440 | 3.84375 | 4 | # Binary Search
a = [1,5,7,8,11,13,16]
def binary_search(a, key, start, end):
if start <= end:
mid = int((start+end)/2)
if a[mid] > key:
return binary_search(a, key, start, mid-1)
elif a[mid] < key:
return binary_search(a, key, mid+1,end)
else:
... |
60b43a72356f7f93ba251381bdab9ddde3c1cf7e | Keonhong/IT_Education_Center | /Jumptopy/Codding_Test/Theater.py | 617 | 3.859375 | 4 | #영화관 티켓 판매기
while True:
print("안녕하세요. IT영화관을 찾아주셔서 감사합니다.")
a = int(input("나이를 입력하세요: (-1 종료)"))
if a < 3 and a > 0:
print("%s세의 입장료는 무료입니다. 감사합니다."% a)
continue
if a >= 3 and a < 13:
print("%s세의 입장료는 10달러입니다. 감사합니다."% a)
continue
if a >= 13:
print("%s세의 입장료는 ... |
ff015f3ea57661249e54e7c2b58d495b8abe9306 | jcarball/python-programs | /examen.py | 437 | 3.84375 | 4 | i=2
while i >= 0:
print("*")
i-=2
for n in range(-1, 1):
print("%")
z=10
y=0
x=z > y or z==y
lst=[3,1, -1]
lst[-1] = lst[-2]
print(lst)
vals = [0,1,2]
vals[0], vals[1] = vals[1], vals[2]
print(vals)
nums=[]
vals = nums
vals.append(1)
print(nums)
print(vals)
nums=[]
vals = nums[:]
vals.append(1)
print(nu... |
c3857ae5f2dfd19fab3eef8691cc6ef1a9ed4b56 | thientt03/C4E26 | /C4E26/Session3/while_intro.py | 148 | 3.84375 | 4 | loop_count = 0
loop = True
while True:
print("Running...")
loop_count += 1
print(loop_count)
if loop_count > 2:
loop = False |
740712f8d0eaa2f72d590b9c6caf130419e97e4c | arpankbasak/pymol-animations | /tutorials/basics/01-moviesetup.py | 1,433 | 3.671875 | 4 | __author__ = 'sebastians'
# PyMOL Animation Tutorials -- 01 - Movie Setup
# This tutorial will show you how to set up a python script for writing an PyMOL animation.
# To start PyMOL from a python script, import the pymol modules
import pymol
from pymol import cmd
# The next line is essential to prevent any threadin... |
935e42f3c05449ef92c6d49e8c73ba366cff4d7c | joshtsengsh/Learn-Coding-with-Python | /07. Math/math2.py | 722 | 4.34375 | 4 | #Created by Josh Tseng, 5 May 2020
#This file shows you some concepts related to performing math calculations in Python using float values
#Note that num1 is a float value, and num2 is an int value
num1 = 5.0
num2 = 10
#All calculations involving float values will result in a float value being produced
print("Additi... |
4bbb11c54c029b2c28fad0c0b6991d865cb99276 | kkdai/python_learning | /input_check.py | 480 | 3.828125 | 4 |
def is_input_number(any_input):
try:
val = int(any_input)
return True
except ValueError:
return False
def is_input_string(any_input):
'''
Any input could be string, so this always be True
'''
try:
val = str(any_input)
return True
except ValueError:
... |
3e4161da89e1161f7a8e933eebf6701e35766d2f | dewanhimanshu/Python | /practical.py | 707 | 4.0625 | 4 | def pattern1(n,patternType):
"""[To print a pattern 1 ]
Args:
n ([int]): [number of rows]
patternType
"""
if patternType == '1':
count = 1
for i in range(1,n+1):
for j in range(1,i+1):
print(count*count,end=' ')
count ... |
4e43be9a21445b4c39b0c028365275d1e79d7969 | finchnest/Python-prac-files | /_quiz1/armstrong number.py | 207 | 3.65625 | 4 | for z in range(0,1000):
if len(str(z))==3:
n1=z%10
n2=(z//10)%10
n3=z//100
if (n1**3+n2**3+n3**3)==z:
print(z," is an armstrong number!")
|
0fc220744de9a8c8cdee42bf69c2ccd9639c9cf3 | Sharmaxz/HarvardX-CS50 | /pset6 - python/mario (less)/mario.py | 324 | 4.25 | 4 | height = 0
# Loop to get the correct value
while (1 >= height or height > 9):
height = int(input("Height: ")) + 1
# Logic to make the pyramid
for i in range(1, height):
for j in range(1, height - i):
print(" ", end='')
for j in range((height - i), height):
print("#", end='')
print(... |
e2b8f3f20673fa627e8b8ee8b80e0e6d1082d0f0 | dingguopeng/python3_test | /求绝对值.py | 164 | 3.796875 | 4 | def my_abs(x):
if x > 0:
return x
else:
return -x
s = float(input('输入一个数:'))
print('该数的绝对值是:',my_abs(s)) |
03c7555365554a32bc8d4627dc33043b5bbf258a | PetrPrazak/AdventOfCode | /2017/02/aoc2017_02.py | 937 | 3.625 | 4 | # https://adventofcode.com/2017/day/2
def solve(lines):
total = 0
for line in lines:
table = line.split()
numbers = list(map(int, table))
amax = max(numbers)
amin = min(numbers)
total += amax - amin
print("Total = ", total)
def solve2(lines):
total = 0
for ... |
a0c8341b9d2973c6cfc18da2247b799626205d31 | Gangamagadum98/Python-Programs | /PythonClass/LearningJson.py | 478 | 3.578125 | 4 | import json
# converting json to dictionary
user = '{"email":"sneha@gmail.com", "password":"pass"}'
dict=json.loads(user)
print(type(dict))
print(type(user))
# converting dictionary to json
dictionary = {'name':'Ganga','mob':'9067787678'}
json1 = json.dumps(dictionary)
print(json1)
print(type(json1))
# converti... |
657416bf0344ace1170c6c5efc6b0166c6ac76cb | Rxma1805/LintCode | /159. Find Minimum in Rotated Sorted Array/1500ms.py | 669 | 3.6875 | 4 | class Solution:
"""
@param nums: a rotated sorted array
@return: the minimum number in the array
"""
def findMin(self, A):
# write your code here
N = len(A)
return self.binarySearchFirstIndex(0,N-1,A,A[N-1])
def binarySearchFirstIndex(self,left,right,A,target):
... |
04c088d083d48e279a66f206c1ed05af092696af | derekbomfimprates/python | /ProjectPython/mainScreen.py | 10,983 | 3.515625 | 4 | #import modules
from tkinter import *
import os
from datetime import date
from datetime import datetime
import requests
import re
main_screen = Tk()
# CREATING THE REGISTRATION SCREEN
def register():
global register_screen
#LAYOUT INFORMATION:
register_screen = Toplevel(main_screen)
register_scree... |
9107df2177c8bd77d22eecc0b3ae6efe8e41baaa | Dlac/Python-For-Everybody | /exer65.py | 390 | 4.1875 | 4 | #take the following python code that stores a string
#str = 'x-dspam-confidence: 0.8475
#use find and string slicing to extract the portion of the string after the colon
# character and tehn use the float function to conver tthe extracted string int a floating point number
x = 'X-DSPAM-Confidence: 0.8475'
print x
pos ... |
dfc64a661dfca677d7b9731586886207098e62de | sergabrod/Python-Code | /gui2/radio_button.py | 682 | 3.9375 | 4 | # -*- coding: utf-8 -*-
# utilizando radio button
from tkinter import *
root = Tk()
opcion = IntVar()
def imprimir():
if opcion.get() == 1:
label2.config(text="has elegido Masculino")
elif opcion.get() == 2:
label2.config(text="has elegido Femenino")
else:
label2.config(text="ha... |
2b663ea9099a5116f59fc84d333a00d69e3528e7 | fabriciovale20/AulasExercicios-CursoEmVideoPython | /Exercícios Mundo 2 ( 36 à 71 )/ex062.py | 920 | 4.15625 | 4 | """
Exercício 62
Melhore o DESAFIO 061, perguntando para o usuário se ele quer mostrar mais alguns termos.
O programador encerra quando ele disser que quer mostrar 0 termos.
"""
print('='*30)
print('{:^30}'.format('GERADOR DE UMA PA'))
print('='*30)
primeiro_termo = int(input('Primeiro termo: '))
razao = int... |
52b89c1bb0457d98e4b068a30311203ff60afb09 | braytonbravo/trabajo10_bravo | /submenu_1.py | 1,200 | 3.671875 | 4 | import libreria
def agregarPosicion():
nombre=libreria.pedir_nombre("Ingrese posicion de jugador:")
contenido=nombre+"\n"
libreria.agregar_datos("info.text",contenido,"a")
print("Posicion guardado")
def mostrarPosicion():
archivo=open("info.text")
datos=archivo.read()
print(datos)
arc... |
484952344b7e7c94d97732a56c3500f05ab3ff82 | Abdelatief/Codeforces-Problems | /A. Pangram.py | 175 | 3.84375 | 4 | # http://codeforces.com/contest/520/problem/A
n = input()
string = input()
string_set = set(string.lower())
if len(string_set) == 26:
print('YES')
else:
print('NO')
|
e0a1ac224ab041f557e5454e43c75d16ae05c846 | orlandopython/tic-tac-toe-oop | /code/ttt4_turtle.py | 2,867 | 3.921875 | 4 | """
Tic Tac Toe
This uses Turtle graphics to draw the game board
It puts some "self protection" in the button class
"""
import sys
from turtle import Screen, Turtle
from typing import Callable
FONT = ("Arial", 24, "bold")
BUTTON_COLOR = "blue"
SYMBOL_COLOR = "white"
BUTTON_STRETCH = 5
BUTTON_SHAPE = "square"
FILLER ... |
27abcf787e6b79daed3a8bfbab20c539e826bf52 | pricixavier/Think-Phython | /vowel.py | 141 | 3.859375 | 4 | d=['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U']
s=char(input("enter the letter"))
if(a in d):
print("vowel")
else:
print("invalid")
|
8aac005909cd57659ecf57a721418b1c603e6d9c | maknetaRo/pythonpractice | /while_ex4.py | 732 | 4.09375 | 4 | """
Write a program that asks the user to enter a password. If the user enters the
right password, the program should tell them they are logged into the system.
Otherwise, the program should ask them to reenter the password. The user should
only get five tries to enter the password, after which point the program
should... |
9788816cfb5d6917e646bf8c4ccdeee7c2730e43 | zhbbupt/ospaf-primary | /Ospaf/src/Matplotlib/DrawChart.py | 239 | 3.796875 | 4 | '''
use matplot to draw some charts
@author: Garvin
'''
import matplotlib.pyplot as plt
def BarChart(name,num):
plt.bar(range(len(num)), num, align='center')
plt.xticks(range(len(num)), name, size='large')
plt.show()
|
6538ffc09e72b1552b813034d0e0d1482ee07dad | devjoi2018/simple_password_generator_python | /simple_password_generator.py | 2,319 | 3.921875 | 4 | # This code is part of the tests that I have been doing with Github Copilot.
# Program that generates passwords randomly
# The length of the password must be requested from the user through the console
# The user should be asked if they want to include special characters in the opassword
# If the user selects 'y'... |
36a06dfab09c09c7e9f6c14a35b148fc16988c72 | Touchhub/Ahri | /lian/info_3.py | 268 | 3.953125 | 4 | math=input("math:")
pe=input("pe:")
age=input("age:")
print(type(age))
job=input("job:")
name=input("name")
info='''
-------info of {0}-------
math={1}
pe={2}
age={3}
job={4}
'''.format(name,
pe,
age,
job,
math)
print(info) |
c386b270da19bb4b8cd89874a97d99f6d7ea8ec0 | seymakara/CTCI | /01ArraysAndStrings/LCclimbingTheStairs.py | 417 | 3.734375 | 4 | class Solution(object):
def climbStairs(self, n):
if n == 1:
return 1
if n == 2:
return 2
one_step_before = 2
two_steps_before = 1
all_ways = 0
for i in range(2,n):
all_ways = one_step_before + two_steps_before
... |
3be8119a9adbbafb71042ff10355fcd4d8fc8016 | jobafash/InterviewPrep | /common-ds/lls.py | 7,994 | 4.34375 | 4 | '''
Connected data(nodes) is dispersed throughout memory.
In a linked list, each node represents one item in the list.
This is the key to the linked list: each node also comes with a little extra
information, namely, the memory address of the next node in the list.
This extra piece of data—this pointer to
the next ... |
db852fa295bed837efa39df3ca81e77006f7c894 | WangXu1997s/store | /统计列表中每个数出现的次数.py | 196 | 3.671875 | 4 |
List = [1,4,7,5,8,2,1,3,4,5,9,7,6,1,10]
setL = set(List)
#print(setL.pop())
for i in range(len(setL)):
view = setL.pop()
print("{0}出现了{1}次。".format(view,List.count(view))) |
9215f9ce7e5f571fb25d5e2b10b44fc8a2f69f1e | mxruedag/ProblemSolving | /project-euler/Problem4.py | 351 | 3.546875 | 4 | def is_palindrome(n):
strn = str(n)
if len(strn) <= 1:
return True
noLastOrFirst = strn[1:-1]
return strn[0] == strn[-1] and is_palindrome(noLastOrFirst)
max_pal = 0
for i in xrange(1000):
for j in xrange(i,1000):
new = i*j
if is_palindrome(new) and max_pal < new:
... |
05d1f40563b9d99b38f00350e793f2975b8393f5 | rashigupta37/tic_tac_toe | /Game.py | 2,875 | 3.640625 | 4 | import copy
#game class
class Game:
def __init__(self):
self.board = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
self.win = 0 #winner
self.curPlayer = 1 #current player
self.boardSize = 3 #board-size
self.moveHistory = [] #stores move history
self.p1 = None #first player
... |
5fdffcece872a84525531747e9927b9e603d53a9 | Surya0705/Python_Colorful_Pattern | /Main.py | 538 | 4.0625 | 4 | import turtle # Importing the Module.
colors=['red', 'deeppink2', 'cyan', 'chartreuse', 'blue', 'yellow'] # Giving a set of Colors.
turtle.bgcolor('black') # Giving it a background Color.
turtle.speed(20) # Giving it a speed.
for x in range(360): # Starting a loop.
turtle.pencolor(colors[x%6]) # Changing Colors.
... |
a8aa1bd1ff0d95512892fba4f4b226bfed534d4e | Rakk4403/deep-learning-from-scratch | /common/differential.py | 2,058 | 3.546875 | 4 | # author: rakk4403
import numpy as np
import matplotlib.pylab as plt
def numerical_diff_badcase(f, x):
"""
It would be rounding error, if input is too small.
"""
h = 10e-50 # close to 0
return (f(x + h) - f(x)) / h
def numerical_diff(f, x):
# Right function
h = 1e-4 # 0.0001
return... |
d94bf97b404dd62c7bd34da11059fc82506448c3 | JEONJinah/Shin | /quick_sort.py | 957 | 3.875 | 4 | # 주어진 리스트를 2 그룹으로 나누는 코드 작성
def quick_sort(in_list, left, right): # 재귀호출로 작성시 함수의 매개변수도 변경되어야함.
n = len(in_list)
pl = left # 0
pr = right #n - 1
x = in_list[(left+right) //2 ]
# x = in_list[n // 2] # 재귀 호출로 해당 함수를 호출할 경우에는 (left, right)
while pl <= pr:
while in_list[pl] < ... |
356e0e5b5970efe4d557a592a580619602be7b1a | HelloImKevo/PyPlayground | /src/pluralsight_misc/examples.py | 3,041 | 3.671875 | 4 | #!/usr/bin/env python3
"""
Miscellaneous Pluralsight examples.
"""
import datetime
import math
print("Reticulating spline {} of {}.".format(4, 23))
# String formatting with a tuple
print("Galactic position x={pos[0]}, x={pos[1]}, z={pos[2]}"
.format(pos=(65.2, 23.1, 82.2)))
# String formatting and import sub... |
1c1d8185ddb52f86cec08ee82e654f5fa6b27b21 | diwadd/Algs | /quicksort.py | 1,394 | 3.734375 | 4 | import random
def partition(a, p, r):
"""
Intorduction to algorithms 3rd ed.
Cormen et al.
Page 171, Section 7.1
:param a: An array.
:param p: Index in a.
:param r: Index in a.
"""
x = a[r]
i = p - 1
for j in range(p, r):
if a[j] <= x:
i = i + 1
... |
72551ad3dd4dd73b2a7e342d4009ca287471c00d | ksingh7/python-programs | /password_checker.py | 700 | 3.921875 | 4 | def passwordChecker(string):
import re
x = True
while x:
if (len(string) < 6 or len(string) > 12):
print "Incorrect length"
break
elif not (re.search('[a-z]',string)):
print "no lower case characters found"
break
elif not (re.search('[A... |
e5f8bcd6a8a84bcc19faa5ae06609bcea2caea29 | balbinoaylagas/telus-py-training-B2 | /telus_py_training_b2/py_dictionaries.py | 7,823 | 4.59375 | 5 | """
Python Dictionaries
"""
# Dictionary
# Dictionaries are used to store data values in key:value pairs.
# A dictionary is a collection which is unordered, changeable and does not allow duplicates.
# Dictionaries are written with curly brackets, and have keys and values:
# Create and print a dictionary:
thisdict =... |
0ff5e10c2173301e12bff7727520d318ac6427a7 | Jaamunozr/Archivos-python | /Archivos Python Documentos/Cifrados/Python Prueba/AES_Encriptar.py | 1,944 | 3.5 | 4 | print ('-'*120)
print ('\n ALGORITMO DE ENCRIPTACION AES \n ')
def Alg_AES():
while True:
try:
llave= input ('Indique el archivo en que se encuentra alojada la llave (ejm: "llave.txt"): \n \n')
key = open(llave, 'rb')
key = key.read()
key = key [:-1]
break
except FileNotFoundError:
print ('''\n ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.