blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
bf4fb0bb615781cd26ea4c7fde9ee78f21c5dff0 | archana-nagaraj/experiments | /Udacity_Python/Excercises/testingConcepts.py | 890 | 4.21875 | 4 | def vehicle(number_of_tyres, name, color):
print(number_of_tyres)
print(name)
print(color)
vehicle(4, "Mazda", "blue")
# Trying Lists
courses = ['Math', 'Science', 'CompSci']
print(courses)
print(len(courses))
print(courses[1])
print(courses[-1])
#Lists slicing
print(courses[0:2])
print(courses[:2])
pr... | true |
8ce320224914c3dbbc166d7c59c43588bfbea60e | archana-nagaraj/experiments | /Udacity_Python/Excercises/secret_message.py | 617 | 4.125 | 4 | import os
def rename_files():
#(1)get file names from a folder
file_list = os.listdir(r"/Users/archananagaraja/Desktop/AN_Personal/Udacity_Python/alphabet")
print(file_list)
current_dir = os.getcwd()
print("My current directory is: "+current_dir)
os.chdir(r"/Users/archananagaraja/Desktop/AN_Per... | false |
9a2a1d2058cc7a2b6345d837173e109f20b39ed5 | jeb26/Python-Scripts | /highestScore.py | 622 | 4.21875 | 4 | ##Write a prog that prompts for a number of students. then each name and score and
##then displays the name of student with highest score.
scoreAcc = 0
nameAcc = None
currentScore = 0
currentName = None
numRuns = int(input("Please enter the number of students: "))
for i in range(numRuns):
currentName ... | true |
fdb5d39c2ed2c61416aeffb1e4dbc491241ce316 | sonht113/PythonExercise | /HoTrongSon_50150_chapter5/Chapter5/Exercise_page_145/Exercise_04_page_145.py | 338 | 4.1875 | 4 | """
Author: Ho Trong Son
Date: 18/08/2021
Program: Exercise_04_page_145.py
Problem:
4. What is a mutator method? Explain why mutator methods usually return the value None.
Solution:
Display result:
58
"""
#code here:
data = [2, 5, 24, 2, 15, 10]
sum = 0
for value in data:
sum +=... | true |
d713c91065792ffb55927b59ab859b791b85b3b6 | sonht113/PythonExercise | /HoTrongSon_50150_chapter3/Chapter3/Exercise_page_70/exercise_01_page_70.py | 793 | 4.25 | 4 | """
Author: Ho Trong Son
Date: 23/07/2021
Program: exercise_01_page_70.py
PROBLEM:
1. Write the outputs of the following loops:
a. for count in range(5):
print(count + 1, end = " ")
b. for count in range(1, 4):
print(count, end = " ")
c. for count in range... | false |
25a467d72816cf35cf0b5ef9b94503dd40376c2a | sonht113/PythonExercise | /HoTrongSon_50150_chapter2/Chapter2/exercise_page_46/exercise_04_page_46.py | 624 | 4.125 | 4 | """
Author: Ho Trong Son
Date: 11/07/2021
Program: exercise_04_page_46.py
PROBLEM:
4) What happens when the print function prints a string literal with embedded
newline characters?
SOLUTION:
4)
=> The print function denoted print() in a computer programming language such as Python is a function that pr... | true |
7d4ed044ec86306dff4cb4752b0d6d9202fad492 | sonht113/PythonExercise | /HoTrongSon_50150_Chapter4/Chapter4/Project_page_132-133/project_12_page_133.py | 1,421 | 4.15625 | 4 | """
Author: Ho Trong Son
Date: 5/08/2021
Program: Project_12_page_133.py
Problem:
12. The Payroll Department keeps a list of employee information for each pay period in a text file.
The format of each line of the file is the following:
<last name> <hourly wage> <hours ... | true |
805f1755caf35c97cf3c31dfe3436ffc407ccb01 | sonht113/PythonExercise | /HoTrongSon_50150_chapter5/Chapter5/Exercise_page_149/Exercise_04_page_149.py | 522 | 4.125 | 4 | """
Author: Ho Trong Son
Date: 18/08/2021
Program: Exercise_04_page_149.py
Problem:
4. Define a function named summation. This function expects two numbers, named low and high, as arguments.
The function computes and returns the sum of the numbers between low and high, inclusive.
Solution:
Disp... | true |
ca59990c60f302bcb8521710ad34a14d493224f4 | sonht113/PythonExercise | /HoTrongSon_50150_chapter3/Chapter3/Exercise_page_70/exercise_02_page_70.py | 364 | 4.1875 | 4 | """
Author: Ho Trong Son
Date: 23/07/2021
Program: exercise_02_page_70.py
PROBLEM:
2. Write a loop that prints your name 100 times. Each output should begin on a new line.
SOLUTION:
"""
# Code here:
name = "Ho Trong Son"
for i in range(100):
print(name, "(" + str(i+1) + ")")
# Result:
# Ho Trong Son (1... | true |
e8e4d0c2a84f2bf905a9a4c3721e132249cfd403 | sonht113/PythonExercise | /HoTrongSon_50150_Chapter4/Chapter4/Project_page_132-133/project_05_page_132.py | 1,139 | 4.5625 | 5 | """
Author: Ho Trong Son
Date: 5/08/2021
Program: Project_05_page_132.py
Problem:
5. A bit shift is a procedure whereby the bits in a bit string are moved to the left or to the right.
For example, we can shift the bits in the string 1011 two places to the left to produce the string 1110.
Not... | true |
1e23187a25a230abed4a21b60cdda3e90ae27930 | sonht113/PythonExercise | /HoTrongSon_50150_Chapter4/Chapter4/Exercise_page_118/Exercise_01_page_118.py | 805 | 4.25 | 4 | """
Author: Ho Trong Son
Date: 5/08/2021
Program: Exercise_01_page_118.py
Problem:
1. Assume that the variable data refers to the string "Python rules!". Use a string method from Table 4-2
to perform the following tasks:
a. Obtain a list of the words in the string.
b. Convert the ... | true |
a6971bf97f895b2eafc8af4aba0a631b0bc3dfbe | sonht113/PythonExercise | /HoTrongSon_50150_Chapter4/Chapter4/Exercise_page_125/Exercise_03_page_125.py | 682 | 4.3125 | 4 | """
Author: Ho Trong Son
Date: 5/08/2021
Program: Exercise_03_page_125.py
Problem:
3. Assume that a file contains integers separated by newlines. Write a code segment that opens the
file and prints the average value of the integers.
Solution:
Display result:
Average: 5.0
"""
#Cod... | true |
8fe5c46bdf8a1c42a910d3135d1a8f0dde4fee4f | sonht113/PythonExercise | /HoTrongSon_50150_chapter6/Chapter6/Exercise_page_182/Exercise_04_page_182.py | 522 | 4.125 | 4 | """
Author: Ho Trong Son
Date: 01/09/2021
Program: Exercise_04_page_182.py
Problem:
4. Explain what happens when the following recursive function is called with the value 4 as an argument:
def example(n):
if n > 0:
print(n)
example(n - 1... | true |
4ba7d4715f7716794594ae54630d63a3ad3e3745 | sonht113/PythonExercise | /HoTrongSon_50150_chapter3/Chapter3/Project_page_99-101/project_07_page_100.py | 1,986 | 4.1875 | 4 | """
Author: Ho Trong Son
Date: 24/07/2021
Program: project_07_page_100.py
Problem:
7. Teachers in most school districts are paid on a schedule that provides a salary based on their number of years
of teaching experience. For example, a beginning teacher in the Lexington School District might be paid $30,0... | true |
9ddbfa493304a945a607310e245ba8265ebd8a26 | AAM77/Daily_Code_Challenges | /codewars/6_kyu/python3/who_likes_it.py | 2,339 | 4.28125 | 4 | # Name: Who Likes It
# Source: CodeWars
# Difficulty: 6 kyu
#
# URL: https://www.codewars.com/kata/who-likes-it/train/ruby
#
#
# Attempted by:
# 1. Adeel - 03/06/2019
#
#
##################
# #
# Instructions #
# #
##################
#
#
# You probably know the "like" system from Faceboo... | true |
fca476b8dd0f39eacd82ee137010acc742dfb1c3 | keshopan-uoit/CSCI2072U | /Assignment One/steffensen.py | 1,470 | 4.28125 | 4 | # Keshopan Arunthavachelvan
# 100694939
# January 21, 2020
# Assignment One Part Two
def steffensen(f, df, x, epsilon, iterations):
'''
Description: Calculates solution of iterations using Newton's method with using recursion
Parameters
f: function that is being used for iteration (residual)
df: d... | true |
eae0607b690abe39fd59214c1d018ac0ddc24d13 | fhorrobin/CSCA20 | /triangle.py | 290 | 4.125 | 4 | def triangle_area(base, height):
"""(number, number) -> float
This function takes in two numbers for the base and height of a
triangle and returns the area.
REQ: base, height >= 0
>>> triangle_area(10, 2)
10.0
"""
return float(base * height * 0.5)
| true |
42467a9b02e36935f5c34815dc53081841a156fb | tsung0116/modenPython | /program02-input.py | 479 | 4.125 | 4 | user_name = input("Enter your name:")
print("Hello, {name}".format(name=user_name))
principal = input("Enter Loan Amount:")
principal = float(principal)
interest = 12.99
periods = 4
n_years = 2
final_cost = principal * (1+interest/100.0/periods)**n_years
print(final_cost)
print("{cost:0.02f}".format(cost=final_cost)... | true |
b64bed1f594bd9703b82659dc96c2313b05fc621 | mateusrmoreira/Curso-EM-Video | /desafios/desafio24.py | 280 | 4.1875 | 4 | """ 16/03/2020 jan Mesu
Crie uma programa que peça o nome de uma cidade
e diga se a cidade começa ou não com a palavra SANTO
"""
cidade = str(input('Escreva o nome da sua cidade :> ')).strip().upper()
santo = cidade[:6]
print(f'Tem santo no nome da cidade? {"SANTO " in santo}') | false |
e28f61aba7d0d793a4ceac0b89a24ac245c0d06e | DanaAbbadi/data-structures-and-algorithms-python | /tests/stacks_and_queues/test_queues.py | 1,822 | 4.125 | 4 | from data_structures_and_algorithms.stacks_and_queues_challenges.queue import (Queue, Node)
def test_create_empty_Queue():
nums = Queue()
assert nums.front == None
def test_enqueue_one_value():
nums = Queue()
nums.enqueue(1)
assert nums.front.value == 1
def test_enqueue_multiple_values():
n... | false |
0e034002296b0cf3d7c0486907d571802341606d | DanaAbbadi/data-structures-and-algorithms-python | /data_structures_and_algorithms/stacks_and_queues_challenges/stacks.py | 1,922 | 4.28125 | 4 | from data_structures_and_algorithms.stacks_and_queues_challenges.node import Node
# from node import Node
class Stack(Node):
def __init__(self):
self.top = None
def push(self, *args):
"""
Takes a single or multiple values as an argument and adds the new nodes with that value ... | true |
ddb6bb1bc35904275e44ba87e46cf1efe7983c0f | DanaAbbadi/data-structures-and-algorithms-python | /data_structures_and_algorithms/challenges/binary_tree/breadth_first.py | 1,541 | 4.1875 | 4 | class Node:
def __init__(self,value):
self.value = value
self.left = None
self.right = None
class BinaryTree:
"""
This class is responsible of creating and traversing the Binary Search Tree.
"""
def __init__(self):
self.root = None
def breadth_first(self... | true |
30b58144b16e936bea70ff6d1bb79c56db04947c | avikchandra/python | /Python Assignment/centredAverage.py | 574 | 4.28125 | 4 | #!/usr/bin/env python3
'''
"centered" average of an array of integers
'''
# Declare the list
num_list=[-10, -4, -2, -4, -2, 0]
# Find length
list_len=len(num_list)
# Check if length is odd or even
if list_len%2 == 0:
# For even length, find average of two centred numbers
mean_result=(num_list... | true |
8d812c5251edda45c2a531b9bf28ed4b138e233c | avikchandra/python | /Python Assignment/wordOccurence.py | 1,459 | 4.125 | 4 | #!/usr/bin/env python3
'''
highest occurences of words in file "sample.txt"
'''
def main():
# Declare dict
word_dict={}
punct_list=[',','.','\'',':','?','-'] # list of punctuations
# Create file object from file
file_obj=open("sample.txt", 'r')
word_list=[]
# Read line fro... | true |
fbb14a7e554803b8d3e42998a545bd399ab9c795 | avikchandra/python | /Python Advanced/sentenceReverse.py | 303 | 4.4375 | 4 | #!/usr/bin/env python3
'''
Reverse words in sentence
'''
# Take input from user
orig_string=input("Enter the string: ")
str_list=orig_string.split()
# Option1
#str_list.reverse()
#print(' '.join(str_list))
# Option2
reversed_list=list(str_list[::-1])
print(' '.join(reversed_list))
| true |
2f6421bb1c3a27757237ea75657e5e1e62ad9d3d | danlunin/dictionaries | /Dict_list.py | 1,208 | 4.125 | 4 | #!/usr/bin/env python3
class Dictionary:
def __init__(self, dict_list=None):
if dict_list:
self.dict_list = dict_list
else:
self.dict_list = []
def __str__(self):
return str(self.dict_list)
def __repr__(self):
return str(self.dict_list)
def __ge... | false |
ee1aeab37fc4b91f7f8f65b50aba287b8e9c1801 | Joldiazch/holbertonschool-higher_level_programming | /0x06-python-classes/2-square.py | 460 | 4.375 | 4 | #!/usr/bin/python3
class Square:
"""class Square that defines a square by: (based on 0-square.py)
Attributes:
size_of_square (int): Description of `attr1`.
"""
def __init__(self, size_of_square=0):
if type(size_of_square) is not int:
raise TypeError('size must be an integer'... | true |
54c574df0d191bcd3e68f076859588c74827b1ef | beckam25/ComputerScience1 | /selectionsort.py | 2,652 | 4.375 | 4 | """
file: selectionsort.py
language: python3
author: bre5933@rit.edu Brian R Eckam
description:
This program takes a list of numbers from a file and
sorts the list without creating a new list.
Answers to questions:
1) Insertion sort works better than selection sort in a case where you have
a very long list t... | true |
079ac76649cfff4b61345dd077e68178de0ffc52 | joseluismendozal10/test | /DATA ANALYTICS BOOTCAMP/June 19/Python/2/quick check up .py | 266 | 4.125 | 4 | print("Hello user")
name = input("what is your name?")
print ("Hello" + name)
age = int(input("whats your age?"))
if age >= 21:
print("Ah, a well traveled soul you are ye")
else:
print("aww.. you're just a baby!")
| true |
ebca2a200c8e7b27ae234835003b6d15e0d6a3cd | JaiberS/holbertonschool-higher_level_programming | /0x07-python-test_driven_development/0-add_integer.py | 372 | 4.21875 | 4 | #!/usr/bin/python3
"""
>>> add_integer(2, 3)
5
"""
def add_integer(a, b=98):
"""
>>> c = add_integer(2, 3)
"""
if type(a) is not int:
if type(a) is not float:
raise TypeError('a must be an integer')
if type(b) is not int:
if type(b) is not float:
raise Type... | false |
25f5ba74734da7afb773999499cca4c79685c717 | r0hansharma/pYth0n | /prime number.py | 319 | 4.125 | 4 | no=int(input('enter the no to check\n'))
if(no>1):
for i in range(2 , no):
if(no%i==0): print(no,'is not a prime number')
else:
print( no,"is a prime number")
elif(no==1):
print("1 is neither a prime nor a compposite number")
else:
print("enter a number greater than 1") | true |
27908d6450779964609a859a83c29decd4e67d3e | bnsh/coursera-IoT | /class5/week4/leddimmer.py | 605 | 4.25 | 4 | #! /usr/bin/env python3
"""This is week 4 of the Coursera Interfacing with the Raspberry Pi class.
It simply dims/brightens the LED that I've attached at pin 12 back and forth."""
import math
import time
import RPi.GPIO as GPIO
def main():
GPIO.setmode(GPIO.BOARD)
GPIO.setup(12, GPIO.OUT)
pwm = GPIO.PWM(12, 50... | true |
e2fda25298068dda88406226945b707a7514a200 | JesNatTer/python_fibonacci | /fibonacci.py | 464 | 4.1875 | 4 | numbers = 20 # amount of numbers to be displayed
def fibonacci(n): # function for fibonacci sequence
if n <= 1:
return n
else:
return fibonacci(n-1) + fibonacci(n-2) # function formula for fibonacci
if numbers <= 0:
print("Please enter positive value") # amount of numbers cannot be l... | true |
15cfa3ed4506417d5eb879b43e1ac0a6f3d9b5bc | Moiseser/pythontutorial | /ex15.py | 719 | 4.375 | 4 | #This allows your script to ask you on the terminal for an input
from sys import argv
#this command asks you what the name of your text file you want to read is
script,filename = argv
#this opens the file and then assigns the opened file to a variable
txt = open(filename)
#here we print the name of the file
print 'Her... | true |
98442c545f269213e63e8a6f966c01db056c21f5 | Moiseser/pythontutorial | /ex3.py | 562 | 4.375 | 4 | print "I will now count my chickens:"
print 'Hens' , 25+30/6
print 'Roosters', 100-25 * 3 % 4
print 'What is 4 % 3' , 4 % 3
print 'Now I will count my eggs:'
print 3 + 2 +1 -5 +4 % 2 -1 /4 + 6
print '1 divide by 4' , 1/4
print '1.0 dive by 4.0' , 1.0/4.0
print 'It is true that 3+2 < 5 - 7 ?'
print 3 + 2 < 5 - 7
... | true |
1f13b414cb94ff7e57a9a2a41ac470e41dfd52ba | dongjulongpy/hackerrank_python | /Strings/find_a_string.py | 385 | 4.1875 | 4 | def count_substring(string, sub_string):
string_list = list()
length = len(sub_string)
for i in range(len(string)-length+1):
string_list.append(string[i:i+length])
return string_list.count(sub_string)
if __name__ == '__main__':
string = input().strip()
sub_string = input().strip()
... | true |
76265670bce143a07b85821de09bab6355a40e92 | LisaLen/code-challenge | /interview_cake_chals/find_rotation_point.py | 1,661 | 4.125 | 4 | '''I opened up a dictionary to a page in the middle and started flipping through,
looking for words I didn't know. I put each word I didn't know at increasing
indices in a huge list I created in memory. When I reached the end of the
dictionary, I started from the beginning and did the same thing until I reached
the ... | true |
0b98b66200151b0dc6bd322824f2d53b37e2329c | LisaLen/code-challenge | /primes/primes.py | 927 | 4.28125 | 4 | """Return count number of prime numbers, starting at 2.
For example::
>>> is_prime(3)
True
>>> is_prime(24)
False
>>> primes(0)
[]
>>> primes(1)
[2]
>>> primes(5)
[2, 3, 5, 7, 11]
"""
def is_prime(number):
assert number >= 0
if number < 2:
return False
... | true |
1c627ef942bc3401647b955fda0cd4a9139e6e57 | iliakur/python-experiments | /test_strformat.py | 1,311 | 4.125 | 4 | """12/08/2016 my colleague Leela reported getting a weird error.
She was trying to perform an equivalent of the following string interpolation:
`" a {0}, b {1}".format(some_dict["key"], ["key2"])`
She had forgotten to type `some_dict` for the second argument of `format`.
However the error she got was unrelated to tha... | true |
e50d72ab79c96789a88454a52ceb0c54985130e9 | Lusarom/progAvanzada | /ejercicio38.py | 825 | 4.5 | 4 | #Exercise 38: Month Name to Number of Days
#The length of a month varies from 28 to 31 days. In this exercise you will create
#a program that reads the name of a month from the user as a string. Then your
#program should display the number of days in that month. Display “28 or 29 days”
#for February so that leap years... | true |
beeea37473e0c78c74d28ca618548df2fab1cf0b | Lusarom/progAvanzada | /ejercicio40.py | 766 | 4.5 | 4 | #Exercise 40: Name that Triangle
#A triangle can be classified based on the lengths of its sides as equilateral, isosceles
#or scalene. All 3 sides of an equilateral triangle have the same length. An isosceles
#triangle has two sides that are the same length, and a third side that is a different
#length. If all of the... | true |
b2c18894797ee2043d24a28316aa7e6884bcfeb3 | Lusarom/progAvanzada | /ejercicio41.py | 796 | 4.3125 | 4 | #Exercise 41: Note To Frequency
#The following table lists an octave of music notes, beginning with middle C, along
#with their frequencies (Hz)
#Note Frequency
# C4 261.63
# D4 293.66
# E4 329.63
# F4 349.23
# G4 392.00
# A4 440.00
# B4 493.88
nombre = input('Inserta el nombre de la n... | false |
79b32bf67300146e872698d4b3ad2779c0914829 | mmeitesDIM/USMB-BachelorDIM-Algo--PUBLIC | /assignments/Session1/S1remove_whiteSpace.py | 1,261 | 4.3125 | 4 | # -*- coding: utf-8 -*-
"""
brief : remove whitespace caracter in a string
Args :
# @input_string : the string to remove whitespace
# @return the string without whitespace
raise :
"""
def remove_whitespace(input_string):
if len(input_string)==0:
print('aucune chaîne de caractère en entrée')
... | false |
32799865345f5c901d665edadf4cc0904cbaff3d | DJBlom/Python | /CS1101/Unit_7/Discussion.py | 1,141 | 4.65625 | 5 | """ This is a program to demonstrate how tuples can be usefull loops over lists and dictionaries. """
def listZip():
st = 'Code'
li = [0, 1, 2, 3]
print('Zip function demo.')
t = zip(li, st)
for i, j in t:
print(i, j... | true |
4a2455564ea6478e6ea519a97befc90cc8a3aed2 | nimkha/IN4110 | /assignment3/wc.py | 1,391 | 4.46875 | 4 | #!/usr/bin/env python
import sys
def count_words(file_name):
"""
Takes file name and calculates number of words in file
:param file_name:
:return: number of words in file
"""
file = open(file_name)
number_of_words = 0
for word in file.read().split():
number_of_words += 1
... | true |
3626f86acddcde796092a53d014f8f50137ace0a | prasannatuladhar/30DaysOfPython | /day17.py | 1,685 | 4.375 | 4 | """
1) Create a function that accepts any number of numbers as positional arguments and prints the sum of those numbers. Remember that we can use the sum function to add the values in an iterable.
2) Create a function that accepts any number of positional and keyword arguments, and that prints them back to the user. Y... | true |
35d7c42f4c010a1e13be3938b4f5a9853ac1be3b | prasannatuladhar/30DaysOfPython | /day16.py | 1,224 | 4.5625 | 5 | """
1) Use the sort method to put the following list in alphabetical order with regards to the students' names:
students = [
{"name": "Hannah", "grade_average": 83},
{"name": "Charlie", "grade_average": 91},
{"name": "Peter", "grade_average": 85},
{"name": "Rachel", "grade_average": 79},
{"name": "Lauren", "grade... | true |
a6b674c546b274b86005d37f47214a4395906407 | alexeysorok/Udemy_Python_2019_YouRa | /Basics/03_string.py | 927 | 4.28125 | 4 | greeting = "Hello!"
first_name = "Jack"
last_name = "White"
print(greeting + ' ' + first_name + ' ' + last_name)
print(len(greeting)) # длина
print(greeting[-1])
print(greeting[2:5])
print(greeting[::-1]) # перевернуть строку
print(greeting.upper())
print(greeting.lower())
print(greeting.split()) # разделяет по проб... | true |
2baf17cc2c72406fcc1f3b089a986727cfd25230 | ztnewman/python_morsels | /circle.py | 619 | 4.21875 | 4 | #!/usr/bin/env python3
import math
class Circle:
def __init__(self,radius=1):
if radius < 1:
raise ValueError('A very specific bad thing happened')
self.radius = radius
def __str__(self):
return "Circle("+str(self.radius)+")"
def __repr__(self):
return "... | true |
52b40ae26017b13d5f259c7790c95987186e71bd | erinszabo/260week_5 | /main.py | 2,301 | 4.34375 | 4 | """
Chapter 6 in Runestone Exercises:
2, 3 - Do the recursive search without slicing. 5, 6, 7, 15, 16
"""
if __name__ == '__main__':
print("")
print("")
print("2) Use the binary search functions given in the text (recursive and iterative). Generate a random, "
"ordered list of integers and do a ... | true |
1aba5ddb6b34e4f6ee1a0d11f74a20de7cf975c8 | tannazjahanshahi/tamrinpy | /tamrin3.py | 1,151 | 4.3125 | 4 | # # for i in range(6):
# # for j in range(i):
# # print ('* ', end="")
# # print('')
# # for i in range(6,0,-1):
# # for j in range(i):
# # print('* ', end="")
# # print('')
# numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9] # Declaring the tuple
# cnt_odd=0
# odd_list=[]
# cnt_even=0
# even_list=... | true |
2eeee06b978d55b99a68eeffa12eb62a127ee0c3 | LinhPhanNgoc/LinhPhanNgoc | /page_63_project_09.py | 614 | 4.21875 | 4 | """
Author: Phan Ngoc Linh
Date: 02/09/2021
Problem:
Write a program that takes as input a number of kilometers and prints the corresponding number of nautical miles.
Use the following approximations:
• A kilometer represents 1/10,000 of the distance between the North Pole and the equator.
• There ar... | true |
b4f79d10f725f9ab9120f67282f4d34726f60430 | hafizur-r/Python | /week_2/Problem2_5.py | 1,324 | 4.40625 | 4 | """
Problem 2_5:
Let's do a small simulation. Suppose that you rolled a die repeatedly. Each
time that you roll the die you get a integer from 1 to 6, the number of pips
on the die. Use random.randint(a,b) to simulate rolling a die 10 times and
printout the 10 outcomes. The function random.randint(a,b) will
gen... | true |
34e659a741a9be2903e86f40143d58e38623fa5b | hafizur-r/Python | /week_3/Problem3_4.py | 1,400 | 4.34375 | 4 | #%%
"""
Problem 3_4:
Write a function that is complementary to the one in the previous problem that
will convert a date such as June 17, 2016 into the format 6/17/2016. I
suggest that you use a dictionary to convert from the name of the month to the
number of the month. For example months = {"January":1, "Febru... | true |
1d8cb954d0348ffababd476a6c0cf61ea093411e | acse-os920/acse-1-assessment-3-acse-os920-master | /acse_la/det.py | 742 | 4.21875 | 4 | import numpy as np
def det(a):
"""
Calculates the determinant of a square matrix
of arbitrary size.
Parameters
----------
a : np.array or list of lists
'n x n' array
Examples
--------
>> a = [[2, 0, -1], [0, 5, 6], [0, -1, 1]]
>> det(a)
22.0
>> A = [[1, 0... | false |
885164b1fd52886a7d065fd8cdadf1b7b15d9d57 | yanjun91/Python100DaysCodeBootcamp | /Day 9/blind-auction-start/main.py | 978 | 4.15625 | 4 | from replit import clear
from art import logo
#HINT: You can call clear() to clear the output in the console.
print(logo)
print("Welcome to the secret auction program.")
continue_bid = True
bidders = []
while continue_bid:
name = input("What is your name?: ")
bid = int(input("What's your bid?: $"))
# Store... | true |
87465432a6a8898d2c138ea3fd51b5156fdd146f | BeLEEU/AI-For-CV | /每日一题/basic/Begining/003.py | 601 | 4.125 | 4 | 415. ЧĴ
һַжǷΪһĴֻĸ֣ԴСд
1:
: "A man, a plan, a canal: Panama"
: true
: "amanaplanacanalpanama"
2:
: "race a car"
: false
: "raceacar"
import re
class Solution(object):
def isPalindrome(self, s):
"""
:type s: str
:rtype: bool
"""
s=s.lower()
s=re.sub(r'[^a-z0-9]', "... | false |
ae0e1ab06706b644f72d16c2f6dafe0be4ef814a | xufeng010203/ML | /alogorithm/02_归并排序.py | 1,103 | 4.1875 | 4 | '''
归并排序
:分治
84571362
8457 1362
84 57 13 62
8 4 5 7 1 3 6 2
48 57 13 62
4578 1236
12345678
'''
def merge(left, right):
"""
合并两个有序数组
:param left: arr
:param right: arr
:return:
"""
l, r = 0, 0
result = []
while l < len(left) and r < len(righ... | false |
14620c9f5db9edf4caa28a5df352bcf303f45a6c | vadimsh73/python_tasks | /character string/9_10.py | 1,123 | 4.28125 | 4 | # -*-coding:UTF-8-*-
name_1 = input("Первый город")
name_2 = input("Второй город")
name_3 = input("Третий город")
print("Максимальная длина {}".format(max(len(name_1), len(name_2), len(name_3))))
print("Минимальная длина {}".format(min(len(name_1), len(name_2), len(name_3))))
if max(len(name_1), len(name_2), len(nam... | false |
a196a7540550ffb301675dbc5138757faabf422a | MaGo1981/MITx6.00.1x | /MidtermExam/Sandbox-ExtraProblems-NotGraded/Problem9.py | 928 | 4.59375 | 5 | '''
Problem 9
1 point possible (ungraded)
Write a function to flatten a list. The list contains other lists, strings, or ints.
For example, [[1,'a',['cat'],2],[[[3]],'dog'],4,5] is flattened into [1,'a','cat',2,3,'dog',4,5]
def flatten(aList):
'''
'''
aList: a list
Returns a copy of aList, which is a flatten... | true |
f665521d39d777428e35e4c66706e0ccf5eed10d | camitt/PracticePython_org | /PP_Exercise_1.py | 1,175 | 4.28125 | 4 | from datetime import date
# Exercise 1
# Create a program that asks the user to enter their name and their age. Print out a message addressed to them that tells them the year that they will turn 100 years old.
# Extras:
#
# 1. Add on to the previous program by asking the user for another number and printing out that m... | true |
f60727bc1404c6a3631e4a9b158d847abe44afef | AnkyXCoder/PythonWorkspace | /practice.py | 939 | 4.53125 | 5 | # Strings
first_name = "Ankit"
last_name = "Modi"
print(first_name)
print(last_name)
full_name = first_name + last_name
print(full_name)
# printing name with spaces
full_name = first_name + ' ' + last_name
print(full_name)
# OR you can print it like this also
# with no difference
print(first_name + ' ' + last_nam... | true |
43491586c77d23d9aba8416dd658cc7bf795f917 | AnkyXCoder/PythonWorkspace | /Object Oriented Programming/Abstraction.py | 1,463 | 4.5625 | 5 | # Create a class and constructors
# Abstraction
# create an object
class PersonalCharacter:
# global attribute
_membership = True
# constructor
def __init__(self, name = 'anonymous', age = 0, strength = 100): # dunder method
"""This is a constructor using __init__ which is called a duncder meth... | true |
180c54cc32d9d18b773f9a91e734b19f254c5014 | AnkyXCoder/PythonWorkspace | /python basics/dictionary.py | 2,859 | 4.3125 | 4 | # Dictionary
# data structure that stores data in terms of keys and values as pairs
# list is a sorted data structure, list of people in queue
# dictionary has no order, list of a persons belongings in wardrobe
user2 = dict(name = "Johny")
print(user2)
# another way of creating dictionary
dictionary = {
# immu... | true |
81982a4ea086b205b116518aa20113f130b6d0d8 | AnkyXCoder/PythonWorkspace | /Object Oriented Programming/Modifying_Dunder_Methods.py | 1,175 | 4.75 | 5 | # Whenever an Object is created and instantiated, it gest access to all the basic Dunder Methods available to it as per Python
# Programming Language.
# By defining the Dunder Method in the Class Encapsulation, the access to Dunder Methods are modified.
class SuperList(list): # Defining SuperList as the Subclass of t... | true |
45c8680dc29404c7cd53bf30445d9c821705c9d4 | zhjohn925/niu_algorithm | /S03_Interpolation_search.py | 1,573 | 4.5625 | 5 | # Interpolation search can be particularly useful in scenarios where the data being searched is uniformly
# distributed and has a large range.
# For example:
# Large Data Sets: If you have a large data set and the elements are uniformly distributed, interpolation search
# can provide faster search times compared to b... | true |
20c2f4cf45a6a501895565d2f40273263d77430c | zhjohn925/niu_algorithm | /L20_Bucket_Sort.py | 2,347 | 4.1875 | 4 | # Bucket Sort is a linear-time sorting algorithm on average when the input elements are uniformly
# distributed across the range.
# It is commonly used when the input is uniformly distributed over a range or when the range of values
# is relatively small compared to the input size.
def bucket_sort(arr):
# Crea... | true |
f8ca4890c4833c2d752a3dcf14dc404089e7c85a | Aka-Ikenga/Daily-Coding-Problems | /swap_even_odd.py | 527 | 4.21875 | 4 | """Good morning! Here's your coding interview problem for today.
This problem was asked by Cisco.
Given an unsigned 8-bit integer, swap its even and odd bits. The 1st and 2nd bit should be swapped, the 3rd and 4th bit should be swapped, and so on.
For example, 10101010 should be 01010101. 11100010 should be 11010001... | true |
a26239a775b14953e7dfe6c922bbf7a95b7e6a69 | juliangyurov/js-code | /matrix.py | 1,170 | 4.71875 | 5 | # Python3 program to find the sum
# of each row and column of a matrix
# import numpy library as np alias
import numpy as np
# Get the size m and n
m , n = 3, 3
# Function to calculate sum of each row
def row_sum(arr) :
sum = 0
print("\nFinding Sum of each row:\n")
# finding the row sum
for i in ra... | true |
64fefed9d00b683cbbcc88668ed7d17baef8dd57 | elizabethgulsby/python101 | /the_basics.py | 2,376 | 4.25 | 4 | # print "Liz Gulsby"
# name = "Liz Gulsby"
# name = "Liz " + "Gulsby"
# fortyTwo = 40 + 2;
# print fortyTwo
# fortyTwo = 84 / 2;
# print fortyTwo;
# array...psyche! Lists (in Python)
animals = ['wolf', 'giraffe', 'hippo'];
print animals
print animals[0]
print animals[-1] # gets the last element - hippo, here
animals... | true |
f4d5d91147e0a5749f7570a2fd85133fd4fcddaf | down-dive/python-practice | /maxNum.py | 596 | 4.3125 | 4 | # Max Num
# In this activity you will be writing code to create a function that returns the largest number present in a given array.
# Instructions
# - Return the largest number present in the given `arr` array.
# - e.g. given the following array:
arr = [1, 17, 23, 5, 6];
# - The following number should ... | true |
47e869c625a2c8769d7e7765ef5f992404fd6eeb | javedmomin99/Find-the-greatest-Number-out-of-3-numbers | /main.py | 384 | 4.1875 | 4 | def name(num1,num2,num3):
if num1 > num2 and num1 > num3:
return num1
elif num2 > num1 and num2 > num3:
return num2
else:
return num3
num1 = int(input("pls enter number 1\n"))
num2 = int(input("pls enter number 2\n"))
num3 = int(input("pls enter number 3\n"))
print(name(num1,num2,num... | false |
cbc3fe3f32e2879d6594aef7746f7007dceb2743 | Cwagne17/WordCloud-Generator | /WordCloud.py | 2,114 | 4.1875 | 4 | # Word Cloud
#
# This script recieves a text input of any length, strips it of the punctuation,
# and transforms the words into a random word cloud based on the frequency of the word
# count in the text.
#
# To try it - on ln20 change the .txt file to the path which youd... | true |
0c05275b5642bdfaa6db3f433c2983c9f9f74c70 | klivingston22/tutorials | /stingzz.py | 465 | 4.15625 | 4 | str = 'this is string example....wow!!!'
print str.capitalize() #simply capitalises the first letter
sub = 'i'
print str.count (sub, 4, 40) # this should output 2 as 'i' appears twice
sub = 'wow'
print str.count(sub) # this should output 1 as 'wow' only appears once
print len(str) # this should output 33 as th... | true |
4693819abd24999a8d71594784cda3099b640b7e | yuriivs/geek_python_less02_dz | /lesson02_dz05.py | 734 | 4.3125 | 4 | # Реализовать структуру «Рейтинг», представляющую собой не возрастающий набор натуральных чисел.
# У пользователя необходимо запрашивать новый элемент рейтинга.
# Если в рейтинге существуют элементы с одинаковыми значениями, то новый элемент с тем же значением должен разместиться после них.
my_list = [7, 5, 3, 3, 2]
... | false |
cd728160534e09d7cb8adee8b4bebaaf81d083a3 | shivanikarnwal/Python-Programming-Essentials-Rice-University | /week2-functions/local-variables.py | 853 | 4.1875 | 4 | """
Demonstration of parameters and variables within functions.
"""
def fahrenheit_to_celsius(fahrenheit):
"""
Return celsius temperature that corresponds to fahrenheit
temperature input.
"""
offset = 32
multiplier = 5 / 9
celsius = (fahrenheit - offset) * multiplier
print("... | true |
824d7672f35bf799e5ce0914c29bfed54805866d | siddeshshewde/Competitive_Programming_v2 | /Daily Coding Problem/Solutions/problem002.py | 1,075 | 4.1875 | 4 | """
This problem was asked by Uber.
Given an array of integers, return a new array such that each element at index i of the new array is the product of all the numbers in the original array except the one at i.
For example, if our input was [1, 2, 3, 4, 5], the expected output would be [120, 60, 40, 30, 24]. If ... | true |
725fd29a6a090a89a375b345965e88b4bbb173d8 | DanishKhan14/DumbCoder | /Python/Arrays/bestTimeToBuySellStock.py | 581 | 4.3125 | 4 | """
Max profit that we can get in a day is determined by the minimum prices in previous days.
For example, if we have prices array [3,2,5,8,1] we can calculate the min prices array [3,2,2,2,1]
and get the difference in our max profit array [0,0,3,6,0]. We can see clearly the max profit is 6,
which is buy from the index... | true |
280a5cbb31989e73535ff4b77dc9f727ca36dd8a | ktb702/AutomateTheBoringStuff | /sum.py | 854 | 4.15625 | 4 | # PROBLEM STATEMENT
# If we list all the natural numbers between 1 and 10 (not including 1 or 10) that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
# Write code using a language of your choice that will find the sum of all the multiples of 3 or 5 between 1 and 1000 (not including... | true |
ca608a5b39e151d3fccadfd2dae2b543f847624d | shawnstaggs/Basic-Sorting-Implementation | /Basic Sorting Implementation/Basic_Sorting_Implementation.py | 1,306 | 4.25 | 4 | def bubble_sort(list_object):
working_list = list_object[:]
for pass_count in range(len(working_list)-1, 0, -1):
for step in range(pass_count):
if working_list[step] > working_list[step+1]:
working_list[step+1],working_list[step]=working_list[step],working_list[step+1]
re... | false |
37f59db3e5bb8925c6913bf7f309c6e375da0069 | gerardoxia/CRACKING-THE-CODING | /1.8.py | 636 | 4.1875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
def isSubstring(str1,str2):
length1=len(str1)
length2=len(str2)
check=True
if length1>length2: return False
for index2 in range(length2-length1+1):
index=index2-1
for index1 in range(length1):
index=index+1
if s... | true |
31339c4dfd1287b66e689816a8f2ba69b4ceb88f | katherine-davis/katherine-davis.github.io | /day 12.py | 1,525 | 4.15625 | 4 | ###########################################################################
#********************************--day 12--********************************
##Write a function called initials
##it to take in three perameters
## first name
## last name
## and middle name
## and then return their initials... | true |
3f70f8f5a551e0daebf6ef8f8b083fd552bff472 | qzlgithub/MathAdventuresWithPython | /ex1.2CircleOfSquares.py | 303 | 4.15625 | 4 | # Write and run a function that draws 60 squares, turning right 5 degrees after each square. Use a loop!
from turtle import *
shape('turtle')
speed(0)
def createSquares():
for j in range(4):
forward(100)
right(90)
for j in range(60):
createSquares()
right(5)
| true |
6333f91ccd0c372887a2367b29e3fbbb0a2b0d9c | AlexOfTheWired/cs114 | /FinalProject/Final_Project.py | 2,346 | 4.125 | 4 | """
Final Project Proposal()
Create a cash register program.
- On initialize the user sets amount of Bills and Coins in register
(starting bank amount)
- Set Sales Tax
- sales_tax = 2.3%
- Then print Register status:
- Amount of Coins and Bills
- Total cash amount
Render Transaction:
(S... | true |
d60c724b32214d29b29a8cc0bf2b1fd47b82f3be | Environmental-Informatics/python-learning-the-basics-Gautam6-asmita | /Second attempt_Exercise3.3.py | 1,009 | 4.5 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Created on 2020-01-16 by Asmita Gautam
Assignment 01: Python - Learning the Basics
Think Python Chapter 3: Exercise 3.3
Modified to add header and comments for resubmission on 2020-03-04
"""
"""
While considering th each rows of the grid we can see 2 patters of the row... | true |
6d4bdfc40c0577433770d818112673b30c153306 | PreciadoAlex/PreciadoAlex.github.io | /Projects/Series_In_Python/Step_2.py | 531 | 4.25 | 4 | # cosine function using the taylor series
import math
x = int(input("select a number: "))
def cosine(x):
y = 1 - ((x**2/2) + (x**4/24) - (x**6/720) + (x**8/40320))/math.factorial(2)
return y
pi = 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480... | false |
df1ee3a21892feab3d619c813550c104e702370a | fantastic-4/Sudoku | /src/Parser/validator.py | 2,874 | 4.15625 | 4 | class Validator:
def __init__(self):
self.digits = "123456789"
self.rows = "ABCDEFGHI"
def validate_values(self,grid):
'''Function to validate the values on grid given.
Return True if their values are numeric or False if their not.'''
full_line=""
... | true |
bb12fd942559c665cd13f3c12d458ed43b646d01 | andersonvelasco/Programming-2020B | /Calculadora.py | 771 | 4.21875 | 4 | #Script:Calculadora
'''
Programa que, dadas dos variables N1 = 5 y N2 = 6, permita realizar
las operaciones aritméticas básicas (suma, resta, multiplicación, división) y visualice
por pantalla el resultado de estas 4 operaciones.
'''
#INPUTS
print("Calculadora que permitira obtener los resultados")
print("de las operac... | false |
bb521b8932abe5d21f01a144b5c384caa32daf2e | FelixFelicis555/Data-Structure-And-Algorithms | /GeeksForGeeks/Sorting/Bubble_Sort/bubble_sort.py | 436 | 4.125 | 4 | def bubbleSort(list,n):
for i in range(0,n-1):
for j in range(0,n-i-1):
if list[j]>list[j+1]:
#swap
temp=list[j]
list[j]=list[j+1]
list[j+1]=temp
print("Sorted Array : ",end=' ')
print(list)
def main():
list=[]
print("Enter the numbers in the list(Enter x to stop): ")
while True:
num=inpu... | true |
7c9aae80093542f3b41713cdffcf3fb093407be8 | jancal/jan2048python | /plot_ols.py | 2,296 | 4.34375 | 4 | #!/usr/bin/python
# -*- coding: utf-8 -*-
"""
=========================================================
Linear Regression Example
=========================================================
This example uses the only the first feature of the `diabetes` dataset, in
order to illustrate a two-dimensional plot of this regre... | true |
2a6b635baa99f5e27d0c7d89506bca8519ff6ba2 | SoadB/100DaysOfCode-Python | /Day_2.py | 431 | 4.1875 | 4 |
# Comment in one line
print("Hello, World!")
# Code as a comment to prevent executing
# print("Good night")
# Comments in multi line
# This is the comment
# Written in
# More than just one line
print("اليوم الثاني وتعلم كتابة التعليقات بلغة بايثون")
# Multi line String
"""
If you want to
write multi line
string , y... | false |
2535cb0e40bc6cfdec4510b6d264a9a7f8a711c8 | rachaelthormann/Project-Euler-Python | /Problem3.py | 701 | 4.21875 | 4 | """
File name: Problem3.py
Description: This program will find the largest prime factor
of the number 600851475143.
Author: Rachael Thormann
Date Created: 3/21/2016
Date Last Modified: 3/21/2016
Python Version: 3.4
"""
def largest_prime_factor(num):
"""Finds the largest prime factor."""
i = 2
#... | true |
3b5e0d1bf01b242fac32661aba45c6d6a0983f6c | kalnaasan/university | /Programmieren 1/PRG1/Übungen/Übung_06/Alnaasan_Kaddour_0016285_3.py | 1,390 | 4.125 | 4 | """ This script is the solution of Exercise Sheet No.4 - Task 3 and 4 """
__author__ = "0016285: Kaddour Alnaasan"
__credits__ = """If you would like to thank somebody
i.e. an other student for her code or leave it out"""
__email__ = "qaduralnaasan@gmail.com"
def length_list(text):
length = len(tex... | true |
a58af9f6b048d0aa853c45a59689da0bc8abea76 | olugboyegaonimole/python | /a_simple_game.py | 2,907 | 4.4375 | 4 |
#A SIMPLE GAME
class Football():
class_name=''
description='' #THIS IS THE INITIAL VALUE OF THE PROPERTY
objects={}
#1. WHEN A SETTER IS USED, YOU MUST ASSIGN AN INITIAL VALUE TO THE PROPERTY
#2. HERE FOR EXAMPLE, THE ASSIGNMENT TAKES PLACE WHEN THE PROPERTY IS DEFINED AS A CLASS ATTRIBUTE
... | true |
02f2947e9e98e73e640aa8a46cf21878ee94bcc8 | pawnwithn0name/Python3EssentialTraining | /GUI/5.event-hangling.py | 728 | 4.1875 | 4 | '''
After the root window loads on the system, it waits for the occurence of some event. These events can be button clicks, motion of the mouse, button release, etc. These events are handled by defining functions that are executed in case an event occurs.
'''
from tkinter import *
def handler1():
print('White')
de... | true |
95d4f71e7e6a505afc4f3156a3cb57d64077db6d | pawnwithn0name/Python3EssentialTraining | /02 Quick Start/forloop.py | 338 | 4.4375 | 4 | #!/usr/bin/python3
# read the lines from the file
fh = open('lines.txt')
for line in fh.readlines():
# Print statement 'end' argument in Python 3 allows overriding the end-of-line character which
# defaults to '\n'. Each line in the file already has a carriage return so the end-of-line is not needed.
print... | true |
d5cf8c7b947bc831607a66f10325b62c445eaa15 | javifu00/Battleship | /Usuario.py | 1,156 | 4.1875 | 4 | class Usuario:
"""
Clase donde se deteminan los valores de cada usuario que juegue (username, nombre, edad, genero, puntaje, disparos efectuados)
"""
def __init__(self, username, nombre, edad, genero, puntaje=1, disparos_efectuados=100):
self.username = username
self.nombre = nombre
... | false |
918d17e7abb26b3e6e1290cbe09c4592090cf43d | dvishwajith/shortnoteCPP | /languages/python/containers/dictionary.py | 2,402 | 4.375 | 4 | #!/usr/bin/env python3
dict = {'Name': 'Zara', 'Age': 7, 'Class': 'First', 7:'testintkey', 1.5:'testfloatkey', (1,1.5):'testTuplekey'}
print(dict)
# if you define values with same keys they will be replaces . for example key 7 here
dict_2 = {'Name': 'Amir', 'Age': 8, 'Class': 'First', 7:'testintkey', 1.5:'testfloatke... | false |
e28e734decc6a09e159ce7105997df8d2bb1f437 | dvishwajith/shortnoteCPP | /languages/python/algorithms/graphs/bfs/bfs.py | 998 | 4.25 | 4 | #!/usr/bin/env python3
graph = {
'A' : ['B','C'],
'B' : ['D', 'E'],
'C' : ['F'],
'D' : [],
'E' : ['F'],
'F' : []
}
from collections import deque
print("bfs first method. Using deque as a FIFO because list pop(0) is O(N)")
def BFS(graph, start):
node_fifo = deque([]) #using deque becaus... | true |
7cd2eef61cd8036e0e78001a306b0737f7d9e191 | EfimT/pands-problems-2020 | /homework 2.py | 266 | 4.21875 | 4 | # Write a program that asks a user to input
# a string and outputs every second letter in reverse order.
sentence = (input("Enter a string : "))
sentence = sentence [::-1]
print ("Heres is you're string reversed and every second letter is:", sentence[::2]) | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.