blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
88a8a134073e3d7f806be2bf04f61e65323d6ff8 | SeanKhoo02/DPL5211Tri2110 | /Lab 2 submission/Lab 2.3.py | 241 | 3.859375 | 4 | # Student ID: 1201201336
# Student Name: Khoo Chong Qin
FORMULA_1 = 1.8
FORMULA_2 = 32
C = float(input("Please enter the temperature in Celsius: "))
F = C*FORMULA_1 + FORMULA_2
print("The temperature in Fahrenheit right now is: ", F)
|
7c54603190f332cdeb7e8be86fa32f018afb2ab8 | JMcWhorter150/dictionary_exercises | /phonebook.py | 3,307 | 4.25 | 4 | # DICT = {
# # 'Karen' : '7068598025',
# # 'Joe' : '7098527065'
# }
# Must have a menu
# What do you want to do (1-5)?
def print_main_menu():
print("""Electronic Phone Book
=====================
1. Look up an entry
2. Set an entry
3. Delete an entry
4. List all entries
5. Quit
""")
us... |
a9516f5aa403144f784e23a91f36bd31022ce9b2 | aksharanigam1112/MachineLearningIITK | /packageML01/Practical15.py | 88 | 3.828125 | 4 | for num in range(1,11):
print(num)
else:
print("This is else block of the loop") |
e995fe8cb99dd3291219410ce178ce6182f8434b | wgranados/matplotlib | /examples/pie_and_polar_charts/polar_bar.py | 786 | 3.96875 | 4 | """
=======================
Bar chart on polar axis
=======================
Demo of bar plot on a polar axis.
"""
import numpy as np
import matplotlib.pyplot as plt
# Fixing random state for reproducibility
np.random.seed(19680801)
# Compute pie slices
N = 20
theta = np.linspace(0.0, 2 * np.pi, N, endpoint=False)
r... |
7902a459a32e1b7d846eb436a31e327470d8cd27 | konichiwashka/data_structures | /bucket_sort.py | 930 | 3.5625 | 4 | from bubble_sort import bubble_sort
def bucket_sort(my_list, n):
bucket = [[] for x in range(n)]
my_list_sorted = []
var = max(my_list)/n
z = 0
if z == n:
return z
else:
for z in range(n):
bucket[z] = [my_list[x] for x in range(len(my_list)) if (z+1)*var >= my_list[... |
4f9eb3861e559913a316a90b09df893b9bd1a4e0 | Raw-anAbdullah/Saudidevorg | /Lesson2.py | 210 | 4.21875 | 4 | print("Hello World")
if 5 > 2:
print("Five is greater the Two!")
"""
Utlizing multiline comments
...
Code below will show an error (Code is from lesson 1)
if 5 > 2:
print("Five is greater the Two!")
"""
|
bfceff80fc89296214fb8ba2d4cfb7355af4d8c6 | EJLabaria/FibonacciNumbers | /Print_FibonacciaNumbers.py | 681 | 3.515625 | 4 | #Print Fibonacci Numbers
#Print only Even Fibbonacci Numbrers
#current_fib = 0
fib_list = [0] * 100
even_fib_list = [0]*100
fib_list_report = [0] * 40
#Assume the following:
fib_list[0] = 0
fib_list[1] = 1
fib_list[2] = 1
fib_list[3] = 2
i = 4
j = 0
for i in range(4,100):
#while j < 100:
fib_list[i] = fib_l... |
d459f16743f6c12cd50321b455da1a719883699b | ShaoA182739081729371028392/Competitive-Programming | /Algorithms/B Heaps and Eager Dijkstra's.py | 11,634 | 3.71875 | 4 | # Implement an Index Binary Heap, for Eager Dijkstra's with Early Stopping
import math
class BidirectionalHashMap():
'''
This class just stores the bidirection dictionaries needed for the index binary heap
'''
def __init__(self):
self.dict = {}
self.inverse = {}
self.values = {}
class BinaryHeap():
... |
e8a8cd80f225533174f677f0e0a4032182af5bae | ShijieLiu-PR/Python_Learning | /month01/python base/day01/exercise01.py | 116 | 3.703125 | 4 | name = input("Please input name:")
age = input("Please input age:")
print("name is:", name)
print("age is:", age)
|
4a0058e0312a9a12ba041f19d9c2b8a61edd4bfe | rainamra/AssortedProblem | /5.py | 268 | 3.90625 | 4 | #5
def overlapping (list1 : [str], list2 : [str]):
for i in list1:
for j in list2:
if i == j:
return True
return False
print(overlapping(["r", "g", "i"], ["p", "j", "r"]))
print(overlapping(["r", "g", "i"], ["p", "j", "d"])) |
e3f49987001eb97e8d7827eef333882eb49ed124 | stoyan3d/python-algorithms | /tests/test_stack.py | 1,829 | 3.5 | 4 | from datastructures.stack import Stack
import unittest
class TestStack(unittest.TestCase):
def test_is_empty_on_stack_with_items(self):
stack = Stack()
stack.push(2)
self.assertFalse(stack.is_empty)
def test_is_empty_on_empty_stack(self):
stack = Stack()
self.assertTr... |
8b3c2ae94ecbe9a5400283ef956423e5b5fc6f09 | yvrjsharma/RNN | /CNN_Text_Classification.py | 6,369 | 3.78125 | 4 |
# ## **CNN for Text Classification**
# Investigating the use of CNNs with **Multiple** and **Heterogeneous Kernel** sizes as an alternative to an LSTM solution.
# In[ ]:
#Creating Training(25,000)+Validation(15,000) and Test(10,000) sttartefied dataset - a split of 50-30-20% respectively
#First splitting dataset of... |
122db71b45d8725aa097270efa28c32196b9b6c0 | tdefa/big-fish | /bigfish/stack/augmentation.py | 4,161 | 3.625 | 4 | # -*- coding: utf-8 -*-
# Author: Arthur Imbert <arthur.imbert.pro@gmail.com>
# License: BSD 3 clause
"""
Functions to augment the data (images or coordinates).
"""
import numpy as np
from .preprocess import check_parameter
from .preprocess import check_array
def augment_2d(image):
"""Augment an image applying ... |
a75c4c8fe67536620755bd1ba4e6f89b15f6ff7b | sidv/Assignments | /Ramya_R/Ass19Augd19/Rectangle.py | 1,071 | 4.15625 | 4 | import math
#parent class
class Rectangle:
def __init__(self, length, breadth):
self.length = length
self.breadth = breadth
def area(self):
return self.length*self.breadth
def __add__(self, length, breadth):
return self.length+self.breadth
def __str__(self):
return f'length is {self.length} and bread... |
bb3bc9d19284caf412c12c7abf270ccef8b5614b | Groookie/pythonBasicKnowledge | /006_02_input.py | 1,080 | 3.90625 | 4 | #!/usr/bin/python3
# -*- coding:utf-8 -*-
# author: https://blog.csdn.net/zhongqi2513
# ====================================================
# 内容描述: 输入相关
# ====================================================
# Python提供了一个input(),可以让用户输入字符串,并存放到一个变量里
# 不管你输入的是什么,接收到的都是字符串
name = input()
print(name)
print(type(name)... |
e1e0cb56d60a5d0ed30fe614e42e788eaa1de374 | ashishku/pythonTrainings | /code/genrators/two.py | 222 | 3.921875 | 4 | def head(count, iterable):
counter = 0
for item in iterable:
if counter == count:
return
counter += 1
yield item
h = head(3, [1, 2, 3, 4, 5, 6])
next(h)
next(h)
next(h)
next(h) |
3ba08e5d2050f2afff679d29dee9faac09958648 | campbellmarianna/Code-Challenges | /python/flip_horizontal_axis.py | 2,108 | 3.890625 | 4 | ''' Firecode.io Problem
You are given an m x n 2D image matrix (List of Lists) where each integer
represents a pixel. Flip it in-place along its horizontal axis.
Example:
Input image :
1 1
0 0
Modified to :
0 0
1 1
'''
def flip_horizontal_axis(matrix):
# base... |
d1f0b3692b7f166d06cb93713b29f57b3619c7d6 | IrfanZM/sat_cc_euler | /9.py | 480 | 3.859375 | 4 | # There exists exactly one Pythagorean triplet for which a + b + c = 1000.
# Find the product abc.
import math
b = 0
c = 0
limit = 1000
for a in range(1, int(limit), 1):
for b in range(a+1, limit - 2*a):
c = math.sqrt(a**2 + b**2)
# print(a,b,c)
if float(c).is_integer() and a + b + c == 1... |
5f415c945348a2851fb1302a597566e9c6f1aba9 | TheBrian/Practice | /Python/Homework/IntialFileAssignment1.py | 392 | 4.3125 | 4 | # user input for number of numbers being cube rooted.
n = int(input("How many numbers would you like to get the cube root of?: "))
nums = []
#For loop runs number of inputs and adds inputs into nums array for later cube rooting
for i in range(0, int(n)) :
x = int(input("Input a number: "))
nums.append(x)
#Sta... |
32cd921baa56b9dd1b798ab0a7911bf93566c594 | rcparent17/Advent2020 | /01/1b.py | 693 | 3.5 | 4 | numbers = []
with open("1.input") as inp:
numbers.extend([int(x.strip()) for x in inp])
a = numbers[0]
b = numbers[1]
c = numbers[2]
solFound = a + b + c == 2020
if not solFound:
for i in range(3, len(numbers)):
a = numbers[i]
for j in range(i + 1, len(numbers)):
b = numbers[j]
... |
e391355d76cb4bdaf634753c8b27ae429bb93243 | namita-kumar/ReadFilterIMU | /ReadIMU/ReadSerial.py | 537 | 3.609375 | 4 | #This script reads the data in the serial port and stores it in output.txt
import serial
#Select serial port to read from
serial_port = 'COM3';
baud_rate = 38400; #In arduino, Serial.begin(baud_rate)
#Create or open output file
write_to_file_path = "output.txt";
output_file = open(write_to_file_path, "w+");
s... |
0c23d7e485c9cfc4a4b07a8a619142660a672c50 | mnikn/scheme-evaluator | /src/expression_formattor.py | 1,384 | 3.515625 | 4 | class ExpressionFormattor:
def format(self,exp):
if exp.isdigit() or (exp.find("'") != -1 or exp.find('"') != -1) or (exp.find("(") == -1 and exp.find(")") == -1):
return exp
exp = exp.replace("\n"," ")
return self._convert_to_list(exp)
def _convert_to_list(self,exp):
... |
cd6c390210887139b1d5a7eb57b1dffe2c2df6dd | eulersformula/Lintcode-LeetCode | /Reverse_Linked_List_II.py | 934 | 4.125 | 4 | #Reverse a linked list from position m to n.
#Example: Given 1->2->3->4->5->NULL, m = 2 and n = 4, return 1->4->3->2->5->NULL.
#Challenge: Reverse it in-place and in one-pass
"""
Definition of ListNode
class ListNode(object):
def __init__(self, val, next=None):
self.val = val
self.next = next
"... |
e3107d1ad243b23694cf2707018f6ac723828cba | cifpfbmoll/practica-3-python-JaumeFullana | /Practica3/P3Ejercicio4.py | 376 | 4.125 | 4 | #Pide al usuario que introduzca 3 calificaciones, y calcule la media de estas.
print ("Inserta las 3 calificaciones para saber la media")
calificacionA=input("Primera calificacion")
calificacionB=input("Segunda calificacion")
calificacionC=input("Tercera calificacion")
media=((float(calificacionA)+float(calificacionB)+... |
df861b128cbcce6c7a9fc22bff5fa96dcaae727a | steven-snelling/Python-Exercises | /adaptor_demo/adapter_car_example_object.py | 1,848 | 3.65625 | 4 | from abc import ABCMeta, abstractmethod
# Object Adapter :: Using COMPOSITION
# TARGET INTERFACE
class Car(metaclass=ABCMeta):
@abstractmethod
def get_wheels(self):
pass
@abstractmethod
def drive(self):
pass
@abstractmethod
def apply_paint_job(self, colour):
pass
c... |
bc562c052a4cde9bea7e6b21b386ad0522d5cdc5 | jianxx/exercism | /python/armstrong-numbers/armstrong_numbers.py | 177 | 3.71875 | 4 | def is_armstrong_number(number):
result = 0
number_str = str(number)
for c in number_str:
result += pow(int(c), len(number_str))
return result == number
|
4064d90aef2d97a8ea119fbcb4ceceb43b94d8bc | bobbykawade/Python-Practice-Problems | /Python/mergesort.py | 203 | 3.71875 | 4 | def factorial(n):
if n = 1:
return 1
else:
return n * factorial(n-1)
print(factorial(5))
def merge_sort(li):
if len(li) <= 1:
return li
|
a29a4a0ecf12d49b818a33382f9ad29a8a425b49 | AdamHoffma/hackerrank | /HackerFile/Unique Paths/UniquePaths.py | 570 | 3.5625 | 4 | import timeit
# code_to_test = """
# def uniquePaths(n, m):
# if n == 1 or m == 1:
# return 1
# return uniquePaths(n - 1, m) + uniquePaths(n, m - 1)
# print(uniquePaths(15, 15))
# """
# elapsed_time = timeit.timeit(code_to_test, number=1)/1
# print(elapsed_time)
def paths(m... |
8f55a85c5b77882bc0c1dcd73bff7191d89c6afe | bPichitchai/hello-world | /quiz_program/read_write.py | 478 | 3.59375 | 4 | from pathlib import Path
# Get file path for questions
data_folder = Path("resource/")
file_name = "question.txt"
data_file = data_folder / file_name
# Read text file using 'pathlib'
questions = data_file.read_text().splitlines()
# Open and read file using 'open' function and 'with' statement
with open(data_file, "r... |
dfad0c5f01da31ae8bd29ba94bf7b034b30d5d93 | BryanSWong/Python | /ex39sd1.py | 1,557 | 4.125 | 4 | # create a mapping of state to abbreviation
states = {
'Utah': 'UT',
'Vermont': 'VT',
'Virginia': 'VA',
'Washington': 'WA',
'Wisconsin': 'WI'
}
# create a basic set of states and some cities in them
cities = {
'WI': 'Madison',
'WA': 'Olympia',
'VI': 'Richmond'
}
# add some more cities
... |
f88cf8c03f75f401fff71897c7a10b8128cf33ea | justinharringa/aprendendo-python | /exercicios/mateus/13-49-eu estou triste.py | 578 | 4.09375 | 4 |
numero = int(input('digite um número'))
for multiplo in range(1, 11):
# print(numero)
# print(multiplo)
print('{} = {} vezes {}'.format(numero * multiplo, numero, multiplo))
# print(numero * multiplo, '=', numero, 'vezes', multiplo)
# a1 = n*1
# a2 = n*2
# a3 = n*3
# a4 = n*4
# a5 = n*5
#... |
f542b4ede371c7e48bf4e97d2931b1318c2a42ba | Artur-by/Overone | /homework5.py | 2,345 | 3.953125 | 4 | """Задача №5:
Дмитрий считает, что когда текст пишут в скобках (как вот тут, например), его читать не нужно.
Вот и надумал он существенно укоротить время чтения, написав функцию, которая будет удалять все, что расположено внутри скобок.
Помогите ленивому Диме разработать функцию shortener(st),
которая будет удалять все... |
5110c31497da3d96c1b46b523b0b3781d03844f0 | hoshinotsuki/DataStructures_Algorithms | /geeksforgeeks/word-break-problem-trie-solution.py | 1,109 | 3.765625 | 4 | class Trie:
def __init__(self):
self.nexts = {}
self.eow = False
def is_leaf(self):
return len(self.nexts) == 0
def insert(self, word):
n = len(word)
cur = self
for i in range(n):
c = word[i]
if not c in cur.nexts:
cur... |
ef9bd97cd211cf20000099d60db08dc5264ccc1f | JAHoenigmann/SecretSanta | /secretsanta/api/helpers.py | 2,225 | 3.875 | 4 | class email_string():
"""
This is a helper class that takes in a GiftRecipient (or two of them) and returns an email message email_string
The passed in GiftRecipient is taken in this format:
['first_name', 'last_name', 'email', 'street_address', 'city', 'state', 'zip_code']
"""
def __init__(sel... |
50adf2fd4eb87c10bee991788fb0ec219180e6b6 | ananyacleetus/15-112 | /doubling.py | 292 | 3.546875 | 4 | #!/usr/bin/python
#acleetus
def doubling(rate):
low = 0.
high = 10000.
guess = 5000.
guess_error = 5000.
p =1.
while (guess_error>0.001):
if ((p*((1+rate)**(guess)))-2*p)>=0:
high = guess
else:
low = guess
guess = (high+low)/2.
guess_error = (high-low)/2.
return guess
|
f271b1247dae360c8cf0a3982a59f3681aacf5df | hasanseam/CookingFuture | /ERROR.py | 210 | 3.625 | 4 |
testCase = int(input())
for i in range(testCase):
feedbackString = input()
if feedbackString.find("010")!=-1 or feedbackString.find("101")!=-1:
print ("Good")
else:
print("Bad") |
9e12c0ec8c19cb555f08619e3e1e1dd5b753320f | mccreery/sandbox | /python/mojibake.py | 651 | 3.765625 | 4 | #!/usr/bin/env python3
"""Corrupts text files by repeatedly encoding them as UTF-8 and interpreting it as CP1252"""
import sys, io, os
def do(file, times=1):
"""Corrupt the file the given number of times, creating mojibake errors"""
if isinstance(file, io.TextIOBase):
text = file.read()
for i in range(times):
... |
f9928541979f9e61157635bde8bae6f5b44c7df5 | EndaLi/exercise_inbook | /package12/learnpython.py | 206 | 3.65625 | 4 | filename = 'learning_python.txt'
with open(filename) as file_replace:
lines = file_replace.readlines()
for line in lines:
new_line = line.replace('python','java')
print(new_line.rstrip())
|
c9c108211c0772cc8bcf461a2096198ac7029bbe | jz33/LeetCodeSolutions | /T-1240 Tiling a Rectangle with the Fewest Squares.py | 2,716 | 4.21875 | 4 | '''
1240. Tiling a Rectangle with the Fewest Squares
https://leetcode.com/problems/tiling-a-rectangle-with-the-fewest-squares/
Given a rectangle of size n x m, find the minimum number of integer-sided squares that tile the rectangle.
Example 1:
Input: n = 2, m = 3
Output: 3
Explanation: 3 squares are necessary to co... |
0396703e40eaf2dc58cb4716e22c4d4a3facd698 | Susama91/Project | /Programs/Sanfoundry/String/3.py | 73 | 3.640625 | 4 | i = 1
while True:
if i%2 == 0:
break
print(i)
i += 2
|
c7244352dc66be7208b802295fb0370ca5c420eb | asherLZR/algorithms | /sorting/heap_sort.py | 2,030 | 3.8125 | 4 | from abstract_data_types.referential_array import build_array
class Heap:
def __init__(self):
self.array = build_array(100)
self.count = 0
def __len__(self):
return self.count
def swap(self, i, j):
self.array[i], self.array[j] = self.array[j], self.array[i]
def larg... |
7b143ffb4cc0ee50dbeed9f190aa2e4e34367361 | tharang/my_experiments | /python_experiments/11_list_methods.py | 571 | 4.40625 | 4 | # -*- coding: utf-8 -*-
__author__ = 'vishy'
week = ['mon', 'tue', 'wed', 'thur', 'fri', 'sat']
#methods in list - len, max, min, sorted
print("max in the list {} is {}".format(week, max(week)))
print("min in the list {} is {}".format(week, min(week)))
print("alphabetically sorting the list {} looks like ==> {}".f... |
da4ae048c6b7aa7daa15a8bdf9b872bce48cd73b | powermosfet/vectorphysics | /v.py | 1,919 | 4.09375 | 4 | import math
class Vector(list):
def __init__(self, *args):
if len(args) == 1 and type(args[0]) == list:
list.__init__(self, args[0])
else:
for x in args:
self.append(x)
for i in range(len(self)):
self[i] = float(self[i])
def __add__(self, o):
if type(o) == Vector:
if len(self) == len(o):
... |
2c1ae3a0f76f1df1c0a3cb5a23e647fc6c3636c3 | Danielwong6325/ICTPRG-Python | /Week5/Quizz Question1.py | 507 | 3.84375 | 4 | #define the list of number provided as numlist
numlist = [66,43,1,6,2,99,4]
#define variable i equal 0
i=0
#using a while loop to stated that the number of variable i will be less than the length of the numlist defnied which is true.
while i < len(numlist):
#using an if statement to say that if the number presented in ... |
3291753deb55dd17a79a58f53c0adad6f2e9a87c | kaylezy/Batch-Three | /Isolo/Python/CAESAR_ALGORITHM.py | 2,087 | 4.3125 | 4 | '''CAESAR'S ALGORITHM FOR ENCRYPTING AND DECRYPTING MESSAGES BY ADEYINKA MICHAEL AYOOLUWA
PHONE NO:08131244877
EMAIL:ayomichaels16@gmail.com
CLASS:CODE LAGOS PYTHON BATCH 3, CLASS1
INSTRUCTOR:MR. CHIBOGWU EMMANUEL
THIS LINES OF CODES HELPS USERS TO ENCRYPT AND DECRYPT MESSAGES,
... |
9328f1827492db7b88ccf85463b578778938e2a6 | bettalazza99/PCS2-Homework | /QuickSort and Merge Sort.py | 1,918 | 3.75 | 4 | import matplotlib.pyplot as plt
setup="""
import random
def partition(arr,low,high):
i = ( low-1 )
pivot = arr[high]
for j in range(low , high):
if arr[j] <= pivot:
i = i+1
arr[i],arr[j] = arr[j],arr[i]
arr[i+1],arr[high] = arr[high],arr[i+1]
return ( i+1 )
def qu... |
a8ebf717ebfc9eb28ea49274e3621458a4b0fb3e | ciesielskiadam98/pp1 | /06-ClassesAndObjects/z21.py | 837 | 3.71875 | 4 | import statistics
class Statystyka():
def __init__(self, coll):
self.coll = coll
def add_number(self):
self.coll.append(int(input('Dodaj liczbę do zbioru: ')))
def show(self):
for i in self.coll:
print(i, end = ' ')
def maxx(self):
self.max1 = max(self.coll)
... |
aba68dc824df08b90d9c752b3e7ccd8a74268f2a | brianlash/codefights | /stringsRearrangement.py | 2,248 | 3.578125 | 4 | # Given an array of equal-length strings, check if it is possible to
# rearrange the strings in such a way that after the rearrangement the strings
# at consecutive positions would differ by exactly one character.
#
# Example
#
# For inputArray = ["aba", "bbb", "bab"], the output should be
# stringsRearrangement(inputA... |
ddba6361aa4f19d2ec02a574a34277a53cc34189 | rebeccasedgwick/pym | /multiplication.py | 158 | 3.515625 | 4 | print("-" * 46)
i = 1
while i < 11:
n = 1
while n < 10:
print("%4d" % (i * n), end=" ")
n += 1
print()
i += 1
print("-" * 46)
|
11076aa97aeb5dbc953f4531b54100a25d7774f8 | srjgit/misc | /PyEx/DS/rmvdupChars.py | 460 | 3.515625 | 4 |
def removeDupChars(str):
bFlags = [False]*128
retstr = ''
for c in str:
if not bFlags[ord(c)]:
retstr = retstr+c
bFlags[ord(c)] = True
return retstr
def removeDupChars2(str):
seenChar = {}
retstr = ''
for c in str:
if not seenChar.has_key(c):
... |
208db11b8def425d348879f26481d4630767cac4 | ryanmoyer/python-sum-of-digits | /test_sum_digits.py | 510 | 3.6875 | 4 | #!/usr/bin/env python
import unittest
from sum_digits import sum_of_digits
class TestSumDigits(unittest.TestCase):
def test_empty(self):
self.assertEqual(sum_of_digits(''), 0)
def test_single_digit(self):
self.assertEqual(sum_of_digits('9'), 9)
def test_double_digits(self):
self.a... |
6f9312f4e3550f40d1ce62ee510c1fb82d7f7983 | JohnathanTang/EECS113-Processor-Hardware-Software-Interfaces | /113_FinalProject/Source Code/CIMIS.py | 3,461 | 3.796875 | 4 | from __future__ import print_function
import json
from urllib.request import urlopen
import urllib
from datetime import datetime, timedelta
import time
#App Key for et.water.ca.gov to request and access weather data for our program
#This app key was given from registration for developer account
#For this project w... |
4f911f826c6c457f6442343707dd0469847a9b83 | ggoldani/ExerciciosPythonBrasil | /Exercicios Estrutura Sequencial/exercicio03.py | 173 | 3.640625 | 4 | numero_1 = eval(input('Informe um numero: '))
numero_2 = eval(input('Informe outro numero: '))
soma = numero_1 + numero_2
print(f'A some dos números informados é {soma}.') |
64cda0ce23db1095c3649f0e21fca5478ea27a29 | patriciaslessa/pythonclass | /classes5.py | 1,185 | 3.5625 | 4 | # Classe Bola: Crie uma classe que modele uma bola:
#
# Atributos: Cor, circunferência, material
# Métodos: trocaCor e mostraCor
class Bola:
def __init__(self, cor, raio):
self.cor = cor
self.raio = raio
def mostrar_cor(self):
print(self.cor)
def mostrar_raio(self):
print... |
d092201d450ba8d2dab08207abeffc311cad554d | bmanandhar/python_refresher | /datetime.py | 1,252 | 4.15625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Nov 4 09:01:17 2019
@author: bijayamanandhar
"""
import datetime
#start time
import time
print(time.localtime())
x = datetime.datetime.now()
print('Start time: ', x)
#code starts below
#code ends here
#end time = y
y = datetime.datetime.n... |
96df70f617e5cec85e86f135bb7856691d8e610c | MokahalA/ITI1120 | /Lab 10 Work/lab10_solved.py | 10,738 | 4.40625 | 4 | import math
class Point:
'class that represents a point in the plane'
## exectuting Point(2,3)
## 1. creates an object of type point
## 2. calls an objects __init__ method
## 3. produces an object's memory address
## Assigning to a new variable using dot operator
## CREATES THAT VARIABLE INSIDE OF THE OBJECT
#... |
135c795a8138ae4f7c5f88f569c086a02d879005 | Kurmanalie/Aman_py | /xaxaton.py | 3,102 | 3.90625 | 4 | # prodoljit = 'y'
# while prodoljit == 'y':
# f_num = int(input("Введите число: "))
# oper = input("Введите операцию: ")
# s_num = int(input("Введите второе число:"))
# if oper == '+':
# print (f_num + s_num)
# elif oper == '-':
# print (f_num - s_num)
# elif oper== '*' :
# ... |
fb80cc60f50e972a0c4dbde55be78d9a5c803bc6 | shreeyash07/Race-condition | /racecondition.py | 518 | 3.703125 | 4 | import threading
x = 0
def increment():
global x
x += 1
def thread_task():
for _ in range(100000):
increment()
def main_task():
global x
x = 0
thread1 = threading.Thread(target=thread_task)
thread2 = threading.Thread(target=thread_task)
thread1.start... |
896a6dd2dd1824ade53747ca8cd7cb613bc399dc | guiyingo/python | /Pythoncode/补充:日期处理.py | 804 | 3.875 | 4 | # =============================================================================
# 4.3.3 数据插入数据库 by 王宇韬 代码更新:www.huaxiaozhi.com 资料下载区
# =============================================================================
import datetime
today = datetime.datetime.now()
yesterday = today - datetime.timedelta(days=1)
today = to... |
872b4c04051518ba25e07430234bf95b32aba8a2 | Jakesh-Bohaju/python | /factorial_recursion.py | 429 | 3.59375 | 4 | # note update program is as incremental development
# leak of faith is checking some sample and conclude all is correct
def factorial(n):
if not isinstance(n, int): # type checking, it check whether the n is int or other data type
return None
if n == 1: # brak condition
return 1
r... |
aa5d57a091382aa20582ede837f658abd5e3ab6d | Cloudbeast/NYU_Python | /stringsplitter.py | 200 | 3.875 | 4 | print("Enter an odd length string: ")
s = input()
size = len(s)
mid = size // 2
print("Middle character: ", s[mid])
print("First half: ", s[0: mid])
print("Second half: ", s[mid+1:size])
|
7e089a6de61382bd1c59d692edb145fc2a2ba235 | CleverCat07/tickets | /karina_dz3.py | 283 | 3.640625 | 4 | from turtle import *
a = float(input("Одна сторона квадрату: "))
b = float(input("Збільшення сторони: "))
for k in range(4):
for i in range(4):
forward(a)
right(90)
a = a + b
up()
left(90)
forward(10)
down() |
4b32da206c2f93bd6f27a52f994e10815e85357b | GadiHerman/machine_learning_book | /lab5/img11.py | 283 | 3.5625 | 4 | from PIL import Image
import numpy as np
#import matplotlib.pyplot as plt
pixels = np.zeros([100,200,3],dtype=np.uint8)
pixels[:,:100] = [255, 0, 0]
pixels[:,100:] = [0, 0, 255]
print(pixels.shape,type(pixels))
img = Image.fromarray(pixels)
img.show()
#plt.imshow(img)
#plt.show()
|
a98d8fb7a22969a1e491561b05e870de856f752e | priyabdas/arrayQuestions | /pairSum.py | 572 | 3.796875 | 4 | #Pair Sum
# Given an array of numbers find a pair in the array who's sum is the target
#
# inputs array = [ 2, 45 , 3, 32 , 12 ] , targetSum = 34
# output [2,32]
#
# Created by Priyabrata Das on 07/06/21
#
def pairSum (arr, targetSum):
res = []
foundMap = {}
for value in arr:
diff = targetSum -... |
0150c18a10d5340bd54cf5d782e24c09677e9768 | Digikids/Fundamentals-of-Python | /loops.py | 253 | 3.90625 | 4 | # i = 25
# while i <= 50:
# print(i)
# i += 1
#What are even numbers?
# numbers = [12, 4, 3, 15, 7, 23, 90, 5, 8, 21]
# for i in numbers:
# if i % 2 == 0:
# print(i)
for i in range(1, 10):
print(f"{i} x 2 = " + str(i * 2)) |
9f4ff5bf2d69daf218096c918ed9ef44723ca5a4 | cn298/Semester-2 | /test.py | 1,300 | 3.671875 | 4 | print("hello world")
x = 10
print(type(x))
x = 0.1
print(type(x))
a = 10
b = 2
x = a + b / b * 2**a
print(x)
x = "string"
print (type(x))
y = "also a string"
print (type(y))
z = "m"
print (type(z))
my_string = "The little brown fox"
print(my_string[0:10])
print(my_string[0:3])
print(my_string[17:21])
print(my_st... |
4ef445d78b702fcd34de6badda4c1da02a256a29 | ParkerCS/programming2-assignments-butigard | /searching_problems.py | 2,394 | 4.34375 | 4 | '''
Complete the following 3 searching problems using techniques
from class and from Ch15 of the textbook website
'''
import re
# This function takes in a line of text and returns a list of words in the line.
def split_line(line):
return re.findall('[A-Za-z]+(?:\'[A-Za-z]+)?', line)
#1. (7pts) Write code which f... |
57189bc0ac166c1d8c25abdf357aa3fcab3387cf | Brendo0515/SI206FinalProjectPancakes | /Zomato_vis.py | 663 | 3.546875 | 4 | import matplotlib
import matplotlib.pyplot as plt
import sqlite3
# read data from database
def zomato_vis(db_filename):
conn = sqlite3.connect(db_filename)
cur = conn.cursor()
# select all restaurant ratings
cur.execute('SELECT Restaurant_Rating from Zomato')
results = cur.fetchall()
ratings = ... |
e1edece1618b9a0ca80d2cdda03c5f5cbdb4ac3d | alan-hogarth/functions_hmwrk | /src/python_functions_practice.py | 616 | 3.859375 | 4 | def return_10():
return 10
def add(num_1, num_2):
return(num_1 + num_2)
def subtract(num_10, num_5):
return(num_10 - num_5)
def multiply(num_4, num_2):
return(num_4 * num_2)
def divide(num_10, num_2):
return(num_10 / num_2)
def length_of_string(test_string):
return 21
def join_string(strin... |
5621be6028cc61144833dccb3dc4a6ae1b2504f3 | abdallawi/PythonBasic | /classes/advanced/ExtendingBuiltInTypes.py | 1,381 | 4.59375 | 5 | # In Python we can fairly easy extend all sort of Built-in Types.
# This is of course very powerful and can be done for a number of reasons:
# We could make some own implementations for certain methods of the base class.
# We can add certain methods that we're not needed for the base class, but would be very useful i... |
5d320a844eef8e2b93df9d22f49a8ead388df36c | nitya-govind/LearningPython | /venv/1_OperatorsAndDataTypes.py | 2,631 | 4.84375 | 5 | """
--------------------------------------------------------
1. Operators
--------------------------------------------------------
a. What are operators?
-> +, -, /, *, //, **, %, =, and, or, not, ==, !=. <, >, <=, >=,
b. Operators follow what rules for precedence?
-> BO(Exponent)ModulusDMAS rule (**, * / //, %, + -)
-... |
0a833c7403aaf5d1263168b4f8c2577861efdf45 | Bosun225/zuri-backend-training | /mytellerapp.py | 2,679 | 3.90625 | 4 | def main():
import datetime
import time
now = datetime.datetime.now()
balance = [3000, 5000, 7000, 9000]
name = input("Please enter your account name:")
allowedUser = ['Abdul', 'Qudus', 'Bimpe', 'Ade']
allowedPassword = ['PasswordAbdul', 'PasswordQudus', 'PasswordBimpe', 'PasswordAde']
... |
44bce0201a9beaa07d52953de6a81fd62531ef12 | mtj6/class_project | /personal_message.py | 68 | 3.53125 | 4 | name = "ruth"
print("Hi, " +name.title() + ", I'm learning Python!") |
2fe96d7e2a98699e88c75ca3d47cbdac0314a788 | kristiansantos11/tardigrades | /Shopee Workshop/LCCL Python Intermediate/hands-on-6.py | 292 | 3.921875 | 4 | # Hands on 6
# Write a function, repeats, that take a string. It outputs the number of characters
# that occur more than once in that string. Ignore casing.
def repeats(s):
return len([c for c in set(s.lower()) if s.lower().count(c) > 1])
print(repeats('aaaa'))
print(repeats('abcba'))
|
318547e9b87e85c4d259ca4a2eeba456d56e5145 | KonstantinosAng/CodeWars | /Python/[7 kyu] scrabble score.py | 653 | 3.859375 | 4 | # see https://www.codewars.com/kata/558fa34727c2d274c10000ae/solutions/python
from TestFunction import Test
def scrabble_score(st):
values = {"aeioulnrst": 1, "dg": 2, "bcmp": 3, "fhvwy": 4, "k": 5, "jx": 8, "qz": 10}
score = 0
for letter in st:
for key, value in values.items():
if letter.l... |
54881e9e818e34456a789b9c08bb3bd2a410d246 | Chalub/mat-esp-python-intro-2015 | /marlos-sidharta/bubble-sort.py | 1,692 | 3.90625 | 4 | import matplotlib.pyplot as plt
a=0
lista=[11, 18, 3, 1, 16, 12, 6, 19, 5, 0, 14, 4, 17, 9, 13, 7, 10, 15, 2, 8]
print("Lista original:", lista)
#total de algarismos
N=20
x=range(0,N)
y=lista
plt.figure()
plt.title("Lista original")
plt.xlabel("Indices")
plt.ylabel("Numeros")
plt.plot(x, y, 'ok')
plt.savefig("Fig/bubb... |
ef0b408ae0298a2308239a816bf0289bed4d67d1 | kitarp07/newproject | /lab1/while true.py | 149 | 3.9375 | 4 | import random
num = random.randint(1,30)
while True:
guess = int(input("please guess the number: "))
if guess==num:
print('right')
|
4c22abcc9ef436ebd1144873e794e15fc0d97c13 | fp-computer-programming/cycle-5-labs-P22inolan | /lab_5-2.py | 280 | 4.1875 | 4 | # Author: IBN (ADMG) 10/27/2021
word1 = input("Give me any word: ")
word2 = input("Give me any word: ")
if word1 < word2:
print(word1 + " comes before " + word2)
elif word2 < word1:
print(word2 + " comes before " + word1)
else:
print(word1 + " is equal to " + word2)
|
3f25c2f44cd75dbad6d992b545a3c4e6f9a16305 | ZJXD/DropBoxFile | /Python/Vim 博客-Python学习/标准库/Python-标准库-02-时间与日期.py | 2,526 | 4.125 | 4 | # 时间与日期
# Python 具有良好的时间和日期管理功能。实际上,计算机只会维护一个时间叫做:
# 挂钟时间(wall clock time),这个时间是从某个固定时间起点到现在的时间间隔
# 时间起点的选择与计算机相关,但是一台计算机,这一时间起点是固定的其他是从这个得到
# 此外,计算机和可以测量CPU实际上运行的时间,也就是处理时间(processor clock time)
# 用来测量计算机性能,当CPU处于闲置状态时,处理器时间会暂停
# time包-------------------------------------------------------------------------
# time ... |
10bb8442bf60a15954b9b8481e5b809323b98d56 | AliceGuliaeva/cs102 | /homework01/caesar.py | 2,154 | 4.40625 | 4 | import typing as tp
def encrypt_caesar(plaintext: str, shift: int = 3) -> str:
"""
Encrypts plaintext using a Caesar cipher.
>>> encrypt_caesar("PYTHON")
'SBWKRQ'
>>> encrypt_caesar("python")
'sbwkrq'
>>> encrypt_caesar("Python3.6")
'Sbwkrq3.6'
>>> encrypt_caesar("")
''
""... |
5c5714b93700715384d0f82da527623e2f83cf86 | ningyanke/book_p3 | /GUI/tkinter/code/canvas/多个item使用同一个tag.py | 511 | 3.578125 | 4 | #!/usr/bin/env python
# coding=utf-8
"""
tags 对象标签,可以为对象添加标签,通过标签来控制对象的属性
"""
from tkinter import *
root = Tk()
# 创建一个Canvas,设置其 背景色为白色
canvas = Canvas(root, bg='white')
# 使用tags指定一个tag(r1)
rt = canvas.create_rectangle(10, 10, 110, 110, tags=('r1', 'r2', 'r3'))
canvas.pack()
canvas.create_rectangle(20, 20, 80, 80, t... |
955c80d09037e3b1d8b314de354403760de24c8a | mukesh25/python-mukesh-codes | /stringpattern/strpattern4.py | 395 | 4.125 | 4 | # write a program to REVERSE order of words present in the given String?
# input = Learning python is very easy
# output = easy very is python Learning
s = input('enter some string to reverse: ')
l = s.split() #['Learning','python','is','very','easy']
print(l)
l1 = l[::-1] #['easy','very','is','python','Learning']... |
7c786bdab79b16fe625a71014dd04f7c3d9059cf | Monikabandal/My-Python-codes | /The celebrity Problem.py | 588 | 3.734375 | 4 | """
{{0, 0, 1, 0},
{0, 0, 1, 0},
{0, 0, 0, 0},
{0, 0, 1, 0}};
"""
def isknows(a,b,list):
return list[a][b]==1
def celebrity_problem(list):
length=len(list[0])
a=0
b=length-1
while(a<b):
if(isknows(a,b,list)):
a=a+1
else:
b=b-1
fo... |
d86f1ff3a12683b6b76979f53494d9faccfb5c66 | kristjan/turtle | /chaos_triangle.py | 1,146 | 3.828125 | 4 | #!/usr/bin/env python3
import math
import random
import sys
import turtle
SCREEN_WIDTH = 800
SCREEN_HEIGHT = 800
TRIANGLE_SIZE = 10
screen = turtle.Screen()
screen.setup(SCREEN_WIDTH + TRIANGLE_SIZE*4, SCREEN_HEIGHT + TRIANGLE_SIZE*4)
t = turtle.Turtle()
def halfway(a, b):
return (
(a[0] + b[0]) / 2... |
9beefaee0cd2529075f223c1e2fb39871d45f24c | bjlovejoy/workoutPi | /challenge.py | 5,594 | 3.515625 | 4 | import os
import datetime
from time import time, sleep
from gpiozero import Button, RGBLED, Buzzer
from colorzero import Color
from oled import OLED
'''
Creates or appends to file in logs directory with below date format
Each line contains the time of entry, followed by a tab, the entry text and a newline
'''
def lo... |
c0ac654b67a7176c4568b964a011aa0a0e419721 | apollyonl/IntroZero | /Problemas Python/Problema2.py | 267 | 3.640625 | 4 | t = int (input ("Capacidad del tanque: "))
print("Porcentaje del medidor de gas: ")
m = int (input ("Lectura del Medidor: "))
mi = int (input ("Millas por galon: "))
g = t * (m/100) * mi
if g > 200:
print("¡Procede!")
else:
print("¡Consigue gasolina ya!")
|
276fcbd47c2cd06d96cac7d0e63092c30b72a3eb | Max-Hsu/Homework | /G1-2/Python/4/PA3.py | 12,740 | 3.953125 | 4 | # Homework 3
# Due: Sunday, June 16th at noon.
# What to submit: a file named <your_student_id>.pa3.py
# Beware: Don't cheat -- you will be caught and fail the class.
# Beware: Don't procrastinate -- you will be busy studying you other classes
# later next week.
# Beware: Don't not do it. Although not wor... |
bd480c16127314a6f758852dd473e77d81d87a3d | aubique/daily | /python/p3_181027_2114.py | 2,266 | 3.75 | 4 | #!/usr/bin/env python3
#p3_181027_2114.py
# Color-app
# Lesson 2: Widgets
import tkinter as tk
RED = "red"
ORANGE = "orange"
YELLOW = "yellow"
GREEN = "green"
CYAN = "cyan"
BLUE = "blue"
PURPLE = "purple"
class Instance:
def __init__(self, master):
colors = self.getColorDictionary()
... |
b6f2edfb87e206e4a6b7bb97b36fce48a37972d0 | Kallbrig/Film-Directory-Name-Cleaner | /main.py | 2,002 | 3.5 | 4 | import os
from pathlib import Path
import re
import sys
try:
arg_path = sys.argv[1]
except:
print('Please pass the path of the folders you\'d like renamed')
sys.exit()
print(f'Parsing at path: {arg_path}')
if input("This can't be reversed. Are you sure you want to continue? (y/n)\n") == 'y':
print(... |
fd3143eb7d631d8aadfc2a4ddfa69c67ba4403a9 | ShiuLab/PseudogenePipeline | /_scripts/1_3_v2_MakeFastaCodeName.py | 1,247 | 3.96875 | 4 | #This script is designed to take a fasta file with a huge name, replace the name
#with a code and make a reference file with the code and original name for the
#purpose of getting the original name back
#Updated on Jan 16, 2013
import sys
inp = open(sys.argv[1]) #input fasta file
out = open(sys.argv[2], "w") #ou... |
807d1e72cd840bfadb7597a38886cdbec081283c | MinhVu88/PythonCC_2ndEd_Matthes | /Chapter_11/test_survey_1.py | 2,622 | 4.3125 | 4 | # the setUp() method
'''
- In test_survey_0.py we created a new instance of AnonymousSurvey in each test method and
we created new responses in each method.
- The unittest.TestCase class has a setUp() method that allows you to create these objects once and
then use them in each of your test methods.
- When yo... |
e446c96608938cc9ef95352d575a7aa20f553aa2 | arnodeceuninck/GASTO | /Geheel/Hashmap.py | 11,141 | 3.71875 | 4 | class TreeItem():
def __init__(self, item, key):
self.item = item
self.key = key
self.next = None
self.prev = None
class Hashmap():
def __init__(self, size, type):
self.tableSize = size
self.hashTable = [None] * (self.tableSize)
self.step = 1
self... |
80bc9689128857408ba929607ae0190d04052d64 | amedina14/master-python | /03-operatori/assegnazione.py | 350 | 3.796875 | 4 | eta = 55 # = assegna 55 a eta
print(eta)
eta += 5
eta = eta + 5
eta -= 5
print(eta)
# Operatori incrementali e decrementali
year = 2021
#Incremento
#year = year + 1
year += 1
#Decremento
#year = year - 1
year -= 1
#Pre incremento
year = 1 + year
#Pre decremento
year = 1 - year
print(year)
"""
in python non esist... |
696ab9435160a5ea1e8d60c0cb4acd8728ad9d7e | bpross/MyCourses-Scheduler | /django/scheduler/administrator/professor.py | 1,443 | 3.9375 | 4 | #Course Scheduling Algorithm
#CMPS 115
#Linda Werner
#professor.py
#Authors: egall24, bpross
import sys
class Professor:
id = 0
name = ''
#initializes professor with ID and name
def __init__(self, id = None, name = None,course_list = None):
if id is None:
self.id = None
else:
self.id = id
if name is N... |
07db1b0de4dcafd26024e64a02fd2b104d50eb78 | ilyas0v/codewars-python-solutions | /draw_home.py | 354 | 3.765625 | 4 | def my_crib(n):
ev=""
k=n
for i in range(0,n):
ev=ev+(k)*" "+"/"+i*2*" "+"\\"+(k)*" "+"\n"
k-=1
#for i in range(0,n):
ev=ev+"/"+2*n*"_"+"\\\n"
for i in range(0,n-1):
ev=ev+"|"+2*n*" "+"|"+"\n"
ev=ev+"|"+2*n*"_"+"|"
return ev
while True:
inp = input("Nece mertebel... |
86de52a241ae3645d41c693383b7b232c95126c5 | gcnTo/Stats-YouTube | /outliers.py | 1,256 | 4.21875 | 4 | import numpy as np
import pandas as pd
# Find the outlier number
times = int(input("How many numbers do you have in your list: "))
num_list = []
# Asks for the number, adds to the list
for i in range(times):
append = float(input("Please enter the " + str(i+1) + ". number in your list: "))
num_list.append(ap... |
974fb61a41aecfc63d49e0733d1a15b71d983a1a | madhurasapkal/2020-interns | /feature_1_2.py | 7,936 | 3.859375 | 4 | #Python 3.7.4
from tkinter import *
import json
import datetime
import turtle
import urllib.request
import random
def reset():
pass
c = (0,0,0)
def drawBar(t, height,old,date):
""" Get turtle t to draw one bar, of height. """
global c
try:
if c[0]<220 and c[1]<220 and c[2]<220:... |
130a3b04081ea68600b089ccb334d58a0a36ea41 | GBoshnakov/SoftUni-OOP | /Iterators and Generators/fibonacci_generator.py | 284 | 3.921875 | 4 | def fibonacci():
def fib(n):
if n == 0:
return 0
if n == 1:
return 1
return fib(n-2) + fib(n-1)
i = 0
while True:
yield fib(i)
i += 1
generator = fibonacci()
for i in range(10):
print(next(generator))
|
1be4506659a2fefcdf5e4d3ab1816ca6794d992a | ascription/whateveriwant | /rename_file.py | 722 | 4.0625 | 4 | #TO REMOVE NUMBERS FROM FILE NAMES.
import os
def rename_files():
#(1) get file names from a folder
file_list = os.listdir("/Users/johnsanchez/Downloads/prank")
print(file_list)
saved_path = os.getcwd()
#THE PATHS IM A LITTLE CONFUSED ON, LIKE 17
print ("Current Working Directory is "+saved_path... |
bca53f02efe9a9dc2cf37311ee9de04b24725644 | mikoada/CA116 | /week-2/weekend.py | 65 | 3.609375 | 4 | n = input()
if n = 4:
print "weekend"
else:
print "weekday" |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.