blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 545k | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 545k |
|---|---|---|---|---|---|---|
21b26bf025b3a40199771b433f8e592906d2e85d | ProngleBot/my-stuff | /Python/py files/udemy.py | 115 | 3.828125 | 4 | def add_numbers(x,y):
sum = x + y
return sum
num1 = 5
num2 = 6
print("The sum is", add_numbers(num1, num2)) |
32b051aab1979bdbfebd0a416184a735eb8e298a | ProngleBot/my-stuff | /Python/scripts/Weird calculator.py | 849 | 4.21875 | 4 | try:
x = int(input('enter first number here: '))
y = int(input('enter second number here: '))
operators = ['+','-','*', '/']
operator = input(f'Do you want to add, multiply, subtract or divide these numbers? use {operators}')
def add(x, y):
result = x + y
return result
def subtr... |
dc2a08d86e16079ae334445d83ce45fa77c27c79 | TareqJudehGithub/higher-lower-game | /main.py | 2,274 | 4.125 | 4 | from replit import clear
from random import choice
from time import sleep
from art import logo, vs, game_over_logo
from game_data import data
def restart_game():
game_over = False
while game_over == False:
restart = input("Restart game? (y/n) ")
if restart == "y":
# Clear screen between rounds:
... |
79081596fb45bc7a43d4b93ff97a84e35feada74 | rommguy/python-games | /src/sorter.py | 2,275 | 3.78125 | 4 | # First merge sort implementation
from typing import List
from functools import reduce
from math import floor
from multiprocessing import Pool
import time
def merge_lists(left: List[int], right: List[int]) -> List[int]:
result = []
left_index = 0
right_index = 0
right_len = len(right)
left_len = l... |
78c728a4054ef882875af57e0eb78a6245630250 | Parmazaan/Informatica5 | /06 - Condities/ToetsVraag2.py | 878 | 3.90625 | 4 | lengte = float(input('de gelijke lengte van beide personen: '))
naam1 = input('de naam van de eerste persoon: ')
gewicht1 = float(input('het gewicht van de eerste persoon:'))
naam2 = input('de naam van de tweede persoon: ')
gewicht2 = float(input('het gewicht van de tweede persoon: '))
bmi1 = int(gewicht1) / (int(leng... |
2b990d5047b1a09a30d1f567b892ef4bf1c3244c | Parmazaan/Informatica5 | /04 - Variabele/Transformaties.py | 139 | 3.59375 | 4 | a = (int(input('a: ')))
b = (int(input('b: ')))
print('f(x) = 2(x - 3)^2 + 4')
print('g(x) = 2(x - ' + str(3 + a)+')^2 + ' + str(4 + b)) |
ca32c6c1b1c25589a4a7b19bff863f54b453c0ca | patel-jaimin/Competitive-Programming | /CodeChef/Python/Chef and Interactive Contests(CHFINTRO).py | 1,471 | 3.9375 | 4 | # Chef and Interactive Contests
# Problem Code: CHFINTRO
# "Every beginning has an end… and an editorial." - taran_1407
# What the hell are all these interactive problems? What does flushing output mean? So many questions… Chef explains it in an easy way: you must communicate with a grader program, which accepts you... |
189e65519653efe0148ad87cca17b5288a0ba235 | patel-jaimin/Competitive-Programming | /LeetCode/Python/Subarray_Sum_Equals_K.py | 934 | 3.5625 | 4 | # 560. Subarray Sum Equals K
# Given an array of integers and an integer k, you need to find the
# total number of continuous subarrays whose sum equals to k.
# Example 1:
# Input:nums = [1,1,1], k = 2
# Output: 2
# Constraints:
# The length of the array is in range [1, 20,000].
# The range of numbers in the array ... |
5fde83dc64d2c69985c69f70a1a43e9fc7841745 | AndrewJGaut/OpenIE-Bias-Analysis | /AlterDataset/PostProcessExtractionsNormalize/Normalize.py | 1,666 | 3.765625 | 4 | '''
This code takes extracted relations and post-processes them so that it's easier to find occupation and gendered words.
Basically:
all words are stemmed
all plural words are made singular
all words are made lowercase
Nothing else is changed.
'''
import nltk
import contractions
import inflect
infl = inflect.en... |
3833683ed1fc770777d0a7d002d03969cfc67726 | AndresR25/User1.2 | /User.py.py | 1,066 | 3.609375 | 4 | class User:
def __init__(self,n,lt,ag):
self.name=n
self.lastname=lt
self.age=ag
self.amount=0
def deposit(self, amount):
self.amount += amount
return self
def make_withdrawl(self,amount):
self.amount -= amount
return self
def displa... |
685d9ea5a5410d4a18dc9e68c64857d6820b7160 | nerdless/English-Verbs-on-Python | /practice_verbs.py | 3,366 | 3.75 | 4 | from random import shuffle
from csv import reader as read
csv_file = open("Verbs.csv", "rb")
reader = read(csv_file)
verbs = {}
sep = "\xc2\xa0or\xc2\xa0"
for row in reader:
infinitive, s_past, p_participle = row
if sep in s_past:
s_past = s_past.split(sep)
if sep in p_participle:
p_parti... |
2523fc25ca0f622afccd5d89ab3396376ebb7de3 | thakur-nishant/Data-Mining | /KNearestNeighbor/K-NearestNeighbor.py | 4,464 | 3.609375 | 4 | from math import *
import numpy as np
import DataHandler as dh
import random
# Program initialization and split data into training and testing dataset
# We use DataHandler module to split the data as required.
def start(filename, class_ids, test_instances, fold=5):
# print("For class id:",class_ids)
format... |
5e2415db7845f5d341c38700b63993cd4eaa1dbe | preytaren/showMeTheCode-Solutions | /q12.py | 353 | 3.53125 | 4 | import re
from q11 import get_filter_words
def replace_filter():
word = ''
filter_words = get_filter_words()
while word != 'END':
word = raw_input()
for filter_word in filter_words:
word = word.replace(filter_word, '*'*(len(filter_word)/3))
print word
if __name__ == ... |
0f901fd61541369c456ae66c739dbdea697ab37e | JoshOrndorff/Grader | /grader_add.py | 2,145 | 3.96875 | 4 |
def add_student(cur):
""" Interactively adds zero or one students to the database.
All names will be automatically truncated to 32 characters.
Returns whether a student was actually added.
"""
print("Enter student info. (Leave first name blank to end.)")
fname = input("First Name: ")... |
7edfec4b419c3096c44636155a5c6e3a974a739d | Fabien-B/rusty-ransac | /generate.py | 624 | 3.625 | 4 | #!/usr/bin/python3
import random
def add_noise(x, sig):
noise = sig*(random.random() - 0.5)
if random.random() < 0.2:
noise = 20*sig*(random.random() - 0.5)
return x + noise
def get_y(x, factors):
y = 0
for i, factor in enumerate(factors):
y += factor * x**i
return y
def write... |
e65e5726db78fbf0daaf6fce7a5104c7aa64e8f3 | ferbcn/Color-Picker | /ColorPicker.py | 3,737 | 3.71875 | 4 | """
===========================
Color Picker and Visualizer
===========================
Simple matplotlib plot example with named colors and its visual representation.
Left mouse button on color copies its name to the clipboard
Right mouse button copies its HEX value (double right click copies rgb values as a string)
... |
182fc5d9cea9fae6c989e18385be32df11c7b3cd | chqlee/Hypergraphs | /venv/Lib/site-packages/pygraph/functions/biconnected_components.py | 10,927 | 3.53125 | 4 | """Implements functionality to find biconnected components."""
from collections import deque, defaultdict
from .connected_components import get_connected_components_as_subgraphs
from ..helpers import get_subgraph_from_edge_list
def find_biconnected_components(graph):
"""Finds all the biconnected components in a... |
20c60ce32bc96deabf9092a7829f244a2cf2c0d9 | LanaTch/Algorithms | /Lesson2/Lesson2_t7_hw.py | 501 | 3.890625 | 4 | # 7. Напишите программу, доказывающую или проверяющую, что для множества
# натуральных чисел выполняется равенство: 1+2+...+n = n(n+1)/2,
# где n - любое натуральное число.
n = int(input('введите натуральное число: '))
summa = 0
for i in range(n):
summa += i + 1
sum_n = n * (n + 1) / 2
print(f'1 + 2 + ... + n ... |
80626348a01db6f5a9a53e17f1e916c5f7980654 | LanaTch/Algorithms | /Lesson3/Lesson3_t8_hw.py | 828 | 3.9375 | 4 | # 8. Матрица 5x4 заполняется вводом с клавиатуры кроме последних элементов строк.
# Программа должна вычислять сумму введенных элементов каждой строки и
# записывать ее в последнюю ячейку строки. В конце следует вывести полученную матрицу.
SIZE_COL = 4
SIZE_ROW = 5
matrix = []
for i in range(SIZE_ROW):
summa = 0
... |
24040ed03a2da00152c06876f5be2788681137e5 | LanaTch/Algorithms | /Lesson7/hw7_t1.py | 1,583 | 3.609375 | 4 | # 1. Отсортируйте по убыванию методом "пузырька" одномерный целочисленный массив,
# заданный случайными числами на промежутке [-100; 100). Выведите на экран исходный
# и отсортированный массивы. Сортировка должна быть реализована в виде функции.
# По возможности доработайте алгоритм (сделайте его умнее).
import random... |
9c4bf078dfe05ef74a48ec7e1edb42e4b2439084 | tayebimed/Informatique-Python | /Exercices/pgcd.py | 864 | 3.59375 | 4 | #!/usr/bin/env python3
# Time-stamp: <2018-07-26 16:56 ycopin@lyonovae03.in2p3.fr>
"""
Calcul du PGCD de deux entiers.
"""
# Entiers dont on calcule le PGCD
a = 306
b = 756
# Test usuels : les nombres sont bien positifs et a > b
assert (a > 0) and (b > 0)
if a < b:
a, b = b, a # Interversion: o... |
60c9b68333f9a33ca526e156e0947db767f69892 | ianneyens/Ch.03_Input_Output | /3.0_Jedi_Training.py | 1,461 | 4.65625 | 5 | # Sign your name:Ian Neyens
# In all the short programs below, do a good job communicating with your end user!
# 1.) Write a program that asks someone for their name and then prints a greeting that uses their name.
"""
print()
name = str(input("What is your name?:"))
print()
print("Hello", name)
'''
# 2. Write a prog... |
fe2efd7b9f41bffae06a1987993156481d55280d | LostAmI/All | /HT1_add_1.2_v.1.1.py | 1,529 | 3.546875 | 4 | import random
# EX 1.1 v 1.4
# Rand or Inp option, to add same func
Quastion = input('Random or Input?')
if Quastion == 'Random' or 'random':
SpendSec = random.randint(0, 86400) # 1 Day
print(str(SpendSec) + '\n')
elif Quastion == 'Input' or 'input':
SpendSec = input('Enter time in seconds'... |
bedc3d04701d73d83d276880a9e018f01b48b71f | dmuiruri/utilities | /conver_tseries_json.py | 2,776 | 3.859375 | 4 | import json
import pandas as pd
import numpy as np
"""
This module is a collection of tools used to convert a dataframe into
a JSON format which allows the data to be easily parsed to around the
stack.
The structure of the data is as shown below. The account name is
picked as the column name.
account_his... |
19d2b8a62a478f9eff361d030ed55cf3c9aa73bd | lpmurray16/2015-2019 | /Old_DePaul_Classes/Python Class/recursion_practice.py | 9,551 | 4.34375 | 4 | ########################################################
# CSC 242 Section 504 Winter 2017
# Recursion exercises (Ch. 10)
########################################################
def factorial(n):
'nonrecursive version of factorial'
answer = 1
for i in range(1,n+1):
answer *= i
return... |
862460579fd1804484f2dcdad9a3bb9fed8e6ec9 | aisyesm/algorithms-and-data-structures | /data-structures/doubly_linked_list.py | 1,427 | 3.5625 | 4 | class _DoublyLinkedBase:
'''A base class for providing a doubly linked list representation.'''
class _Node:
'''Lightweight, nonpublic class for storying a doubly linked node.'''
__slots__ = '_element', '_prev', '_next' # streamline memory
def __init__(self, element, prev, next):
... |
dcd2efddee64970de7a77163cbb3413ff3cd588a | burkea/FCND-Motion-Planning | /grids.py | 9,788 | 3.65625 | 4 | from abc import abstractmethod
from udacidrone.frame_utils import global_to_local,local_to_global
import numpy as np
class Grid:
def __init__(self):
self.grid = None
self.edges = None
@abstractmethod
def create_grid(self,data, drone_altitude, safety_distance):
None
@abstractmet... |
5c6f82dd9ef1ce74aa0fbbf79537c1f7203eb61c | brunpa/solvingSudoku | /sudoku_TASK.py | 4,998 | 3.640625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Jan 04 08:13:32 2017
Formulates sudoku as a CSP, solving the riddle from
https://www.sudoku.ws/hard-1.htm as an example.
@author: stdm
@modif: tugg
"""
import sys
sys.path.append("./python-constraint-1.2")
import constraint as csp
# -----------------------... |
d30a8339678effc870e6dc5ad82917d1282acff9 | Laikovski/codewars_lessons | /6kyu/Convert_string_to_camel_case.py | 796 | 4.625 | 5 | """
Complete the method/function so that it converts dash/underscore delimited words into camel casing.
The first word within the output should be capitalized only if the original word was capitalized
(known as Upper Camel Case, also often referred to as Pascal case).
Examples
"the-stealth-warrior" gets converted to "... |
eaa974e6367967cadc5b6faa9944fbaaa760557f | Laikovski/codewars_lessons | /6kyu/Longest_Palindrome.py | 511 | 4.28125 | 4 | # Longest Palindrome
#
# Find the length of the longest substring in the given string s that is the same in reverse.
#
# As an example, if the input was “I like racecars that go fast”, the substring (racecar) length would be 7.
#
# If the length of the input string is 0, the return value must be 0.
# Example:
#
# "a" -... |
cd4a14aa502abbcba0519428a684b01be17c0427 | Laikovski/codewars_lessons | /6kyu/New_Cashier_Does_Not_Know.py | 1,292 | 4.28125 | 4 | # Some new cashiers started to work at your restaurant.
#
# They are good at taking orders, but they don't know how to capitalize words, or use a space bar!
#
# All the orders they create look something like this:
#
# "milkshakepizzachickenfriescokeburgerpizzasandwichmilkshakepizza"
#
# The kitchen staff are threatenin... |
6e5087b04396d852eff9c16d714eabb9b0c45175 | sohaibfarooqi/ml | /linear_regression/logistic_function.py | 1,869 | 3.796875 | 4 | """
This file implements simple linear regression with one variable. Output Y is plotted against one feature X.
MSE and R^2 are calculated to determine how well model fits in.
Example from sklearn site: http://scikit-learn.org/stable/auto_examples/linear_model/plot_ols.html#sphx-glr-auto-examples-linear-model-plot-ols... |
90bf50fee8f6d1940bada5add8a4335a0d6462dd | kxu12348760/PythonPractice | /sort.py | 1,293 | 4.28125 | 4 | # Simple insertion sort
def insertion_sort(array):
arrayLength = len(array)
for i in range(1, arrayLength):
item = array[i]
j = i - 1
while j >= 0 and array[j] > item:
array[j + 1] = array[j]
j = j - 1
array[j + 1] = item
return array
# Iterative bottom-up mergesort
def merge_sort(array):
mergeLength... |
15154525c00d8007bec428d8749046877836eced | alcibiadesBustillo/GUIs-with-Tkinter | /cipher_cesar/gui_cesar_cipher.py | 3,794 | 3.734375 | 4 | from tkinter import *
from tkinter.filedialog import askopenfilename, asksaveasfilename
import cesar as cs
import os
current_directory = os.getcwd()
def open_file():
"""Openfile for editing
"""
filepath = askopenfilename(
initialdir = current_directory,
filetypes=[("Text Files", "*.txt"),... |
3dffb3e7b971c0961c1d655dfec9be04cf0609b8 | alcibiadesBustillo/GUIs-with-Tkinter | /cipher_cesar/cesar.py | 1,558 | 4.0625 | 4 | from random import randint
# Generate a random integer between 1 and 26
#SHIFT = 22 #randint(1,26)
TEXT = "ESTE ES UN MENSAJE DE AMISTAD"
TEXT2 = "AOPA AO QJ IAJOWFA ZA WIEOPWZ"
#ENCRYPTION = ""
#DECRYPTION = ""
def encryption(text, SHIFT):
ENCRYPTION = ""
for character in text:
# Check if char... |
aecd95cb9a29890136688bffeb3d378dc70574fd | bryandeagle/practice-python | /03 Less Than Ten.py | 648 | 4.34375 | 4 | """
Take a list, say for example this one:
a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
and write a program that prints out all the elements of the list
that areless than 5.
Extras:
1. Instead of printing the elements one by one, make a new list that has all
the elements less than 5 from this list in it and print o... |
6f9a10bbf9d0064cc111e7be3a9ed458fc615e46 | bryandeagle/practice-python | /18 Cows And Bulls.py | 1,358 | 4.375 | 4 | """
Create a program that will play the “cows and bulls” game with the user.
The game works like this:
Randomly generate a 4-digit number. Ask the user to guess a 4-digit number.
For every digit that the user guessed correctly in the correct place, they
have a “cow”. For every digit the user guessed correctly in the w... |
2fec0f04fce0558c8f4a2d9ff8ced1f36c8b2c14 | bryandeagle/practice-python | /06 String Lists.py | 406 | 4.4375 | 4 | """
Ask the user for a string and print out whether this string is a palindrome or
not. (A palindrome is a string that reads the same forwards and backwards.)
"""
string = input('Give me a string:').lower()
palindrome = True
for i in range(int(len(string)/2)):
if string[i] != string[-i-1]:
palindrome = Fa... |
ab34c03b50a5306d7c6c937530f9029f3467db10 | bryandeagle/practice-python | /16 Password Generator.py | 692 | 4.03125 | 4 | """
Write a password generator in Python. Be creative with how you generate
passwords - strong passwords have a mix of lowercase letters, uppercase
letters, numbers, and symbols. The passwords should be random, generating
a new password every time the user asks for a new password. Include your
run-time code in a main m... |
d618c13b78ab24c94a80d3484cb2f5899ca097c0 | nebbles/de2-com2-indiv | /lib/external.py | 775 | 3.609375 | 4 | # This file imports code collected from elsewhere.
# This file isnt actually used, not enough time to implement
def spellchecker(string_in, compare_list):
word1 = str.lower(string_in)
for i in compare_list:
word2 = i
len_1 = len(word1)
len_2 = len(word2)
x = [[0]*(len_2+1) for _... |
035ed2f01b49e00b355dee68968cfd337ab4c06e | Fadhel00100/getStringNumber- | /num.py | 471 | 3.546875 | 4 |
user = input('Enter you string: ')
def theuser(user):
fadhel = user.split()
d={}
for x in fadhel:
if x not in d.keys():
d[x] = 0
d[x] += 1
print(d)
theuser(user)
'''
username = input('enter: ')
def strring(username):
var = username.split()
dict = {}
for... |
4d47b7832f0dab3df6df1967a16e0f04d9808b99 | uozcan12/Twitter-Data-Normalization | /normalization.py | 14,836 | 3.53125 | 4 | # -*- coding:utf-8 -*-
import nltk
import re
import difflib
from deasciifier import Deasciifier
from nltk.tokenize import word_tokenize
import collections
from nltk.tokenize import WordPunctTokenizer
tweet=input("Normalize edilecek tweeti giriniz :")
#tweet='@dida bi yere gitcem "büttttttüüüünnnnn insanlar hür, hysy... |
65794003fb80e104c1ea43d7d372da3f5e4e0e46 | VGAD/deadliest-date | /game/helper.py | 508 | 3.671875 | 4 | import pygame
def load_image(image):
"""
If an image is passed, returns the image. If a string is passed, loads
an image from the given filename.
"""
temp_image = image
# Load the image if a filename is given
if type(image) == str:
temp_image = pygame.image.load(image).convert_... |
2642206c725019e2d8b6ba9df80e8e81b2c6dba2 | Star-Coder-7/Dictonaries-and-Sets | /adventure_game_two.py | 1,922 | 4 | 4 | venues = {0: "Now, you are relaxing in front of a screen learning Python",
1: "Now, you are standing at the end of a road before a small brick building",
2: "Now, you are at the top of a hill",
3: "Now, you are inside a building, a well house for a small stream",
4: "Now, you are... |
efa1dc9d2e9481890f4cbb993819652b7dcfb7d4 | hunnam5220/Codeup | /01. 기초 100제/02. 기초 입출력문 및 연산자_56/1025. 정수 1개 입력받아 나누어 출력하기.py | 115 | 3.59375 | 4 | s = list(input())
arr = ['0000', '000', '00', '0', '']
for x in range(len(s)):
print('[' + s[x] + arr[x] + ']') |
f61530b2d6595e91b78e1f875d7d62d5b91461c0 | aroraavinash/ga-learner-dsmp-repo | /avinash/code.py | 1,126 | 3.78125 | 4 | # --------------
# Given string
topper = 'andrew ng'
# Code starts here
name_first_last=topper.split()
first_name=name_first_last[0]
last_name=name_first_last[1]
full_name=last_name+" "+first_name
certificate_name=full_name.upper()
print(certificate_name)
# Code ends here
# --------------
# Code starts here
course... |
830ba1aaf3732e02dfe8b24e7bf570ac06a813e8 | muskan3400/python_guess_game | /guess_game.py | 2,913 | 3.890625 | 4 |
import random
import string
print("WELCOME TO THE GUESS GAME!")
print("\n")
name=input("What is your name:")
print("\n")
print("Choose difficulty level")
print("B:Beginner level")
print("I:Intermediate level")
print("A:Advanced level")
B=["early","table","abroad","letter","python","advice","actor","github","branch... |
0fb11eee1a32337ca6e50074f5436081cb371a63 | asreedh3/Machine-Learning | /Polynomial Regression.py | 1,960 | 3.84375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Dec 19 20:56:04 2018
@author: Ashlin
"""
import pandas as pd
import numpy as np
from sklearn.metrics import r2_score
import matplotlib.pyplot as plt
mydata=pd.read_csv('Position_Salaries.csv')
y=mydata.iloc[:,-1]
# This is done so that we can make X as a matri... |
7315bdbf501779650f2c42d23fe09b34f2e38993 | Cooper201811/dz_1 | /while_1.py | 252 | 3.953125 | 4 | mylist = ["Вася", "Маша", "Петя", "Валера", "Саша", "Даша"]
name = 'Глеб'
while name != 'Валера':
name = mylist.pop()
print(mylist)
if name == 'Валера':
print('Валера нашелся!') |
76e81c1b372e45580f9d806cae196c95ee52131c | Cooper201811/dz_1 | /while_6.py | 356 | 3.921875 | 4 | dictionary = {"Как дела?": "Хорошо", "Что делаешь?": "Программирую"}
def ask_user():
while True:
ask_me = input('Задайте мне вопрос: ')
if ask_me in dictionary:
print(dictionary[ask_me])
else:
print('Я не знаю.')
continue
ask_user() |
a6edbba947fe0fc1f81107b7a1943258f900050b | GregoryTolmochow/GregoryTolmochow | /Gregory.py | 17,733 | 3.90625 | 4 | #Gregory Tolmochow
#Computer Science Final Project
#May 19, 2020
import random
import time
import math
def name():
global x
x = input('Enter you name: ') #Intro information on data being used about player
print()
time.sleep(3)
print('Now be careful this next input will determine how long you are ... |
0ee536099d09e1bfce4ad1087ecf151e388078cd | Stvad/pyconie_dsl | /examples/elixir_pipes.py | 691 | 3.828125 | 4 | from itertools import groupby
from pipeop import pipes
"""
Elixir style pipes in Python.
"""
def group_to_dict(group_by_object):
return {key: list(value) for key, value in group_by_object}
def group_by_character_set(input_string):
print(group_to_dict(
groupby(map(lambda x: x.lower(),
... |
be2abcbecf6bd9166c5b44e2736dbc9451f84d21 | JNazare/QR_Encoder | /QRprepData_ak.py | 4,977 | 4.15625 | 4 | ## README: Teddie/Jessica, you want to list of decimal integers in the last line
## of this script that is # printed with 'For Teddie ...'
## also, i used Python 3.0, so you'll have to change the # print()
## statements to remove the parenthesis, if running it in Python 27
### QR code en... |
aa8f8c6caf722dd1dd4751ec81136c261b1790b2 | wh0930/A-Code-Assistant | /Python/Python选修课/第二次作业/format output.py | 47 | 3.515625 | 4 | a=input()
a=float(a)
print("{:.3f}".format(a))
|
c250bbf98982c493adbdb95226c4ee1aa514dce7 | chaitanya-lohar/tkinter-project | /22-radiobutton.py | 839 | 3.671875 | 4 | from tkinter import *
from tkinter import messagebox
root=Tk()
root.geometry("700x700")
root.resizable(0,0)
var1=StringVar()
var1.set("Radio")
def fun1():
messagebox.showinfo("order received",f"we have received your order for {var1.get()}")
l1=Label(root,text="what would you like to have ?",font="tim... |
1ae29820879142b03042576ca66bc500aac48d8b | chaitanya-lohar/tkinter-project | /20-Radiobutton.py | 931 | 3.734375 | 4 | from tkinter import *
from tkinter import messagebox
root=Tk()
root.geometry("400x400")
x=IntVar()
def show1():
if(x.get()==1):
# messagebox.showinfo("courses","you clicked on python")
messagebox.askquestion("courses",f"do you want to purchase this {'Python'} course?")
else:
... |
f4bcc31f7c821c32cec255f5c3c898aaf458f198 | chaitanya-lohar/tkinter-project | /IP address.py | 544 | 3.71875 | 4 | # to find IP ddress
import socket
hostname=socket.gethostname()
print(hostname)
ip_address=socket.gethostbyname(hostname)
print(ip_address)
# -----------------------------------------------
# for check internet speed in python
# import os
# os.system('cmd/k"ping localhost"')
#-------------------------------... |
a29b974e347d31bf2186b04f425dcfa4a315aba6 | KB-Naveen/ISE-5th-sem-SL-Lab | /partA_1.py | 621 | 4.0625 | 4 | #(i)
n = int(input("Enter number of elements : "))
print("Enter elements : ")
l = []
for i in range(n):
temp = int(input())
l.append(temp)
print("List :",l)
#(ii)
print("Minimum element :",min(l))
print("Maximum element :",max(l))
#(iii)
e = int(input("Enter the element to insert :"))
p = int(input("Enter the... |
49d9e932803a636a266c5d4bfab5059c0a14ba79 | KB-Naveen/ISE-5th-sem-SL-Lab | /partB_8.py | 538 | 3.5 | 4 | class rev:
def __init__(self,sentense):
self.s = sentense
def reverse(self):
self.s = self.s.split()
self.s.reverse()
return " ".join(self.s)
o = ['a','A','e','E','i','I','o','O','u','U']
s_list = []
for i in range(3):
print("Enter sentense",(i+1),": ",end='')
s = inpu... |
2f12138956586c72818de4c13b73eb04e0e0d9fb | stybik/python_hundred | /programs/27_print_dict.py | 309 | 4.21875 | 4 | # Define a function which can generate a dictionary where the keys are numbers
# between 1 and 20 (both included) and the values are square of keys.
# The function should just print the values only.
numbers = int(raw_input("Enter a number: "))
dic = {n: n**2 for n in range(1, numbers)}
print dic.values()
|
21f8d378f04829a3aa26f59287f7e0afaa909727 | stybik/python_hundred | /programs/51_fibonacci.py | 200 | 3.546875 | 4 | def f(n):
if n == 0:
return 0
elif n == 1:
return 1
else:
return f(n-1) + f(n-2)
n = int(raw_input())
val = [str(f(x)) for x in range(0, n+1)]
print ",".join(val)
|
646f89a757e6406543bec77dab04d9f61f97308d | stybik/python_hundred | /programs/10_whitespace.py | 342 | 4.125 | 4 | # Write a program that accepts a sequence of whitespace
# separated words as input and prints the words after
# removing all duplicate words and sorting them
# alphanumerically.
string = "Hello world, I am the boss boss the world should fear!"
words = string.split(" ")
print ("The answer is: ")
print (" ".join(sorte... |
ddcc1201c4fdd399c98f67689fc6a90cc5677069 | stybik/python_hundred | /programs/6_formula.py | 480 | 4.15625 | 4 | # Write a program that calculates and prints the value according to the given formula:
# Q = Square root of [(2 * C * D)/H]
# Following are the fixed values of C and H:
# C is 50. H is 30.
# D is the variable whose values should be input to your program in a comma-separated sequence.
import math
c = 50
h = 30
val = [... |
2f86621b953186c71e491a3fd164c96deca3b7f2 | stybik/python_hundred | /programs/21_robot.py | 1,045 | 4.53125 | 5 | # A robot moves in a plane starting from the original point (0,0). The robot can move toward UP, DOWN, LEFT and RIGHT with a given steps. The trace of robot movement is shown as the following:
# UP 5
# DOWN 3
# LEFT 3
# RIGHT 2
# ¡
# The numbers after the direction are steps. Please write a program to compute the dist... |
051820ad6fc76ac8ec4e01a0e3c12d71bc1509f7 | stybik/python_hundred | /programs/61_random_list.py | 155 | 3.53125 | 4 | # Please write a program to generate a list with 5 random numbers between 100
# and 200 inclusive.
import random
print random.sample(range(100, 200), 5)
|
e196c2186a359c1a966cea16dcedd8239695dade | Lazarus-XD/Password_Manager | /main.py | 6,212 | 3.703125 | 4 | import sqlite3
from cryptography.fernet import Fernet
import cryptography
import random
import string
import stdiomask
def storeUser(username):
cur.execute("INSERT INTO info (username) VALUES (?)", (username,))
conn.commit()
def addServiceAndPass(username, key):
"""Store the randomly generated password in... |
add07e8e258ea6c5cfcd183ffb64fb358d8ef2b8 | longcyue/learning | /venv/day16.py | 1,525 | 3.84375 | 4 | # # class Foo:
# # def f1(self):
# # print('from Foo.f1')
# #
# # def f2(self):
# # print('from Foo.f2')
# #
# #
# # class Bar(Foo):
# # def f1(self):
# # print('from Bar.f1')
# #
# #
# # b = Bar()
# # print(b.__dict__) # {}
# # b.f1() # from Bar.f1
#
#
# class People:
# def __... |
35f0d86fa443709624c9dbbdfa89414a19501719 | Yukine-Alterma/Parse-Program | /parseprogram.py | 330 | 3.671875 | 4 | info = input("Enter the following information : Name, age, gender, species, relationship status : ")
list = ' '.join(info.split())
mylist = list.split()
print(mylist)
print("Name : " + mylist[0])
print("Age : " + mylist[1])
print("gender : "+mylist[2])
print("Species : "+mylist[3])
print("Relationship Status : "+my... |
e8c0bb6e208075677e606dc2ea91bd461e31b7c7 | ere8o/python_snippets | /binary_search.py | 882 | 3.6875 | 4 | def binary_search(arr, srch_v, lo, hi):
mid = lo + int((hi - lo)/2)
arr_v = arr[mid]
if srch_v == arr_v:
return mid
if srch_v > arr_v:
mid = binary_search(arr, srch_v, mid, hi)
if srch_v < arr_v:
mid = binary_search(arr, srch_v, lo, mid)
return mid
arr = [1, 4, ... |
22e1d41e05991af8fa7b46bf52dc529fe601404b | kNosek1618/bootpycamp_functions_1.0 | /CommonReturnMistakes.py | 413 | 3.875 | 4 |
# TWO OPTIONS FOR DEFINE IF STATEMENT WITH RETURN METHOD
def is_odd_number(num):
if num % 2 != 0:
return True
else:
return False
print(is_odd_number(4))
print(is_odd_number(9))
###########################
# IN FUNCTION LIKE THIS 'ELSE' IS UNNECESSARY
def is_odd_number(num):
if num % 2 !=... |
fcacc856a49bc8bce2da69e559df0893df600188 | kNosek1618/bootpycamp_functions_1.0 | /KeywordArguments.py | 299 | 4.0625 | 4 |
# Example of input in function
def add():
a = input()
a = int(a)
return a+1
print(add()) # 3
##################################
# OTHER EXAMPLE OF INPUT TO FUNCTION
def add(a):
a = int(a)
return a+1
print(add(input("enter number"))) # Question for number and RESULT 3
|
f99c6ae04e0440e396e320cebad34e84cb13e777 | scchristian/ceaser | /decrypt_ceaser_uts.py | 595 | 3.546875 | 4 | import os
SYMBOLS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
def decrypt(cipher, key):
translated = ''
for symbol in cipher:
if symbol in SYMBOLS:
translatedIndex = (SYMBOLS.find(symbol) - key) % 52
translated = translated + SYMBOLS[translatedIndex]
... |
5ef33f3751013f7f5d6849528f28606af37cdc95 | bingganye/pymldemo | /code/python/ui/simple.py | 1,214 | 3.703125 | 4 | #!/usr/bin/python3
# -*- coding: utf-8 -*-
"""
ZetCode PyQt5 tutorial
In this example, we create a simple
window in PyQt5.
Author: Jan Bodnar
Website: zetcode.com
Last edited: August 2017
"""
import sys
from PyQt5.QtGui import QFont
from PyQt5.QtWidgets import QApplication, QWidget, QToolTip, QPushButton
import pa... |
304ce8046e74f12c11f976470d7d5d2aafe02409 | s9521057/FirstTest | /FirstPython.py | 86 | 3.5625 | 4 | from datetime import datetime
now_time=datetime.now()
print('Time is '+ str(now_time)) |
d8d9aed0cff9bae25ac1a92cb7e20e6abbf3fb45 | JoeyParshley/met_cs_521 | /jparshle@bu.edu_hw_4/jparshle@bu.edu_hw_4_11_3.py | 2,270 | 3.84375 | 4 | """
Joey Parshley
MET CS 521 O2
3 APR 2018
hw_4_11_3
Description: Rewrite Listing 11.2, GradeExam.py, to display the students in
increasing order of the number of correct answers.
"""
def getListOfStudents(m,count,i):
"""
Description: creates a list of list of the students each sublist
... |
61585cbf2848306932b35664530ba2ba925d1f22 | JoeyParshley/met_cs_521 | /jparshle@bu.edu_hw_3/jparshle@bu.edu_hw_3_8_1.py | 1,687 | 4.3125 | 4 | """
Joey Parshley
MET CS 521 O2
30 MAR 2018
hw_3_8_1
Description: Write a program that prompts the user to enter a Social Security
number in the format ddd-dd-dddd, where d is a digit. The program displays
Valid SSN for a correct Social Security number or Invalid SSN otherwise.
"""
def ssn_val... |
f93777f6c35830ee9f5f4384b1054ee86a8d253e | JoeyParshley/met_cs_521 | /jparshle@bu.edu_hw_2/jparshle@bu.edu_hw_2_3_3.py | 3,211 | 3.828125 | 4 | """
Joey Parshley
MET CS 521 O2
26 MAR 2018
hw_2_3_3
Description: Compute the estimated enclosed by Atlanta, Georgia; Orlando,
Florida; Savannah, Georgia; and Charlotte, North Carolina based on the
GPS locations obtained from www.gps-data-team.com/map/
"""
import math
# greate global variable for... |
30b1452a33dc76783e68a00f0a2a329acb1402a9 | JoeyParshley/met_cs_521 | /jparshle@bu.edu_hw_2/jparshle@bu.edu_hw_2_2_3.py | 774 | 4.40625 | 4 | """
Joey Parshley
MET CS 521 O2
26 MAR 2018
hw_2_2_3
Write a program that reads a number in feet, converts it to meters, and
displays the result.
One foot is 0.305 meters.
"""
# Greet the user and prompt them for a measurement in feet
print("\nThis program will read a measurement in feet from ... |
2a4854737b37f2659e6b11ca4dd1e91fd0162448 | JoeyParshley/met_cs_521 | /jparshle@bu.edu_hw_2/jparshle@bu.edu_hw_2_3_1.py | 2,292 | 4.53125 | 5 | """
Joey Parshley
MET CS 521 O2
26 MAR 2018
hw_2_3_1
Write a program that prompts the user to enter the length from the center of
a pentagon to a vertex and computes the area of the pentagon
"""
# import the math module to use sin and pi
import math
# Contstants to be used in functions
# used to c... |
562937f67a29f6e75b6fa1b92131ea7806efeff4 | JoeyParshley/met_cs_521 | /recursive_sum.py | 187 | 4.1875 | 4 | def sum(n):
if n == 0:
return 0
else:
return n + sum( n - 1 )
n = int(input("Enter a positive integer: "))
print("The sum of positive integers up to {0} is {1}".format(n, sum(n))) |
4a77f879061013eec3f8d0c136288e6e826d796f | anwartan/arkademy | /1.py | 294 | 3.859375 | 4 | def triangle(x):
if(x.isdigit()):
if(int(x)<=0):
print("Paramemeter harus angka dan positif!")
else:
for i in range(1,int(x)+1):
print(i*"#")
else:
print("Paramemeter harus angka dan positif!")
a=input()
triangle(a)
|
a9c76ec6572eb8027ce6ebd169c50a8b63f105dc | puneet4840/Data-Structure-and-Algorithms | /Queue in Python/5 - Double Ended Queue.py | 2,380 | 4.46875 | 4 | # Double Ended Queue: When insertion and Deletion can be done on both (rear and front) ends.
# It is called Double Ended Queue or Deque.
print()
class Dequeue():
def __init__(self):
self.size=int(input("Enter the szie of Dequque: "))
self.Deque=list()
def Insert_from_rear_side(self,item):
... |
be808b86dd30bf6983fa13f28a5feba15ef6efce | puneet4840/Data-Structure-and-Algorithms | /Queue in Python/1 - Creating Queue using python List.py | 1,889 | 4.25 | 4 | # Queue is the ordered collection of items which follows the FIFO (First In First Out) rule.
## Insertion is done at rear end of the queue and Deletion is done at front end of the queue.
print()
class Queue():
def __init__(self):
self.size=int(input("\nEnter the size of the Queue: "))
self.que=lis... |
c449d00c72a0a67890903b445ca85e44f979548f | puneet4840/Data-Structure-and-Algorithms | /Recursion in Python/Print even numbers.py | 151 | 3.984375 | 4 | # Print even numbers till 100
print()
def even(n):
if n<=100:
if n%2==0:
print(n,end=" ")
even(n+1)
even(1) |
9467799833a6c78fc4097870f8ec7c917f45ca68 | puneet4840/Data-Structure-and-Algorithms | /Stack in Python/3 - Reverse a string using stack.py | 571 | 4.1875 | 4 | # Reverse a string using stack.
# We first push the string into stack and pop the string from the stack.
# Hence, string would be reversed.
print()
class Stack():
def __init__(self):
self.stk=list()
self.str=input("Enter a string: ")
def Push(self):
for chr in self.str:
se... |
5d1c063e0094fcf79a7907b970b28f0b699396fc | puneet4840/Data-Structure-and-Algorithms | /Hashing in Python/Chaining Method/1 - Implementing Hashing using Simple Array.py | 2,901 | 4.09375 | 4 | # Implementing Hashing using simple array and Chaining Technique.
print()
class Node:
def __init__(self,data):
self.data=data
self.next=None
class Hashing:
def __init__(self,size):
self.size=size
self.hash_table=[None]*self.size
def Hash_Function(self,item):
retur... |
0552dcd035f75378738f69c2a723dc0e64598ad7 | puneet4840/Data-Structure-and-Algorithms | /Graph in Python/4 - Detecting Cycle in Graph/2 - Detect Cycle in Directed Graph.py | 2,540 | 3.9375 | 4 | # Detect Cycle in Undirected Graph using BFS(Bradth First Search) method.
print()
class Graph:
def __init__(self,vertices):
self.vertices=vertices
self.graph={}
for vertex in self.vertices:
self.graph[vertex]=[]
def add_edge(self,s,d):
if d in self.graph[s]:
... |
79b5b14d8006fc6ee9598d4bfc46518289510fe4 | puneet4840/Data-Structure-and-Algorithms | /Linked List in Python/2 - Doubly Linked List/4 - Insertion before specific node.py | 2,390 | 4.25 | 4 | # Inserting a node before a specific node in the linked list.
print()
class Node():
def __init__(self,data):
self.prev=None
self.data=data
self.next=None
class Linked_list():
def __init__(self):
self.start=None
def insert_node(self,data):
temp=Node(data)
if... |
1292d9ae7544923786c98b67c4c2c426314f3cac | puneet4840/Data-Structure-and-Algorithms | /Recursion in Python/Binary Search using python.py | 798 | 4.125 | 4 | # Binary Search using Python.
# It takes o(logn) time to execute the algorithm.
l1=list()
size=int(input("Enter the size of list: "))
for i in range(size):
l1.append(int(input(f"\nEnter element {i+1}: ")))
l1.sort()
def Binary_Search(l1,data,low,high):
if(low>high):
return False
else:
... |
3c59fac110d7dc36481371f87c8e64b6e228bb68 | puneet4840/Data-Structure-and-Algorithms | /Recursion in Python/Calculating the maximum element in a list.py | 239 | 4.0625 | 4 | # Here we are using a recursive method to calculate the maximum number in a list.
print()
l=[1,5,3,4,2]
def maximum(l,n):
if n==1:
return l[0]
else:
return max(l[n-1],maximum(l,n-1))
n=len(l)
print(maximum(l,n))
|
4e32b479e611d555a62153b4d800753457636bfe | puneet4840/Data-Structure-and-Algorithms | /Tree in Python/Binary Search Tree/3 - Deletion in BST having one children.py | 2,395 | 3.96875 | 4 | # Deletion in BST having one children.
print()
class Node:
def __init__(self,data):
self.data=data
self.left=None
self.right=None
class Linked_list:
def __init__(self):
self.root=None
def Insert_node(self,data):
temp=Node(data)
if self.root==None:
... |
d03538d4dca196e6fda1d7508233a8f9ce2852a6 | puneet4840/Data-Structure-and-Algorithms | /Linked List in Python/5 - Queue using Linked LIst/12 - Queue using Linked lIst.py | 1,436 | 4.1875 | 4 | # Implementing Queue using Linked list.
print()
class Node():
def __init__(self,data):
self.data=data
self.next=None
class Linkd_list():
def __init__(self):
self.start=None
def Insert_at_end(self,data):
temp=Node(data)
if self.start==None:
self.start=te... |
9a46984cc1655739334a16a11f1f252dc20cdd91 | puneet4840/Data-Structure-and-Algorithms | /Recursion in Python/Print numbers from 1 to 10 in a way when number is odd add 1 ,when even subtract 1.py | 393 | 4.3125 | 4 | # Program to print the numbers from 1 to 10 in such a way that when number is odd add 1 to it and,
# when number is even subtract 1 from it.
print()
def even(n):
if n<=10:
if n%2==0:
print(n-1,end=' ')
n+=1
odd(n)
def odd(n):
if n<=10:
if n%2!=0:
... |
fa0bf4de5631301d3ee23a655a62980dde419eab | puneet4840/Data-Structure-and-Algorithms | /Linked List in Python/1 - Singly Linked List/2 - Creating linked list.py | 1,266 | 4.21875 | 4 | # Linked List is the collection of nodes which randomly stores in the memory.
print()
class Node():
def __init__(self,data):
self.data=data
self.next=None
class Linked_List():
def __init__(self):
self.start=None
def Insert_Node(self,data):
temp=Node(data)
if self.s... |
d0cab036eb084c555f428a868e594328e6761b47 | puneet4840/Data-Structure-and-Algorithms | /Linked List in Python/2 - Doubly Linked List/6 - Delete Last Node.py | 1,560 | 4.15625 | 4 | # Delete Last Node
print()
class Node():
def __init__(self,data):
self.prev=None
self.data=data
self.next=None
class Linked_List():
def __init__(self):
self.start=None
def Insert_Node(self,data):
temp=Node(data)
if self.start==None:
... |
f20449e9e7d1a74d3310812618954502083207e3 | thiagomess/pyhton | /OO2/Pessoa.py | 426 | 3.640625 | 4 | class Pessoa:
tamanho_cpf = 11
def __init__(self, cpf, nome):
self.cpf = cpf
self.nome = nome
def valida_cpf(self):
# precisamos usar o __class__ para definir que queremos o atributo de classe.
return True if len(self.cpf) == __class__.tamanho_cpf else False
pe = Pessoa('... |
142b961996b24abc6de9c3b754473af445b6c591 | wugelihai/month_01 | /day_02/02—获取进程编号.py | 1,944 | 3.546875 | 4 | # 1.导入进程包
import multiprocessing
import time
import os
# 跳舞任务
def dance():
dance_process_id = os.getpid()
print('dance_process_id:', dance_process_id, multiprocessing.current_process())
# 获取这个子进程的父进程编号
dance_process_parents_id = os.getppid()
print('sing_process_parents_id的主进程编号是:', dance_process_p... |
71da37afb9b5e21f01a16b6777b4c46aa13adc94 | hchasestevens/hunger_game | /Underminer.py | 7,831 | 3.65625 | 4 | # ===UNDERMINER===
'''
General strategy:
- Assume other players are inferring identity via reputation as described
below.
- Assume (at least some of) these other players are employing tit-for-tat.
- If in a position with a slightly better reputation than some opponent
and the ability to decrease own reputation to ... |
0db68988185be46ab2e389805b117aa8bf1e3a50 | RasPat1/practice | /algs-python/subsequence.py | 562 | 3.890625 | 4 | """
Largest possible subsequence
Taken a list of integers select the largest
subsequence in which all digits are strictly increasing
"""
import random
def main():
ssSize = random.randint(1, 20);
ss = makeSS(ssSize);
print ss;
print getSS(ss)
def makeSS(size):
return random.sample(range(1,101), size)
def getSS(... |
570ce4c7be39132e0170b9554316315f562ed5db | TKorshikova/PythonQA | /3.1.py | 802 | 4.15625 | 4 | # импорт всегда первый
import random
# Создаем список с заданными параметрами
def create_list(count, maximum):
# возвращаем список от 1 до заданного числа с заданным количеством элементов
return [random.randint(1, maximum) for i in range(count)]
# пользователь вводит количество элементов
inputCount = int(in... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.