blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
9b9e0bd9b4787a24bfc333e1f440ee144073f4bf | tabish606/python | /identity_matrix.py | 645 | 4.15625 | 4 | #print identity matrix for example
# 1 0 0
# 0 1 0
# 0 0 1
m = int(input('enter the order of matrix : '))
#list comprehension
#mat = [[] for i in range (0,m)]
#mat = [[0 for j in range(0,m) for i in range(0,m)]]
#mat = [[int(input()) for i in range(0,m)] for i in range(0,m)]
mat = []
for i in range(0... | false |
7d6b7ba3ac0bf3ee292dfa0178f6414549ececb3 | ycw786369470/PythonTest | /算法/快速排序/快排.py | 885 | 4.15625 | 4 |
def quick_sort(list1, left, right):
#左右下标
if left >= right:
return None
n = left
m = right
#基准值
base = list1[n]
while n < m:
#从右边往左边找一个比base小的
while list1[m]>=base and n < m:
m -= 1
if n == m:
list1[n] = base
else:
... | false |
0384000aaaedfd61cf915234cc419e4d9deff281 | kadamsagar039/pythonPrograms | /pythonProgramming/bridgelabzNewProject/calender.py | 653 | 4.15625 | 4 | """Calender Program
This program is used to take month and year from user and print corresponding Calender
Author:
Sagar<kadamsagar039@gmail.com>
Since:
31 DEC,2018
"""
from ds_utilities.data_structure_util import Logic
def calender_runner():
"""
This method act as runner for calender_queue(month, y... | true |
d389e3a7ad0bd05f8ec5f50d0c9b3d192859f41a | StudentDevs/examples | /week1/2.py | 1,958 | 4.8125 | 5 | """
Tutorials on sqlite (quickly grabbed off google, there may be better ones):
https://stackabuse.com/a-sqlite-tutorial-with-python/
https://pynative.com/python-sqlite/
"""
import sqlite3
def main():
print('Connecting')
conn = sqlite3.connect(':memory:')
# Configure the connection so we can use the res... | true |
a268b45504f17b58cdf3e5537a47f68ec6e9faa3 | 3NCRY9T3R/H4CKT0B3RF3ST | /Programs/Python/bellman_ford.py | 1,438 | 4.1875 | 4 | #This function utilizes Bellman-Ford's algorithm to find the shortest path from the chosen vertex to the others.
def bellman_ford(matrix, nRows, nVertex):
vertex = nVertex - 1
listDist = []
estimation = float("inf")
for i in range(nRows):
if (i == vertex):
listDist.append(0)
... | true |
442271b97e0a30d58c9e2a03a58a6e119112524a | jefflike/python_advance | /packet/006.鸭子类型与多态.py | 2,597 | 4.125 | 4 | '''
__title__ = '006.鸭子类型与多态.py'
__author__ = 'Jeffd'
__time__ = '4/14/18 4:39 PM'
'''
'''
tips:鸭子类型就是,当看到一只鸟走起来像鸭子,游泳像鸭子,叫起来也像鸭子
那么这只鸟就可以称作鸭子
python的多态性就是基于鸭子类型的
'''
# 在python中具有同样的方法的类我们可以把他归并成一类事物
class turtle:
def swim(self):
print('turtle swimming')
class duck:
def swim(self):
print('... | false |
8b8177c2acb317808a8e4808293cdc8b690f230f | NirajPatel07/Algorithms-Python | /insertionSort.py | 376 | 4.125 | 4 | def insertionSort(list1):
for i in range(1,len(list1)):
curr=list1[i]
pos=i
while curr<=list1[pos-1] and pos>0:
list1[pos]=list1[pos-1]
pos-=1
list1[pos]=curr
list1=list(map(int, input("Enter Elements:\n").split()))
print("Before Sorting:\n",list1)
... | true |
2a575b03af1d4347b73917510fd275583fa674c3 | GrandPa300/Coursera-RiceU-Python | /01_Rock-paper-scissors-lizard-Spock/Rock-paper-scissors-lizard-Spock.py | 2,074 | 4.15625 | 4 | # Mini Project 1
# Rock-paper-scissors-lizard-Spock
# The key idea of this program is to equate the strings
# "rock", "paper", "scissors", "lizard", "Spock" to numbers
# as follows:
#
# 0 - rock
# 1 - Spock
# 2 - paper
# 3 - lizard
# 4 - scissors
# helper functions
import random
def number_to_name(number):
# fil... | true |
66dca308dded21abc0509cd24802891564c63c0d | Taylorsuk/Game-of-Hangman | /hangman.py | 2,950 | 4.125 | 4 | import random
import re
# import the wordlist
txtfile = open('word_list.txt', 'r')
wordsToGuess = txtfile.readlines()
allowedGuesses = 7
incorrectGuesses = []
correctGuesses = []
randomWord = random.choice(wordsToGuess).strip()
guessWord = []
maskCharacter = '*'
# we have a random word so we can now start the game
pr... | true |
78182f8b7eeed49d51da5ad194732dbee021ddf4 | aiqingr/python-lesson | /pythonProject/python1/inputExample.py | 319 | 4.21875 | 4 | # num_input = input("Input a number")
# print(num_input ** 2)
# First two line will popup an error because the input function always return a string
# This will be Method One
# num_input_1 = input("input a number: ")
# print(int(num_input_1) ** 2)
num_input_2 = int(input("input a number: "))
print(num_input_2 ** 2)
| true |
41aed98b579dcc9e7621c9356685aacc33fcf7e9 | fivaladez/Learning-Python | /EJ10_P2_Classes.py | 981 | 4.28125 | 4 | # EJ10_P2 Object Oriented - Classes
# Create a class
class exampleClass:
eyes = "Blue"
age = 22
# The first parameter MUST be self to refers to the object using this class
def thisMethod(self):
return "Hey this method worked"
# This is called an Object
# Assign the class to an a variabl... | true |
ebbdc407c8e93e02618d8aec68213b2229de61ec | fivaladez/Learning-Python | /EJ21_P2_Lambda.py | 1,006 | 4.375 | 4 | # EJ21_P2 Lambda expression - Anonymous functions
# Write function to compute 3x+1
def f(x):
return 3*x + 1
print f(2)
# lambda input1, input2, ..., inputx: return expression in one line
print lambda x: 3*x + 1
# With the above declaration we still can not use the function,
# we need a name, so, we can do the... | true |
99002d0f430011ee9f40ac32feac98b84b435544 | fivaladez/Learning-Python | /EJ11_P2_SubClasses_SuperClasses.py | 1,065 | 4.40625 | 4 | # EJ11_P2 Object Oriented - subClasses and superClasses
# SuperClass
class parentClasss:
var1 = "This is var1"
var2 = "This is var2 in parentClass"
# SubClass
class childClass(parentClasss):
# Overwrite this var in this class
var2 = "This is var2 in childClass"
myObject1 = parentClasss()
prin... | true |
3194e6d5a08128b1eb943b29f579bf3bf72b1d68 | tanish522/python-coding-prac | /stack/stack_1.py | 415 | 4.15625 | 4 | # stack using deque
from collections import deque
stack = deque()
# append() function to push element in the stack
stack.append("1")
stack.append("2")
stack.append("3")
print('Initial stack:')
print(stack)
# pop() fucntion to pop element
print('\nElements poped from stack:')
print(stack.pop())
print... | true |
2e1f82907b455f15ddaa77b4a3841c2dd61f6de5 | ArsenArsen/claw | /claw/interpreter/commands/cmd_sass.py | 1,764 | 4.125 | 4 | """
Takes the given input and output directories and compiles all SASS files in the input into the output directory
The command takes three parameters, namely target, directory, and glob:
sass <source> <target> [style]
The source parameter is relative to the claw resource directory
The target parameter is where th... | true |
649df4c7b9f19ab38d3924cd2dc68f956b70f90b | iEuler/leetcode_learn | /q0282.py | 1,461 | 4.28125 | 4 | """
282. Expression Add Operators
https://leetcode.com/problems/expression-add-operators/
Given a string that contains only digits 0-9 and a target value, return all possibilities to add binary operators (not unary) +, -, or * between the digits so they evaluate to the target value.
Example 1:
Input: num = "123", ta... | true |
444ef66071c458cf92cfff248f813ab29608c91e | Prashant1099/Simple-Python-Programs | /Count the Number of Digits in a Number.py | 318 | 4.15625 | 4 | # The program takes the number and prints the number of digits in the number.
n = int(input("\nEnter any Number = "))
count = 0
temp = n
while (n>0):
n //= 10
count += 1
print("-----------------------------------")
print("Number of Digits in ",temp, " = ",count)
print("-----------------------------------") | true |
b8da10fe0d52d9d8ff08344c4bc8d3465b8f3e6d | atifahsan/project_euler | /p1.py | 275 | 4.21875 | 4 | # If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
# Find the sum of all the multiples of 3 or 5 below 1000.
numbers = [i for i in range(1, 1000) if not i % 3 or not i % 5]
print(sum(numbers)) | true |
1179247685bb98e5de3d5de793ba677670d18e55 | ananth-duggirala/Data-Structures-and-Algorithms | /Arrays and Strings/reverse_string.py | 338 | 4.28125 | 4 | """
Problem statement: Reverse a string.
"""
def reverseString(string):
newString = ""
n = len(string)
for i in range(n):
newString += string[n-1-i]
return newString
def main():
string = input("This program will reverse the entered string. \n\nEnter string: ")
print(reverseString(string))
if __name__ == "_... | true |
277cf603c8c3652936bc7f1ff1e6ded0111c82b0 | ClaudiaStrm/Introducao_ciencia_da_computacao | /04-01_fizzbuzz.py | 572 | 4.125 | 4 | #Escreva a função fizzbuzz que recebe como parâmetro um número inteiro e retorna
#'Fizz' se o número for divisível por 3 e não for divisível por 5;
#'Buzz' se o número for divisível por 5 e não for divisível por 3;
#'FizzBuzz' se o número for divisível por 3 e por 5;
#Caso a função não seja divisível 3 e também não sej... | false |
8391191aa5fc0ff6eb1d36d55e9105a6dc655c01 | kodfun/PythonOgreniyorum | /Strings5.py | 2,834 | 4.1875 | 4 | # STRING METOTLARI
# https://www.w3schools.com/python/python_strings_methods.asp
s = "merhaba DÜNYA"
print(s.capitalize())
print(s.upper())
print(s.lower())
print("01234567890123456789")
print("KODLUYORUM".center(20))
print("KODLUYORUM".center(20,"*"))
# KAÇ TANE A HARFİ GEÇİYOR?
s = "ankara"
print(s.count("a"))
... | false |
8af2e44e30d2e180e9b16f63c69d2d53d6a1594b | Suman196pokhrel/TkinterPractice | /more_examples/m7e_canvas_and_mouse_events.py | 2,551 | 4.3125 | 4 | """
Example showing for tkinter and ttk how to:
-- Capture mouse clicks, releases and motion.
-- Draw on a Canvas.
Authors: David Mutchler and his colleagues
at Rose-Hulman Institute of Technology.
"""
import tkinter
from tkinter import ttk
class PenData(object):
def __init__(self):
self.co... | true |
d6577d3cba76440597da1653413a156453e16514 | maainul/Python | /pay_using_try_catch.py | 244 | 4.125 | 4 | try:
Hours=input('Enter Hours:')
Rates=input('Enter Rates:')
if int(Hours)>40:
pay=40*int(Rates)+(int(Hours)-40)*(int(Rates)*1.5)
print(pay)
else:
pay=int(Hours)*int(Rates)
print(pay)
except:
print('Error,Please enter numeric input.')
| true |
dc54502a549f56b66637befa2cbf522f744357c0 | maainul/Python | /Centimeter_to_feet_and_inch.py | 265 | 4.125 | 4 | cm=int(input("Enter the height in centimeters:"))
inches=0.394*cm
feet=0.0328*cm
print("The length in inches",round(inches,2))
print("The length in feet",round(feet,2))
OUTPUT:
Enter the height in centimeters:50
The length in inches 19.7
The length in feet 1.64
| true |
f0efb4420fc64de14a50e2ad08c873ba103fcc11 | kuldeepc08/PythonPrograms | /palindrome.py | 451 | 4.25 | 4 | '''Palindrome number'''
def Reverse(num):
rem=0
while num!=0:
rem=num%10+rem*10
num= int(num//10)
return rem
def main():
num=input("Enter the number")
num1=Reverse(num)
print("Reverse number is %d" %num1)
if (num1==num):
... | false |
4719c9d94b43e37e25802ebdb2f92a8eaeb735a8 | sudheer-sanagala/intro-python-coursera | /WK-03-Loops/while_loops.py | 2,178 | 4.3125 | 4 | # while loops
x = 0
while x < 5:
print("Not there yet, x =" + str(x))
x = x + 1
print("x = "+str(x))
#current = 1
def count_down(start_number):
current = start_number
while (current > 0):
print(current)
current -= 1 #current = current -1
print("Zero!")
count_down(3)
"""
Print prime numbers
A... | true |
dd0c19ae77a22d440a86212bb03966d240c56b91 | Robbot/ibPython | /src/IbYL/Classes/Polymorphism.py | 1,050 | 4.1875 | 4 | '''
Created on 16 Apr 2018
@author: Robert
'''
class network:
def cable(self): print('I am the cable')
def router(self): print('I am the router')
def switch(self): print('I am the switch')
def wifi(self): print('I am wireless router, cable does not matter')
class tokenRing(network):
de... | true |
7999ace79084e36c7190d8a1bd42eca5daad30f6 | leon-sleepinglion/daily-interview-pro | /014 Number of Ways to Climb Stairs/main.py | 413 | 4.15625 | 4 | '''
If we look at the solution as a function f(n) where n = number of steps
f(1) = 1
f(2) = 2
f(3) = 3
f(4) = 5
f(5) = 8
f(6) = 13
This is in fact a fibonacci sequence! Hence the solution can be implemented
as a function that calculates the (n+2)th fibonacci number
'''
def staircase(n):
x = [0,1]
for i in range(n):... | true |
0493b5cd7e50e3b1acd3487d7f0db5c13e9c6e15 | AT1924/Homework | /hw10/functional.py | 1,772 | 4.15625 | 4 | class InvalidInputException(Exception):
def __str__(self):
return "Invalid Input Given."
def apply_all(f_list, n):
"""apply_all: [function], number -> [number]
Purpose: applies each function in a list to a single number
Consumes: a list of functions and a number
Produces: a list of numbers ... | true |
5463864d5969765af54156c9a19bde20de80b71e | wwyywg/Py3 | /02_python核心编程/01_Python核心编程/ww_07_iterable.py | 628 | 4.125 | 4 | from collections.abc import Iterable, Iterator
if __name__ == '__main__':
# 判断是否可以迭代
# print(isinstance([], Iterable))
# print(isinstance({}, Iterable))
# print(isinstance('abc', Iterable))
# print(isinstance((x for x in range(10)), Iterable))
# print(isinstance(100, Iterable))
# 迭代器
p... | false |
33655816cfafa233b306d61f4534338cebeced0a | Lord-Gusarov/holbertonschool-higher_level_programming | /0x06-python-classes/1-square.py | 514 | 4.21875 | 4 | #!/usr/bin/python3
"""
Task 1
Write a class Square that defines a square by
>Private instance attribute: size
>Instantiation with size (no type/value verification)
>You are not allowed to import any module
"""
class Square:
"""
A class that defines a Square
"""
def __init__(self, size):
"""I... | true |
3f48b004bfa01617330bbcc06c11751187786c86 | Lord-Gusarov/holbertonschool-higher_level_programming | /0x0B-python-input_output/1-write_file.py | 319 | 4.1875 | 4 | #!/usr/bin/python3
"""Task: Write to a file
"""
def write_file(filename="", text=""):
"""writes to a file, overtwiting it if it exist
Args:
filename (str): desire name of the output file
text (str): what is to be written
"""
with open(filename, 'w') as f:
return f.write(text)
| true |
f636dc47edfa679588c09af316acb7a9fc07db5e | Lord-Gusarov/holbertonschool-higher_level_programming | /0x06-python-classes/2-square.py | 960 | 4.46875 | 4 | #!/usr/bin/python3
"""Task2
Write a class Square that defines a square by
Private instance attribute: size
Instantiation with optional size: def __init__(self, size=0):
Size must be an integer, otherwise raise a TypeError exception with the
message size must be an integer
If size is less than 0, raise a V... | true |
e38e998dba656061bb5af65d2cd338e0bd30de8b | xinyifuyun/-Python-Programming-Entry-Classic | /chapter_three/02.py | 310 | 4.21875 | 4 | a = ("first", "second", "third")
print("The first element of the tuple is %s" % a[0])
print("The second element of the tuple is %s" % a[1])
print("The third element of the tuple is %s" % a[2])
print("%d" % len(a))
print(a[len(a) - 1])
b = (a, "b's second element")
print(b[1])
print(b[0][0])
print(b[0][2])
| true |
f6568d0cecef38406016d82249b846b7e86efa32 | Ikshitkate/java-html-5-new-project | /python/krishnamurthyNo.py | 778 | 4.15625 | 4 | # Python program to check if a number
# is a krishnamurthy number
# function to calculate the factorial
# of any number
def factorial(n) :
fact = 1
while (n != 0) :
fact = fact * n
n = n - 1
return fact
# function to Check if number is
# krishnamurthy/special
def isKrishnamur... | false |
4226dba34eb2675e4ec98106e3c11eaa0a98f8ce | disha2sinha/Data-Structures-and-Algorithms | /DATA-STRUCTURES/Stack/InfixToPostfixConversion.py | 1,325 | 4.21875 | 4 | def precedence(operator):
if operator == '+' or operator == '-':
return 1
if operator == '*' or operator == '/':
return 2
if operator=='^':
return 3
def postfix(expression):
stack = []
p = ''
stack.append('(')
exp_list.append(')')
for i in range(0, l... | false |
0a171e7b70560728837047bc976f01c145fcc474 | sartorileonardo/Curso-Intro-Python-Univali | /Aula01/aula01EstruturaRepeticaoWhileFactorial.py | 495 | 4.25 | 4 | print("Teste WHILE")
#O numero factorial é como 5 = 5*4*3*2*1
factorial_number = input("Entre com um número:")
factorial_number = int(factorial_number)
if factorial_number > 0:
step = factorial_number
total = factorial_number
while step > 1:
step -= 1
total *= step
print("O fatori... | false |
4d5100673e0f2e9a6647e200d5cbe52f6e17ae42 | NachoBokita/Ejercicios | /EjercicioClase5/ejercicio5.py | 969 | 4.15625 | 4 |
"""
=> Ejercicio 5:
Realizar una función asociar() que reciba como parametro dos listas
de la misma longitud de elementos y devuelva un diccionario de pares
clave-valor asociando cada elemento de ambas listas segun su indice.
Ej:
empleado = ['Juli', 'Carlos', 'Roberto', 'Marta']
... | false |
b050f7dcbcc0a529ec03ac638af6c04cac4e6026 | Aneeka-A/Basic-Python-Projects | /addition_problems.py | 1,561 | 4.5625 | 5 | """
File: addition_problems.py
-------------------------
This piece of code will create addition problems (with 2 digit numbers).
New problems will continue to be displayed until the user gets 3 correct answes in a row.
"""
import random
# Declaring the minimum and the maximum numbers that can appear in the question.
... | true |
e3d93082e02229e0723365df2f15d2705bc4f625 | RawOnion/AlgorithmLearning | /Algorithm/quickSort.py | 1,007 | 4.28125 | 4 | '''
快速排序
1.选择基准点
2.将列表分成两个子列表:小于基准点元素的列表和大于基准点列表的元素
3.对两个子列表分别进行快速排序
'''
import random
def quick_sort(arr):
if len(arr)<2:
return arr
else:
pivot=random.choice(arr)
pivot_index=arr.index(pivot)
#所有小于基准值的元素组成的子列表
i=0
less=[]
greater=[]
while i<len(a... | false |
2c5b327a4407c39fc58e0fd3183737bb136626b3 | aryoferdyan/Python-Projects-Protek | /Praktikum 08/langkahkerja.py | 1,886 | 4.25 | 4 | print("1.Buatlah list a = [1, 5, 6, 3, 6, 9, 11, 20, 12] dan b = [7, 4, 5, 6, 7, 1, 12, 5, 9")
a = [1,5,6,3,6,9,11,20,12]
b = [7,4,5,6,7,1,12,5,9]
print(a)
print(b)
print('')
print("2.Sisipkan nilai 10 ke dalam indeks ke 3 dari a, dan 15 ke dalam indeks ke 2 dari b")
#insert(indeks ke-9, nilai)
a.insert(3,10)
b.insert... | false |
d001674dd6a054da8536bdfb8565cb423a5e49e2 | Onselius/mixed_projects | /factors.py | 741 | 4.34375 | 4 | #! /usr/bin/python3
# factors.py
# Finding out all the factors for a number.
import sys
def check_args():
if len(sys.argv) != 2:
print("Must enter a number")
sys.exit()
elif not sys.argv[1].isdigit():
print("Must enter a number")
sys.exit()
else:
return True
check... | true |
882145ab3ef396f1cf082b5a6e912dad48597167 | chnandu/practice-problems | /string-problems/unique_chars.py | 644 | 4.25 | 4 | #!/usr/bin/python
# Check if given string has all unique characters or not
def check_uniqueness(str_):
"""Check if given string has all unique characters and return True
:param str_: Given string
:returns: True, if all characters are unique. Else, False.
"""
char_dict = {}
for c in str_:
... | true |
4327f65151e2054c6ece88b694faa02ec3449d09 | Shaaban5/Hard-way-exercises- | /py files/ex9+10.py | 897 | 4.15625 | 4 |
days = "Mon Tue Wed Thu Fri Sat Sun"
months = "\nJan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug\tso on" # \n print in new line & \t print tap
print "Here are the days: ", days
print "Here are the months: ", months
print """
There's something going on here.
With the three double- quotes.
We'll be able to type as... | true |
44f95e83ddebe7cf08f73ca9c9e66e4307b1ae58 | Shaaban5/Hard-way-exercises- | /py files/ex27+28.py | 1,613 | 4.1875 | 4 | print True and True # T
print False and True # F
print 1 == 1 and 2 == 1 # F
print "test" == "test" # T
print '\n'
print 1 == 1 or 2 != 1 # T
print True and 1 == 1 # T
print False and 0 != 0 # F
print True or 1 == 1 # T
print '\n'
print "test" == "testing" # F
print 1 != 0 and 2 == 1 # F
print "test" != "te... | true |
9b78e17fab9b4e8c0a71bf89bacb5a2a4caa7b74 | Ruizdev7/pyEjercicios | /listas.py | 1,989 | 4.375 | 4 | miLista=["elem1", 5, 78.35, "elem4"] #estructura de una lista
print(miLista[0])
print(miLista[1])
print(miLista[2])
print(miLista[3])
print(miLista[-1])
print(miLista[-2])
print(miLista[-3])
#Accediendo a porciones de listas
print(miLista[0:3])
print(miLista[:3])
print(miLista[1:2])
print(miLista[2:])
#Funcion a... | false |
9fd35de9093f9f05025455b55fb72eb32d2f698d | AsmitaKhaitan/Coding_Challenge_2048 | /2048_game.py | 1,920 | 4.40625 | 4 |
#importing the Algorithm.py file where all the fuctions for the operatins are written
import Algorithm
import numpy as np
#Driver code
if __name__=='__main__':
#calling start() function to initialize the board
board= Algorithm.start()
while(True):
t = input("Enter the number (move) of your cho... | true |
bbab08378125425090805932e229d260c12158d0 | iez1784/learn | /Python/PythonLearnRocket/python_rocket/python_5.py | 1,094 | 4.1875 | 4 | # -*- coding: UTF-8 -*-
__author__ = 'zhangedison'
"""
请写出下面代三运后后的结果,并解释原因
"""
def makeActions(N):
acts = []
for i in range(N):
acts.append(lambda x: i ** x)
return acts
acts = makeActions(5)
print("===makeAction===")
for act in acts:
print(act(2))
print()
"""
第一题当中:
得到结果是:
16,16,16,16,16
ma... | false |
1978e3ac3665e1c5b096ee01da1da17a967873cd | ckitay/practice | /MissingNumber.py | 998 | 4.3125 | 4 | # All numbers from 1 to n are present except one number x. Find x
# https://www.educative.io/blog/crack-amazon-coding-interview-questions
# n = expected_length
# Test Case 1 , Expect = 6
from typing import List
from unittest import TestCase
class Test(TestCase):
def test1(self):
self.assertEqual(find_mi... | true |
d7cfc5ab4e6ee45b677b0b4351d6222e3f96af13 | izukua11might/belajarpython | /for loop.py | 1,072 | 4.125 | 4 | # list sebagai iterable
gorengan = ['bakwan','cireng','tahu isi','tempe goreng','ubi goreng']
for g in gorengan:# g yang di depan for merupakan variable baru
print (g) #yang mengakses data di variable gorengan oleh command for
print(len(g)) #yang di aplikasikan dengan menprint g
#Co... | false |
452b696d838bfd7d77b0c02ea9129f168d6b1786 | SuproCodes/DSA_PYTHON_COURSE | /OOP.py | 1,994 | 4.125 | 4 | class Employee:
def __init__(self, name):
self.name = name
def __repr__(self):
return self.name
john = Employee('John')
print(john) # John
#----------------------------
# Dog class
class Dog:
# Method of the class
def bark(self):
print("Ham-Ham")
# Create a new instance
charlie = Dog()
# C... | true |
f6e13f9d47f8524f63c175d086f49de917c678d4 | vipin-s0106/DataStructureAndAlgorithm | /Linkedlist/reverse_linked_list.py | 1,465 | 4.125 | 4 | class Node:
def __init__(self, data):
self.data = data
self.next = None
class Linkedlist:
def __init__(self):
self.head = None
def add(self, data):
new_node = Node(data)
if self.head is None:
self.head = new_node
else:
temp = self.h... | true |
fd879e688bc00a100698b5f53fcf5731c22ebcd4 | AlanAloha/Learning_MCB185 | /Programs/completed/at_seq_done.py | 694 | 4.1875 | 4 | #!/usr/bin/env python3
import random
#random.seed(1) # comment-out this line to change sequence each time
# Write a program that stores random DNA sequence in a string
# The sequence should be 30 nt long
# On average, the sequence should be 60% AT
# Calculate the actual AT fraction while generating the sequence
# Rep... | true |
8241b6ba8e8ddb44e4cef872bab429c057b54c02 | lalusafuan/DPL5211Tri2110 | /Lab 2.6.py | 308 | 4.125 | 4 | # Student ID: 1201201699
# Student Name : Lalu Muhammad Safuan Bin Maazar
import math
radius = float(input("Enter radius :"))
volume = (4/3)*math.pi * radius**3
surface = 4 * math.pi * radius **2
print("The volume of the sphrere is : {}".format(volume))
print("The surface area of the sphrere is : {}".for... | false |
01d632d6197fb44a76eadc59fba2ea73f48d3c70 | jptheepic/Sudoku_Solver | /main.py | 2,359 | 4.21875 | 4 |
#The goal of this project is to create a working sudoku solver
#This solution will implement recustion to solve the board
#This function takes in a 2D array and will print is as a sudoku board
def print_board(board):
for row in range(0,len(board)):
for col in range(0,len(board)):
#prints the boarder for ... | true |
959f6649dcedb7c3521a54fcf325126b3a5cc4b9 | Lamchungkei/Unit6-02 | /yesterdays.py | 830 | 4.3125 | 4 | # Created by: Kay Lin
# Created on: 28th-Nov-2017
# Created for: ICS3U
# This program displays entering the day of the week then showing the order
from enum import Enum
# an enumerated type of the days of the week
week = Enum('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday')
# inp... | true |
6345ba09eeaf5446e3202fef5c2a8faa43591d9d | ArildH/Python-exercises | /if-loop-test.py | 476 | 4.15625 | 4 | #test of for loops
students = {}
students[001] = "Arild Heyyland";
students[002] = "Turid Hoeyland";
students[003] = "Oddrun H. Heyyland";
students[004] = "Harald Heyyland";
students[005] = "Signe Heyyland";
students[006] = "Arne Heyyland";
students[007] = "Ivar Heyyland";
def search_students(student_no):
for ke... | false |
afd1a5dc6d85d64c9a6300a420a8253fb9d8d6e9 | yiboliu26/yibopython | /practice83.py | 1,630 | 4.15625 | 4 | def city_country(city_name, country_name):
"""show_city_info"""
city = city_name + ', ' + country_name
return city.title()
place = city_country('santiago', 'chile')
print(place + "!")
place = city_country('tokyo', 'japan')
print(place + "!")
place = city_country('beijing', 'china')
print(place + "!")
place... | false |
854300cb49d11a58f9b72f1f3a59d4a12012cd9c | jb3/aoc-2019 | /day-3/python/wire.py | 1,486 | 4.15625 | 4 | """Structures relating to the wire and points on it."""
import typing
from dataclasses import dataclass
@dataclass
class Point:
"""Class representing a point in 2D space."""
x: int
y: int
def right(self: "Point") -> "Point":
"""Return a new point 1 unit right of the point."""
return ... | true |
647d1d36759511e86ef6434c8a59daf7b345e888 | AnushSomasundaram/Anush_Python_projects | /Anush_assignments/1st_sem/python/first assignment/area_of_triangle.py | 221 | 4.15625 | 4 | #Write a program to find the area of triangle given
# base and height.
def area_of_triangle(height,base):
area = 0.5*height*base
print("The area of the given trianle is ",area,"units.")
area_of_triangle(1,6)
| true |
1c527311d782ceeec6e04e27d6f4b70e0532f9e4 | AnushSomasundaram/Anush_Python_projects | /chap4_fuctions/lambda.py | 458 | 4.25 | 4 | #lambda functions are just inline functions but specified with the keyword lambda
def function_1(x):return x**2
def function_2(x):return x**3
def function_3(x):return x**4
callbacks=[function_1,function_2,function_3]
print("\n Named Functions")
for function in callbacks:
print("Result:",function(3))
callbacks=\
... | true |
3b9a3df013329cc99b8ac392ca6d1f2c1bbcbcde | AnushSomasundaram/Anush_Python_projects | /compsci_with_python/chap2/largestword.py | 310 | 4.125 | 4 | length= int(input("Enter the number of elements in the list"))
words=[]
for i in range (0,length):
print("Word no.",i,":-")
words.append(str(input()))
longest=0
for i in range (1,length):
if len(words[i])>len(words[longest]):
longest=i
print("longest word is :-",words[longest])
| true |
cb7875e93bb7619218691f2beba46a87f691d96c | AnushSomasundaram/Anush_Python_projects | /Anush_assignments/1st_sem/python/first assignment/operations.py | 598 | 4.125 | 4 | """Write a Python program that allows the user to enter two integer values,
and displays the results when each of the following arithmetic operators are applied. For example,
if the user enters the values 7 and 5, the output would be,
7+5=12
7-5=2 and so on."""
number1=int(input("Please enter the first integer:-"))
... | true |
76d43d9bc8db00125fde1eb88ffb25d7546b43c8 | MithilRocks/python-homeworks | /bitwise_homework/divisible_by_number.py | 399 | 4.3125 | 4 | # hw: wtp to check if a number is multiple of 64
def divisible_by_number(num):
if num & 63 == 0:
return True
else:
return False
def main():
number = 128
if divisible_by_number(number):
print("The number {} is divisble by 64".format(number))
else:
print("The number {}... | true |
0880f00fcc0cda49c2cbd4de54e5ed0969156f3b | MYadnyesh/Aatmanirbhar_program | /Week 1/add.py | 512 | 4.15625 | 4 | #Program 1:- Addition of 2 numbers
def add(x,y):
print("The addition is : ")
return x+y
while True:
print(add(int(input("Enter 1st number: ")),int(input("Enter 2nd number: "))))
a=input("Do you want to continue (Press Y to continue)")
if(a=='y' or a=='Y') is True:
continue
else:
... | true |
b45735562a84f066be681ba592a610118e6da06c | MYadnyesh/Aatmanirbhar_program | /Week 1/primeIntr.py | 633 | 4.1875 | 4 | #Program 2 :- To print all the Prime numbers in an given interval
lower = int(input("Enter a starting number"))
upper = int(input("Enter a ending number "))
print("Prime numbers between", lower, "and", upper, "are:")
for num in range(lower, upper + 1):
if num > 1:
for i in range(2, num):
if (num ... | true |
a177115cde3a19cf9e2397aa844610b5a62ffb0c | CIS123Sp2020A/extendedpopupproceed-tricheli | /main.py | 614 | 4.21875 | 4 | #Tenisce Richelieu
from tkinter import
import tkinter.messagebox as box
#The first step after imports is crate a window
window = Tk()
#This shows up at the top of the frame
window.title('Message Box Example')
#create the dialog for the window
def dialog():
var = box. askyesno('Message Box', 'Proceed?')
if ... | true |
d625e1281292b5111a2387c83179662dcee3690a | Rishabh450/PythonConcepts | /mutability.py | 807 | 4.125 | 4 | friends_last_seen ={
'name': 'Rishabh',
'id': 15
}
print(id(friends_last_seen))
friends_last_seen ={
'name': 'Rishabh',
'id': 15
}
print(id(friends_last_seen))
# mutable object, when dictionary is passed in argument the change occus
# in same memory location same object, be careful this can be dangerou... | false |
99dbdf5273d32350e7a7186cfeb2dca59819bbae | surajnikam21/simplePatterns.py | /basic/3conditions.py | 618 | 4.25 | 4 | #if else
num1 = 2
num2 = 3
if (num1 == num2):
print('Equals')
else:
print('Not Equals')
# multi if elif els
if(num1 != num2):
print('Not Equal')
elif(num1 == num2):
print("Equals")
elif(num1 > num2 ):
print("num1 > num2")
else:
print("some data")
str1 = 'Suraj'
str2 = 'suraj'
if(str1== st... | false |
d251c01650c960e33c1414cbba09e7ec68b12d39 | KenOtis/Rock-Paper-Scissors-Game | /RockPaperScissors.py | 1,343 | 4.15625 | 4 | import random
import time
def main():
a=["rock","paper","scissors"]
go="yes"
print("\nLets play Rock, Paper, Scissors! \nBest of 3 wins.")
computer=0
user=0
while (computer<2 or user<2 ):
b=(random.choice(a))
choice=input("Your choice: ")
time.sleep(2)
... | false |
7ec6c5f2363d20cdd567aff4f9cc48718e77f895 | silastsui/pyjunior | /strloops/backwards.py | 551 | 4.15625 | 4 | #!/usr/bin/python
#backwards
text = str(raw_input("Enter a phrase: "))
#solution1 (wat)
print text[::-1]
#solution2 (for x in range)
reverse = ""
a = len(text)
for x in range(len(text)-1, -1,-1):
reverse += text[x]
print reverse
#solution3 (for let in text)
backwards = ""
for let in text:
backwards = let + backw... | true |
41b6e2352903bb2459a65f981655f9c7ed7ce60b | silastsui/pyjunior | /intloops/bin2dec.py | 245 | 4.125 | 4 | #!/usr/bin/python
#bin2dec converter
def bin2dec(num):
power = len(num)-1
dec = 0
for x in num:
dec = dec + int(x)*(2**power)
power -= 1
return dec
num = raw_input("Enter a binary number: ")
print bin2dec(num)
| false |
1802b34d83cbfb6b9026a99c6e30da00d950fa5c | strikingraghu/Python_Exercises | /Ex - 04 - Loops.py | 2,676 | 4.125 | 4 | """
In general, statements are executed sequentially.
The first statement in a function is executed first, followed by the second, and so on.
There may be a situation when you need to execute a block of code several number of times.
Programming languages provide various control structures that allow... | true |
d5d43273000fb4a88b57e33c5fa7377264f2a707 | strikingraghu/Python_Exercises | /Ex - 14 - File Handling.py | 1,925 | 4.53125 | 5 | """
In this article, you'll learn about Python file operations.
More specifically, opening a file, reading from it, writing into it, closing it and various file methods.
"""
import os
# Opening File
file_open = open("c:/python_file.txt")
print(file_open) # We can see the path of file, mode of oper... | true |
5fa07f44836ffb22fcd8a237bc1cf8e572c154ac | strikingraghu/Python_Exercises | /Ex - 08 - Tuples.py | 2,146 | 4.28125 | 4 | """
A tuple is a sequence of immutable Python objects. Tuples are sequences, just like lists.
Differences between tuples and lists are, the tuples cannot be changed unlike lists!
Also, tuples use parentheses, whereas lists use square brackets.
"""
sample_tuple_01 = ('Ram', 3492, 'Suresh')
sample... | true |
041fa7d58b4c8916abf660eb1bfa82ff8f1b0b6f | SaketSrivastav/epi-py | /trees/check_bst.py | 1,156 | 4.1875 | 4 | #! /usr/bin/python
class Check_Bst():
def check_balanced(self, node):
"""
Input: A tree node
Output: (+)ve number if BST is balanced, otherwise -1
Description: Start with root node and calculate the height of the left
subtree and right subtree. If an absolute difference of... | true |
454081e675b5dfb9a82293d3a79fa2ff90be90fc | rakibkuddus1109/pythonClass | /polymorphism.py | 763 | 4.375 | 4 | # polymorphism : Many ways to define the method
# Method overloading
# Method overriding
# Method overloading: Considering relevant methods based upon no. of arguments that method has
# even though the method names are same
# Python doesn't support method overloading
# class Operation:
# def mul(self,a,... | true |
99355f7b9957a8dcd2c176e4436969861e571a2b | rakibkuddus1109/pythonClass | /exception_handling.py | 1,837 | 4.34375 | 4 | # Exception Handling: Handling the exception or error
# In-built exception : comes with programming language itself
# User-defined exception : setting up our own defined exception
# In-built exception:
# a = [6,5.6,'Python',0,67]
# for j in a:
# print(1/j) # this would give in-built exception when 'Pyt... | true |
01d9fb6b2beaaf0ec20b04968465667abf6e7a42 | ivan-yosifov88/python_basics | /Nested Conditional Statements/03. Flowers.py | 954 | 4.125 | 4 | numbers_of_chrysanthemums = int(input())
number_of_roses = int(input())
number_of_tulips = int(input())
season = input()
is_day_is_holiday = input()
chrysanthemums_price = 0
roses_price = 0
tulips_price = 0
bouquet_price = 0
if season == "Spring" or season == "Summer":
chrysanthemums_price = 2
roses_price = 4.1... | true |
bc1e774ca217588ba4a73263971168008f430fe0 | ivan-yosifov88/python_basics | /Exams -Training/05. Movie Ratings.py | 706 | 4.15625 | 4 | import sys
number_of_films = int(input())
max_rating = 0
movie_with_max_rating = ""
min_rating = sys.maxsize
movie_with_min_rating = ""
total_sum = 0
for films in range(number_of_films):
movie_title = input()
rating = float(input())
total_sum += rating
if rating > max_rating:
max_rating = rating... | true |
6b71ca64eda2419f32feae09a63cb0967b0d1da9 | ivan-yosifov88/python_basics | /Conditional Statements- Exercise/18. Weather Forecast - Part 2.py | 299 | 4.125 | 4 | temperature = float(input())
if 26 <= temperature <= 35:
print("Hot")
elif 20.1 <= temperature <= 25.9:
print("Warm")
elif 15 <= temperature <= 20:
print("Mild")
elif 12 <= temperature <= 14.9:
print("Cool")
elif 5 <= temperature <= 11.9:
print("Cold")
else:
print("unknown") | false |
c61bb81014dba0334bb13516bd8044cc520bde54 | Williano/Solved-Practice-Questions | /MaleFemalePercentage.py | 1,308 | 4.1875 | 4 | # Script: MaleFemalePercentage.py
# Description: This program ask the user for the number of males and females
# registered in a class. The program displays the percentage of
# males and females in the class.
# Programmer: William Kpabitey Kwabla
# Date: 11.03.17
# Declaring the percentage v... | true |
2582a618219a2e0d3d43d30273d576a824303311 | Williano/Solved-Practice-Questions | /mass_and_weight.py | 1,791 | 4.71875 | 5 | # Scripts : mass_and_weight
# Description : This program asks the user to enter an object’s mass,
# and then calculates its weight using
# weight = mass * acceleration due to gravity.
# If the object weighs more than 1,000 newtons,
# it displays a message indicati... | true |
5086ee66505c76e27be7738c6022065c451771bb | Williano/Solved-Practice-Questions | /MultiplicationTable.py | 2,041 | 4.3125 | 4 | # Script: MultiplicationTable.py
# Description: This program ask for a number and limit and generates
# multiplication table for it.
# Programmer: William Kpabitey Kwabla
# Date: 20.07.16
# Defines the main function.
def main():
# Calls the intro function
intro()
# Declares variable for rep... | true |
596e39993129339fa272c671b82d43c35ccaf17e | Akarshit7/Python-Codes | /Coding Ninjas/Conditionals and Loops/Sum of even & odd.py | 284 | 4.15625 | 4 | # Write a program to input an integer N
# and print the sum of all its even
# digits and sum of all its odd digits separately.
N = input()
total = 0
evens = 0
for c in N:
c = int(c)
total += c
if c % 2 == 0:
evens += c
odds = total - evens
print(evens, odds)
| true |
c2bd3cbe9df4bb5ce621a2acc22bcc30b0d8628d | Akarshit7/Python-Codes | /Coding Ninjas/Conditionals and Loops/Check number.py | 295 | 4.15625 | 4 | """
Given an integer n, find if n is positive, negative or 0.
If n is positive, print "Positive"
If n is negative, print "Negative"
And if n is equal to 0, print "Zero".
"""
n=int(input())
if n>=1:
print("Positive")
elif n == 0:
print("Zero")
elif n<=1:
print("Negative")
| false |
4dfe380f00ab58f5741096abaf9493e869792cef | kelvDp/CC_python-crash_course | /chapter_5/toppings.py | 2,546 | 4.4375 | 4 | requested_topping = 'mushrooms'
# checks inequality: so if the req_topping is NOT equal to anchovies, then it will print the message
if requested_topping != 'anchovies':
print("Hold the anchovies!")
# you can check whether a certain value is in a list, if it is the output will be true, and if not --> false:
more... | true |
630e926f49514037051c98cded41250dc8c12f11 | kelvDp/CC_python-crash_course | /chapter_10/word_count.py | 929 | 4.4375 | 4 | def count_words(file):
"""Counts the approx number of words in a file"""
try:
with open(file,encoding="utf-8") as f:
contents = f.read()
except FileNotFoundError:
print(f"Sorry, but this file {file} does not exist here...")
else:
words = contents.split()
num_... | true |
17c8acde979e31854089ac390484e05079ebdbca | kelvDp/CC_python-crash_course | /chapter_6/TIY_6-11.py | 637 | 4.3125 | 4 | cities = {
"New York":{"country": "America", "population": 5000000, "fact": "Bill de Blasio is the mayor"},
"Amsterdam": {"country": "Netherland", "population": 850000, "fact": "Houses the Van Gogh Museum"},
"Johannesburg": {"country": "South Africa", "population": 957000, "fact": "Was home to Nelson Mandel... | false |
fcefa167431b4e2efd08e9f95b43fb57cf3bd37b | kelvDp/CC_python-crash_course | /chapter_2/hello_world.py | 469 | 4.5 | 4 | #can simply print out a string without adding it to a variable:
#print("Hello Python World!")
#or can assign it to a variable and then print the var:
message= "Hello Python world!"
print(message)
#can print more lines:
message_2="Hello Python crash course world!!"
print(message_2)
#code that generates an error :
... | true |
59cdb01876a7669b21e7d9f71920850a2a88091c | kelvDp/CC_python-crash_course | /chapter_3/cars.py | 919 | 4.75 | 5 | cars = ['bmw', 'audi', 'toyota', 'subaru']
#this will sort the list in alphabetical order but permanently, so you won't be able to sort it back:
cars.sort()
print(cars)
# You can also sort this list in reverse alphabetical order by passing the
# argument reverse=True to the sort() method. The following example sorts... | true |
9a6c01e73c78e5c039f7b4af55924e22b1d4ca85 | kelvDp/CC_python-crash_course | /chapter_4/dimensions.py | 542 | 4.21875 | 4 | dimensions = (200, 50)
#tuples are basically same as lists but they are immutable which means you can't change them without re-assigning the whole thing
print(dimensions[0])
print(dimensions[1])
print("\n")
#!!! cant do this : dimensions[0] = 250 !!!
#you can loop through them just like a list
#this is how to chan... | true |
906a57cb5b9813652c9d66960ab30f157c769421 | kelvDp/CC_python-crash_course | /chapter_10/write_message.py | 1,615 | 4.84375 | 5 | # To write text to a file, you need to call open() with a second argument telling
# Python that you want to write to the file.
filename = "programming.txt"
with open(filename,"w") as file_object:
file_object.write("I love programming!")
# The second
# argument, 'w', tells Python that we want to open the file in ... | true |
8f732d671d158a32dfa7e691f588bef489b74ae8 | beffiom/Learn-Python-The-Hard-Way | /ex6.py | 1,204 | 4.71875 | 5 | # initializing a variable 'types_of_people' as an integer
types_of_people = 10
# initializing a variable 'x' as a formatted string with an embedded variable
x = f"There are {types_of_people} types of people."
# initializing a variable 'binary' as a string
binary = "binary"
# initializing a variable 'do_not' as a strin... | true |
cd1e137d53325fcd2f7084654877b0c10646ae40 | sitaramsawant2712/Assessment | /python-script/problem_1_solution_code.py | 926 | 4.34375 | 4 | """
1. If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9.
The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000.
(Answer: 233168) (solution code attached: problem_1_solution_code.py)
"""
def natural_number_multi_three_and_five(low... | true |
1e19e559c0b05629da03e82dacaf3bf925aa9d7e | kundanjha1076/new-python-cours | /string.py | 232 | 4.1875 | 4 | name="kundan "
age=19
print("hello {} your age is {}".format(name,age))#.format method
#f method
print(f"hello {name} your age is {age}")
print(len(name))
x="kundan kumar jha"
y=x.upper()
print(y)
a="kundan kumar jha"
print(a.replace("kundan","kiran")) | false |
cc7a50c93dded63e648a1e0f3c627cf0e490b207 | OngZhenHui/Sandbox_Prac3 | /ascii_table.py | 1,054 | 4.1875 | 4 | def main():
character = str(input("Enter a character: "))
print("The ASCII code for {} is {}".format(character, ord(character)))
lower_limit = 33
upper_limit = 127
number = get_number(lower_limit, upper_limit)
print("The character for {} is {}".format(number, chr(number)))
for i in range(... | true |
d9d43b943dd3dd38d8c0584f1fac139ad181b38c | aJns/cao19 | /E4/ex04_01.py | 1,970 | 4.21875 | 4 | """
This coding exercise involves checking the convexity of a piecewise linear function.
You task is to fill in the function "convex_check".
In the end, when the file is run with "python3 ex04_01.py" command, it should display the total number of convex functions.
"""
# basic numpy import
import num... | true |
ca00bc72743cb5168f449a4e7032d3cfdcb884c4 | mikeykh/prg105 | /13.1 Name and Address.py | 2,405 | 4.25 | 4 | # Write a GUI program that displays your name and address when a button is clicked (you can use the address of the school). The program’s window should appear as a sketch on the far left side of figure 13-26 when it runs. When the user clicks the Show Info button, the program should display your name and address as sho... | true |
a2f82639d7a3d84317e5d0c3bfe6e5d8b9ea91dc | mikeykh/prg105 | /Automobile Costs.py | 2,135 | 4.59375 | 5 | # Write a program that asks the user to enter the
# monthly costs for the following expenses incurred from operating
# his or her automobile: loan payment, insurance, gas, oil, tires and maintenance.
# The program should then display the total monthly cost of these expenses,
# and the total annual cost of these expense... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.