blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
19b238adf4824b846a668fed2b44fa463730fd6d | abdilfaruq/LearnPython | /Python/Key.py | 337 | 3.71875 | 4 | """
SEQUENCES
List [] - Tuples {} - Dictionary {}
key:value
"""
data = {1:{'name':'Hilman', 'age': '17', 'hobby' : 'sing'},
2: {'name': 'Jhonny', 'age': '47', 'hobby': 'eating sugar'}}
for key, value in data.items():
print("\nKeynya: ", key)
for key2 in value:
print(key2 + ... |
2ac87aa89c9510a6cf8178a3d0f297465e19b12a | abdilfaruq/LearnPython | /Python/oop/player.py | 2,730 | 4.4375 | 4 | """
OOP - Object Oriented Programming
Class dan Object
"""
"""
class Player:
name = 'Mbappe'
def getName(self):
return self.name
#di luar kelas
pemain = Player()
print(pemain.getName())
"""
"""
class Player:
name = ''
def getName(self, name):
self.name = name... |
e777af7baa520e61c13b01addb0e5af28d48fc25 | mtorralvo/python-programming-maria-torralvo | /mid-term/average_function.py | 1,319 | 4.59375 | 5 | # average_function.py
# For this exercise the pseudo-code is required (in this same file)
# Write a function that calculates the average of the values of
# any vector of 10 numbers
# Each single value of the vector should be read from the keyboard
# and added to a list.
# Print the input vector and its average
# Define... |
39a6786c348084f307d0bc5c153b876c04622746 | Pravin2796/python-practice- | /chapter 7/lists_loop.py | 107 | 3.59375 | 4 | fruits = ['banana','mango','apple','pineapple']
i = 0
while i<len(fruits):
print(fruits[i])
i = i+1 |
0b426fdcf8159c9529f29482984386b281b20f82 | Pravin2796/python-practice- | /chapter 10/instanceattribute.py | 230 | 3.96875 | 4 | class Employee:
company = "google"
salary = 100
harry = Employee()
rajni = Employee()
# creating instance attribute salary for both objects
harry.salary = 300
# rajni.salary = 400
print(harry.salary)
print(rajni.salary) |
66bc5180a36d27174ebf7780aa9b6230fb703f6d | Pravin2796/python-practice- | /chapter 7/assignment 7/5.py | 178 | 4.03125 | 4 | num = int(input("enter the no : \n"))
if num < 0:
print("enter positive no")
else:
sum = 0
while (num>0):
sum += num
num -= 1
print("total is : ",sum)
|
a5a16e8640190fc920d4184c18b0a69aeb1b4b30 | Pravin2796/python-practice- | /chapter 4/lists.py | 182 | 3.75 | 4 | # create the list
a = [1,2,4,56,78,99,100]
print(a[2])
print(a)
a[0]=90
print(a)
b= [1,3,34,'pravin']
print(b)
# list slicing
friends= ['harry','tom ','sam',50]
print(friends[0::2]) |
9d05f5b3dc625ef011ca1323f476ace16a819376 | Pravin2796/python-practice- | /chapter 6/asignment 6/6.py | 208 | 4.15625 | 4 | marks = int(input("enter the marks\n"))
if marks>=90:
grade = "excl"
elif marks>=80:
grade = "A"
elif marks>=70:
grade = "B"
else:
grade = "F"
print("your grade is " + grade) |
e74f17b9c2723df2a1cbd2c13d9e7cc6ad297686 | gaicigame99/wangzherongyaozhushou | /day05.py | 4,047 | 3.859375 | 4 | def show_main_view():
print("-^-"*35)
welcomes = """
欢迎使用中国计量大学学员管理系统
# 1,学员信息创建
# 2,学员信息修改
# 3,学员信息删除
# 4,学员信息查询
# 5,退出
"""
print(welcomes)
print("-v... |
3afb96060355881479bd583ed8e36e65bc8a72c0 | surajbnaik90/devops-essentials | /PythonBasics/PythonBasics/Files/file1.py | 923 | 3.6875 | 4 | #Read & write file
file = open("C:\surajbnaik90\PythonBasics\PythonBasics\Files\sample.txt",'r')
for line in file:
print(line, end='')
file.close()
print("\n")
print("*" * 100)
#Read & write using 'with': No need to close the file
with open("C:\surajbnaik90\PythonBasics\PythonBasics\Files\sample.txt",'r') as file:... |
5eedd0109c274f0b01071836eef25f379f3a8a82 | surajbnaik90/devops-essentials | /PythonBasics/PythonBasics/Binary/binary1.py | 197 | 4.28125 | 4 | #Printing binary numbers from 1 to 20
for i in range(20):
print("{0:>2} in binary is {0:08b}".format(i))
#Binary Shift left = Multiplies number by 2
#Binary Shift right = Divides number by 2
|
8dd43eaefca8414d5345ccf804136f8fdf56ac56 | surajbnaik90/devops-essentials | /PythonBasics/PythonBasics/Challenges/challenge3.py | 523 | 3.71875 | 4 | #Find a meal without spam in it and print out the ingredients of that meal.
menu =[]
menu.append(["egg","spam","bacon"])
menu.append(["egg","sausage","bacon"])
menu.append(["egg","spam"])
menu.append(["egg","bacon", "spam"])
menu.append(["egg","bacon","sausage", "spam"])
menu.append(["spam","bacon","sausage","spam"])
... |
8812cb45980f4ad20a48a50d3a21ce34902c7374 | riddhi-jain/DSAready | /Matrix/Max Area of Island.py | 1,642 | 3.984375 | 4 | '''Given a non-empty 2D array grid of 0's and 1's, an island is a group of 1's (representing land) connected 4-directionally (horizontal or vertical.) You may assume all four edges of the grid are surrounded by water.
Find the maximum area of an island in the given 2D array. (If there is no island, the maximum area is ... |
91e1afe716211d3c4159a9756624b35ce763b230 | riddhi-jain/DSAready | /Binary Trees/Lowest Common Ancestor of a Binary Tree.py | 1,893 | 3.890625 | 4 | '''
Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.
According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two nodes p and q as the lowest node in T that has both p and q as descendants (where we allow a node to be a descendant of itse... |
c7b4b82121ad04666ab0c8f7b472a7b201ab8e50 | riddhi-jain/DSAready | /Graph/Alphabet Rangoli/Alphabet Rangoli.py | 429 | 3.59375 | 4 | from string import ascii_lowercase
list_ch = [al for al in ascii_lowercase]
n = int(input("Enter the size for rangoli(1-26): "))
data = [list_ch[i] for i in range(n)]
width = len('-'.join(data[n-1:n-n:-1] + data[n-n:n]))
for i in range(1, n+1):
print('-'.join(list_ch[n-1:n-i:-1] + list_ch[n-i:n]).center(width, "-... |
bc12ca239c4d275fde06abb6e107a9f1e9eeee7d | riddhi-jain/DSAready | /Strings/All Subsequences.py | 1,096 | 4.21875 | 4 | '''Given a string, we have to find out all subsequences of it. A String is a subsequence of a given String, that is generated by deleting some character of a given string without changing its order.
Explanation :
Step 1: Iterate over the entire String
Step 2: Iterate from the end of string
in order to gener... |
986739e9299443a18c59e86352fccc4f7bf29426 | riddhi-jain/DSAready | /Matrix/Set Matrix Zero.py | 2,832 | 4.4375 | 4 | '''
Given an m x n integer matrix matrix, if an element is 0, set its entire row and column to 0's, and return the matrix.
You must do it in place.
Example:
1 1 1
1 0 1
1 1 1
Input: matrix = [[1,1,1],[1,0,1],[1,1,1]]
Output: [[1,0,1],[0,0,0],[1,0,1]]
Algorithm
1. We iterate over the matrix and we mark the first cel... |
c5b50913894eb9bddda287eab11857f48df20556 | riddhi-jain/DSAready | /Backtracking/Generate Parentheses.py | 1,113 | 3.765625 | 4 | '''Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.
Input: n = 3
Output: ["((()))","(()())","(())()","()(())","()()()"]
Approach:
We can start an opening bracket if we still have one (of n) left to place. And we can start a closing bracket if it would not exceed t... |
d54bded605d52b47c9f93674cc5416adf8db3aa3 | Kadam-Rutuja/Tkinter_in_python | /text.py | 149 | 3.75 | 4 | import tkinter
from tkinter import *
w = Tk()
tx = Text(w,height=5,width=20,font='20')
tx.pack()
tx.insert(END,'Hello from Tkinter')
w.mainloop() |
a5e3cf0c20815a7d6a36fcb816f26bb6a16007d7 | G00398347/programming2021 | /week03/lab3.2 Fun with number/Lab3.2.3floor.py | 532 | 4.5625 | 5 | #this programme takes a float, converts it to an integer and rounds it down
#Author : Ruth McQuillan
#the term give to rounding down is floored
import math
numberToFloor = float (input('Enter a float number:')) #this is where the user enters the decimalised number they wish to round down
flooredNumber... |
f9873be5674d6748f03f47f840cbab4dd7272434 | G00398347/programming2021 | /week03/w3schstringmessing2.py | 1,414 | 4.1875 | 4 | #remove whitespace
a = " Hello World! "
print (a.strip())
#replace a string with another string
b = a.strip () #this is my own attempt to remove the white space before replacing
#this step was not in the w3schools example
print (b.replace("H", "J"))
#sp... |
f13748409d2c248adf6d74659052907d18babef3 | G00398347/programming2021 | /week02/subtract.py | 438 | 3.65625 | 4 | #This programme subtracts 4 from 21
#Author: Ruth McQuillan
x = 21 #21 is given a variable name
y = 4 #4 is given a variable name
print (x-y) #outputs the answer to the subtraction of 4 from 21
#This programme checks if 2 is equal to 3
#Author: Ruth McQuillan
a = 2 #2 is given a variab... |
b919f8ed0c6ed05f1ed7750752f463a575cb5eb3 | G00398347/programming2021 | /week03/lab3.2 Fun with number/Lab3.2.1round.py | 713 | 4.34375 | 4 | #This programme rounds a number
#Author: Ruth McQuillan
numberToRound = float (input ("Enter a float number:")) #this asks for a number with a decimal point
roundedNumber = round(numberToRound) #this uses the round built in function to round the float number entered at in... |
5f20ddbeb51010d64354b51ee3e73d67ff0e777e | alexzhu25/hello-world | /webpage-extract/webpageExtract.py | 940 | 3.71875 | 4 | #!/usr/bin/python
#Get website input from user. Scans website and outputs text to file with name related to website
import os
import codecs
import requests
from bs4 import BeautifulSoup
website = input("Please input a website (include http): ")
websitename = website.split('/')
filename = websitename[2] + ... |
8d97aeea3d04a67790e623670b274873bd6bcabb | nuljon/Python-Course-Files | /BasicCoding_Drills/Step47 _Drill_using_range_function.py | 591 | 4.59375 | 5 | '''
Python Course - Step 47 - Programming Drills using Range()
Start IDLE and use the Python range() function with one parameter to display the
following:
0
1
2
3
'''
for i in range(4):
print(str(i), end='\n')
print(end='\n\n\n')
'''
When this is working show it to your instructor.
Use the Python range() functio... |
8222324cdf2f1ef5585aea8e5517a1971b19ce52 | nuljon/Python-Course-Files | /BasicCoding_Drills/number_list.py | 192 | 4.125 | 4 | # create list of numbers
number_list = [1,2,3,4,5]
empty_list = []
# loop each member in list
for x in number_list:
# print x**2
empty_list.append(x**2)
print empty_list
|
29a0ffc58f9ba6b5171b3eed3a701dbf6805f0c1 | nuljon/Python-Course-Files | /Coding_Drills/mySort.py | 1,876 | 4.375 | 4 | '''
Step 49 DRILL:
Write your own version of the sorted() method in Python. This method should take a list as an argument and return a list that is sorted in ascending order. Call your method passing in the following lists as arguments and print out each sorted list to the shell. This should be an algorithm that you w... |
49a1faaeb4ee4ddf744ad1802778381009d61e15 | SethMarceno/ODE-Solving | /Backwards Eulers Method.py | 995 | 3.578125 | 4 | f = lambda t, x: #Insert relevant ODE here
def NewtonsMethod(p0, tol, n0, h, w0, t):
f = lambda x: x - w0 - (h*((-15*(x - (t**(-3)))) - (3/(t**4))) )
f_prime = lambda x: 1 + 15*h
i = 1
while i <= n0:
p = p0 - (f(p0)/f_prime(p0))
if abs(p - p0) < tol:
return p
i += 1
... |
dd11ac17e6e110449c0acc2562911e64e7437e3f | alexliew/learn_python_the_hard_way | /ex34.py | 234 | 3.65625 | 4 | animals = ['bear', 'python', 'peacock', 'kangaroo', 'whale', 'platypus']
print(animals[1])
print(animals[3 - 1])
print(animals[1 - 1])
print(animals[3])
print(animals[5 - 1])
print(animals[2])
print(animals[6 - 1])
print(animals[4])
|
7a7fa467697de821158e852ccb85a01f79c608d5 | mharishub/HacktoberFest2021 | /python/implementAStar.py | 3,217 | 3.734375 | 4 |
# A star Algorithm function ------------------------------------------!!
def A_Star_Algo(StartNode, EndNode):
open_set = set(StartNode)
closed_set = set()
distance = {} # store distance from starting node
parents = {} # Adjacency map of all nodes
distance [StartNode] = 0 # ditance of starting ... |
85d40ea5f5dcb62d4024816f162f6f32675a7e3d | FryeGao/algorithms | /array/array_test.py | 4,729 | 3.53125 | 4 | class Solution:
# 先来一个二分搜索
def binary_search(self,nums,target):
left,right = 0,len(nums)-1 # [left,right]
while left <= right:
mid = (left + right) // 2
if nums[mid] == target:
return mid
elif nums[mid] > target:
ri... |
0f5e056ab801fa5aab71962dd721ec86c737a2d9 | xuz11rhit/09-ImplementingClasses | /src/Point.py | 2,021 | 3.96875 | 4 | def main():
test_point()
def test_point():
p1 = Point(20, 30)
p2 = Point(200, 150)
p3 = Point(100, 30)
p1.move_to(10, 20)
p1.move_by(20, 60)
print(p1.distance)
print(p1.get_distance_traveled())
print(p1.closer_to(p2, p3))
print(p1.halfway_to(p2))
class Point(object):
def __... |
9cfbe510d5b3e23e9e42960aac832f8b5a5951c8 | sohom-das/Python-Practice | /LPTHW - Ex16.py | 1,379 | 4.3125 | 4 | from sys import * #importing function from the sys module
script, filename = argv #get argv command line arguments (when executing the file) and assigning it two variables
print(f"This is your file: {filename}")
print("If you don't want tha... |
7120daf2e5519f4f7b613413541098ec76c06f0c | SuneastChen/other_python_demo | /文件备份与修改.py | 234 | 3.59375 | 4 |
print('--------------------------- ---------------------------')
import fileinput
for line in fileinput.input('123.txt',backup='.back'):
line=line.replace('999','123')
print(line,end='')
f=open('123.txt.back')
print(f.read())
|
c144d7e2ee79ccc62cc7aa796a85f450675eb54a | JavaWantaBe/zerynth_thumbstick_click | /thumbstick.py | 3,480 | 3.5 | 4 | """
.. module:: Thumbstick Click
*****
Thumbstick click
*****
Module is a simple spi based thumbstick that can be used for navigation or movement. Converstion
of analog movements are converted via a SPI based ADC with 12bit resolution.
**Resources**
* Product Page: http://www.mikroe.com/click/thumbstick/
* Product... |
9ab201354ff9b4144eb0aa581fb971ca57459cb1 | HiouaniHalim/Zip | /abc moduel.py | 2,977 | 3.796875 | 4 | # C:\Users\Hlim\Desktop\TK.zip ' PATH '
# Programmer by HALIM_HIOUANI
# This script is for beginners in the field of Python
# Explain some library properties zipfile
import zipfile
import datetime
import os
import abc
import exceptions
import time
ALL = ['ZIP']
class ZIP (object):
__doc__ = 'This ... |
b8f131767d3a02dd4310bb58e7709737aab5d080 | GDBSD/ml_sprouts | /stochastic_gradient_boosting.py | 2,932 | 3.796875 | 4 | # -*- coding: utf-8 -*-
from math import sqrt
from sklearn import datasets
from sklearn.metrics import accuracy_score
from sklearn.metrics import mean_squared_error
from sklearn.model_selection import train_test_split
from sklearn.ensemble import GradientBoostingClassifier
from sklearn.ensemble import GradientBoostin... |
82dc61d8f67889ddd2c974ae20a7a4781c378f50 | letsfika/trt_data_lit_grp_python | /Lesson2/mining_twitter_lesson_2.py | 4,894 | 3.71875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Jan 9 19:13:08 2017
@author: marga
"""
import pandas as pd
pd.set_option('display.max_colwidth', -1)
tweet_df = pd.read_csv("C:/Users/marga/Desktop/tweet_sample.csv", delimiter=",", encoding = "utf-8")
# A look at the dimension of the dataframe
tweet_df.shape
# A look at... |
8ea5a65d190947429ad3dc7a0b8e4795f4445090 | AliceSeo/preparationForCodingCompetition | /sugar_delivery.py | 2,872 | 4.15625 | 4 | # Title: ŠEĆER
# Retrieved from Croatian Open Competition in Informatics > COCI 2010/2011 > Contest #7
# http://hsin.hr/coci/archive/2010_2011/contest7_tasks.pdf
# Q.
# Mirko works in a sugar factory as a delivery boy. He has just received an order: he has to deliver exactly N kilograms
# of sugar to a candy store on ... |
9319be37db0d9f763a478425ed9d1ee841c4b32a | AliceSeo/preparationForCodingCompetition | /dial.py | 1,976 | 3.625 | 4 | # Title: Dial
# Retrieved from Contest > Croatian Open Competition in Informatics > COCI 2012/2013 > Contest #6 #1
# http://hsin.hr/coci/archive/2012_2013/contest6_tasks.pdf
# Q:
# Mirko's grandma still uses an ancient pulse dial telephone with a rotary dial.
# For each digit that we want to dial, we need to turn the... |
683ed201265c13617398135b5be5eaaecddb8982 | AliceSeo/preparationForCodingCompetition | /note.py | 1,611 | 4.125 | 4 | # Title: Note
# Retrieved from Contest > Croatian Open Competition in Informatics > COCI 2009/2010 > Contest #1 #1
# https://www.acmicpc.net/problem/2920
# Q:
# C major scale consists of 8 tones: c d e f g a h C.
# For this task we number the notes using numbers 1 through 8.
# The scale can be played ascending, fro... |
39d701a10635736ae9b5f3ab47cb623173fc7867 | SergeyOcheretenko/LabsPython | /lab2.py | 973 | 3.875 | 4 | #Lab 2
import math
#1
def func1(a):
if a >= 1:
return math.cos(a) * (math.sin(a) ** 2)
elif a > 0 and a < 1:
return math.log(a) ** 2
else:
return 'no value'
a = float(input('Enter a: '))
print('Result: ' + str(round(func1(a), 10)))
print()
#2
def func2(b):
if b < 0:
return round(b ** (1/3), 10) % 1
else... |
6bf52d191b6cc9ddc782b4797e2ad7d628330e72 | RachelBlin/keras-retinanet | /keras_retinanet/models/resnet_modified.py | 11,957 | 3.703125 | 4 | """
keras_resnet.models._2d
~~~~~~~~~~~~~~~~~~~~~~~
This module implements popular two-dimensional residual models.
"""
import keras.backend
import keras.layers
import keras.models
import keras.regularizers
import keras_resnet.blocks
import keras_resnet.layers
class ResNet2D(keras.Model):
"""
Constructs a `... |
6107985cb7e3ce37035b19ea45d03f6292eaea31 | elllot/data-structures-python | /MinStack.py | 1,080 | 4.09375 | 4 | """
Stack that keeps track of the minmum value in the stack.
Uses O(n) extra space to keep minmum at each value
O(1) push, pop, peek, get_min
Easily modifiable to implement a max stack instead
"""
class MinStack:
def __init__(self):
self._stack = []
self._min = None
"""
Pops and returns the element at the... |
900b19f8b3c0ae3d853ccfbbd8552eb90040e483 | elllot/data-structures-python | /InsertDeleteRandom.py | 1,148 | 3.625 | 4 | import random
"""
Data Structure supports the following operations:
Insert - O(1)
Delete - O(1)
GetRandom - O(1)
Note: This version does not allow duplicates
"""
class InsertDeleteRandom:
def __init__(self):
self. _arr = []
self. _map = {}
"""
Tries to insert val into the list.
:param val: value to b... |
fb19bc6bc982198bbe013477cd0b5b5d899cefa0 | poovanna886/hello_world- | /factorial.py | 112 | 4.0625 | 4 | n = int(input("Enter any number"))
fact = 1
while n:
fact = fact * n
n = n-1
print("FActorial")
print(fact)
|
f9cd9a373f024fdfd497e759a727ab968c5c5ce1 | Pabitha-1/python-1 | /palin.py | 129 | 3.75 | 4 | a=int(raw_input())
temp=a
c=0
while(a>0):
b=a%10
c=c*10+b
a=a/10
if(temp==c):
print("yes")
else:
print("no")
|
bf4c6a5f7b7ca8ee8ba4704124958b1360f3b4fb | Pabitha-1/python-1 | /alp.py | 89 | 3.828125 | 4 | c=str(raw_input())
if c in("a","e","i","o","u"):
print("Vowel")
else:
print("Consonant")
|
986c09394547205c651d1a7f7a48768686195313 | Pabitha-1/python-1 | /player_set3_whitespaces.py | 131 | 3.609375 | 4 | str=str(raw_input())
a=list(str)
for i in range(len(a)):
if a[i]==' ':
a[i]=''
ans=''
for i in a:
ans=ans+i
print(ans.strip())
|
85fcb1f61665b5e862280e7e0d2ff932968ad029 | Pabitha-1/python-1 | /isomorphic.py | 605 | 3.53125 | 4 | b = 256
string1,string2=str(raw_input()).split()
def areIsomorphic():
m = len(string1)
n = len(string2)
if m != n:
return ("no")
marked = ["no"] *b
map = [-1] *b
for i in range(n):
if map[ord(string1[i])] == -1:
... |
3b38828f407968109c43d263bfae74922ad48b62 | ashok052/code_snippets | /Python/DailyInterviewPro/25_Witness.py | 626 | 4.21875 | 4 | """
Hi, here's your problem today. This problem was recently asked by Google:
There are n people lined up, and each have a height represented as an integer.
A murder has happened right in front of them,
and only people who are taller than everyone in front of them are able to see what has happened.
How many witnesses ... |
b84502e337ccc1e235c0b7c3552421eed05b4437 | ashok052/code_snippets | /Python/DailyInterviewPro/13_Stairs.py | 424 | 3.890625 | 4 | """
Hi, here's your problem today. This problem was recently asked by LinkedIn:
You are given a positive integer N which represents the number of steps in a staircase.
You can either climb 1 or 2 steps at a time.
Write a function that returns the number of unique ways to climb the stairs.
Challenge: Can you find a so... |
dc29f4116e2dee59b9a81726d8d647e3a81617a5 | LukeTonin/simple-deep-learning | /simple_deep_learning/mnist_extended/array_overlay.py | 6,154 | 3.59375 | 4 | """This module contains utility functions for performning manipulations of images stored as arrays.
"""
from typing import List
import numpy as np
from ..bounding_box import format_bounding_box, calculate_iou
def overlay_arrays(array_shape: tuple,
input_arrays: np.ndarray,
inp... |
47835118357bedf9199e87310697ba1ef13f05f1 | XUANXUANXU/8-Mathematics | /code/code/矩阵.py | 247 | 3.53125 | 4 | import numpy as np
a = np.array([[2,1,-3],[1,2,-2],[-1,3,2]])
A = np.mat(a) #使用 mat 方法将 2 维数组转化为矩阵
print(A)
# print(A.T) #A.T 表示 A 矩阵的转置矩阵:
print(A.I) #A.I 表示 A 矩阵的逆矩阵:
|
a448588f09a489d97e974341e292b0385d36b0b7 | loeand16/CSF | /hw2.py | 2,056 | 4.0625 | 4 | # Name: Andrew Loewen
# Evergreen Login: loeand16
# Computer Science Foundations
# Programming as a Way of Life
# Homework 2
# You may do your work by editing this file, or by typing code at the
# command line and copying it into the appropriate part of this file when
# you are done. When you are done, running this f... |
cccecd43fad45f90175193964d0aba04a087e679 | NKoundinya/Python | /D to B.py | 116 | 3.75 | 4 | a=""
i=0
k=0
num=input()
while(num>0):
a+="num%2"
a+="0"
a+="num%2"
num/=10
print a
|
512d51f21fac30767dc9d8c567a9a2872ef3ab6c | NKoundinya/Python | /Latin.py | 220 | 3.8125 | 4 | n=input("Range: ")
array=[[0 for i in range(n)] for i in range(n)]
print array
for i in range(0,n):
for j in range(0,n):
array[i][j]=input()
for i in range(0,n):
for j in range(0,n):
array[j][i]
|
525059aff77cebef1b92c53117c0dd6add2f17d8 | Fei-WL/Leetcode | /117 填充节点下一个右侧.py | 754 | 3.640625 | 4 | from Tree import stringToTreeNode
from Tree import TreeNode as Node
class Solution:
def connect(self, root: 'Node') -> 'Node':
if root is None:
return None
parents = []
parents.append(root)
while len(parents) != 0:
limit = len(parents)
while limit... |
d0ed5d63aac4f55ad2d6f87e821a6cbbb6f38a81 | Fei-WL/Leetcode | /Offer/03 数组中重复的数字.py | 312 | 3.65625 | 4 | from typing import List
class Solution:
def findRepeatNumber(self, nums: List[int]) -> int:
existed = [False] * max(nums)
for num in nums:
if existed[num]:
return num
existed[num] = True
nums = [2, 3, 1, 0, 2, 5, 3]
Solution().findRepeatNumber(nums) |
bc329f23917a73f369623526350b62b6c00ec57d | Fei-WL/Leetcode | /48 旋转图像.py | 1,112 | 3.890625 | 4 | from typing import List
class Solution:
def rotate(self, matrix: List[List[int]]):
"""
Do not return anything, modify matrix in-place instead.
"""
# 如果用[[0]*len(matrix)]*len(matrix),那么就会导致最后这几行的结果是一样的
# 使用了辅助矩阵
# 还有两种,分别是利用四个等式变换,构建旋转;还有个是先翻转,再转置
temp_matrix ... |
106b451222c3452234cac291f0d2d6678aac3cd0 | Fei-WL/Leetcode | /204 计数质数.py | 953 | 3.6875 | 4 | import math
from collections import Counter
class Solution:
def isPrime(self, x):
if x == 2:
return True
for idx in range(2, int(math.sqrt(x)+1)):
if x % idx == 0:
return False
return True
def countPrimes(self, n: int) -> int:
if n <= 2:
... |
54f9c532cdfb2eb309d7cd4042f0e9b6312806d2 | CTEC-121-Spring-2020/mod-5-programming-assignment-GrantParkinson | /Prob-2/Prob-2.py | 1,729 | 3.890625 | 4 | # Module 4
# Programming Assignment 5
# Prob-2.py
# <Grant Parkinson>
# IPO
# function definition
# inputs: cost of items, amount tendered
# process: calculate change in terms of number of each denomination
# output: summary line, number of each denomination
def change_machine_step_1(amountTendered, costOf... |
8e24e14554b6fddc78094cb9986ef4a1c8f51b15 | Sanzhar09/web | /LABS/1b.py | 143 | 3.84375 | 4 | a = int(input())
print("The next number for the number",a,"is", str(a+1) + ".")
print("The previous number for the number",a,'is',str(a-1)+".") |
f009a958265e050c8a30b2fcf488dd6e9c0f3a3d | mark10hyun/DatabaseStudentRecords | /venv/updateStudent.py | 1,074 | 3.984375 | 4 | import sqlite3
class updateStudent:
@staticmethod
def updateRec():
conn2 = sqlite3.connect('StudentDB.sqlite')
# cursor is something that performs an action
c = conn2.cursor()
userExit = 1
while userExit == 1:
inputID = int(input("Enter Student Id that you ... |
553de8213423c1620a363d990e1f1a751ee7638e | eden-fenster/Shower | /shower.py | 2,388 | 4.0625 | 4 | #!/usr/bin/env python3
"""Take a shower"""
import logging
import sys
logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.DEBUG)
# This is an object describing the state of a shower.
class Shower:
"""Shower class"""
def __init__(self, shower: bool, bath: bool, currently_taking: bool, small_... |
40dc733027d58c28dc0a449a81683691b82d80b1 | MiryalaNarayanaReddy/Data_and_Applications | /project/phase-4/Coding/date_time.py | 388 | 3.53125 | 4 | from datetime import date, datetime, time
def date_time_now():
d = datetime.now()
dt = d.strftime("%Y-%m-%d %H:%M:%S")
# dt = f"%d-%d-%d %d:%d:%d"%(d.year,d.month,d.day,d.hour,d.minute,d.second)
return dt
def date_now():
d = datetime.now()
dt = d.strftime("%Y-%m-%d")
# dt = f"%d-%d-%d %d:%... |
f560fd4682e76b932009982d909324a0f98aaee9 | AlvaroAbarca/Taller-Python | /pregunta3.py | 1,074 | 3.984375 | 4 | from math import pow
def calculo_notas(notas):
prom = 0
aux_prom = 0
nota_alta = 0
nota_baja = 0
for x in notas:
aux_prom += x
if(x > nota_alta):
nota_alta = x
if(nota_baja == 0 or x < nota_baja):
nota_baja = x
prom = aux_prom/len(notas)
retur... |
e213de67a6489558065b5e7f1c4dde0f8694a9a6 | puhitaku/motd-generator | /main.py | 5,627 | 3.65625 | 4 | from PIL import Image
class Color(object):
"""The class that contains a color code and its name"""
def __init__(self, name, code, rgb = (0,0,0)):
"""Set the name of the color and code"""
self._name = name
self._code = code
self._rgb = rgb
def get_name(self):
return... |
423266cb4cb07227e763fa34c621c797ac82dacf | ByeongGil-Jung/Python-OOP | /src/exercise_1/C_Person.py | 2,452 | 3.578125 | 4 | class Person(object):
def __init__(self, year, month, day, sex):
self.year = year
self.month = month
self.day = day
self.sex = sex
def __str__(self):
return 'The Birthday :: {} years, {} month, {} rd \nGender :: {}'.format(self.year, self.month, self.day, self.sex)
... |
9c22aa14b04d1fca50087333338b66737892ed9a | DavidFliguer/devops_experts_course | /homework_1/exercise_1_2_3.py | 341 | 4.15625 | 4 | # Create 2 vars with the value "5" and 5
five_str = "5"
five_int = 5
# Save the boolean result of the comparison of above vars
comparison = five_str == five_int
# Sum the two vars (Since will give error due to trying to add string with int, surround by try except)
try:
my_sum = five_str + five_int
except:
... |
2aa00faf681313f3ed864bfbbbe3599489f096df | DavidFliguer/devops_experts_course | /homework_2/exercise_c.py | 174 | 3.765625 | 4 | my_number = 3
if my_number == 1:
print("summer")
elif my_number == 2:
print("winter")
elif my_number == 3:
print("fall")
elif my_number == 4:
print("spring")
|
2a724320feda5d0ef6433e895c2d90cde1a3fe6f | DavidFliguer/devops_experts_course | /homework_2/exercise_a.py | 72 | 3.578125 | 4 | x = 20
y = 5
if x > y:
print("BIG")
elif x < y:
print("small")
|
7e53cd8cc503493156dfa0b3e7b6bdd9e7a170bc | Moly-malibu/MIT_6.00SC_VPT_Learn_Together | /lec25_queue_network_model/mit_bus_queue_network.py | 12,116 | 4.28125 | 4 | ##It simulates a shuttle service in which a single
##bus serves a loop. It starts with some generally useful
##classes for modeling queueing networks, and then uses some
##of them to build the bus simulation.
"""
NOTE: we are computing the average wait time of those passengers that get picked up
"""
import random,... |
d08b927bb4fd90c2068a90711f81f416ab425712 | Moly-malibu/MIT_6.00SC_VPT_Learn_Together | /BigO_and_algorithm/lec6_recursion.py | 1,650 | 4.21875 | 4 | # recursive call to find the exponential result
def find_exponential(Num, x):
"""
Num to the power of x
"""
# Base case:
if x == 1:
return Num
else:
return Num * find_exponential(Num, x-1)
print(find_exponential(5, 3))
print(find_exponential(2, 5))
print(">>>>>>>>>>>>>")
# rec... |
af5ff15d7cc2116273186013ce63f92096d99fc8 | Moly-malibu/MIT_6.00SC_VPT_Learn_Together | /BigO_and_algorithm/quiz_1_for_lec1-9.py | 1,946 | 3.828125 | 4 | word_list = ["tab", "bat", "go", "dota", "python", "bear", "singapore"]
def findAll(wordList, lStr):
"""
assumes: wordList is a list of words in lowercase.
lStr is a str of lowercase letters.
No letter occurs in lStr more than once
returns: a list of all the words in wordList that ... |
9999aad617986ca547a317f07e011ea171a7b04a | Moly-malibu/MIT_6.00SC_VPT_Learn_Together | /edx_2016_600_2x/lec6_random_seed.py | 759 | 3.84375 | 4 | import random
mylist = []
for i in range(random.randint(1, 10)):
random.seed(0)
if random.randint(1, 10) > 3:
number = random.randint(1, 10)
mylist.append(number)
print(mylist)
# a list of 7s of random length
print("*** Random Seed = 0")
random.seed(0)
for i in range(5):
print(random.rand... |
153af17d14c512953b0be756df8636aff0a6acdd | Moly-malibu/MIT_6.00SC_VPT_Learn_Together | /Problem_Set1_CreditCard/Problem_Set1_CreditCard.py | 3,784 | 4.40625 | 4 | """ Paying Off Credit Card Debt
minimum monthly payment is split to cover
1. interest paid
2. principal paid
"""
import time
# Problem 1 paying the minimum
# write a program to calculate the credit card balance after one year
# if the person only pays the minimal monthly payment
def summary_of_paying_minimal():
... |
524576fee151bcdfc11062fecfa6ddb05540aae7 | Moly-malibu/MIT_6.00SC_VPT_Learn_Together | /edx_2016_600_2x/lec8_monte_carlo_red_green_ball.py | 929 | 4.15625 | 4 | import random
random.seed(0)
def pick3balls():
# 3 red balls and 3 green balls
balls = list("RRRGGG")
picked = []
for i in range(3):
pick_ball = random.choice(balls)
picked.append(pick_ball)
balls.remove(pick_ball)
return picked
# print(pick3balls())
def noReplacementSim... |
8add1d2460a589af28486bb97910cc0cdbfa3cdd | Mauzzz0/study-projects | /python/lab3_python/22.4.py | 404 | 3.671875 | 4 | import math
def roots_of_quadratic_equation(*kwargs):
a = b = c = 0
if len(kwargs) == 0 or len(kwargs) > 3:
return None
elif len(kwargs) == 2:
b = kwargs[0]
c = kwargs[1]
elif len(kwargs) == 3:
a = kwargs[0]
b = kwargs[1]
c = kwargs[2]
x1 = (-b+math.... |
139bb68f8ba9fa89401da1eee7466f68a8702968 | Mauzzz0/study-projects | /python/lab2_python/12.5.py | 620 | 4.03125 | 4 | import re
def largest_substring(string):
length = 0
x = 0
y = 0
match = None
for y in range(len(string)):
for x in range(len(string)):
substring = string[y:x]
if len(list(re.finditer(re.escape(substring), string))) > 1 and len(substring) > length:
matc... |
01390d110155e5554cd3a62e5a28f310bb72cb82 | Mauzzz0/study-projects | /python/lab2_python/13.5.py | 189 | 3.96875 | 4 | arr = list()
for _ in range(int(input())):
b = input()
a = int(input())
arr.append([a, b])
b = list(reversed(sorted(arr)))
for item in reversed(sorted(arr)):
print(item[0])
|
657e30b26e261be0fd3f41fe6c581d5629f4afc9 | Mauzzz0/study-projects | /python/lab3_python/24.5.py | 356 | 3.765625 | 4 | def gematri(sequence):
sequence = [x.lower() for x in sequence]
# Если не углубляться в нумерологию, то сортировка по гематрию является ни чем иным, как лексикографическим порядком
# Поэтому вот ;)
print(*sorted(sequence), sep="\n")
|
2a8d58ea62842f608a6cd50a0aca1d8099ad62b4 | Mauzzz0/study-projects | /python/lab3_python/18.2.py | 221 | 3.75 | 4 | def making_sure_the_function_name_is_correct():
res = "denied"
for _ in range(3):
if input() == "password":
res = "allowed"
print(res)
return
print(res)
return
|
6b9489f8ec427625ab54b42347bcf6caf7203c88 | KemelbekovRM/GeekBrains | /Zadanie_4.py | 460 | 3.875 | 4 | # 4. Пользователь вводит целое положительное число. Найдите самую большую цифру в числе.
# Для решения используйте цикл while и арифметические операции.
param = int(input('Введите число - '))
itog = 0
while param > 0:
max_chislo = param % 10
param //= 10
if max_chislo > itog:
itog = max_chislo
prin... |
a0b8f61c06edca868c1dfabf6fd59336305c8688 | FFugi/aoc | /2021/01/01.py | 1,002 | 3.765625 | 4 |
import sys
def part_one(measurements):
counter = 0
prev = measurements[0]
for idx, m in enumerate(measurements):
if idx == 0:
continue
if m > prev:
counter += 1
prev = m
return counter
def calc_three(measurements, idx):
sum = 0
for i in range(... |
bdcf39a69fac554f1e82206eb3271c8bac6ae303 | ZhangKaiyuSVW/DataEngine | /day01/zy01.py | 175 | 3.78125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Jan 30 21:03:21 2021
@author: zhangkaiyu
"""
#课程作业1
x=0
for a in range(2,101,2):
x=x+a
print(x)
|
1d1d42a19d0b0c59f1a78eb25fdb50165ad72714 | christofs/romde | /skripts/extract_persdata.py | 2,020 | 3.5 | 4 | #!/usr/bin/env python3
# Filename: cleanromde_pers.py
"""
# Function to clean up HTML scraped from romanistik.de/pers.
# Makes use of "re"; see: http://docs.python.org/2/library/re.html
"""
#######################
# Import statements #
#######################
from bs4 import BeautifulSoup
import csv
import re
im... |
30c4ac7735606a0172ffe8305357a20eb6e74bea | ThompsonBethany01/python-exercises | /data_structure_manipulation_exercises.py | 7,176 | 4.375 | 4 | #!/usr/bin/env python
# coding: utf-8
# # The following questions reference the students data structure below. Write the python code to answer the following questions:
# 1. How many students are there?
# In[4]:
#shows length of dictionary, aka 14 items
len(students)
# 2. How many students prefer light coffee? Fo... |
0407da747eb06b684b9866792dd24c162931c3c3 | pritam1997/OOPS | /animal_class.py | 411 | 3.78125 | 4 | class Animal:
def __init__(self,name,Class):
self.name = name
self.Class = Class
class Acquitic(Animal):
def __init__(self):
super().__init__(name,Class)
class Amphibion(Animal):
def __init__(self,name, Class, age):
super().__init__(name,Class)
def behave(self):
return f"{self.name} is ab... |
ac216e217aa09407555d389299bef6eebb9057dd | jshams/CS-2.2-Advanced-Recursion-and-Graphs | /graphs/challenge4/knapsack.py | 5,032 | 3.6875 | 4 | # from graph import ADTGraph
# class Knapsack():
# def __init__(self, items=[]):
# '''initialize this knapsack with a directed graph
# the start vertex of the graph being a frozenset with all possible items
# input is an array of tuples (tuples are items)
# ex: items = [(1,2),(4,2)... |
ac99570db2a01ca6880f0fc6570292e6a1d518f0 | rwylie/python-exercises | /FunctionEx/degree_conversion_plot.py | 175 | 3.546875 | 4 | import matplotlib.pyplot as plot
def f(x):
return x * 9 /5 + 32
xs = list(range(-5, 5))
ys = []
for x in xs:
ys.append(f(x))
plot.plot(xs, ys)
plot.show()
f()
|
4c1afb0da27ee6c0e23cc16d10ffd13ad0e3a9c4 | rwylie/python-exercises | /guess4.py | 501 | 4.15625 | 4 | secret_num = 5
print ("I am thinking of a number between 1 and 10.")
guess_count = 6
while guess_count > 0:
guess_count -=1
print("You have " + str(guess_count) + " guesses left.")
if guess_count == 0:
print("Sorry, no more guesses")
break
guess = int(input("What's my number?"))
if ... |
393b99d23b0a04f93c145eb5d40f69c218d81e50 | rwylie/python-exercises | /coins.py | 240 | 4.0625 | 4 | answer = ''
count = 0
print("You have 0 coins")
answer = input("Do you want another coin?")
while answer == 'yes':
count += 1
print("You have " + str(count) + " coins")
answer = input("Do you want another coin?")
print ("Bye")
|
40ce23d71432903689bd16cc86ac38b991b8acf9 | rwylie/python-exercises | /Python_part_2/long_long_vowels.py | 214 | 3.59375 | 4 | l = ["aa", "ee", "ii", "oo", "uu"]
l2 = ["aaaaa", "eeeee", "iiiii", "ooooo", "uuuuu"]
my_string = "This cheese is good!"
for i in range(0, len(l)):
my_string = my_string.replace(l[i], l2[i])
print(my_string)
|
bbb5f569e915e7032a908d7abac9b644957c0a6b | rwylie/python-exercises | /guess3.py | 399 | 4.15625 | 4 | import random
random_num = random.randint(1, 10)
print ("I am thinking of a number between 1 and 10.")
guess = int(input("What's my number?"))
while guess != random_num:
guess = int(input("Guess again."))
if guess < random_num:
print("Number is too low.")
elif guess > random_num:
print("Num... |
1f03a7d00ee4bb2544902cb723dcf0dac0647274 | haehn/clustering_project | /clustering_project/class_files/deprecated/Node.py | 5,349 | 3.71875 | 4 | class Node(object):
def __init__(self,anc,bl=1):
self.ancestor=anc # ancestor Node
self.children=[] # children Nodes
self.branch=bl # branch length of branch leading to actual node
self.name="" # name of... |
c2eb9a8c0ec647bd9d9ab32d64854855a34adea0 | Kaczy6point9/projekt_PP | /Python/weasel.py | 1,556 | 3.546875 | 4 | import random
import string
def randomString(size):
return ''.join(random.choice(string.ascii_uppercase + ' ') for _ in range(size))
def stringmutation(sentence):
new_senetence = list(sentence)
index = random.randrange(len(sentence))
new_senetence[index] = random.choice(string.ascii_uppercase + ' ')
return... |
d94c58eca90068bd1e44765ab10d28af3e17200d | calebtechno/Module-5 | /listy_lo.py | 732 | 4.03125 | 4 | if __name__ == "__main__":
food = ['beans', 'rice']
food_addition = ['bread', 'pizza']
food.append('broccoli')
food.extend(food_addition)
print(food[0:2])
print(food[-1])
breakfast = "eggs, fruit, orange juice"
listy = breakfast.split(",")
print(listy)
print(len(lis... |
7458b5eb0ecd8cc52cd94f33a5a11f6cd4f6f064 | raipier8818/Academy | /HYUCSE/Grade1/소프트웨어입문설계/Python/2020063045_hw5.py | 2,013 | 3.765625 | 4 | class Student:
def __init__(self,name):
self.name = name
self.list = []
def input_score(self, subject, score):
self.subject = subject
self.score = int(score)
if self.score >=95:
self.grade = "A+"
self.g_score = 4.5
elif self.score >= 90... |
fb7da1f15b19923d26e5fce19f51ad792760d582 | imkouyo/Markdown-Editor | /Problems/Print book info/main.py | 442 | 3.828125 | 4 | def print_book_info(title, author=None, year=None):
# Write your code here
if (author is None or author == "None") and (year is None or year == "None"):
print('"{}"'.format(title))
else:
author = "" if (author is None or author == 'None') else " by {}".format(author)
year = "" if (y... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.