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 |
|---|---|---|---|---|---|---|
5110936e39117ad59aabf0a69b03f11627b43def | The-Riz5-Iz6-Wiz4/PythonExercise1 | /RunwayLengthRizky.py | 315 | 3.890625 | 4 | #input, v for velocity, a for acceleration
v = float(input("Enter the plane's take off speed in m/s: "))
a = float(input("Enter the plane's acceleration in m/s^2: "))
#Formula for min runway length
Runway = (v**2)/(2*a)
#Output
print("The minimum runway length for this airplane is", round(Runway, 4), "meters") |
a3ae007c55ee2cfe220cd9094b4eaa38822ded38 | CountTheSevens/dailyProgrammerChallenges | /challenge001_easy.py | 803 | 4.125 | 4 | #https://www.reddit.com/r/dailyprogrammer/comments/pih8x/easy_challenge_1/
# #create a program that will ask the users name, age, and reddit username. have it tell them the information back,
#in the format: your name is (blank), you are (blank) years old, and your username is (blank)
#for extra credit, have the program... |
d23e945fb14965f2d07e327149378f79389e26bc | emanuele1234/esercitazione-22-03-2020 | /main.py | 364 | 3.953125 | 4 | nome=input('inserisci il tuo nome ' )
età= input('inserisci la tua età ')
DoveVivi=input('inserisci la città in cui abiti ')
Fam=input('inserisci il numero di persone nella tua famiglia ')
print(" ciao " + nome + " hai " + età+ " anni " + " vivi a " + DoveVivi + " nella tua famiglia siete " + Fam )
x=10
b=4
for i in ... |
2b9725c92b14019c5dbf3add29d24f99c37c0554 | ramneekc/Python-practice | /Prime_Factors.py | 480 | 4.09375 | 4 | #Function to find prime factors of a number
def prime_factors(x):
number =2
arr = list()
while (number <= x):
if (x % number) == 0: #Checks if remainder is 0
arr.append(number) #if remainder is 0, appends the number in the list
x = x/number #Then keep div... |
9ad6bdfc6dd78ccf4974011677b0b2d2a8e7ecab | Arsemon4ik/my_projects_OOP | /Figures(1.10.1)/Figures.py | 585 | 3.84375 | 4 | class Circle:
def __init__(self, x=0 ,y=0 ,width=0 ,height=0):
self.x = x
self.y = y
self.width = width
self.height = height
def GetInf(self):
return print("Circle ({0}, {1}, {2}, {3}). ".format(self.x,self.y,self.width,self.height))
class Recktangle:
def __ini... |
748b1fc72ef44444603c1ddb5d523361b2fef57d | joedave1/python | /permutethecollectionofnumbers.py | 345 | 3.890625 | 4 | def permutethenumber(nums):
res_perms = [[]]
for n in nums:
new_perms = []
for perm in result_perms:
for i in range(len(perm)+1):
new_perms.append(perm[:i] + [n] + perm[i:])
res_perms = new_perms
return res_perms
a = [1,2,3]
print("before permutation: ",a)
print("after permutations:... |
7230422542419f317702d1ccd90bca72f6271c63 | joedave1/python | /dletionofdictionary.py | 127 | 3.609375 | 4 | d={"red":10,"blue":34}
if "red" in d:
del d["red"]
print(d)d={"red":10,"blue":34}
if "red" in d:
del d["red"]
print(d)
|
fec114dd44a3b0725fed2699e1bf3b311969e1ab | joedave1/python | /patternreverse.py | 211 | 3.734375 | 4 | def pattern(n):
for i in range(0,n):
for k in range(n,i,-1):
print(" ",end="")
for j in range (0,i+1):
print("*",end="")
print("\r")
n=int(input())
pattern(n)
|
0ac9dce99d8fa19c1b685d6b29ac8dab23176d40 | dmsmiley/Python_FunProjects | /higher-lower_guessing_game.py | 869 | 4.09375 | 4 | #creating guessing game from 1-100. computer tells user if the num is higher or lower. congrats message when correct guess. print out num of guesses. allow users to restart
import random
import sys
def end_game():
print("\nThank you for playing!")
print("Good bye!")
print(input("Press ENTER to exit"))
... |
64db6b4bc1cbdbbd32f0ff61f7ccc9b555a93f62 | pillieshwar/heaven | /dict_of_bdays.py | 768 | 4.03125 | 4 | #!/usr/bin/python
# -*- coding: utf-8 -*-
from datetime import date
from datetime import datetime
def dict_of_bdays():
today = date.today()
d1 = today.strftime("%d/%m")
dict = {
'17/07': 'Eshwar',
'01/03': 'Devi',
'04/11': 'Nana',
'02/06': 'Amma',
'04/09': 'Krishna',... |
199cc666d97a3fdc6e1afc98ec06c33f005ae051 | iSkylake/Algorithms | /Tree/ValidBST.py | 701 | 4.25 | 4 | # Create a function that return True if the Binary Tree is a BST or False if it isn't a BST
class Node:
def __init__(self, val):
self.val = val
self.left = None
self.right = None
def valid_BST(root):
inorder = []
def traverse(node):
nonlocal inorder
if not node:
return
traverse(node.left)
inorder.... |
7c6895415c7f493062c06626e567fa32c3e66928 | iSkylake/Algorithms | /Array/Merge2Array.py | 735 | 4.15625 | 4 | # Given two sorted arrays, merge them into one sorted array
# Example:
# [1, 2, 5, 7], [3, 4, 9] => [1, 2, 3, 4, 5, 7, 9]
# Suggestion:
# Time: O(n+m)
# Space: O(n+m)
from nose.tools import assert_equal
def merge_2_array(arr1, arr2):
result = []
i, j = 0, 0
while i < len(arr1) and j < len(arr2):
if arr1[i] <= ... |
4c06aaff66f7cd2dfd918d4249988da2375ec831 | iSkylake/Algorithms | /Array/DynamicArray.py | 641 | 3.609375 | 4 | class Dynamic_Array:
def __init__(self):
self.array = [None for i in range(2)]
self.capacity = 2
self.fill = 0
def incrementSize(self):
tempArray = self.array
self.capacity *= 2
self.array = [None for i in range(self.capacity)]
for i in range(self.fill):
self.array[i] = tempArray[i]
def push(self,... |
92803502bd1d37d5c73015816ba141e760938491 | iSkylake/Algorithms | /Linked List/LinkedListReverse.py | 842 | 4.15625 | 4 | # Function that reverse a Singly Linked List
class Node:
def __init__(self, val=0):
self.val = val
self.next = None
class LinkedList:
def __init__(self):
self.head = None
self.tail = None
self.length = 0
def append(self, val):
new_node = Node(val)
if self.length == 0:
self.head = new_node
else:... |
54cbfa4a99036b2435dd5568eca342d1a7a972a4 | iSkylake/Algorithms | /Array/LongestPalindrome.py | 1,542 | 3.921875 | 4 | # Given a string, determine the longest substring palindrome
# Example:
# "OnlyBananaIsAlowed" => 5
# Suggestion:
# Time: O(n^2)
# Space: O(n)
from nose.tools import assert_equal
# def longestPalindrome(n, s):
# max_lenght = 0
# for i in range(n):
# left = i
# right = i + 1
# count = 0
# while left >= 0 ... |
bfbbd4597dc0bd440c79c7caacf6b8a9da719db3 | iSkylake/Algorithms | /Array/IslandCoordinate.py | 725 | 3.765625 | 4 | matrix = [
[0, 1, 1, 1, 1, 0],
[0, 1, 0, 0, 1, 0],
[1, 1, 0, 0, 1, 1],
[0, 1, 1, 1, 1, 0],
[0, 1, 0, 0, 1, 0],
]
def islandCoordinate(matrix):
coordinates = []
for i in range(len(matrix)):
for j in range(len(matrix[i])):
if matrix[i][j] == 0:
if i == 0 and j == 0 or i == 0 and matrix[i][j-1] == 1 o... |
7b96cb85af8b54357dc5a1a134016d6e34b1430d | NAruneshwar/SSW810 | /HW08_Arun_Nalluri.py | 3,480 | 3.59375 | 4 | import os
import datetime
from prettytable import PrettyTable
def date_arithmetic():
""" This function performs date Operations"""
date1 = "Feb 27, 2000"
dt1 = datetime.datetime.strptime(date1,"%b %d, %Y") #changing the date format into python date
dt2 = dt1 + datetime.timedelta(days=3)
date2 ... |
670c181474a898dedcab7c157a324d51e811a9a8 | NAruneshwar/SSW810 | /HW04_Arun_Nalluri.py | 4,989 | 4.21875 | 4 | import unittest
def GCD(x,y):
"""Takes two inputs and returns the Greatest common divisor and returns it"""
while(y):
x, y = y, x % y
return x
class Fraction:
"""Class Fraction creates and stores variables while also doing operations with fractions"""
def __init__(self,numerator,d... |
82a0de9056535e13b6096bf799a206446410dc6d | verronique/git-repo | /lesson1_normal.py | 3,288 | 3.75 | 4 | #__author__ = Veronika Zelenkevich
# Задача-1: Дано произвольное целое число, вывести самую большую цифру этого числа.
# Например, дается x = 58375.
# Нужно вывести максимальную цифру в данном числе, т.е. 8.
# Подразумевается, что мы не знаем это число заранее.
# Число приходит в виде целого беззнакового.
# Подск... |
9fa9a917c2e1b2087edd8e93461fa62b780e32d0 | annafawn/CSC231---Introduction-to-Data-Structures | /Lab 02 - General Python and Classes/GeneratingPolygons.py | 1,201 | 3.703125 | 4 | import math, csv
class RegularPolygon:
def __init__(self, num_sides,side_length):
self.num_sides = int(num_sides)
self.side_length = float(side_length)
def compute_perimeter(self):
return round(self.num_sides * self.side_length, 2)
class EquilaterialTriangle(RegularPolygon):
def ge... |
5e204a443e3b9f351b676d9f41a2358f2590ac21 | ThanitsornMsr/Programming-for-Everybody | /Chapter/Chapter_6.py | 2,132 | 3.796875 | 4 | str1 = 'Hello'
str2 = "there"
bob = str1 + str2
print(bob)
str3 = '123'
x = int(str3) + 1
print(x)
name = input('Enter: ')
print(name)
apple = input('Enter: ')
x = int(apple) - 10
print(x)
fruit = 'banana'
letter = fruit[1]
print(letter)
x = 3
w = fruit[x - 1]
print(w)
x = len(fruit)
print(x)
... |
85175fd2beadd66c25e275671d701c13b2961b0b | ThanitsornMsr/Programming-for-Everybody | /Chapter/Chapter_5.py | 1,972 | 3.84375 | 4 | # Chapter 5
n = 5
while n > 0:
print(n)
n = n - 1
print('Blastoff!')
print(n)
while True:
line = input('> ')
if line == 'done':
break
print(line)
print('Done!')
while True:
line = input('> ')
if line[0] == '#':
continue
if line == 'done':
bre... |
abccf9b34b1f331b6714bbf84491691eef4e6b12 | ThanitsornMsr/Programming-for-Everybody | /Exercise/Exercise_7.py | 989 | 3.8125 | 4 | fname = input('Enter a file name: ')
ofname = open(r"C:/Users/User/PycharmProjects/Python_for_EveryOne/"+fname)
for line in ofname:
line = line.rstrip().upper()
print(line)
fname = input('Enter a file name: ')
ofname = open(r"C:/Users/User/PycharmProjects/Python_for_EveryOne/"+fname)
count = 0
sum = 0... |
113535781dd630c4dd4ed35d73e7506969d8c6f1 | hiepbkhn/itce2011 | /StandardLib/parallel/sum_primes_no_parallel.py | 1,213 | 3.859375 | 4 | '''
Created on Dec 27, 2012
@author: Nguyen Huu Hiep
'''
#!/usr/bin/python
# File: sum_primes.py
# Author: VItalii Vanovschi
# Desc: This program demonstrates parallel computations with pp module
# It calculates the sum of prime numbers below a given integer in parallel
# Parallel Python Software: http://www.parallelp... |
2c20b1594b4e36e383abd525c33c382b4ad83fce | hShivaram/pythonPractise | /ProblemStatements/CountTheChocolates.py | 692 | 3.734375 | 4 | # Description : Sanjay loves chocolates. He goes to a shop to buy his favourite chocolate. There he notices there is an
# offer going on, upon bringing 3 wrappers of the same chocolate, you will get new chocolate for free. If Sanjay has
# m Rupees. How many chocolates will he be able to eat if each chocolate costs c Ru... |
0824e7d93385a87358503bc289e984dfeae38f8c | hShivaram/pythonPractise | /ProblemStatements/EvenorOdd.py | 208 | 4.4375 | 4 | # Description
# Given an integer, print whether it is Even or Odd.
# Take input on your own
num = input()
# start writing your code from here
if int(num) % 2 == 0:
print("Even")
else:
print("Odd")
|
7f77696fcdae9a7cef174f92cb12830cde16b3cb | hShivaram/pythonPractise | /ProblemStatements/AboveAverage.py | 1,090 | 4.34375 | 4 | # Description: Finding the average of the data and comparing it with other values is often encountered while analysing
# the data. Here you will do the same thing. The data will be provided to you in a list. You will also be given a
# number check. You will return whether the number check is above average or no.
#
# -... |
8134e9b86592e07cf1cd0da048c825ca28038332 | hShivaram/pythonPractise | /Practice/practice5.py | 207 | 3.71875 | 4 | n=int(input())
sum=0
digits = [int(x) for x in str(n)]
#print(digits)
for i in range(len(digits)):
sum+=(digits[i]**3)
#print(i,sum)
#print(sum)
if(sum==n):
print("True")
else:
print("False") |
ea9f715320a8b82965a8f9a5057eaf6dd2a00470 | pmartincalvo/tick-tack-refactor | /solutions/requirements_group_1_solution/rendering.py | 1,116 | 3.84375 | 4 | """
Functions for presenting the state of the game visually.
"""
from typing import List
from solutions.requirements_group_1_solution.board import Board, Cell
def render_board(board: Board) -> str:
"""
Build a visual representation of the state of the board, with the contents
of the cells being their m... |
91c3151db15aff8be38a477f70dab75f6db92e0b | 1180301001SHEN/HIT_evolutionary_computation | /Utils/Distance.py | 2,553 | 4 | 4 | ''' @ auther Sr+'''
import math
class Distance():
'''Some methods to compute the distance'''
def compute_EUC_2D(node1, node2):
'''EUC_2D distance'''
node1_x, node1_y = node1.get_coordinate()
node2_x, node2_y = node2.get_coordinate()
distance_x = abs(node1_x-node2_x)
di... |
88b0bb352312bcc91504585873afb726428d2e8c | valours/sandbox-python | /main.py | 743 | 3.734375 | 4 | # coding: utf-8
from random import randint
first_names = ["Valentin", "Melanie", "Mathilde"]
last_names = ["Bark", "Four", "Quick"]
def get_random_name(names):
random_index = randint(0, 2)
return names[random_index]
print(get_random_name(first_names))
freelancer = {
"first_name": get_random_name(firs... |
5b54d69790c6d524c1b253b8bec1c32ad83c4bf8 | LoktevM/Skillbox-Python-Homework | /lesson_011/01_shapes.py | 1,505 | 4.25 | 4 | # -*- coding: utf-8 -*-
# На основе вашего кода из решения lesson_004/01_shapes.py сделать функцию-фабрику,
# которая возвращает функции рисования треугольника, четырехугольника, пятиугольника и т.д.
#
# Функция рисования должна принимать параметры
# - точка начала рисования
# - угол наклона
# - длина стороны
... |
8e0b377e80418e6ff51ddc1a5394544c1423dabf | LoktevM/Skillbox-Python-Homework | /lesson_005/02_district.py | 1,413 | 3.609375 | 4 | # -*- coding: utf-8 -*-
# Составить список всех живущих на районе и Вывести на консоль через запятую
# Формат вывода: На районе живут ...
# подсказка: для вывода элементов списка через запятую можно использовать функцию строки .join()
# https://docs.python.org/3/library/stdtypes.html#str.join
import district.c... |
f5689f9880f64dd2b65bfd4035b34287388f7a3d | LoktevM/Skillbox-Python-Homework | /lesson_004/practice/02_fractal.py | 1,162 | 3.5625 | 4 | # -*- coding: utf-8 -*-
import simple_draw as sd
sd.resolution = (1000,600)
# нарисовать ветку дерева из точки (300, 5) вертикально вверх длиной 100
point_0 = sd.get_point(300, 5)
# написать цикл рисования ветвей с постоянным уменьшением длины на 25% и отклонением на 30 градусов
angle_0 = 90
length_0... |
ada930e3b25e2523238eea7cb49b332b60da7f7d | madanmeena/python_hackerrank | /Built-Ins/python-sort-sort.py | 449 | 3.703125 | 4 | #https://www.hackerrank.com/challenges/python-sort-sort/problem
#!/bin/python3
import math
import os
import random
import re
import sys
if __name__ == '__main__':
nm = input().split()
n = int(nm[0])
m = int(nm[1])
arr = []
for _ in range(n):
arr.append(input())
... |
19798513e26fdf780beab48cb257b9c1fac3b903 | madanmeena/python_hackerrank | /set/py-set-add.py | 220 | 3.84375 | 4 | #https://www.hackerrank.com/challenges/py-set-add/problem
# Enter your code here. Read input from STDIN. Print output to STDOUT
stamps = set()
for _ in range(int(input())):
stamps.add(input())
print(len(stamps)) |
dd1602abd3d3c7f238c29f9f74e53ef6372549f6 | dianazmihabibi/Case1_Basic | /assessment.py | 1,275 | 3.640625 | 4 | import re
from collections import Counter
word_list = []
file = 'sample_text.txt'
#Read file
Words = open(file, 'r').read()
#Removing delimiter and replace with space
for char in '\xe2\x80\x93-.,\n\"\'!':
Words=Words.replace(char,' ')
Words = Words.lower()
#Split the words
word_list = Words.split()
#Find how much... |
9e9b8426a682a43c61c770039736edf5437b86a3 | nandap1/foodCourtOrder | /foodCourt.py | 4,061 | 4.15625 | 4 | '''
Displays DeAnza's food court menu and produces a bill with the correct orders for students and staff.
'''
#initialize variables
food_1 = 0
food_2 = 0
food_3 = 0
food_4 = 0
food_5 = 0
flag = True
item = ("")
staff = ("")
exit_loop = False
def display_menu():
print("DEANZA COLLEGE FOOD COURT MENU:")
print(... |
63a055bb9ee454b6c6ad68defb6b540b6cb74323 | Hosen-Rabby/Guess-Game- | /randomgame.py | 526 | 4.125 | 4 | from random import randint
# generate a number from 1~10
answer = randint(1, 10)
while True:
try:
# input from user
guess = int(input('Guess a number 1~10: '))
# check that input is a number
if 0 < guess < 11:
# check if input is a right guess
if guess == answ... |
1b1432b1123ef3781466f454e1b04fca7134dd4f | kvsingh/lyrics-sentiment-analysis | /text_analysis.py | 1,277 | 3.515625 | 4 | import nltk
from nltk.corpus import stopwords # Filter out stopwords, such as 'the', 'or', 'and'
import pandas as pd
import config
import matplotlib.pyplot as plt
artists = config.artists
df1 = pd.DataFrame(columns=('artist', 'words'))
df2 = pd.DataFrame(columns=('artist', 'lexicalrichness'))
i=0
for artist in artis... |
233b8e8cc6295adad5919285230971a293dfde80 | abhaydixit/Trial-Rep | /lab3.py | 430 | 4.1875 | 4 | import turtle
def drawSnowFlakes(depth, length):
if depth == 0:
return
for i in range(6):
turtle.forward(length)
drawSnowFlakes(depth - 1, length/3)
turtle.back(length)
turtle.right(60)
def main():
depth = int(input('Enter depth: '))
drawSnowFlakes(depth, 100)... |
51558f22e5262038813d7f4ce3e5d2ad2836e6d9 | Creativeguru97/Python | /Syntax/ConditionalStatementAndLoop.py | 1,372 | 4.1875 | 4 | #Condition and statement
a = 300
b = 400
c = 150
# if b > a:
# print("b is greater than a")
# elif a == b:
# print("a and b are equal")
# else:
# print("a is greater than b")
#If only one of statement to excute, we can put togather
# if a == b: print("YEAHHHHHHHHH !!!!!!!!!!!")
# print("b is greater than... |
d988912a14c4fe3d6bb41458d10898d6cddc991a | fairypeng/a_python_note | /leetcode/977有序数组的平方.py | 825 | 4.1875 | 4 | #coding:utf-8
"""
给定一个按非递减顺序排序的整数数组 A,返回每个数字的平方组成的新数组,要求也按非递减顺序排序。
示例 1:
输入:[-4,-1,0,3,10]
输出:[0,1,9,16,100]
示例 2:
输入:[-7,-3,2,3,11]
输出:[4,9,9,49,121]
提示:
1 <= A.length <= 10000
-10000 <= A[i] <= 10000
A 已按非递减顺序排序。
来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/squares-of-a-sorted-array
著作权归领扣网络所有。商业转载... |
f3ea4fb3de5655c3732e57eb23b625ec6903d210 | fairypeng/a_python_note | /leetcode/908最小差值I.py | 1,818 | 4.0625 | 4 | #coding:utf-8
"""
给定一个整数数组 A,对于每个整数 A[i],我们可以选择任意 x 满足 -K <= x <= K,并将 x 加到 A[i] 中。
在此过程之后,我们得到一些数组 B。
返回 B 的最大值和 B 的最小值之间可能存在的最小差值。
示例 1:
输入:A = [1], K = 0
输出:0
解释:B = [1]
示例 2:
输入:A = [0,10], K = 2
输出:6
解释:B = [2,8]
示例 3:
输入:A = [1,3,6], K = 3
输出:0
解释:B = [3,3,3] 或 B = [4,4,4]
提示:
1 <= A.length <= 10000
... |
67a57fa1510b08374f7e0401a3f86e9963318652 | fairypeng/a_python_note | /leetcode/961重复N次的元素.py | 863 | 3.953125 | 4 | #coding:utf-8
"""
在大小为 2N 的数组 A 中有 N+1 个不同的元素,其中有一个元素重复了 N 次。
返回重复了 N 次的那个元素。
示例 1:
输入:[1,2,3,3]
输出:3
示例 2:
输入:[2,1,2,5,3,2]
输出:2
示例 3:
输入:[5,1,5,2,5,3,5,4]
输出:5
提示:
4 <= A.length <= 10000
0 <= A[i] < 10000
A.length 为偶数
来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/n-repeated-element-in-size-2n-array... |
7b8c35c4f8a982eca181334b692273f15fdcb0f1 | fairypeng/a_python_note | /cookbook/1.2解压可迭代对象赋值给多个变量.py | 536 | 3.59375 | 4 | def drop_first_last(grades):
first,*middle,last = grades
return sum(middle) / len(middle)
gra = (100,99,89,70,56)
print(drop_first_last(gra))
line = 'nobody:*:-2:-2:Unprivileged User:/var/empty:/usr/bin/false'
uname,*fields,homedir,sh = line.split(":")
print(uname,fields,homedir,sh)
uname,*_,homedir,sh = lin... |
c484b80169ea63e5b7df08d01f2433421786ad6e | hhweeks/Mandelbrot | /Mandelbrot.py | 2,813 | 3.875 | 4 | import numpy as np
from PIL import Image, ImageDraw
"""
True/False convergence test
"""
def test_convergeance(c, maxiter):
n = 0 # count iterations
z = c
while (abs(z) <= 2 and n < maxiter):
z = z * z + c
n += 1
if (abs(z) > 2): # catch diverging z on n=maxiter
return False
... |
ec7d0173a8eb106805370b4a596256b1c8ac1342 | gurmehakk/CO_Assignment_1 | /CO_M21_Assignment-main/Simple-Assembler/assembler.py | 13,877 | 3.890625 | 4 | def spaceerror():
for i in statements.keys():
for j in statements[i][0]:
x=len(j)
j=j.strip()
y=len(j)
if(x!=y):
print("More than one spaces for separating different elements of an instruction at line "+str(statements[i][1]))
ex... |
ddaaf31b0c7fe36cbf57e17a20f188c276a9f075 | jefte23/Python | /Operadores | 668 | 4.0625 | 4 | print ("Test Equality and Relational Operators")
number1 = input("Enter first number:")
number1 = int(number1)
number2 = input("Enter second number:")
number2 = int(number2)
if number1 == number2 :
print("%d is equal to %d" % (number1, number2))
if number1 != number2 :
print("%d is not equal to %d" % (numbe... |
17f3d115d3764b69ebb8cdc9ae70c6a255ffc223 | EvidenceN/DS-Unit-3-Sprint-1-Software-Engineering | /sprint-challenge - answers/acme_report.py | 1,870 | 3.75 | 4 | import random
from random import randint, sample, uniform
from acme import Product
import math
adjectives = ['Awesome', 'Shiny', 'Impressive', 'Portable', 'Improved']
nouns = ['Anvil', 'Catapult', 'Disguise', 'Mousetrap', '???']
def generate_products(num_products=30):
'''
generate a given number o... |
5d3bb4e438cf010e62b2fe97cf05ce191a65d29c | samuelmutinda/leetcode-practice | /palindrome.py | 827 | 3.875 | 4 | def isPalindrome(x):
"""
:type x: int
:rtype: bool
"""
def split(word):
return [char for char in word]
if x < 0:
return False
digitarray = split(str(x))
xstring = str(x)
if len(digitarray)%2 == 0:
b = int((len(digitarray)/2) - 1)
right = ""
le... |
dee57a6ebf2ca0350a8449f9cb4474ab93811dce | AleksC/bioskop | /src/provere.py | 1,557 | 4.0625 | 4 | def unos_stringa(ciljana_provera):
'''
Provera namenjena pravilnom unosu imena i prezimena novih korisnika.
'''
provera = False
while not provera:
string_za_proveru = input("Molimo unesite " + ciljana_provera + " novog korisnika: ")
pom_prom = string_za_proveru.split()
if len... |
a867f7c5bc43e29c40a6ad5b475c43ce447217b8 | leo10816/practice-git | /bubblesort.py | 427 | 3.90625 | 4 | def bubblesort(data):
print('原始資料為:')
listprint(data)
for i in range(len(data)-1,-1,-1):
for j in range(i):
if data[j]>data[j+1]:
data[j],data[j+1]=data[j+1],data[j]
print('排序結果為:')
listprint(data)
def listprint(data):
for j in range(len(data)):
prin... |
663ac97205d487837d27cd973cb1a91bdf9b8702 | Antoniel-silva/ifpi-ads-algoritmos2020 | /Fabio 2b/Questão 7.py | 1,890 | 4.25 | 4 | #7. As Organizações Tabajara resolveram dar um aumento de salário aos seus colaboradores e lhe
#contrataram para desenvolver o programa que calculará os reajustes. Escreva um algoritmo que leia o
#salário de um colaborador e o reajuste segundo o seguinte critério, baseado no salário atual:
#o salários até R$ 280,00 ... |
9921976bf20825da1a5ce71bf4ba52d01ee5f106 | Antoniel-silva/ifpi-ads-algoritmos2020 | /App celular.py | 2,066 | 4.15625 | 4 | def main():
arquivo = []
menu = tela_inicial()
opcao = int(input(menu))
while opcao != 0:
if opcao == 1:
listacel = cadastrar()
arquivo.append(listacel)
elif opcao == 2:
lista = listar(arquivo)
... |
ed36575ff8fa252383163fa040ec476df213a1de | Antoniel-silva/ifpi-ads-algoritmos2020 | /Questão Alongamento.py | 743 | 3.625 | 4 | num = int(input("Digite a quantidade de números que você pretende digitar: "))
v = [-1] * num
v2 = []
par = 0
impar = 0
pos = 0
neg = 0
for i in range(len(v)):
for i in range(len(v2):
v[i] = int(input("valor: ?"))
if v[i] % 2 == 0 and v[i] >=0:
#v2[i] = v[i]*2
pos+=1
... |
2a49008676cac7c25bc0914644706f5056798ef5 | Antoniel-silva/ifpi-ads-algoritmos2020 | /Fabio 2a/Questão 4.py | 357 | 3.8125 | 4 | #4. Leia 1 (um) número de 2 (dois) dígitos, verifique e escreva se o algarismo da dezena é igual ou diferente
#do algarismo da unidade.
#entradas
a = int(input("Digite um número inteiro de 2 algarismos: "))
num1 = a // 10
num2 = a % 10
if num1 == num2:
print("Os algarismos são iguais.")
else:
print("Os... |
4bb55dfeb2640ca2ba99d32ff68d1c1440126898 | Antoniel-silva/ifpi-ads-algoritmos2020 | /Fabio 2b/Questão 13.py | 1,567 | 4.21875 | 4 | #13. Faça 5 perguntas para uma pessoa sobre um crime. As perguntas são:
#a) "Telefonou para a vítima ?"
#b) "Esteve no local do crime ?"
#c) "Mora perto da vítima ?"
#d) "Devia para a vítima ?"
#e) "Já trabalhou com a vítima ?"
#O algoritmo deve no final emitir uma classificação sobre a participação da pessoa no ... |
351bc82a4422af759022c5f84c26a7f35d266f59 | Antoniel-silva/ifpi-ads-algoritmos2020 | /semana 4 Exploração de marte.py | 205 | 4.09375 | 4 | #Exploração de marte
palavra = str(input("Digite a palavra: "))
con = 0
qtdpalvras = con / 3
for i in palavra:
con +=1
print("A quantidade de palavras recebidas foi: ", con/3, "palavras")
|
46c32dc5a42d22168f750d26e8608afeb34390c7 | Antoniel-silva/ifpi-ads-algoritmos2020 | /Fabio 2a/Questão 3.py | 396 | 3.875 | 4 | #3. Leia 3 (três) números, verifique e escreva o maior entre os números lidos.
a = float(input("Digite o primeiro valor: "))
b = float(input("Digite o segundo valor: "))
c = float(input("Digite o terceiro valor: "))
if a > b and a > c:
print(f'O numero {a} é maior')
if a < b and b > c:
print(f'O numero {b} é... |
5e9b4e2f255ea65059abfeb8a68658de961e9902 | sudh29/Algorithms | /selectionSort.py | 298 | 3.96875 | 4 | # function to sort a list using selction sort
def selectionSort(a):
n = len(a)
for i in range(n):
for j in range(i + 1, n):
if a[j] < a[i]:
a[j], a[i] = a[i], a[j]
# print(a)
return a
x = [5, 2, 6, 7, 2, 1, 0, 3]
print(selectionSort(x))
|
63f54656115085c99710905f8ff2f020a382c1ef | odhran456/pythonComputationalPhysics | /blocks.py | 4,571 | 3.609375 | 4 | import pygame
WIDTH = 640
HEIGHT = 480
FPS = 30
BLACK = (0, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
WHITE = (255, 255, 255)
counter = 0
class Square(pygame.sprite.Sprite):
def __init__(self, x, y, size, mass, velocity, color):
self.mass = mass
self.velocity = velocity
pygame.spri... |
4ff81247fecf557f505793e1d0e62bf1e420c4f8 | mariakalfountzou/First-Coding-Bootcamb | /Python_Part_I/Exercise 3.py | 457 | 3.953125 | 4 | import math
input_a=input("Give me the first side of the triangle:")
input_b=input("Give me the second side of the triangle:")
input_c=input("Give me the third side of the triangle:")
r= (float(input_a)+ float (input_b)+ float (input_c))*(-float (input_a)+ float (input_b)+ float (input_c))*(float (input_a)- float (in... |
47aaec0bae9d6547b03ba391cc316f101217ba93 | mariakalfountzou/First-Coding-Bootcamb | /Python_Part_I/Exercise 4.py | 567 | 3.984375 | 4 | import math
a = input("Enter the value for a, not 0!:")
b = input("Enter the value for b:")
c = input("Enter the value for c:")
d= (float(b)**2-4*float (a)* float (c))
if (float (d) >=0):
x1= (-float(b)+math.sqrt(d)) / (2*float (a))
x2= (-float(b)- math.sqrt(d)) / (2*float (a))
... |
5812c74bf9c585094496173797da68ef29aaad19 | GuiMarion/Musical-Needleman | /functions.py | 16,837 | 3.75 | 4 | from __future__ import print_function
# In order to use the print() function in python 2.X
import numpy as np
import math
DEBUG = False
def printMatrix(M, str1, str2):
P = []
for i in range(len(M)+1):
P.append([])
for j in range(len(M[0])+1):
P[i].append('')
for i in range(... |
60aa3a51ff78c2b24027c2534e4e09f3b4f27bcd | anay-jain/PythonNotebook | /keywordArguments.py | 515 | 3.921875 | 4 | # passing a dictonary as a argument
def cheeseshop(kind , *arguments ,**keywords):
print("I would like to have " , kind , "?")
print("Sorry ! OUT OF STOCK OF" , kind )
for arg in arguments : # *name must occur before **name
print(arg)
print('-'*50)
for kw in keywords: # its a dictonary that is passed as a argu... |
8399f69c52f360f57163477fdec3a96e40b9242d | Tsidia/FizzBuzz | /FizzBuzz.py | 992 | 3.984375 | 4 | import argparse
parser = argparse.ArgumentParser(description="A program that plays FizzBuzz")
parser.add_argument("-target", metavar="-t", type=int, default=100, help="The number to play up to")
parser.add_argument("-fizz", metavar="-f", type=int, default=3, help="The number to print Fizz on")
parser.add_argument("-bu... |
d64bfea5f97a202ed2ae72e5aa7e3c9e0922a7b5 | mourafc73/EclipsePython | /PyEclipseProj/Test/EPAM_SampleTest.py | 934 | 3.765625 | 4 |
# Write a function:
# def solution(A)
# that, given an array A of N integers, returns the smallest positive integer
# (greater than 0)
# that does not occur in A.
# For example, given A = [1, 3, 6, 4, 1, 2], the function should return 5.
# Given A = [1, 2, 3], the function should return 4.
# Given A = [−1, −3]... |
8efa2c375ab800d39f8fb78569e22e4b869a2e72 | xstaticxgpx/netsnmp-py3 | /netsnmp/_hex.py | 2,065 | 3.609375 | 4 | import binascii, struct
def snmp_hex2str(type, value):
"""
Helper func to convert various types of hex-strings, determined by length
"""
# Remove any surrounding quotes
if value[0]=='"' and value[-1]=='"':
# '"AB'" -> 'AB'
_hexstr = value[1:-1]
else:
_hexstr = value
... |
10ff6f69a2918ba5ca3ca0d6220f2441f894b500 | Ege3/HELLO | /YL10.py | 409 | 3.984375 | 4 | puuvilja_list = ['pirn', 'kirss', 'ploom']
print(puuvilja_list[0])
puuvilja_list.insert(3,'apelsin')
print(puuvilja_list[3])
#print(puuvilja_list)
puuvilja_list[2] = 'õun'
print(puuvilja_list)
if "õun" in puuvilja_list:
print("Jah, 'õun' on listis")
print(len(puuvilja_list))
del puuvilja_list[0]
print(puuvilja_list)
... |
7d85621e7b0f989d3c1bca7b45e8a43ced8fed3b | Ege3/HELLO | /YL9.py | 783 | 4.03125 | 4 | esimene = float(input("Sisesta kolmnurga esimene külg: "))
teine = float(input("Sisesta kolmnurga teine külg: "))
kolmas = float(input("Sisesta kolmnurga kolmas külg: "))
#kaks lühemat külge peavad kokku andma kõige pikema külje:
list = [esimene, teine, kolmas]
if (max(list)) == esimene and teine + kolmas >= (max(list... |
18cbdad0a3cfb067b08e9e4710a4bcc67cab413b | sachin-611/practicals_sem3 | /fds/prac_4/file4.py | 6,493 | 4 | 4 | def input_matrix(): # function to take matrix as input
row1=int(input("\nEnter no of rows in Matrix : "))
col1=int(input("Enter no of column in Matrix : "))
matrix=[[0]*col1]*row1
for i in range(row1):
ls=list(map(int,input().split()))
while(len(ls)!=col1):
... |
77385aa72ad3f52dee6494bea4570320d89c4cbb | tmaxe/labs | /Lab_1/spider.py | 194 | 3.796875 | 4 | import turtle
turtle.shape('turtle')
c=12
x=0
a=100
n=360
b=180-n/c
while x<c:
turtle.forward(a)
turtle.stamp()
turtle.left(180)
turtle.forward(a)
turtle.left(b)
x +=1
|
cc33612f8e1f927c1ed1108e5bd3271792b925d7 | EDDChang/Junyi-2021 | /2.py | 682 | 3.59375 | 4 | import unittest
import math
class TargetCalculator:
def count(self, x):
return x - math.floor(x/3) - math.floor(x/5) + 2*math.floor(x/15)
class TargetCalculatorTest(unittest.TestCase):
def test_example_testcase(self):
TC = TargetCalculator()
self.assertEqual(TC.count(15), 9)
def... |
9bda1a952f1ae43c3abb1c02df2a54f943be97aa | arpitmx/PyProjectFiles | /Prog11.py | 1,201 | 3.6875 | 4 |
def PUSH(l):
ll = savelist.l
ll.append(l)
savelist(ll)
return ll
def POP():
ll = savelist.l
if not(l.__len__() == 0):
ll.pop()
savelist(ll)
return ll
else:
print("Can't Pop, No Items in the list.")
def PEEK(n):
ll = savelist.l
return ... |
5f7d1a176d30334fff1acd74acd30443ee63fcbc | malaikaandrade/BOA | /OriObjetos.py | 662 | 3.59375 | 4 | class Perro:
#molde de obejetos
def __init__(self, nombre, raza, color, edad):
self.nombre = nombre
self.raza = raza
self.color = color
self.edad = edad
self.otro = otra_persona
#metodos
def saludar(self):
print('Hola {nombre}, cómo estás? '.format(nombre=self.nombre))
def saludar_a_otra_persona(sel... |
a42ed5941d4c983e667a840cc59b74087b0aba7b | thodge03/CD_Python | /ScoresAndGrades.py | 691 | 3.96875 | 4 | import random
def scores(num):
for i in range(0,num):
random_num = random.randrange(60,101,1)
if random_num >= 60:
if random_num >= 70:
if random_num >= 80:
if random_num >= 90:
print 'Score: ' + str(random_num) + '; Y... |
423c89bd1b2284cbe7ae7ca1588990f99690f602 | CrazyBinXXX/Stock-Project-X | /test.py | 1,026 | 3.953125 | 4 | class ListNode:
def __init__(self, x):
self.val = x
self.next = None
def oddEvenList(head):
# write code here
odd = True
cur = head
head2 = ListNode(-1)
cur2 = head2
last = None
final = None
while cur:
print(cur.val)
if odd:
if not cur.nex... |
6ae10197706b1ade4728287d8c80f19081a62b46 | GingerWW/turtle | /spiral.py | 591 | 4.0625 | 4 | import turtle
turtle.color('purple') #设置画笔颜色
turtle.pensize(2) #设置画笔宽度
turtle.speed(5) #设置画笔移动速度
t=turtle.Screen()
def draw(turtle, length):
if length>0: #边长大于0递归,画到最中心停止
turtle.forward(length)
turtle.left(90) #每次画线后,画笔左转90度
draw(turtle,length-4) #利用递归再次画线,设置离上一圈的画... |
32a4d948882e3266e9d27bdb147c2b5234ef55e3 | adykumar/Grind | /module3.py | 1,158 | 3.8125 | 4 | #-------------------------------------------------------------------------------
# Name: module3
# Purpose:
#
# Author: Swadhyaya
#
# Created: 17/12/2016
# Copyright: (c) Swadhyaya 2016
# Licence: <your licence>
#-------------------------------------------------------------------------------
def ... |
1bbc9011bd011a7f80be71042f27fb4ebebf4171 | adykumar/Grind | /py_MergeSortedArrays.py | 854 | 3.75 | 4 | #-------------------------------------------------------------------------------
# Name: module11
# Purpose:
#
# Author: Swadhyaya
#
# Created: 25/12/2016
# Copyright: (c) Swadhyaya 2016
# Licence: <your licence>
#-------------------------------------------------------------------------------
def ... |
77ad0d661f7eace3987f0b8c1d6ba2b037862474 | Phoenix951/LabsForMSU | /Exc_4.py | 789 | 3.9375 | 4 | def exercise_one(search_number):
"""
В упорядоченном по возрастанию массиве целых чисел найти определенный элемент (указать его индекс)
или сообщить, что такого элемента нет.
Задание 3. Страница 63.
:param search_number: искомое число
:return: индекс искомого числа
"""
list_of_numbers = ... |
430a7b1e252b2b4dd93b638b72570599f46828ca | anhpt1993/generate_number | /generate_number.py | 1,772 | 3.828125 | 4 | # generate numbers according to the rules
def input_data():
while True:
try:
num = int(input("Enter an integer greater than or equal to 0: "))
if num >= 0:
return num
break
else:
print("Wrong input. Try again please")
... |
4b7303be78949893da7503bb769445ca372be4b2 | xxmatxx/orvilleVM | /examples/power.py | 244 | 3.921875 | 4 | def print_int(max_int):
i = 0
while (i < max_int):
print(i)
i = i + 1
print_int(3)
def power(x,p):
i = 0
temp = 1
while(i < p):
temp = temp * x
i = i + 1
return temp
print(power(3,4))
|
8cecdbd7fa5f734297d5668e3d047f7418899023 | dkurchigin/gb-py-lesssons | /lesson6/kd_lesson6_medium.py | 2,709 | 3.734375 | 4 | import random
def programm_title():
print("**************************")
print("*GB/Python/Lesson6/MEDIUM*")
print("**************************")
class Person:
def __init__(self, name="Person"):
self.name = name
self.health = 100
self.damage = 25
self.armor = 10
... |
dddc3e4b90c6260f9b6e0726ebda2063062760d3 | yegeli/Practice | /Practice(pymsql)/exercise01.py | 1,557 | 3.703125 | 4 | """
pymysql使用流程:
1. 创建数据库连接 db = pymsql.connect(host = 'localhost',port = 3306,user='root',password='123456',database='yege',charset='utf8')
2. 创建游标,返回对象(用于执行数据库语句命令) cur=db.cursor()
3. 执行sql语句 cur.execute(sql,list[])、cur.executemany(sql,[(元组)])
4. 获取查询结果集:
cur.fetchone()获取结果集的第一条数据,查到返回一个元组
... |
3ebcdb40617f4f0628d4329c652a288b009a160a | yegeli/Practice | /Review/day13_exercise01.py | 824 | 3.9375 | 4 | """
手雷爆炸,伤害玩家生命(血量减少,闪现红屏),伤害敌人得生命(血量减少,头顶爆字)
要求:
可能还增加其他事物,但是布恩那个修改手雷代码
体会:
封装:分
继承:隔
多态:做
"""
class Granade:
"""
手雷
"""
def explode(self,target):
if isinstance(target,AttackTarget):
target.damage()
class AttackTarget():
"""
... |
373d5194589ea6da392963fa046cb8478a9d52c4 | yegeli/Practice | /第16章/threading_exercise02.py | 483 | 4.15625 | 4 | """
使用Thread子类创建进程
"""
import threading
import time
class SubThread(threading.Thread):
def run(self):
for i in range(3):
time.sleep(1)
msg = "子线程" + self.name + "执行,i=" + str(i)
print(msg)
if __name__ == "__main__":
print("------主进程开始-------")
t1 = SubThre... |
e48b8c38a7a871f60a541a850fb58a177425adbe | hupeipeii/sf | /日历的算法.py | 2,124 | 3.875 | 4 | #!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Thu Nov 2 09:49:04 2017
@author: hupeipei8090
"""
def is_leaf_years(year):
if year%400==0 or year%4==0 and year%100!=0:
True
else:
False
def get_num_of_days_in_month(year,month):
if month in [1,3,5,7,8,10,12]:
... |
38d91e9da11c1e369a56fa4034362cdfe300e258 | jionchu/Problem-Solving | /BOJ/10001~11000/10996.py | 140 | 3.859375 | 4 | num = int(input())
for i in range(num*2):
for j in range(num):
if j%2 == i%2:
print('*',end='')
else:
print(' ',end='')
print()
|
a31c2c79b1f13f4a24f8b3fb9e3b7f48f7860b38 | wkqls0829/codingprac | /baekjoonnum/9506.py | 368 | 3.59375 | 4 | def divisorsum():
n = int(input())
while(n!=-1):
div = []
for i in range(1, n):
if not n%i:
div.append(i)
if sum(div) == n:
print(f'{n} = ' + ' + '.join(map(str, div)))
else:
print(f'{n} is NOT perfect.')
n = int(input()... |
95aa1c3ba7723fe3accc9183b884d0ed188f2cb9 | wkqls0829/codingprac | /baekjoonnum/camoflage.py | 462 | 3.5625 | 4 | import sys
from collections import defaultdict
def solution(clothes):
result = 1
clothes_dict = defaultdict(list)
for c in clothes:
clothes_dict[c[1]].append(c[0])
for _, cd in clothes_dict.items():
result *= len(cd)+1
return result-1
if __name__ == '__main__':
num_clothes = in... |
800f664cf6cd49ef40573f67f0c945971a70fb09 | raekhan1/pythonpractice | /bfsmoles.py | 2,988 | 3.515625 | 4 | class Board:
def __init__(self, moles):
self.board = [] * 6
for i in range(0, 6):
self.board.append([0] * 6)
for mole in moles:
column = (mole - 1) % 4
row = (mole - 1) // 4
self.board[row + 1][column + 1] = 1
def print(self):
for ... |
3fb2f1666a744d8d2c08ac8492d2025f3f6f7c9f | raekhan1/pythonpractice | /catchthefruit4.py | 3,714 | 3.5 | 4 | class gameObject():
def __init__(self, c, xpos, ypos, velocity):
self.c = c
self.xpos = xpos
self.ypos = ypos
self.vel = velocity
class Basket(gameObject):
# using inheritance for the object
# drawing the basket
def display(self):
... |
d896c5ed8d00d633d4cfd6fc2b83484440d482ef | tan-adelle/hacktoberfest-entry | /myapp.py | 1,665 | 3.921875 | 4 | print("Title of program: Exam Prep bot")
print()
while True:
description = input("Exams are coming, how do you feel?")
list_of_words = description.split()
feelings_list = []
encouragement_list = []
counter = 0
for each_word in list_of_words:
if each_word == "stressed":
feelings_list.appe... |
c385a9dfffedbd0794a4775937ca642a3510d7d3 | Cyberfallen/Latihan-Bahasa-Pemrograman | /python/File/dasar.py | 408 | 3.953125 | 4 | print("Baca Tulis File")
print("Menulis Sebuah Teks Nama Ane Ke Txt Ngeh")
f = open("ngeh.txt", "w")
f.write("Aji Gelar Prayogo\n")
f.write("1700018016")
f.close()
print("Mengakhiri Fungsi Tulis File")
print()
print("Membaca File Ngeh.txt")
f = open("ngeh.txt", "r")
for baris in f.readlines():
print(bari... |
874b927a486d77e79b3797f610ebcf7daf0a082d | Cyberfallen/Latihan-Bahasa-Pemrograman | /python/random_angka.py | 169 | 3.53125 | 4 | import random
print("Program Untuk Menampilkan Angka Sembarang")
print("Batas = 20")
print("Pembatas = 50")
for x in range(20):
print (random.randint(1,10))
print |
2391e9662e168d79c6021d15b27af3411d56cb33 | Cyberfallen/Latihan-Bahasa-Pemrograman | /python/kondisi.py | 485 | 3.78125 | 4 | print "Program Untuk Membuat Suatu Kondisi Sekaligus Meneima Inputan"
print "Apa Tipe Gender Anda : "
a = raw_input("L/P : ")
if a == "L" or a == "l" :
print "Anda Laki-Laki"
elif a == "P" or a == "p" :
print "Anda Perempuan"
else :
print "Inputan Tidak Sesuai"
print "Bentuk Logika"
print " "
print "Apakah Anda Sia... |
a0cc1bb2589478949fa5ebf250857dda8c9ce464 | Cyberfallen/Latihan-Bahasa-Pemrograman | /python/Memotong_List.py | 266 | 3.625 | 4 | finisher = ["aji", "gelar", "pray"]
first_two = finisher[1:3]
print(first_two)
"""
Kepotong Sebelah Kiri
1: --> gelar, pray
2: --> pray
3: -->
Memotong Dari Sebelah Kanan
:1 --> aji
:2 --> aji, gelar
:3 --> aji, gelar, pray
1:3 -->gelar, pray
""" |
ff2c02e52a904c563aaf56b47e8ef57bd921a4a1 | Cyberfallen/Latihan-Bahasa-Pemrograman | /python/While.py | 107 | 3.703125 | 4 | print("Contoh Program Untuk Penggunaan While")
print("Batas = 20")
a=0
while a<=20:
a = a+1
print(a) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.