blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
a516c8d763aad72944dd59d8395b06a9aa1b56b6 | dineshkumarkummara/my-basic-programs-in-java-and-python | /folders/python/javatpoint/factorial.py | 254 | 4.15625 | 4 | n=int(input("enter any number:"))
factorial=1
if n<0:
print("number can not be negative")
elif n==0:
print("the factorial of 0 is 1")
else:
for i in range(1,n+1):
factorial*=i
print("the factorial of" , n ,"is" ,factorial, "." )
| false |
d3ec9f8db3eceae68a3392d8de84c8acd9155de2 | muskanmahajan486/communication-error-checksum | /parity/index.py | 409 | 4.40625 | 4 | # Python3 code to get parity.
# Function to get parity of number n.
# It returns 1 if n has odd parity,
# and returns 0 if n has even parity
def getParity( n ):
parity = 0
while n:
parity = ~parity
n = n & (n - 1)
return parity
# Driver program to test getParity(... | true |
706f75c1b7da25049bdc240b0620b8303fcc8e72 | rahulcode22/Data-structures | /Arrays/BubbleSort.py | 583 | 4.4375 | 4 | '''
Bubble sort is a example of sorting algorithm . In this method we at first compare the data element in the first position with the second position and arrange them in desired order.Then we compare the data element with with third data element and arrange them in desired order. The same process continuous until the ... | true |
709312e9a2f50148b6393f5adc5bb9c59d722fb8 | rahulcode22/Data-structures | /Two Pointers/RemoveElements.py | 660 | 4.1875 | 4 | '''
Given an array and a value, remove all the instances of that value in the array.
Also return the number of elements left in the array after the operation.
It does not matter what is left beyond the expected length.
Example:
If array A is [4, 1, 1, 2, 1, 3]
and value elem is 1,
then new length is 3, and A is now [4... | true |
387179e6134508a1d71e818542318548d568258b | rahulcode22/Data-structures | /Math/FizzBuzz.py | 670 | 4.125 | 4 | '''
Given a positive integer N, print all the integers from 1 to N. But for multiples of 3 print “Fizz” instead of the number and for the multiples of 5 print “Buzz”. Also for number which are multiple of 3 and 5, prints “FizzBuzz”.
'''
class Solution:
# @param A : integer
# @return a list of strings
def fi... | true |
f675a20b4fb1b4acd7b8ca903097b07a666909f2 | rahulcode22/Data-structures | /Tree/level-order-traversal.py | 952 | 4.125 | 4 | class Node:
def __init__(self,key):
self.val = key
self.left = None
self.right = None
def printLevelOrder(root):
h = height(root)
for i in range(1,h+1):
printGivenOrder(root,i)
def printGivenOrder(root,level):
if root is None:
return
if level == 1:
p... | true |
ba2d6b6297ea813c6fbfd92782aada21cb368555 | rahulcode22/Data-structures | /Doublylinkedlist/DLL_insertion.py | 1,145 | 4.28125 | 4 | #Insertion at front
def insertafter(head,data):
new_node=node(data)
new_node.next=head
new_node.prev=None
if head is not None:
head.prev=new_node
head=new_node
#Add a node after a given node
def insertafter(prev_node,data):
if prev_node is None:
return
#Allo... | true |
18208ba62478503b314bb7cae82f24194e732050 | cassiakaren/Manipulando-Textos | /aula09.py | 867 | 4.5 | 4 | #FATIAMENTO
'''frase='Curso em Video Python'
print(frase[3])#vai printar a quarta letra
frase='Curso em Video Python'
print(frase[:13])#vai de um caracter a outro
frase='Curso em Video Python'
print(frase[0:15:2])#vai de um caracter a outro pulando de 2 em 2
frase='Curso em Video Python'
print(frase[::2])
frase='Curso ... | false |
d3123c6a569f57767865a6972bde32d3b858d348 | SamanehGhafouri/Data-Structures-and-Algorithms-in-python | /Experiments/find_largest_element.py | 676 | 4.3125 | 4 | # ######### Find the largest element in array ########
def largest_element(arr):
if len(arr) == 0:
return None
max_num = arr[0]
for i in range(len(arr)):
print(i, arr[i])
if arr[i] > max_num:
max_num = arr[i]
return max_num
ar = [90, 69, 23, 120, 180]
print(largest... | true |
5692a8e56f59808656816b733166021af8f5d3c1 | SamanehGhafouri/Data-Structures-and-Algorithms-in-python | /Sorting/bubble_sort.py | 682 | 4.3125 | 4 | # Bubble sort: takes an unsorted list and sort it in ascending order
# lowest value at the beginning by comparing 2 elements at a time
# this operation continues till all the elements are sorted
# we have to find the breaking point
# Time Complexity: best case: O(n)
# average and worst case: O(n^2)
de... | true |
e35fd14187b0b277064bfc4d2019079376ba4781 | SamanehGhafouri/Data-Structures-and-Algorithms-in-python | /Recursion/reverse_str.py | 516 | 4.15625 | 4 | # C-4.16 reverse a string
def reverse_str(string):
if len(string) == 0:
return '' # we cut the first character and put it in
# the back of the string each time
else: ... | true |
7a37455274916403acdee17331216be6d7cc0810 | SachinKtn1126/python_practice | /11_better_calculator.py | 905 | 4.40625 | 4 | # Title: Creating a better calculator
# Author: Sachin Kotian
# Created date (DD-MM-YYYY): 07-12-2018
# Last modified date (DD-MM-YYYY): 07-12-2018
#
# ABOUT:
# This code is to create a better calculator using if else statement and user input.
# Inpu... | true |
ab0ca448a75ff4094c8c7cfe7f112647a22ec37d | SachinKtn1126/python_practice | /10_if_statements_comparisons.py | 1,217 | 4.15625 | 4 | # Title: If statement in python
# Author: Sachin Kotian
# Created date (DD-MM-YYYY): 07-12-2018
# Last modified date (DD-MM-YYYY): 07-12-2018
#
# ABOUT:
# This code is to try and test the working of if statement
# Defining boolean variables
is_male ... | true |
7dccc8e023f5abc096fc502e0d456b73cf052aaa | alfredvoskanyan/Alfred_homeworks | /Homeworks/Shahane/Alfred_Voskanyan_homework2/ex_1.py | 226 | 4.125 | 4 | list1 = [3, 6, True, True, -1, "abc", (1, 2), [2, 3], 6]
for i in range(len(list1)):
if isinstance(list1[i], tuple):
print("Count of elements are ", i)
print("Tuple's index in list is :", i)
break
| false |
71111a542b32a7815b1dd9c7f55ea93d3e75c2b0 | green-fox-academy/criollo01 | /week-02/day-05/palindrome_maker.py | 299 | 4.3125 | 4 | #Create a function named create palindrome following your current language's style guide.
# It should take a string, create a palindrome from it and then return it.
word = str(input("Write a word! "))
def palin_maker(word):
new_word = word + word[::-1]
print(new_word)
palin_maker(word)
| true |
601f2398b30c816fb76ee389a8a93995b98d2fa5 | green-fox-academy/criollo01 | /week-02/day-02/reverse.py | 306 | 4.5625 | 5 | # - Create a variable named `aj`
# with the following content: `[3, 4, 5, 6, 7]`
# - Reverse the order of the elements in `aj`
# - Print the elements of the reversed `aj`
aj = [3, 4, 5, 6, 7]
# ---solution 1---
for i in reversed(aj):
print(i)
#
# ---solution 2--- (nicer)
print(list(reversed(aj))) | true |
d00d45e57e5f130d3356cefa7bc7b50d63a185fe | saikrishna96111/StLab | /triangle.py | 516 | 4.1875 | 4 | print("enter three sides of a Triangle in the range (0 to 10)")
a=int(input("Enter the value of a "))
b=int(input("Enter the value of b "))
c=int(input("Enter the value of c "))
if a>10 or b>10 or c>10:
printf("invalid input values are exceeding the range")
if (a<(b+c))and(b<(a+c))and(c<(a+b)):
if a==b==... | true |
abc28cc6001d0f1c626995ec69eda14235636446 | brybalicious/LearnPython | /brybalicious/ex15.py | 2,707 | 4.4375 | 4 | # -*- coding: utf-8 -*-
# This line imports the argv module from the sys package
# which makes the argv actions available in this script
# Interestingly, if you run a script without importing argv, yet you type
# in args when you run the script in shell (!= python interpreter), it
# still runs and just igno... | true |
712b189becdfd3d7e3d7c4d86d745425e839345c | mkaanery/practicepython.org | /13.py | 329 | 4.1875 | 4 | num = int(input("Number of fibonacci numbers: "))
def fibonacciNumberGenerator(thisMany):
fib = []
counter = 0
cur = 0
prev = 1
while(counter != thisMany):
cur = cur + prev
prev = cur - prev
counter = counter + 1
fib.append(cur)
print(fib)
fibonacciNumberGener... | false |
a9ac682716f455dad84f242ae37a76b5e732d4b4 | breadpitt/SystemsProgramming | /python_stuff/simple_calculator.py | 472 | 4.34375 | 4 | #!/usr/local/bin/python3
numone = input("Please enter number one ")
op = input("Please enter an operator ")
numtwo = input("Please enter number two ")
numone = int(numone)
numtwo = int(numtwo)
if op == "+":
result = numone + numtwo
print(result)
elif op == "*":
result = numone * numtwo
print(result)
elif op == ... | false |
25bc4acccf3f18d73ef6b5a3fa6ea39dd4ba329e | ABradwell/Portfolio | /Language Competency/Python/Basic_Abilities/Arrays, Lists, and Selection sort/Occurances in List.py | 1,226 | 4.3125 | 4 | '''
Count the number of an element
occurrences in a list
• Create a function that takes a list and an integer v, and
returns the number of occurrences of v is in the list. Add
the variable NP as to count number of times the loop
runs (and display a message).
• The main program should generate a list, call the
function,... | true |
d75e6cfdd1f826e8cbd9c8c8ca744f38b4c4e8fd | ABradwell/Portfolio | /Language Competency/Python/Basic_Abilities/Matricies/Matrix Trandformation.py | 876 | 4.125 | 4 | ##– Exercise 1: Matrix transposed
##– Exercise 2: Sum of an array
##– Exercise 3: Multiplication with arrays
#Exercise One
#November 6th, 2018
'''
for example use... 1 2 3,
4 5 6
'''
def transform(A):
AT = []
collums = len(A)
rows = len(A[0])
i = 0
for i in ra... | true |
1d0ba82cfb5a76e6b7efd43a3b1266cf658dbca5 | JennifferLockwood/python_learning | /python_crash_course/chapter_9/9-13_orderedDict_rewrite.py | 860 | 4.1875 | 4 | from collections import OrderedDict
glossary = OrderedDict()
glossary['string'] = 'simply a series of characters.'
glossary['list'] = 'is a collection of items in a particular order.'
glossary['append'] = 'is a method that adds an item to the list.'
glossary['tuple'] = 'is an immutable list.'
glossary['dictionary'] ... | true |
9082625477c61bdd518483945261039e3868c49d | JennifferLockwood/python_learning | /python_crash_course/chapter_10/10-8_cats_and_dogs.py | 610 | 4.28125 | 4 | def reading_files(filename):
"""Count the approximate number of words in a file."""
try:
with open(filename) as file_object:
lines = file_object.readlines()
except FileNotFoundError:
msg = "\nSorry, the file " + filename + " does not exist."
print(msg)
else:
#... | true |
f9a57cf4fbffe700b4f0c15111c0e78479f0a263 | Jinsaeng/CS-Python | /al4995_hw3_q1.py | 382 | 4.21875 | 4 | weight = float(input("Please enter your weight in kilograms:"));
height = float(input("Please enter your height in meters:"));
BMI = weight / (height ** 2)
if (BMI < 18.5):
status = ("Underweight")
elif (BMI < 24.9 ):
status = ("Normal")
elif (BMI <29.9):
status = "Overweight"
else:
stat... | true |
d1c7ab2c0a3a608ff42596a52315fced6f632d00 | Jinsaeng/CS-Python | /al4995_hw2_q1b.py | 383 | 4.21875 | 4 | weight = float(input("Please enter your weight in pounds:"));
height = float(input("Please enter your height in inches:"));
BMI = (weight*0.453592) / ((height*0.0254) ** 2)
#conversion using the note in the hw, pounds to kilo and inches to meters
#the example BMI is close to the one produced by the program but ... | true |
233187ddede43970dd98411b388c2f2c863fd215 | mihirkelkar/languageprojects | /python/double_ended_queue/doubly_linked_list.py | 899 | 4.15625 | 4 | """
Implementation of a doubly linked list parent class
"""
class Node(object):
def __init__(self, value):
self.next = None
self.prev = None
self.value = value
class DoublyLinked(object):
def __init__(self):
self.head = None
self.tail = None
def addNode(self, value):
if self.head == Non... | true |
95ef2bf61ad082eb270342a36b2f32a2ed5044b7 | mihirkelkar/languageprojects | /python/check_anagram.py | 692 | 4.125 | 4 | #!/usr/bin/python
def make_map(string):
map = {}
for ii in string:
try:
map[ii] += 1
except:
map[ii] = 1
return map
def check_anagram(string_one, string_two):
map_one = make_map(string_one)
map_two = make_map(string_two)
if map_one == map_two:
print "Confirmed anagrams"
else:
print "Not anag... | false |
851d77deec23c2cf86d338bc831ec253065f056b | mihirkelkar/languageprojects | /python/palindrome.py | 280 | 4.25 | 4 | def check_palindrome(string):
if len(string) > 1:
if string[0] == string[-1]:
check_palindrome(string[1:][:-1])
else:
print "Not a palindrome"
else:
print "Palindrome"
text = raw_input("Please enter your text string")
check_palindrome(text.lower().replace(" ",""))
| true |
371272def74700f4b43de365e35cb961abe73b1c | InYourFuture/tree | /tree.py | 2,858 | 4.15625 | 4 | # 循环实现二叉树的前序遍历
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution1:
def preorderraversal(self, root):
ret, stack = [], [root]
while stack:
node = stack.pop()
... | false |
bfe427c331a3d1982b2aa13cf45707e063356568 | mwpnava/Python-Code | /My_own_Python_package/guesser_game/numberGuesserGame.py | 2,373 | 4.28125 | 4 | from random import randrange
from .GuesserGame import Guesser
class GuessMyNumber(Guesser):
""" GuessMyNumber class for calculating the result of arithmetic operations applied to an unknow number
given by the player
Attributes:
numberinMind represents the number a player has in mind at the end o... | true |
4e97f7e8c80fedb802649a3e1c51c60800a15bee | mwpnava/Python-Code | /missingValue3.py | 453 | 4.25 | 4 | '''
Consider an array of non-negative integers.
A second array is formed by shuffling the elements of the first array and
deleting a random element. Given these two arrays, find which element is missing in the second array.
Approach 3
'''
def missingValue(arr1,arr2):
arr1.sort()
arr2.sort()
for n1,n2 in... | true |
05f62b6c58e5b56bbcd2a09007aab7c536e1142b | a-benno/randomizer-cli-tool | /randomize/randomizer.py | 2,205 | 4.15625 | 4 | """
########################################################################################################################
## ##
## Copyright (C) 2021 Adjust GmbH. All rights r... | false |
8362df19e83ad9aa361557272d9abed226133853 | vzqz2186/DAnA_Scripts | /Arrays.Lists/vazquez_hw021218_v1.00.py | 2,015 | 4.15625 | 4 | """
Program: Arrays/List
Author: Daniel Vazquez
Date: 02/10/2018
Assignment: Create array/list with 20 possible elements. Fill with 10
random integers 1 <= n <= 100. Write a function to insert value
in middle of list.
Due Date:
Objective: Write a function to insert value in... | true |
950737cb22b6aec643d62fe81cbb7ef6c446fb20 | frostming/ShowMeTheCode | /q4/count_words.py | 532 | 4.28125 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# 第 0004 题:任一个英文的纯文本文件,统计其中的单词出现的个数。
# @Author: Frost Ming
# @Email: mianghong@gmail.com
# @Date: 2016/3/6
import re
def count_words(file):
pattern = re.compile(r'\b[a-zA-Z\']+\b')
target = open(file, 'r').read()
res = pattern.findall(target)
print res
... | false |
b7757a06f89cacb51cb96eba0c685b4cf31a9b4a | jdobner/grok-code | /find_smallest_sub2.py | 1,537 | 4.21875 | 4 | def find_substring(str, pattern):
""" Given a string and a pattern, find the smallest substring in
the given string which has all the characters of the given pattern.
:param str:
:param pattern:
:return: str
>>> find_substring("aabdec", 'abc')
'abdec'
>>> find_substring("abdbca", 'abc')
'bca'
>>> f... | true |
02c484b6cb30a7187b1b67585dfb0158747db857 | jamestonkin/file_storage | /car_storage.py | 1,195 | 4.34375 | 4 | class Car_storage:
""" This adds functionality and stores car list makes and models"""
def __init__(self):
self.car_makes = list()
self.car_models = list()
def read_car_makes(self):
""" Reads car makes from car-makes.txt file """
with open('car-makes.txt', 'r') as makes:
... | true |
febdf1ea7d39be0fd144488b75c2f145d07a5677 | iumentum666/PythonCrashCourse | /Kapittel 10 - 11/word_count.py | 894 | 4.46875 | 4 |
# This is a test of files that are not found. If the file is not present,
# This will throw an error. We need to handle that error.
# In the previous file, we had an error. Here we will create the file
# In this version we will work with several files
# So the bulk of the code is put in a function
def count_words(fi... | true |
778b825dd6d9fc525030292508023898238c5fb1 | Ryan-Walsh-6/ICS3U-Unit5-05-Python | /mailing_address.py | 2,459 | 4.25 | 4 | #!/usr/bin/env python3
# created by: Ryan Walsh
# created on: January 2021
# this program formats a mailing address
def format_address(addressee_from_user, street_number_from_user,
street_name_from_user, city_from_user, province_from_user,
postal_code_from_user, apt_number_from_... | false |
a8fa29813cb4291a39db8d93c46ff0c9c8d5bded | acpfog/python | /6.00.1x_scripts/Week 8/Final Exam/problem3.py | 966 | 4.46875 | 4 | #
# dict_invert takes in a dictionary with immutable values and returns the inverse of the dictionary.
# The inverse of a dictionary d is another dictionary whose keys are the unique dictionary values in d.
# The value for a key in the inverse dictionary is a sorted list of all keys in d that have the same value in d.
... | true |
ccb58e3365e0bbfc25781cee9c118715a0493513 | acpfog/python | /6.00.1x_scripts/Week 2/do_polysum.py | 979 | 4.3125 | 4 | # A regular polygon has 'n' number of sides. Each side has length 's'.
# * The area of regular polygon is: (0.25*n*s^2)/tan(pi/n)
# * The perimeter of a polygon is: length of the boundary of the polygon
# Write a function called 'polysum' that takes 2 arguments, 'n' and 's'.
# This function should sum the area and squa... | true |
a7699c41987cbf101e478a6a1623e5bf83221997 | paw39/Python---coding-problems | /Problem13.py | 1,257 | 4.34375 | 4 | # This problem was asked by Amazon.
#
# Run-length encoding is a fast and simple method of encoding strings.
# The basic idea is to represent repeated successive characters as a single count and character.
# For example, the string "AAAABBBCCDAA" would be encoded as "4A3B2C1D2A".
#
# Implement run-length encoding and d... | true |
261e8bdcd26d998737654e21ddfbc3c5285743d7 | zzzzz1797/design_pattern_python | /structural/adapter.py | 1,752 | 4.46875 | 4 | """
适配器模式(Adapter pattern)是一种结构型设计模式,帮助我们实现两个不兼容接口之间 的兼容。
详细:
如果我们希望把一个老组件用于一个新系统中, 或者把一个新组件用于一个老系统中,不对代码进行任何修改两者就能够通信的情况很少见。
但又并非总是能修改代码,或因为我们无法访问这些代码(例如,组件以外部库的方式提供),或因为修改代码本身就不切实际。
在这些情况下,我们可以编写一个额外的代码层,该代码层包含 让两个接口之间能够通信需要进行的所有修改。这个代码层就叫适配器。
"""
from typing import Dict
class Comput... | false |
f40e03b6e5812149476681db8ddc24fd22e2063b | HS4MORVEL/Lintcode-solution-in-Python | /004_ugly_number_II.py | 1,009 | 4.25 | 4 | '''
Ugly number is a number that only have factors 2, 3 and 5.
Design an algorithm to find the nth ugly number.
The first 10 ugly numbers are 1, 2, 3, 4, 5, 6, 8, 9, 10, 12...
Notice
Note that 1 is typically treated as an ugly number.
Example
If n=9, return 10.
Challenge
O(n log n) or O(n) time.
'''
from heapq imp... | true |
4cf2e4c7ad4bdd2a9f80a0aa3de54c4c4f0e4270 | fe-sts/curso_em_video | /Python 3 - Mundo 2/4. Repetições em Python (while)/Exercicio 71.py | 1,030 | 4.15625 | 4 | '''
Crie um programa que simule o funcionamento de um caixa eletrônico.
No inicio, pergunte ao usuario qual será o Valor a ser sacado (numero inteiro) eo programa vai informar quantas
cédulas de cada valor serão entregues.
Considere que o caixa possui cédulas de 50, 20, 10 e 1 real.
'''
print("=======Sistemas Caixa ... | false |
161200af3074fd3ca367af21f7099b73cef4ebbd | fe-sts/curso_em_video | /Python 3 - Mundo 3/2. Listas/Exercicio 079.py | 662 | 4.15625 | 4 | '''
Exercício Python 079: Crie um programa onde o usuário possa digitar vários valores numéricos e cadastre-os em uma lista.
Caso o número já exista lá dentro, ele não será adicionado.
No final, serão exibidos todos os valores únicos digitados, em ordem crescente.
'''
lista = []
num = 0
continua = ''
while True:
... | false |
9bc6e1883219e65b6d956f3b624a2d818679d502 | fe-sts/curso_em_video | /Python 3 - Mundo 1/1. Tratando dados e fazendo contas/Exercicio 014.py | 347 | 4.15625 | 4 | #Converter graus celsius em farenheit e kelvin
celsius = float(input('Entre com a temperatura em graus Celsius (ºC): '))
farenheit = (((9 * celsius) / 5) + 32)
print('A temperatura de {0}ºC corresponde a {1} ºF'.format(celsius, farenheit))
kelvin = celsius + 273
print('A temperatura de {0}ºC corresponde a {1} ºK'.for... | false |
33fab8dd21256c3f107d68652af5e6cc9216809a | athina-rm/extra_labs | /extralabs_basic/extralabs_basic.py | 343 | 4.15625 | 4 | #Write a Python program display a list of the dates for the 2nd Saturday of every month for a
#given year.
from datetime import datetime
year=int(input("enter the year:"))
for j in range(1,13):
for i in range (8,15):
dates =datetime(year,j,i)
if dates.strftime("%w")=="6":
print(dates.s... | true |
a6737f8bc4d71bb4d48b3b62c8145626a578007e | athina-rm/extra_labs | /extralabs_basic/module5.py | 273 | 4.375 | 4 | # Find
#Find all occurrences of “USA” in given string ignoring the case
string=input("Enter the string : ")
count=0
count=string.lower().count('usa')
if count==0:
print('"USA" is not found in the entered string')
else:
print(f'"USA" is found {count} times')
| true |
b1020a0e36baa29b31dd14c9f476c80fe095ef95 | rob0ak/Hang_Man_Game | /app.py | 2,728 | 4.125 | 4 | import random
def set_up_game(word, list_of_letters, blank_list):
for letter in word:
list_of_letters += letter
blank_list += "-"
def find_letters(word_list, blank_list, guess, list_of_guesses):
count = 0
# Checks the users guess to see if its within the word_list
for let... | true |
5c708d99765f36579409eca6fa9d389b0f83b16e | Albertpython/pythonhome | /home14.py | 328 | 4.375 | 4 | '''Write a Python program to find the
length of a tuple'''
# tup = ("black", "bmw", "red", "ferrary")
# res = 0
# for x in tup:
# res += 1
# continue
# print(res)
'''Write a Python program to convert a tuple to a string'''
# name = ('A', 'L', 'B', 'E', 'R', 'T')
# print(name[0]+name[1]+name[2]+name[3]+name[4]+nam... | true |
db53054877bc9e03ad2feba2efba6c0792857c32 | panovitch/code-101 | /1_shapes _and_color.py | 1,510 | 4.15625 | 4 | """
Here we introduce the concepts of statements and basic types: strings and integers.
WE talk about how a program is a list of senteses exuted from top to bottom, and
that some commands can result in a change of state, and some commands are just actions to execute.
We also explain what comments are :D
"""
# here we... | true |
2b4f5355db301ea1a0c2892d384a48dec3c3ecae | Ratheshprabakar/Python-Programs | /maxmin.py | 260 | 4.15625 | 4 | print("Enter the three numbers")
a=int(input("Enter the 1st Number"))
b=int(input("Enter the 2nd Number\n"))
c=int(input("Enter the 3rd Number"))
print("The maximum among three numbers",max(a,b,c))
print("The Minimum among three numbers",min(a,b,c))
| true |
2efe25d4a1589a8ad24e0f9307b616bd419201b0 | Ratheshprabakar/Python-Programs | /palindrome.py | 258 | 4.3125 | 4 | #Python program to check whether the number is a palindrome or not
def palindrome(a):
if(a[::-1]==a):
print(a,"is palindrome")
else:
print(a,"is not a palindrome")
def main():
a=input("Enter a number")
palindrome(a)
if __name__=='__main__':
main()
| false |
4879b0be7e47945416bfe1764495968ae896726c | Ratheshprabakar/Python-Programs | /concatenate and count the no. of characters in a string.py | 318 | 4.3125 | 4 | #Concatnation of two strings
#To find the number of characters in the concatenated string
first_string=input("Enter the 1st string")
second_string=input("Enter the 2nd string")
two_string=first_string+second_string
print(two_string)
c=0
for k in two_string:
c+=1
print("No. of charcters in string is",c)
| true |
e54a34636c36321cb03605dfc39b69f1fab40f89 | Ratheshprabakar/Python-Programs | /Multiplication table.py | 241 | 4.28125 | 4 | #To display the multiplication table
x=int(input("Enter the table no. you want to get"))
y=int(input("Enter the table limit of table"))
print("The Multiplication table of",x,"is:")
i=1
while i<=y:
print(i,"*",x,"=",x*i)
i+=1
| true |
7cfa1c977434c386eb3738bb15c0510c2a587563 | adityaapi444/beginner_game | /chocwrap.py | 1,004 | 4.1875 | 4 | #chocolate wrapper puzzle game
# price of one chocolate=2
#you will get 1 chocolate by exchanging 3 wrapper
#write a program to count how many chocolates can you eat in 'n' money
# n is input value for money
#ex.
#input: money=20
#output: chocolate=14 wrapper remains: 2
money=int(input("ente your mone... | true |
cc23ecea36f0ad822e62742354427e8e1a9e4495 | esterwalf/python-basics | /meh.py | 806 | 4.1875 | 4 | >>> grade = eval(input("Enter your number grade (0-100):"))
>>> if grade >= 90:
print("You got an A! :)")
elif grade >= 80:
print("You got a B!")
elif grade >= 70:
("You got a C. ")
elif grade >= 60:
("You got a D... ")
else:
print("You got an F :(")
>>> rainy = input("How's the weather? Is it raini... | false |
681b785e3f09a24c8ab87c58aa759a588ce30e51 | esterwalf/python-basics | /rosette or polygon.py | 1,005 | 4.5625 | 5 | >>> import turtle
>>> t = turtle.Pen()
>>> number = int(turtle.numinput("Number of sides or circles",
"How many sides or circles in your shape?", 6))
>>> shape = turtle.textinput("which shape do you want?",
"Enter 'p' for polygon or 'r' for rosette:")
>>> for x in range(number):
if shape == 'r':
... | true |
989eeaea35c3342c9476735031a4ea1ae496c878 | elaguerta/Xiangqi | /ElephantPiece.py | 1,777 | 4.21875 | 4 | from Piece import Piece
class ElephantPiece(Piece):
"""Creates ElephantPieces
elephant_positions is a class variable, a dictionary of initial positions keyed by player color
Two ElephantPieces are created by a call to Player.__init__()."""
elephant_positions = {
'red': [... | true |
fef6a53d7ac9e0a73aaf7f8a6168c6b2761c2e90 | rambabu519/AlgorithmsNSolutions | /Valid_paranthesis.py | 1,533 | 4.125 | 4 | '''
20. Valid Parentheses
Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.
An input string is valid if:
Open brackets must be closed by the same type of brackets.
Open brackets must be closed in the correct order.
Note that an empty string is also ... | true |
9420188d2d74173dc3b779fe0e6e6a19244712f7 | jakovlev-fedor/tms_python_fedor_jakovlev | /02_lesson/10_or_condition.py | 681 | 4.34375 | 4 | """"""
"""
Используя or и 2 функции из > < <= >= == !=
"""
"""
------------------------------------
1. Создайте 3 условия которые будут истинными (True)
Пример истинного условия: 7 > 2 or 8 == 3
"""
print('#01---------------')
print('b' > 'a' or 'one' != 'two')
print(3 <= 3 or 8 < 80)
print('abc' == 'abc' or ... | false |
4c775b35a1f0a0b9ff4484564abcdfadc8273e01 | kemar1997/Python_Tutorials | /range_and_while.py | 1,213 | 4.5 | 4 | # creates a for loop that iterates through nine times starting with 0
# the range function is equivalent to creating a list but within the for loop only
# Remember: Computers always start counting from 0
# the range function also accepts a range of numbers so the iteration doesn't necessarily,
# have to start from exac... | true |
20781199bff842884181faa97ec7af6d40b239dd | kemar1997/Python_Tutorials | /keyword_arguments.py | 991 | 4.4375 | 4 | # name, action, and item are keywords that hold values either strings or numbers
# these keywords can have a default value which can be set in the parentheses below
def dumb_sentence(name='Kemar', action='ate', item='tuna.'):
print(name, action, item)
dumb_sentence()
# keyword arguments are taken in the function ... | true |
3835ef1d609ddcff8f545fd8fb3df017d7584923 | yuzongjian/pythonLearning | /demo.py | 505 | 4.25 | 4 | #!/usr/bin/env python
# -*- coding:utf-8 -*-
#@Time : 2018/6/25 23:41
#@Author: yuzongjian
#@File : demo.py
name = input("Please input your name:")
# 打印输出有下面三种方法,最常用的是第一种
print("hello {0}".format(name))
print("hello" + name)
print("hello %s" %name)
print("1213"+"100")
classmates = ['123','1123']
print(classmates.__le... | false |
076c7e2aa32dcc8aef746adb9c52fd64a742106d | halamsk/checkio | /checkio_solutions/O'Reilly/cipher_crossword.py | 2,329 | 4.3125 | 4 | #!/usr/bin/env checkio --domain=py run cipher-crossword
# Everyone has tried solving a crossword puzzle at some point in their lives. We're going to mix things up by adding a cipher to the classic puzzle. A cipher crossword replaces the clues for each entry with clues for each white cell of the grid. These ... | true |
70573b9422a6e9b4122522882bf71f6dc902d9a8 | No-Life-King/school_stuff | /CSC 131 - Intro to CS/philip_smith.py | 1,280 | 4.21875 | 4 | def mult_tables_one(num):
"""
Prints a row of the multiplication table of the number 'num'
from num*1 to num*10.
"""
print(num, end="\t")
for x in range(1, 11):
print(x*num, end='\t')
print('\n')
def mult_tables_two(start, end):
"""
Prints the rows of the multiplicatio... | true |
65c80a1aa0437f30ac3b1d8fadffad335da8deb3 | zhengyscn/go-slides | /reboot/lesson6/scripts/oop3.py | 1,018 | 4.21875 | 4 |
'''程序猿
'''
class Programmer(object):
# 局部变量, 所有方法均可以直接访问,无需实例化.
monkey = 'Play Computer'
# 构造函数
def __init__(self, name, age, height):
self.name = name # 可以公开访问
self._age = age # 类的私有属性,是编程规范的约束而非Python语法的越苏
self.__height = height # 对外伪私有属性
# 方法
def ge... | false |
259f11820d403abfd022a319693f15bf0e17156f | nandhinipandurangan11/CIS40_Chapter3_Assignment | /CIS40_Nandhini_Pandurangan_P3_3.py | 1,478 | 4.1875 | 4 | # CIS40: Chapter 3 Assignment: P3.3: Nandhini Pandurangan
# This program uses a function to solve problem 3.3
# P3.3: Write a program that reads an integer and prints how many digits
# the number has, by checking whether the number >= 10, >= 100 and so on.
# (Assume that all integers are less than 10 billion) >> 10 bi... | true |
c6f2dd94451ab8a2877335b133e1a4b8b0e5c838 | betyonfire/gwcexamples | /python/scramble.py | 475 | 4.21875 | 4 | import random
print "Welcome to Word Scramble!\n\n"
print "Try unscrambling these letters to make an english word.\n"
words = ["apple", "banana", "peach", "apricot"]
while True:
word = random.choice(words)
letters = list(word)
random.shuffle(letters)
scramble = ''.join(letters)
print "Scrambled: %s" % s... | true |
f5be1bc6340012b3b3052e8f6a45df116a1c2d5c | Zahidsqldba07/CodeSignal-solutions-2 | /Arcade/Intro/growingPlant.py | 1,072 | 4.53125 | 5 | def growingPlant(upSpeed, downSpeed, desiredHeight):
import itertools
for i in itertools.count():
if upSpeed >= desiredHeight:
return 1
elif i*upSpeed - (i-1)*downSpeed >= desiredHeight:
return i
'''Caring for a plant can be hard work, but since you tend to i... | true |
17b85a690befcc87379b5dd3d1f99bf42f77099b | John-Moisha/Hillel_ITP_Python_16_09 | /Lesson - 1.py | 367 | 4.28125 | 4 |
# num = 5
hi = "Hello, World!"
# print (num, type(num))
# print (hi, type (hi))
# print (hi, num)
# f_number = 0.6
# print(f_number, type(f_number))
print(2 + 3 * 4)
print(2 ** 3) #степень
print('2' + '3')
print(hi * 3)
print(10 / 2) #флоат
print(10 // 2) #целое
print(11 // 2)
print(-11 // 2)
print(11 % 2) #остато... | false |
a288cdf0c28d593175e59f2e8fdff0a2c26cd98f | OmkarD7/Python-Basics | /22_assignment.py | 766 | 4.28125 | 4 | from functools import reduce
#find the sum of squares of all numbers less than 10
numbers = [5, 6, 11, 12]
sum = reduce(lambda a,b:a+b, map(lambda a:a*a, filter(lambda n: n <= 10, numbers)))
print("sum of squares of all numbers which are less than 10: ",sum)
#other way without using lambda
def fun1(a, b):
return a... | true |
709a63ba721c447fad84ff309e45adc0774d29f5 | egosk/codewars | /ML - Iris flower - Scikit/Iris flower - ML - basic exercises.py | 1,849 | 4.125 | 4 | # ML exercises from https://www.w3resource.com/machine-learning/scikit-learn/iris/index.php
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
from scipy import sparse
# 1. Write a Python program to load the iris data from a given csv file into a dataframe and print the shape of the
# data, type o... | true |
da877bb35d8f3728d2bf91305c8b30e46819b30c | egosk/codewars | /print directory contents.py | 606 | 4.15625 | 4 | """
This function takes the name of a directory
and prints out the paths files within that
directory as well as any files contained in
contained directories.
This function is similar to os.walk. Please don't
use os.walk in your answer. We are interested in your
ability to work with nested structures.
"""
import os
d... | true |
f0c640ec86971fe2d02ff454be5bee15e7433c01 | gbalabanov/Hack_BG_101 | /Week1/the_real_deal/substrings_in_string.py | 275 | 4.15625 | 4 | def count_substring(main,sub):
count=0
iterator=main.find(sub)
while(iterator != -1):
count+=1
iterator=main.find(sub,iterator+len(sub))
return count
a=(input("Enter string: "))
b=(input("Enter substring: "))
print(count_substring(a,b));
| false |
088f07aec3fa090ff61b70376bf6e2f169f2241a | Bhumi248/finding_Squareroot_in_python | /squareroot.py | 351 | 4.1875 | 4 | #importing pakage
import math
print "enter the number u want to squreroot"
a=int(input("a:"))
#for finding square root there is defuslt function sqrt() which can be accessible by math module
print" square_root=",math.sqrt(a)
#finding square root without use of math module like:x**.5
print "squareroot usin... | true |
ddcec50206d9d5489168c68d234d31cde528742c | abhilash97sharma/python_codes | /Cond_stat.py | 359 | 4.15625 | 4 | is_male = True
is_tall = False
if is_male:
print("You are a male")
else:
print('You are a female')
if is_male and is_tall:
print("you are male and tall")
elif is_male and not is_tall:
print('you are male and not tall')
elif not is_male and is_tall:
print('you are not male and tall')
else:
prin... | false |
ebdd28443a4eb602e246e5284e300344ce5cd9bf | nihagopala/PythonAssignments | /day3/MaxInThreeNos.py | 700 | 4.5 | 4 | #-----------------------------------------------------------#
#Define a function max_of_three() that takes three numbers as
# arguments and returns the largest of them.
#-----------------------------------------------------------#
def Max_Three(a,y,z):
max_3 = 0
if a > y:
if a > z:
m... | true |
b369116c665c70df576807c8cd7f2a1f7545aae3 | nihagopala/PythonAssignments | /day1/10. TranposeOfMatrix.py | 374 | 4.40625 | 4 | #----------------------------------------#
#Program to display transpose of a matrix
#----------------------------------------#
matrix = [[1, 2],
[3, 4],
[5, 6]]
rmatrix = [[0, 0, 0],
[0, 0, 0]]
for i in range(len(matrix)):
for j in range(len(matrix[0])):
rmatrix[j... | false |
6bcc913eed3ed4d99c607fb12c0400017b247a9e | nihagopala/PythonAssignments | /day1/15. SetOfOperations.py | 545 | 4.53125 | 5 | #----------------------------------------------------------#
#Program to print the result of different set of operations
#----------------------------------------------------------#
set1 = {0, 2, 4, 6, 8};
set2 = {1, 2, 3, 4, 5};
# set union
print("Union of set1 and set2 is",set1 | set2)
# set intersection... | true |
3b52c1a2d001dcaf357f3fc4a6bdfa1745b75ef8 | coding5211/python_learning | /learn2.23/ds_seq.py | 663 | 4.125 | 4 | """
shoplist=["apple","banana","mango","sai"]
str="jackrose"
print("itme 0 is",shoplist[0])
print("item 1 is",shoplist[1])
print("item 2 is",shoplist[2])
print("str 0 is",str[0])
print("itme 1 to 3 is",shoplist[1:2])
print("item 1 end is",shoplist[1:] )
print("item 1 to -1 is",shoplist[1:-1])
print("item start to end ... | false |
8ba142c74997a10c79bf39bcfca62307c8f3eb89 | bs4/LearnPythontheHardWay | /ex32drill.py | 2,263 | 4.625 | 5 | the_count = [1, 2, 3, 4, 5]
fruits = ['apples', 'oranges', 'pears', 'apricots']
change = [1, 'pennies', 2, 'dimes', 3, 'quarters']
# this first kind of for-loop goes through a list
for number in the_count:
print "This is count %d" % number
# same as above
for fruit in fruits:
print "A fruit of type %s" % ... | true |
5958d7e44c80a44c98a28c64c9451631525f27c5 | bs4/LearnPythontheHardWay | /ex06drill.py | 2,124 | 4.125 | 4 | # The below line gives a value for variable x, the value is a string that has a formatter in it
x = "There are %d types of people." % 10
# The below line gives a value for the variable "binary", I think doing this is a joke of sorts
binary = "binary"
# The below line gives a value for the variable "do_not", the value i... | true |
ada0873f48aba1239e05d845c2bb457cda744af4 | bs4/LearnPythontheHardWay | /ex18drill.py | 1,643 | 4.5 | 4 | # this one is like your scripts with argv. The below line has a *, it tells python to take all arguments to the function and put them in args as a list
def print_two(*args):
arg1, arg2 = args
print "arg1: %r, arg2: %r" % (arg1, arg2)
# ok, that *args is actually pointless, we can just do this
def print_tw... | true |
83cf84a173ac21a7801299887f5dc1b22cbb6b7e | kavinandha/kavipriya | /prg3.py | 274 | 4.28125 | 4 | ch = input("please enter your own character:")
if(ch =='a' or ch =='e' or ch =='i' or ch =='o' or ch =='u' or ch =='A' or ch =='E' or ch =='I' or ch =='O' or ch =='U'):
print("the given character",ch,"is a vowel")
else:
print("the given character",ch,"is a consonant")
| false |
f30c80da1a3ca8b3c3b34359cc1f7ecb6f0004bc | alinabalgradean/algos | /insertion_sort.py | 413 | 4.25 | 4 | def InsertionSort(lst):
"""Basic Insertion sort.
Args:
lst [list]: The list to be sorted.
Returns:
lst [list]: Sorted list.
"""
for index in range(1, len(lst)):
position = index
temp_value = array[lst]
while position > 0 and lst[position - 1] > temp_value:
lst[position]... | true |
8dd255cbd492106fcfde67c9221698df5a85045f | andrewlidong/PythonSyntax | /Top18Questions/11_determineValidNum.py | 2,176 | 4.125 | 4 | '''
11. Determine if the number is valid
Given an input string, determine if it makes a valid number or not. For simplicity, assume that white spaces are not present in the input.
4.325 is a valid number.
1.1.1 is NOT a valid number.
222 is a valid number.
is NOT a valid number.
0.1 is a valid number.
22.22. is N... | true |
fd8ea6ece01e686a8beef54bc5af3b8dfab593bf | andrewlidong/PythonSyntax | /Top18Questions/3_sumOfTwoValues.py | 1,277 | 4.21875 | 4 | '''
3. Sum of two values
Given an array of integers and a value, determine if there are any two integers in the array whose sum is equal to the given value. Return true if the sum exists and return false if it does not.
Example:
Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9,
return... | true |
bbcc866382ac2ab1642b31334ee7b53b0d85bac7 | mariajosegaete/Python_Projects | /Property_scraper/menu.py | 1,020 | 4.15625 | 4 | from app import houses
USER_CHOICE = '''
Please enter one of the following:
- 'b' to view all houses
- 'n' to view next book in catalogue
- 'c' to view 10 cheapest houses
- 'q' to quit
---->
'''
def print_houses():
'''house_prices = sorted(books, key=lambda x: (x.rating * -1, x.price))[:10]'''
for house i... | false |
e93d0ce781eb3ff8e8ed1515c3ccc49fb0c47dd9 | drewAdorno/Algos | /Python Algos.py | 2,200 | 4.125 | 4 | import math
'''Sara is looking to hire an awesome web developer and has received applications from various sources. Her
assistant alphabetized them but noticed some duplicates. Given a sorted array, remove duplicate values.
Because array elements are already in order, all duplicate values will be grouped together. As w... | true |
434a69165a75e71a157fa92cef111911f5b577ec | Erika001/CYPErikaGG | /listas2.py | 1,396 | 4.40625 | 4 | # arreglos
# lectura
# escritura / Asignacion
# actualizacion : inserccion, eliminacion, modificacion
# ordenamiento
# busqueda
# escritura
frutas = ["Zapote", "Manzana", "Pera", "Aguacate", "Durazno", "Uva", "Sandia"]
# lectura, el selector [indice]
print(frutas[2])
# lectura con for
# for opcion 1
for indice in ra... | false |
3bb64b4540bed752e3f748ce0af80e2657d373e4 | carcagi/hpython | /part1/P2_looping.py | 1,393 | 4.25 | 4 | # while loops
# Not i++ avaiable
i = 0
while i <= 5:
# print(i)
i += 1
# break and continue
i = 0
while i <= 5:
i += 1
if i == 2:
continue
print(i)
if i == 4:
break
# else
i = 0
while i <= 5:
i += 1
print(i)
else:
print('Is more than 5')
# if you break before else ... | true |
575617625d8ba29a27eebc80b953330d8e20fb9f | famd92/python | /FizzBuzz.py | 565 | 4.3125 | 4 | ###Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz" ####
def fizzbuzz(number):
if (number%3 ==0 and number%5 ==0):
output ... | true |
8857dd572a333f0dd6ea437b128ae88dd03e6d1f | mjanibelli/projetos-iniciantes | /projetos/projeto-gerador-senha/senha_modulo.py | 1,208 | 4.125 | 4 | """Verifica tamanho da senha e a gera.
Atributos:
alfabeto (list): Lista que possui as letras do alfabeto.
numeros (list): Lista dos números de 0 a 9.
chars_especiais (list): Lista de caracteres especiais.
"""
import random
import string
alfabeto = list(string.ascii_letters)
numeros = list(string.digits)... | false |
b4ed82079b3ad9ae8e9e2628c7570668215044b3 | hamdi3/Python-Practice | /Formatting.py | 783 | 4.53125 | 5 | #Formatting in python
str="string"
print("this will type a %s" %(str)) # in %() whatever you write will be changed to a string
print("this will type a %s , %s" %("hello" ,3)) # you can use %s 2 times and more but you use one %() with a comma for diffrient ones
print("this will type a float %1.2f" %(13.4454)) # %1.2f me... | true |
1693064c8e6f44f9a93e4e15de044f87b1801c16 | theCompSciTutor/computerScience | /Algorithms/Sort/MergeSort/merge sort python code.py | 968 | 4.15625 | 4 | # Merge Sort Algorithm
def merge_sort(array):
print('Separating...', array)
if len(array) > 1:
mid = len(array) // 2
left_half = array[: mid]
right_half = array[mid :]
merge_sort(left_half)
merge_sort(right_half)
i = 0
j = 0
k = 0
... | false |
1be9f869ffea5b124cb98630ed9160ce4680d812 | Matheus-Pontes/Curso-Python-3 | /aula_11/ex37.py | 488 | 4.1875 | 4 | # CONVERSÃO DE BASE NUMÉRICAS
# BINÁRIO, OCTAL E HEXADECIMAL
num = int(input("Digite um número inteiro: "))
print('''Escolha a conversão:
[0] BINÁRIO
[1] OCTAL
[2] HEXADECIMAL ''')
option = int(input("Faça sua escolha: "))
if option == 0:
print("{} em BINÁRIO {}".format(num, bin(num)))
elif option == 1:
p... | false |
8121d98e6b70c5383c066422dc0e6a9cbef9598c | iamSurjya/dailycoding | /Day 21 pandas_add_col.py | 769 | 4.1875 | 4 | import numpy as np
import pandas as pd
from numpy.random import rand
np.random.seed(101)
#creating an column pandas DataFrame using an numpy array.
print('pandas DataFrame')
df=pd.DataFrame(rand(5,4),['A','B','C','D','E'],['W','X','Y','Z'])
print(df)
#adding new column to an Existing DataFrame
df['new']=0.233333
prin... | false |
1ecebff7cf8703717fc8bc5d19a795161869c53a | iamSurjya/dailycoding | /Day 12_numpy_advance_indexing.py | 421 | 4.1875 | 4 | import numpy as np
x = np.array([[1, 2], [3, 4], [5, 6]])
print('Array')
print(x)
y = x[[0,1,2], [0,1,0]]
print('\nFrom each row, a specific element should be selected') #fetching [1 4 5]
print(y)
print('\nFrom a 4x3 array the corner elements should be selected using advanced indexing')
x = np.array(
[[ 0, 1, 2],
[... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.