blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
65418f750afea14168ea6f8095b9bf1234b722a8 | KiranGowda10/Add-2-Linked-Lists---LeetCode | /add_2_num.py | 832 | 4.125 | 4 |
class Node:
def __init__(self, data = None):
self.data = data
self.next = None
class LinkedList:
def __init__(self):
self.head = Node()
def append(self, data):
new_node = Node(data)
current_node = self.head
while current_node.next is not None... | true |
25a39a23d66108f8909741e94c7e9e290479c044 | fatmazehraCiftci/GlobalAIHubPythonCourse | /Homeworks/homework2.py | 482 | 4.1875 | 4 | """
Create a list and swap the second half of the list with the first half of the list and
print this list on the screen
"""
def DivideandSwap(list):
length=len(list)
list1=[]
list2=[]
for i in range(int(length/2)):
list1.append(list[i])
remainder=length-int(length/2)
... | true |
3766e43d653c9e92a2fdb946a34de44c0e43905c | shivamagrawal3900/Python-crash-course | /chapter5-if_statements.py | 1,249 | 4.1875 | 4 | cars = ['Audi', 'BMW', 'Jaguar', 'LandRover']
for car in cars:
if car == 'Jaguar':
print(car.upper())
else:
print(car)
# == is case sensitive
print(cars[1]=='bmw')
# > False
# !=
print(cars[1]!='Audi')
# > True
# Numerical Comparisions
# ==, !=, <, >, <=, >=
# Checking multiple values
# 'and' and 'or' ope... | true |
09ea43cd396693c775912dd83794f43c38de8ee5 | deepikaasharma/Parallel-Lists-Challenge | /main.py | 1,333 | 4.125 | 4 | """nums_a = [1, 3, 5]
nums_b = [2, 4, 6]
res = 0
for a, b in zip(nums_a, nums_b):
res += a * b"""
"""Write a function called enum_sum which takes a list of numbers and returns the sum of the numbers multiplied by their corresponding index incremented by one.
Ex: enum_sum([2, 4, 6]) -> (index 0 + 1)*2 + (index 1 ... | true |
8976ba885b018f928284de9128f6b2ce4725c4dc | BibhuPrasadPadhy/Python-for-Data-Science | /Python Basics/100_Python_Programs/Question2.py | 501 | 4.4375 | 4 | ##Write a program which can compute the factorial of a given numbers.
##The results should be printed in a comma-separated sequence on a single line.
##Suppose the following input is supplied to the program:
##8
##Then, the output should be:
##40320
##
##Hints:
##In case of input data being supplied to the ques... | true |
d68c9cf85a4f6a2cb377a94c2c124a55feccd66c | pmk2109/Week0 | /Code2/dict_exercise.py | 1,513 | 4.28125 | 4 | from collections import defaultdict
def dict_to_str(d):
'''
INPUT: dict
OUTPUT: str
Return a str containing each key and value in dict d. Keys and values are
separated by a colon and a space. Each key-value pair is separated by a new
line.
For example:
a: 1
b: 2
For nice pyth... | true |
a63908c918a6b0cbd35b98485fc79683c3923138 | joy-joy/pcc | /ch03/exercise_3_8.py | 1,075 | 4.1875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Jan 17 21:17:17 2018
@author: joy
"""
# Seeing the World
visit_list = ["Machu Picchu", "Phuket", "Bali",
"Grand Canyon", "Santorini", "Dubai",
"New York City", "Paris", "London", "Sydney"]
print("\nVisit List:")
print(vi... | true |
7705715e8e7b21cfbc6b0b3c32d44f9463333c80 | janbalaz/ds | /selection_sort.py | 1,048 | 4.28125 | 4 | from typing import List
def find_smallest(i: int, arr: List[int]) -> int:
"""
Finds the smallest element in array starting after `i`.
:param i: index of the current minimum
:param arr: array of integers
:return: position of the smallest element
"""
smallest = i
for j in range(i + 1, l... | true |
72385e51495ed17597e19bd13f49992ef96df332 | karlmanalo/cs-module-project-recursive-sorting | /src/searching/searching.py | 1,243 | 4.5 | 4 | # TO-DO: Implement a recursive implementation of binary search
def binary_search(arr, target, start, end):
# Handling empty arrays
if len(arr) == 0:
return -1
# Setting midpoint
midpoint = (start + end) // 2
if target == arr[midpoint]:
return midpoint
# Recursion if target i... | true |
fbb99279410300d18b04e4206e9c9b043a4c0866 | egbea123/Math | /Test_REMOTE_389.py | 281 | 4.1875 | 4 | #!/usr/bin/env python
def main ():
num1 = 10.5
num2 = 6.3
# Subtract two numbers
sum = float(num1) - float(num2)
# Display the result
print('The sum of {0} and {1} is {2}',num1, num2, sum )
#division of two numbers
result = 10.5 / 6.3
print ("Result :",result) | true |
e0334e857bed3460736a05791dcd7469ac2fdeab | jakelorah/highschoolprojects | /Senior(2018-2019)/Python/Chapter 2/P2.8.py | 781 | 4.25 | 4 | #Name: Jake Lorah
#Date: 09/14/2018
#Program Number: P2.8
#Program Description: This program finds the area and perimeter of the rectangle, and the length of the diagonal
#Declaring the sides of a rectangle
Side1 = 24
Side2 = 13
Side3 = 24
Side4 = 13
print("The 4 sides of the rectangle are 24 inches, 13 in... | true |
cdf0b54074aa96db6c30c21d0aaf9026ca250317 | jakelorah/highschoolprojects | /Senior(2018-2019)/Python/Tkinter GUI/3by3grid _ Window Project/7.Button_Event_handler.py | 815 | 4.125 | 4 | #Name: Jake Lorah
#Date: 11/26/2018
#Program Number: 7.Button_Event_handler
#Program Description: This program adds a button event handler.
from tkinter import *
window = Tk()
window.title("Welcome To Computer Science 4")
window.geometry('1100x500')
addtext= Label(window, text="Hello How are you tod... | true |
afec42e00509bc8ae26cf9f73bde35d5b47d2ee7 | jakelorah/highschoolprojects | /Senior(2018-2019)/Python/Chapter 4/average.py | 317 | 4.15625 | 4 | #Find the average
total = 0.0
count = 0
inputStr = input("Enter value: ")
while inputStr != "" :
value = float(inputStr)
total = total + value
count = count + 1
inputStr = input("Enter value: ")
if count > 0 :
average = total / count
else :
average = 0.0
print (average)
| true |
939412528610843959ee52b2b4fbd620083c5cb9 | T-D-Wasowski/Small-Projects | /Turtle Artist/Prototype.py | 473 | 4.15625 | 4 | import random
import turtle
turtle.stamp()
moveAmount = int(input("Enter the amount of moves \
you would like your Turtle Artist to make: "))
for i in range(moveAmount):
turtle.right(random.randint(1,51)) #<-- For circles.
turtle.forward(random.randint(1,101))
turtle.stamp() #Do you collec... | true |
bd940f09734b661d4902b0f304f1d38d1530fa44 | MichaelAlonso/MyCSSI2019Lab | /WeLearn/M3-Python/L1-Python_Intro/hello.py | 1,107 | 4.21875 | 4 | print("Hello world!")
print("Bye world!")
num1 = int(raw_input("Enter number #1: "))
num2 = int(raw_input("Enter number #2: "))
total = num1 + num2
print("The sum is " + str(total))
num = int(raw_input("Enter a number: "))
if num > 0:
print("That's a positive number!")
print("Do cherries come from cherry bloss... | true |
ab631a8f16be070bb556ed662c1af5931cd9cbe7 | vishalagg/Using_pandas | /bar_plot.py | 1,829 | 4.625 | 5 | import matplotlib.pyplot as plt
'''
In line charts, we simply pass the the x_values,y_values to plt.plot() and rest of wprk is done by the function itself. In case of bar graph, we have to take care of three things:
1.position of bars(ie. starting position of each bar)
2.position of axis labels.
3.width o... | true |
3cb86970951a4c592edf191fb44af65aca41e321 | rachelprisock/python_hard_way | /ex3.py | 1,014 | 4.21875 | 4 | from __future__ import division
print "I will now count my chickens:"
# PEMDAS so 30 / 6 = 5 and 25 + 5 = 30
print "Hens", 25 + 30 / 6
# 25 * 3 = 75, 75 % 4 = 3, so 100 - 3 = 97
print "Roosters", 100 - 25 * 3 % 4
print "Now I will count the eggs:"
# 4 % 2 = 0, 1 / 4 (no floats with /) = 0
# so 3 + 2 + 1 - 5 + 0 - 0... | true |
34a8d045b8b194670396993143d998ff0ffc8605 | Kyle-Everett10/cp_1404_pracs | /practical_3/oddName.py | 562 | 4.125 | 4 | """Kyle"""
def main():
name = input("Enter your name here: ")
while name == "":
print("Not a valid name")
name = input("Enter your name here: ")
frequency = int(input("How frequent do you want the names to be taken?: "))
print(extract_characters(name, frequency))
def extract_characters... | true |
5536d5bf0689156156e257522381bc2122351be7 | thinpyai/python-assignments | /python_small_exercises/sum_matix_crosses.py | 745 | 4.28125 | 4 | def sum_all_cross(matrix):
"""
Sum all cross direction of matrix.
matrix: input integer value in list.
"""
sum = sum_cross(matrix)
reversed_matrix = list(reversed(matrix))
sum += sum_cross(reversed_matrix)
return sum
def sum_cross(matrix):
"""
Sum matrix in one cross direction.... | true |
de9325d80d1942fec3c7298d01dedc2bd4b864d5 | thinpyai/python-assignments | /python_small_exercises/flatten.py | 1,566 | 4.375 | 4 | # Approximate 1 ~ 1.5h
# For this exercise you will create a global flatten method. The method takes in any number of arguments and flattens them into a single array. If any of the arguments passed in are an array then the individual objects within the array will be flattened so that they exist at the same level as the... | true |
f4291c2cc1fb648f6cb11ceb8dd5de3fb8d078ed | CarlosArro2001/Little-Book-of-Programming-Problems-Python-Edition | /cards.py | 1,100 | 4.375 | 4 | #...
#Aim : Write a program that will generate a random playing cards , when the return return is pressed.
# Rather than generate a random number from 1 to 52 . Create two random numbers - one for the suit and one for the card.
#Author : Carlos Raniel Ariate Arro
#Date : 09-09-2019
#...
#... | true |
266b63afbc2a3739423616db5fc2dd395c6977f5 | shiyuan1118/Leetcode-in-Python | /Leetcode in Python/double index/merge sorted array(88).py | 585 | 4.21875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri May 8 13:09:50 2020
@author: baoshiyuan
"""
#Merge Sorted Array
class Solution:
def merge(nums1, m, nums2, n):
while m>0 and n>0:
if nums2[n-1]>nums1[m-1]:
nums1[m+n-1]=nums2[n-1]
... | true |
c7a9f186a03d699cfb4c205e0d4012f637d9963b | carden-code/python | /stepik/third_digit.py | 356 | 4.15625 | 4 | # A natural number n is given, (n> 99). Write a program that determines its third (from the beginning) digit.
#
# Input data format
# The input to the program is one natural number, consisting of at least three digits.
#
# Output data format
# The program should display its third (from the beginning) digit.
num = input... | true |
74446a287ad4ff8721c0a882051cd13971e88ba4 | carden-code/python | /stepik/removing_a_fragment.py | 504 | 4.1875 | 4 | # The input to the program is a line of text in which the letter "h" occurs at least twice.
# Write a program that removes the first and
# last occurrences of the letter "h" from this string, as well as any characters in between.
#
# Input data format
# The input to the program is a line of text.
#
# Output data format... | true |
69b16d9c547d2c153d686af7d849138a64ca1bd1 | carden-code/python | /stepik/simple_cipher.py | 424 | 4.3125 | 4 | # The input to the program is a line of text.
# Write a program that translates each of its characters into their corresponding code
# from the Unicode character table.
#
# Input data format
# The input to the program is a line of text.
#
# Output data format
# The program should output the code values of the string ch... | true |
69fd35f3faed85dd3ccc5a9a5c1fd5943b52623f | carden-code/python | /stepik/replace_me_completely.py | 360 | 4.21875 | 4 | # The input to the program is a line of text.
# Write a program that replaces all occurrences of the number 1 with the word "one".
#
# Input data format
# The input to the program is a line of text.
#
# Output data format
# The program should display the text in accordance with the condition of the problem.
string = in... | true |
e0268220615c83737c7a823fd3195ed76188ab85 | carden-code/python | /stepik/word_count.py | 468 | 4.40625 | 4 | # The input to the program is a line of text consisting of words separated by exactly one space.
# Write a program that counts the number of words in it.
#
# Input data format
# The input to the program is a line of text.
#
# Output data format
# The program should output the word count.
#
# Note 1. A line of text does... | true |
6be2286fe9476c8ee964976e14b3de72d4228609 | carden-code/python | /stepik/fractional_part.py | 342 | 4.375 | 4 | # A positive real number is given. Output its fractional part.
#
# Input data format
# The input to the program is a positive real number.
#
# Output data format
# The program should output the fractional part of the number in accordance with the condition of the problem.
num = float(input())
fractional = num - (int(nu... | true |
10ccf77bd405de979d859da5f0d2489cecfb845e | carden-code/python | /stepik/prime_numbers.py | 583 | 4.1875 | 4 | # The input to the program is two natural numbers a and b (a < b).
# Write a program that finds all prime numbers from a to b, inclusive.
#
# Input data format
# The program receives two numbers as input, each on a separate line.
#
# Output data format
# The program should print all prime numbers from a to b inclusive,... | true |
98c21ee3a49b5420d1f74200a2b2c097c5c49a7a | carden-code/python | /stepik/same_numbers.py | 483 | 4.15625 | 4 | # A natural number is given. Write a program that determines if a specified number consists of the same digits.
#
# Input data format
# One natural number is fed into the program.
#
# Output data format
# The program should print "YES" if the number consists of the same digits and "NO" otherwise.
num = int(input())
las... | true |
bd2ee920b3b63169a741adedb5fc6c37fad8931f | carden-code/python | /stepik/diagram.py | 469 | 4.21875 | 4 | # The input to the program is a string of text containing integers.
# Write a program that plots a bar chart for given numbers.
#
# Input data format
# The input to the program is a text string containing integers separated by a space character.
#
# Output data format
# The program should output a bar chart.
# Sample I... | true |
d74b3a0f209a35e82e1061370ea268d36cb3f1b4 | carden-code/python | /stepik/reverse_number.py | 558 | 4.53125 | 5 | # Write a program that reads one number from the keyboard and prints the inverse of it.
# If at the same time the number entered from the keyboard is zero,
# then output "The reverse number does not exist" (without quotes).
#
# Input data format
# The input to the program is one real number.
#
# Output data format
# Th... | true |
8c678c8d77d22a603a84c0434d459197f6eadf6f | carden-code/python | /stepik/number_of_members.py | 630 | 4.375 | 4 | # The program receives a sequence of words as input, each word on a separate line.
# The end of the sequence is one of three words: "stop", "enough", "sufficiently" (in small letters, no quotes).
# Write a program that prints the total number of members in a given sequence.
#
# Input data format
# The program receives ... | true |
b06660bcc21e0142f6cdb78adb357b8df1953fb5 | carden-code/python | /stepik/characters_in_range.py | 500 | 4.3125 | 4 | # The input to the program is two numbers a and b.
# Write a program that, for each code value in the range a through b (inclusive),
# outputs its corresponding character from the Unicode character table.
#
# Input data format
# The input to the program is two natural numbers, each on a separate line.
#
# Output data f... | true |
84342c5f534b935c231e13a9836c4af83e840fe2 | carden-code/python | /stepik/sum_of_digits.py | 218 | 4.125 | 4 | # Write a function print_digit_sum () that takes a single integer num and prints the sum of its digits.
def print_digit_sum(_num):
print(sum([int(i) for i in str(_num)]))
num = int(input())
print_digit_sum(num)
| true |
0291ba0bf851212409f7ac5f928153ba0fda249f | carden-code/python | /stepik/line_by_line_output.py | 347 | 4.4375 | 4 | # The input to the program is a line of text. Write a program that displays the words of the entered line in a column.
#
# Input data format
# The input to the program is a line of text.
#
# Output data format
# The program should display the text in accordance with the condition of the problem.
string = input()
print(... | true |
f3e5e2a96224b5ad2133b5683b8803a654141797 | carden-code/python | /stepik/sum_num_while.py | 497 | 4.28125 | 4 | # The program is fed a sequence of integers, each number on a separate line.
# The end of the sequence is any negative number.
# Write a program that outputs the sum of all the members of a given sequence.
#
# Input data format
# The program is fed with a sequence of numbers, each number on a separate line.
#
# Output ... | true |
ce3399dcdfc212a588de430f21cb81735264b258 | Mario-D93/habit_tracker | /t_backend.py | 1,885 | 4.21875 | 4 | import sqlite3
class Database():
'''
The Database object contains functions to handle operations such as adding,
viewing, searching, updating, & deleting values from the sqlite3 database
The object takes one argument: name of sqlite3 database
Class is imported to the frontend script (t_fronted.py)
'''
def _... | true |
89fafeb66a04184fb1f8fe490ecde074c68ae4bc | 0n1udra/Learning | /Python/Python_Problems/Rosalind-master/Algorithmic_009_BFS.py | 1,705 | 4.21875 | 4 | #!/usr/bin/env python
'''
A solution to a ROSALIND problem from the Algorithmic Heights problem area.
Algorithmic Heights focuses on teaching algorithms and data structures commonly used in computer science.
Problem Title: Breadth-First Search
Rosalind ID: BFS
Algorithmic Heights #: 012
URL: http://rosalind.info/probl... | true |
7bc496f3183da034730fad98d0b6bc26b27573c2 | 0n1udra/Learning | /Python/Python_Problems/Rosalind-master/001_DNA.py | 934 | 4.1875 | 4 | #!/usr/bin/env python
'''
A solution to a ROSALIND bioinformatics problem.
Problem Title: Counting DNA Nucleotides
Rosalind ID: DNA
Rosalind #: 001
URL: http://rosalind.info/problems/dna/
'''
from collections import Counter
def base_count_dna(dna):
'''Returns the count of each base appearing in the given DNA se... | true |
c8508b6bba66b1052ca57cc2b9b31af313f805da | 0n1udra/Learning | /Python/Python_Problems/Interview_Problems-master/python/logarithm.py | 732 | 4.1875 | 4 | '''
Compute Logarithm
x: a positive integer
b: a positive integer; b >= 2
returns: log_b(x), or, the logarithm of x relative to a base b.
Assumes: It should only return integer value and solution is recursive.
'''
def myLog(x, b):
if x < b:
return 0
else:
return myLog(x/b, b) + 1
if __nam... | true |
6fb3874538b010fa6367cfd1ef6ed6fd392e91c3 | TheJoeCollier/cpsc128 | /code/python2/tmpcnvrt.py | 1,242 | 4.5 | 4 | ###########################################################
## tmpcnvrt.py -- allows the user to convert a temperature
## in Fahrenheit to Celsius or vice versa.
##
## CPSC 128 Example program: a simple usage of 'if' statement
##
## S. Bulut Spring 2018-19
## Tim Topper, Winter 2013
#############################... | true |
0048afa92e4b1d09b35e2d7ae5c1dbe074f0b60e | shraddhaagrawal563/learning_python | /numpy_itemsize.py | 705 | 4.28125 | 4 | # -*- coding: utf-8 -*-
#https://www.tutorialspoint.com/numpy/numpy_array_attributes.htm
import numpy as np
x = np.array([1,2,3,4,5])
print ("item size" , x.itemsize) #prints size of an individual element
x = np.array([1,2,3,4,5,4.2,3.6])
print ("item size" , x.itemsize) #converts every element to the largest of si... | true |
1e0b7b0aed95cfb2db8b1f382bd898fef6c5e595 | hyetigran/Sorting | /src/recursive_sorting/recursive_sorting.py | 1,465 | 4.125 | 4 | # TO-DO: complete the helpe function below to merge 2 sorted arrays
def merge(arr, arrA, arrB):
# TO-DO
left_counter = 0
right_counter = 0
sorted_counter = 0
while left_counter < len(arrA) and right_counter < len(arrB):
if arrA[left_counter] < arrB[right_counter]:
arr[sorted_co... | true |
5b4b1cea5e01a539d288bde1bbc1ae264434f962 | farooqbutt548/Python-Path-Repo | /strings.py | 1,303 | 4.34375 | 4 | # Strings
# Simple String
'''string1 = ' this is 1st string, '
string2 = "this is 2nd string"
print(type(string1))
connect_string = string1+ " "+string2
print(connect_string)
# print("errer"+3) erreor
print('this is not error'+' ' + str(3))
print('this will print 3 ti... | true |
8b8f9374e4084d763f3b4195f5be59c95deeea50 | Khepanha/Python_Bootcamp | /week01/ex/e07_calcul.py | 287 | 4.125 | 4 | total = 0
while True:
number = input("Enter a number: \n>> ")
if number == "exit":
break
else:
try:
number = int(number)
total += number
print("TOTAL: ",total)
except:
print("TOTAL: ",total)
| true |
faa5907d95f8ab25764f7dd6b0a05ef44f5e7f9b | rp764/untitled4 | /Python Object Orientation /OrientationCode.py | 1,348 | 4.40625 | 4 | # OBJECT ORIENTED PROGRAMMING
# INHERITANCE EXAMPLE CODE
class Polygon:
width_ = None
height_ = None
def set_values(self, width, height):
self.width_ = width
self.height_ = height
class Rectangle(Polygon):
def area(self):
return self.width_ * self.height_
class Triangle(... | true |
1a057628c822895bf6e506846fb5fc7de0e10184 | giovannyortegon/holbertonschool-machine_learning | /supervised_learning/0x07-cnn/1-pool_forward.py | 1,717 | 4.125 | 4 | #!/usr/bin/env python3
""" Pooling """
import numpy as np
def pool_forward(A_prev, kernel_shape, stride=(1, 1), mode='max'):
""" pool - performs pooling on images
Args:
A_prev is a numpy.ndarray of shape (m, h_prev, w_prev, c_prev)
containing the output of the previous layer.
... | true |
e97603a1bf321aaede95c36998fe3c780b94ef84 | giovannyortegon/holbertonschool-machine_learning | /math/0x00-linear_algebra/3-flip_me_over.py | 551 | 4.25 | 4 | #!/usr/bin/env python3
""" the transpose of a 2D matrix """
matrix_shape = __import__("2-size_me_please").matrix_shape
def matrix_transpose(matrix):
""" matrix_transpose - the transpose of a 2D matrix
mat1: Input first matrix
mat2: Input second matrix
Return: New matrix
"""
m_length = matrix_s... | true |
192d8c2fa81b0f8469deb319622e8962d4e1273a | EachenKuang/LeetCode | /code/202#Happy Number.py | 2,457 | 4.125 | 4 | # First of all, it is easy to argue that starting from a number I, if some value - say a - appears again during the process after k steps, the initial number I cannot be a happy number. Because a will continuously become a after every k steps.
# Therefore, as long as we can show that there is a loop after running the ... | true |
4c599c9f902ed403eb88fa39b61657003917751d | Billoncho/EncoderDecoder | /EncoderDecoder.py | 1,469 | 4.5625 | 5 | # EncoderDecoder.py
# Billy Ridgeway
# Encode or decode your messages by shifting the ASCII characters.
message = input("Enter a message to encode or decode: ") # Prompt the user for a message to encode/decode.
message = message.upper() # Convert the string of letters to upper... | true |
66ca9d86e2fc88d1402c31fbc1078c4cf9b262b3 | Sophon96/2021-software-general-homework | /lesson_2_1.py | 1,443 | 4.21875 | 4 | # A student has taken 3 tests in a class, and wants to know their current grade
# (which is only calculated by these tests).
# Ask the user to input all three of the test scores for the student, one by one.
# The program should then calculate the average test score (average is adding all three
# test scores toget... | true |
a2a18544685a691a7b072d14b04f7b2f1e6ddca7 | SebastianoFazzino/Python-for-Everybody-Specialization-by-University-of-Michigan | /Word_coutnter_using_dictionaries.py | 461 | 4.125 | 4 | #how to find the most common word in a text:
openfile = input("Enter file name: ")
file = open(openfile)
counts = dict()
for line in file:
words = line.split()
for word in words:
counts[word] = counts.get(word,0) + 1
bigcount = None
bigword = None
for word, count in counts.items():
... | true |
5cd45a7e4fee6f5440f4126b64ae8e80730e9ae9 | SebastianoFazzino/Python-for-Everybody-Specialization-by-University-of-Michigan | /Conditional Statements.py | 907 | 4.25 | 4 | #Calculating the score
score = input("Enter Score: ")
try:
score = float(score)
if score > 0.0 and score < 0.6:
print ("F")
elif score >= 0.6 and score <= 0.69:
print("D")
elif score >= 0.7 and score <= 0.79:
print ("C")
elif score >= 0.8 and score <= 0.89:
... | true |
e3e14d6b50222fddaea52f6a1a9012daf1654cdb | NakonechnyiMykhail/PyGameStart | /lesson26/repeat.py | 505 | 4.1875 | 4 | # functions without args without return
# 0. import random # library
# 1. create a function with name "randomizer"
# 2. create a varieble with name "data" = 'your text at 6-10 words'
# or "lorem ipsum..."
# 3. select var "data" with text and with random method print
# with for-loop 20 times only ONE character
data = ... | true |
e128dc2672cbf6b6b4dee1c1537884ffcc9dc86a | ridhim-art/practice_list2.py | /tuple_set_dictionary/example_contacts.py | 707 | 4.1875 | 4 | #program where user can add contacta for contact book
contacts = {'help': 100}
print('your temp contact book')
while True:
name = input("=> enter contact name :")
if name:
if name in contacts:
print('=> contact found')
print(f'=> {name} :{contacts[name]}')
else:
... | true |
d9e76d1f7a25dfa8d4e160ce4a1f89fcd8eaf704 | subbuinti/python_practice | /loopControlSystem/HallowDaimond.py | 865 | 4.25 | 4 | # Python 3 program to print a hallow diamond pattern given N number of rows
alphabets = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q',
'R', 'S', 'T', 'U','V', 'W', 'X', 'Y', 'Z']
# Diamond array
diamond = []
rows = -1
# Prompt user to enter number of rows
while rows ... | true |
915ca9bbea032f07b0adc06a94f3409c6d7e3bad | lokeshsharma596/Base_Code | /Pyhton/Lambda_Map_Filter.py | 2,346 | 4.375 | 4 | # Lambda Function
# any no of arguments but only one statement
# single line ,anoymous,no def,no return
# example-1
def sum(a, b, c): return a+b+c
print(sum(4, 5, 1))
add=lambda a,b,c: a+b+c
print(add(4, 5, 1))
# example-2
cube=lambda n:n**3
print(cube(4))
# Map Function
# Atleast Two arguments :function and ... | true |
b201d29f539242f9295b7826df8cd4834b173a02 | gillc0045/CTI110 | /Module3/CTI110_M3HW2_bodyMassIndex_gillc0045.py | 502 | 4.4375 | 4 | # Write a program to calculate a person's body mass index (BMI).
# 12 Jun 2017
# CTI 110 - M3HW2 -- Body Mass Index
# Calvin Gill
weight = float(input("Enter the person's weight (pounds): "))
height = float(input("Enter the person's height (inches): "))
bmi = weight*(703/height**2)
print("The person's BMI va... | true |
f74f8032c81b88479718b6bd9e861f1bb04c77c1 | HussainWaseem/Learning-Python-for-Data-Analysis | /NewtonRaphson.py | 1,625 | 4.1875 | 4 | ''' Newton Raphson '''
# Exhaustive Enum = In this we were using guesses but we were going all the way from beginning to end.
# And we were only looking for correct or wrong answers. No approximation.
# Approximation = It was an improvement over Exhaustive Enum in a way that now we can make more correct guesses
# a... | true |
026139b2e0beed35054a503d4c308c5450e6684b | HussainWaseem/Learning-Python-for-Data-Analysis | /FractionsToBinary.py | 1,695 | 4.3125 | 4 | ''' Fractions to Binary '''
# Method ->> Fractions -> decimals using 2**x multiplication -> Then converting decimal to binary.
# -> Then dividing the resultant binary by 2**x (Or right shift x times) to get the outcome.
num = float(input("Give your fraction : ")) # we have to take a float.
x = ... | true |
346c05201be6379aea4801d2ad28d3b495258b4a | HussainWaseem/Learning-Python-for-Data-Analysis | /Tuples.py | 2,673 | 4.40625 | 4 | ''' Tuples '''
# Immutables.
# defining tuples = With braces or without braces
t = (1,2,'l',True)
print(t)
g = 1,2,'l',False
print(g)
# Tuples are Squences (just like Strings and lists) = So they have 6 properties = len(),indexing,slicing, concatenation,
# iterable and membership test (in and not in)
# Range objec... | true |
85bdb20c063b623b3ba8b576096318804c70b212 | sakar123/Python-Assignments | /Question24.py | 261 | 4.3125 | 4 | """24. Write a Python program to clone or copy a list."""
def clone_list(given_list):
new_list = []
for i in given_list:
new_list.append(i)
return new_list
print(clone_list([1, 2, 3, 4, 5]))
print(clone_list([(1, 2), ('hello', 'ji')]))
| true |
cc02f947a004d1c929d2a1ca6a79808909ed7d02 | sakar123/Python-Assignments | /Question37.py | 410 | 4.1875 | 4 | """37. Write a Python program to multiply all the items in a dictionary."""
def prod_dicts(dict1):
list_of_values = dict1.values()
product_of_values = 1
for i in list_of_values:
product_of_values = i * product_of_values
return product_of_values
print(prod_dicts({1: 1, 2: 4, 3: 9, 4: 16, 5: 2... | true |
69c3484772644518a3245f6a925858232fa066ab | ngongongongo/Python-for-beginners | /Chapter 1 - Python Basics/1.8-Practice.py | 2,669 | 4.4375 | 4 | #1.8 Practice
#----------------------------------------
#Question 1
#Prompt the computer to print from 1 to 10 using loop
#Ask user if he/she wants to do it again using loop
#Question 2
#Write a rock-paper-scissor game
#The winning condition is either the player or the computer win 3 times first
#Hint: import random... | true |
0c5c216e024271752c5cf2cebddfa5d2e70d846c | jingyi-stats/-python- | /python_syntax.py | 865 | 4.1875 | 4 | # Python syntax 语法
# print absolute value of an integer
a = 100
if a >= 0:
print(a)
else:
print(-a)
# print if the input age is adult or not
year = input("Please enter your birth year: ")
print(2020 - int(year))
a = int(2020 - int(year))
if a >= 18:
print("Adult")
else:
print("underage")
# print wh... | true |
b0866402b38328d8070e078a7acef16b8e9fb7eb | Dhiraj-tech/Python-Lab-Exercise | /greater,smallest and odd number among them in list (user input in a list).py | 400 | 4.21875 | 4 | #WAP to take a user input of a list consist of ten numbers and find (1)greater no among the list (2)smaller no among the list (3) list of a odd number
list=[]
odd=0
for i in range(10):
num=int(input("enter a number"))
list.append(num)
print("minimum no among them:",min(list))
print("maximum no among them:",max(... | true |
b96f2252a44943ccef0b5cd6950479cf67241857 | Dhiraj-tech/Python-Lab-Exercise | /(4) define a function and show the multiples of 3 and 5.py | 231 | 4.34375 | 4 | #write a function that returns a sum of multiples of 3 and 5 between 0 and limit(parameter)
def function():
for i in range(21):
sum=0
if i%3==0 or i%5==0:
sum=sum+i
print (sum)
function() | true |
a443b4acf86964757b39b1b912c93259629ca1b4 | ButtonWalker/Crash_Course | /4_Exercise2.py | 455 | 4.125 | 4 | for value in range(1, 21):
print(value)
numbers = []
for value in range(1,1001):
numbers = value
print(numbers)
digits = range(1, 1000001)
print(min(digits))
print(max(digits))
print(sum(digits))
# odd numbers
for value in range(1,21,2):
print(value)
for value in range(3, 30, 3):
print(value)
c... | true |
74bff2e14dc504862c597880f6aeec91e3406fde | abhikot1996/Python-Python-All-In-One-Mastery-From-Beginner-to-AdvanceEasy-Way- | /Python-Python-All-In-One-Mastery-From-Beginner-to-AdvanceEasy-Way-/PracticeWebExersicesProgram.py | 965 | 4.21875 | 4 | # 1) Program to print twinkle twinkle little star poem
#print("""Twinkle, twinkle, little star,\n\t
#How I wonder what you are!\n
#\t\tUp above the world so high,\n
#\t\tLike a diamond in the sky.\n
#Twinkle, twinkle, little star,\n
#\tHow I wonder what you are!)
#""")
# 2) Program to print version of python installed... | true |
fc243f4ddc5a2da7b2385e7a09a2780f1f964d2a | carmelobuglisi/programming-basics | /projects/m1/005-units-of-time-again/solutions/pietrorosano/solution_005-againUnitsOfTime.py | 998 | 4.40625 | 4 | # In this exercise you will reverse the process described in Exercise 24. Develop a program that begins by reading a number of seconds from the user. Then your program should display the equivalent amount of time in the form D:HH:MM:SS, where D, HH, MM, and SS represent days, hours, minutes and seconds respectively. Th... | true |
90f62a8ec5f6cee9e9d88f5bfb8f36599ca33616 | a3X3k/Competitive-programing-hacktoberfest-2021 | /CodeWars/Calculating with Functions.py | 1,540 | 4.34375 | 4 | '''
5 kyu Calculating with Functions
https://www.codewars.com/kata/525f3eda17c7cd9f9e000b39/train/python
This time we want to write calculations using functions and get the results. Let's have a look at some examples:
seven(times(five())) # must return 35
four(plus(nine())) # must return 13
eight(minus(three())) # mu... | true |
481537d5d715298b4f112158bf257dd23967c5d5 | a3X3k/Competitive-programing-hacktoberfest-2021 | /CodeWars/Build Tower.py | 939 | 4.125 | 4 | '''
6 kyu Build Tower
https://www.codewars.com/kata/576757b1df89ecf5bd00073b/train/python
Build Tower
Build Tower by the following given argument:
number of floors (integer and always greater than 0).
Tower block is represented as *
Python: return a list;
JavaScript: returns an Array;
C#: returns a stri... | true |
cb1a541b30cec2a374ec146c53fcab3b074fbfdd | Jsmalriat/python_projects | /dice_roll_gen/dice_roll.py | 2,683 | 4.25 | 4 | # __author__ = Jonah Malriat
# __contact__ = tuf73590@gmail.com
# __date__ = 10/11/2019
# __descript__ = This program takes user-input to determine the amount of times two dice are rolled.
# The program then adds these two dice rolls for every time they were rolled and outputs how many
# times each number 2 - ... | true |
d9630b46886066ea9c30426a08e2edb4f4c41bd3 | tomekregulski/python-practice | /logic/bouncer.py | 276 | 4.125 | 4 | age = input("How old are you: ")
if age:
age = int(age)
if age >= 21:
print("You are good to enter and you can drink!")
elif age >= 18:
print("You can entger, but you need a wristband!")
else:
print("Sorry, you can't come in :(")
else:
print("Please enter an age!") | true |
29e7b459ca79807dc28ea3919a14347de30e5a34 | vanceb/STEM_Python_Crypto | /Session3/decrypt.py | 1,127 | 4.15625 | 4 | ##############################
# Caesar Cypher - Decrypt
##############################
# Define the alphabet that we are going to encode
LETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
# Define variables to hold our message, the key and the translated message
message = 'This is secret'
key = 20
translated = ''
# Change the ... | true |
5eb82c0b75ecd9125a10149ac70f7e9facbbf5c8 | carlhinderer/python-exercises | /reddit-beginner-exercises/ex03.py | 1,357 | 4.59375 | 5 | # Exercise 3
#
#
# [PROJECT] Pythagorean Triples Checker
#
# BACKGROUND INFORMATION
#
# If you do not know how basic right triangles work, read this article on wikipedia.
#
# MAIN GOAL
#
# Create a program that allows the user to input the sides of any triangle, and then return whether the triangle is a Pythagorean
# ... | true |
81b6f41cf4da9ba055fa5b1efd3ba7b6993f04d0 | carlhinderer/python-exercises | /daily-coding-problems/problem057.py | 729 | 4.125 | 4 | # Problem 57
# Medium
# Asked by Amazon
#
# Given a string s and an integer k, break up the string into multiple lines such that
# each line has a length of k or less. You must break it up so that words don't break across
# lines. Each line has to have the maximum possible amount of words. If there's no way t... | true |
e8ec7c1c8e7edd373c1a2dd59a98cb8444317c3a | carlhinderer/python-exercises | /ctci/code/chapter01/src/palindrome_permutation.py | 769 | 4.3125 | 4 | #
# 1.4 Palindrome Permutation:
#
# Given a string, write a function to check if it is a permutation of a palindrome.
# A palindrome is a word or phrase that is the same forwards and backwards. A
# permutation is a rearrangement of letters. The palindrome does not need to be
# limited to just dictionary word... | true |
8bc07815ab7a29e1aa5b472bddaff588fc405cfa | carlhinderer/python-exercises | /zhiwehu/src/ex007.py | 1,033 | 4.21875 | 4 | # Question 7
# Level 2
#
# Question:
# Write a program which takes 2 digits, X,Y as input and generates a 2-dimensional array. The element value in
# the i-th row and j-th column of the array should be i*j.
#
# Note: i=0,1.., X-1; j=0,1,¡Y-1.
#
# Example:
# Suppose the following inputs are given to the program... | true |
322db8f52f43c93c7ee36440e6355b62f1054166 | schase15/Sprint-Challenge--Data-Structures-Python | /names/binary_search_tree.py | 2,965 | 4.4375 | 4 | # Utilize the BST from the hw assignment
# Only need contains and insert methods
class BSTNode:
def __init__(self, value):
self.value = value
self.left = None
self.right = None
# Insert the given value into the tree
# Compare the input value against the node's value
# Check if ... | true |
198ce51002296c632ee5522b2ab4f5dec317727d | wangtaodd/LeetCodeSolutions | /069. Sqrt.py | 586 | 4.25 | 4 | """
Implement int sqrt(int x).
Compute and return the square root of x.
x is guaranteed to be a non-negative integer.
Example 1:
Input: 4
Output: 2
Example 2:
Input: 8
Output: 2
Explanation: The square root of 8 is 2.82842..., and since we want to return an integer, the decimal part will be truncated.
"""
class... | true |
44327cd41d09d206b171781dd89aae73376e2dec | wangtaodd/LeetCodeSolutions | /693. Binary Number with Alternating Bits.py | 770 | 4.25 | 4 | """
Given a positive integer, check whether it has alternating bits: namely, if two adjacent bits will always have different values.
Example 1:
Input: 5
Output: True
Explanation:
The binary representation of 5 is: 101
Example 2:
Input: 7
Output: False
Explanation:
The binary representation of 7 is: 111.
Example 3:
Inp... | true |
42b522c5d47b3f31c12398ee1304a62814dec748 | wangtaodd/LeetCodeSolutions | /530. Minimum Absolute Difference in BST.py | 902 | 4.1875 | 4 | """
Given a binary search tree with non-negative values, find the minimum absolute difference between values of any two nodes.
Example:
Input:
1
\
3
/
2
Output:
1
Explanation:
The minimum absolute difference is 1, which is the difference between 2 and 1 (or between 2 and 3).
Note: There are at l... | true |
ea0ce1b541e74ca38790a66990d809be4ce825af | wangtaodd/LeetCodeSolutions | /107. Binary Tree Level Order Traversal II.py | 1,190 | 4.125 | 4 | """
Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).
For example:
Given binary tree [3,9,20,null,null,15,7],
3
/ \
9 20
/ \
15 7
return its bottom-up level order traversal as:
[
[15,7],
[9,20],
[3... | true |
c130d758ef000ea0de0b0ed4154dfa711f0b4504 | D-Bits/Math-Scripts | /main.py | 1,918 | 4.40625 | 4 | from vectors import get_dot_product
from series import get_fibonacci, get_num_of_fib, sum_of_terms
from math import factorial
# Choices for the user
options = {
'1': 'Calculate the dot product of two vectors.',
'2': 'Get the sum of the first n terms in an arithmetic series.',
'3': 'Get a specific number in... | true |
096ac4e7c999f374495576ced8b6f9ac327a57de | pointmaster2/RagnarokSDE | /SDE/Resources/tut_part2.py | 1,281 | 4.3125 | 4 | """
Tutorial - Part 2
Selection
"""
# You can manipulate the selection of the editor and read its values.
# The example below prints the first three elements of the selected items.
if (selection.Count == 0):
script.throw("Please select an item in the tab!")
for tuple in selection:
print ... | true |
612a5eb267901530782ffe5f82876c970fe34f65 | robseeen/Python-Projects-with-source-code | /Mile_to_KM_Converter_GUI/main.py | 1,119 | 4.34375 | 4 | from tkinter import *
# creating window object
window = Tk()
# Program title
window.title("Miles to Kilometer Converter")
# adding padding to window
window.config(padx=20, pady=20)
# taking user input
miles_input = Entry(width=7)
# grid placement
miles_input.grid(column=2, row=0)
# showing input label
miles_label = ... | true |
5cba02efb718d3cfdb85ee3439261fb2fa28cf9f | robseeen/Python-Projects-with-source-code | /average_height_using_for_loop.py | 852 | 4.125 | 4 | # Finding average height using for loop.
# takeing students height and sperated
student_heights = input(
"Input a list of students heights. Seperated by commas.\n => ").split()
# checking the input in list
for n in range(0, len(student_heights)):
student_heights[n] = int(student_heights[n])
# printing the st... | true |
530fb79024873eee062a23f2eec7096c00c2c3fc | patidarjp87/python_core_basic_in_one_Repository | /29.Co-Prime.py | 573 | 4.125 | 4 |
print('numbers which do not have any common factor between them,are called co-prime factors')
print('enter a value of a and b')
a=int(input())
b=int(input())
if a>b:
for x in range(2,b+1):
if a%x==0 and b%x==0:
print(a,'&',b,'are not co-prime numbers')
break
else:
continue
if x==b:
print(a... | true |
f8471e2937ec8f64d491a1856f103442e7ec41b3 | patidarjp87/python_core_basic_in_one_Repository | /71.cheacksubset.py | 461 | 4.34375 | 4 |
print("program to check whether a given set is a subset of another given set")
s1=set([eval(x) for x in input('enter elements in superset set 1 as it is as you want to see in your set with separator space\n').split()])
s2=set([eval(x) for x in input('enter elements subset set 2 as it is as you want to see in your set ... | true |
d78cd51c22c282a5a5e9c2bdc69442237700985c | patidarjp87/python_core_basic_in_one_Repository | /92.Accoutclass.py | 1,168 | 4.25 | 4 |
print("define a class Account with static variable rate of interest ,instance variable balance and accounr no.make function to set them")
class Account:
def setAccount(self,a,b,rate):
self.accno=a
self.balance=b
Account.roi=rate
def showBalance(self):
print("Balance is ",self.b... | true |
776b3c99569733f3f1746eb1dee10bb971d52684 | patidarjp87/python_core_basic_in_one_Repository | /84.countwords.py | 221 | 4.125 | 4 |
print("script to ciunt words in a given string \n Takes somthing returns something\n Enter a string")
s=input()
def count(s):
l=s.split()
return len(l)
print('no. of words in agiven string is ',count(s))
input()
| true |
ca903da90a4a8ce81c24bcc3258259facbef43eb | kapari/exercises | /pydx_oop/adding.py | 629 | 4.15625 | 4 | import datetime
# Class that can be used as a function
class Add:
def __init__(self, default=0):
self.default = default
# used when an instance of the Add class is used as a function
def __call__(self, extra=0):
return self.default + extra
add2 = Add(2)
print(add2(5))
# >> 7
class Pers... | true |
394e21f7262da6bedbb53a667bc738662033d26a | Aegis-Liang/Python | /HackerRank/Data Structure/2_LinkedLists/10_GetNodeValue.py | 2,559 | 4.25 | 4 |
"""
Get Node data of the Nth Node from the end.
head could be None as well for empty list
Node is defined as
class Node(object):
def __init__(self, data=None, next_node=None):
self.data = data
self.next = next_node
return back the node data of the linked list in the below method.
"""
def Get... | true |
d525e7b1fc92767c602e4911fed11253e09d58ff | Aegis-Liang/Python | /HackerRank/Data Structure/2_LinkedLists/2_InsertANodeAtTheTailOfALinkedList.py | 1,553 | 4.28125 | 4 |
"""
Insert Node at the end of a linked list
head pointer input could be None as well for empty list
Node is defined as
class Node(object):
def __init__(self, data=None, next_node=None):
self.data = data
self.next = next_node
return back the head of the linked list in the below method
"""
de... | true |
62351503e0025c4fd5c358a16036c52d48eccac6 | Aegis-Liang/Python | /HackerRank/Data Structure/2_LinkedLists/3_InsertANodeAtTheHeadOfALinkedList.py | 1,496 | 4.21875 | 4 | """
Insert Node at the begining of a linked list
head input could be None as well for empty list
Node is defined as
class Node(object):
def __init__(self, data=None, next_node=None):
self.data = data
self.next = next_node
return back the head of the linked list in the below method.
"""
def In... | true |
9d11b885c5188412b5ed481fea5a49878ae3753e | sangzzz/AlgorithmsOnStrings | /week3&4_suffix_array_suffix_tree/01 - Knuth Morris Pratt/kmp.py | 905 | 4.1875 | 4 | # python3
import sys
def find_pattern(pattern, text):
"""
Find all the occurrences of the pattern in the text
and return a list of all positions in the text
where the pattern starts in the text.
"""
result = []
# Implement this function yourself
text = pattern + '$' + text
s = [0 f... | true |
60dcba72cc85538aab4f58ddcd1a989e940f9522 | bhargav-makwana/Python-Corey-Schafer | /Practise-Problems/leap_year_functions.py | 654 | 4.3125 | 4 | # Program : Finding the days in the year
# Input : days_in_month(2015, 3)
# Output :
# Numbers of days per month. 0 is used as a placeholder for indexing purposes.
month_days = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
def is_leap(year):
""" Return True for leap years, False for non-leap years"""
... | true |
7eb795b0920e210e7ff11317e1ba199129013837 | HypeDis/DailyCodingProblem-Book | /Email/81_digits_to_words.py | 1,058 | 4.21875 | 4 | """
Given a mapping of digits to letters (as in a phone number), and a digit string, return all possible letters the number could represent.
You can assume each valid number in the mapping is a single digit.
For example if {“2”: [“a”, “b”, “c”], 3: [“d”, “e”, “f”], …} then “23” should return [“ad”, “ae”, “af”, “bd”, ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.