blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
d8a01887aac88b6efa397744ea1ec884071c734e | 40013385/Advanced_Python | /Miniproject/CafeManagementSystem.py | 5,359 | 4.09375 | 4 | """
This is a Cafe management billing system project.
Bill for the order is calculated automatically instead of manually.
"""
class Cafe:
"""Details of customer, table number"""
def __init__(self):
"""Details defined"""
self.cust_name = 2
self.no_of_people = 3
self.table_no = 4... |
34e38f77a9017870fa0fa1e047e1fd5974d61169 | pdunbar1999/hangman | /main.py | 2,898 | 3.984375 | 4 | import random
#variables needed
lst = ["dog", "cat", "peter"]
# Hello World
# I am adding a comment
#Gets the random word
def get_word():
a = random.randint(0,2)
return lst[a]
def word_or_letter(): #asks the user if they want to guess the word or letter
while True: #then asks them for their guess
... |
bd98bb4aed2120f76c0eb976400f00fc8c87d362 | siudakp/geometric_shapes_recognition | /class_counter.py | 318 | 3.640625 | 4 | class LabelCounter:
def count(self, rows):
"""Counts the number of each type in a dataset."""
counts = {}
for row in rows:
label = row[-1]
if label not in counts:
counts[label] = 0
counts[label] += 1
return counts |
d043a969e311249f1b9275c533b68231e86a65f4 | percyperezdante/scripting | /teaching/python/general/examples/input.py | 252 | 3.8125 | 4 | #!/usr/bin/env python3
import sys
print(sys.version_info) # gets the python version
message="Type your name"
typed=input(message)
print("---"+ typed)
number=input("Type a number")
number=int(number)+1
print("Add one to typed number "+str(number))
|
f5153cbcc2a11e9d8c8461b6939591416cb638a3 | sha186/PPL_Assignment | /Assign3/Que3_1.py | 1,343 | 4.25 | 4 | from abc import ABC, abstractmethod
# Base Abstract Class
class Animal(ABC):
def __init__(self, color, eatinghabit):
self._mycolor = color #protected variable
self.__myeatinghabit = eatinghabit #private variable
print("My tone is",self._mycolor,"in colour")
... |
d0480f6157d19bec6476b65c834e2da6358b5589 | sha186/PPL_Assignment | /Assign4/Que4_1.py | 2,177 | 4.3125 | 4 | from abc import ABC, abstractmethod
# Base Abstract Class
class Animal(ABC):
def __init__(self, group, color):
self.mygroup = group
self._mycolor = color
print("My tone is",self._mycolor,"in colour")
# common method
def isgroup(self):
... |
b4ce730b80875b1b4150d1bf0644371d1c74e149 | thitimon171143/ComPro-Adv | /week1/ex7.py | 486 | 3.5 | 4 | class Dog:
species = 'mammal'
def __init__(self,name,age):
self.name = name
self.age = age
def description(self):
return "{} is {} years old".format(self.name,self.age)
def speak(self,sound):
return "{} says {}".format(self.name,sound)
class RussellTerrrier(Dog):
def ... |
033a18ceae6737a296720485f536400f3f68ee76 | laraib-sidd/Data-Structures-And-Algortihms | /Dynamic Programming/Fibonacci.py | 630 | 4.1875 | 4 | """
Creating the fibonacci program using Dynamic Programming
"""
from functools import lru_cache
@lru_cache(maxsize=1000)
def fib_dp(num):
if num < 2:
return num
else:
return fib_dp(num - 1) + fib_dp(num - 2)
cache = {}
def fibo(num):
if num in cache:
return cache[num]
elif... |
14657c74ba5acff9e0a0afb201a23992f6c68090 | laraib-sidd/Data-Structures-And-Algortihms | /Algorithms/Recursion/factorial.py | 527 | 4.3125 | 4 | '''
Write two functions that finds the factorial of any number.
One should use recursive , the other should just use a for loop.
'''
# Recursive
def fact_recursive(number):
if number == 1:
return 1
return number * fact_iterative(number - 1)
# Iterative
def fact_iterative(number):
if number == 1:... |
af9036fd80d67a60535e5df62330220425a4f778 | laraib-sidd/Data-Structures-And-Algortihms | /Algorithms/Sorting/Merge Sort.py | 950 | 4.1875 | 4 | '''
Merge Sort: It uses Divide and Conquer and recursion
Time Complexity : O(n log(n))
Space Complexity : O(n)
'''
def mergeSort(arr):
if len(arr) == 1:
return arr
size = len(arr)
mid = size // 2
left = arr[:mid]
right = arr[mid:]
print(f'Left : {left}')
print(f'Right : {right}')
... |
b37c42fd5ec53ba00c4117223b13545ccd1ecb0a | 4mbk0r/convertidor | /convertidor/main.py | 344 | 3.828125 | 4 | from base_n_to_decimal import converto10
from decimal_to_base_n import *
numero = input("inserte el numero \n").upper();
base_origen = int(input("inserte base de origen \n"))
base_destino = int(input("inserte base de destino \n"))
print ( converto10(numero, base_origen) )
print ( convertobase( converto10(numero, base_o... |
5ed843ed8f63e2db37d83968a712c15b59adf385 | llenroc/interviews-1 | /datastructures/linkedlist/python/algorithms/twopointer/linked-list-cycle.py | 609 | 3.828125 | 4 | class ListNode:
def __init__(self, x):
self.val = x
self.next = None
def has_cycle(head):
if not head:
return False
slow = head
fast = head.next
while slow != fast:
if not fast or not fast.next:
return False
slow = slow.next
fast = fas... |
493604959b772ccc741268284b68cd2e086d5062 | llenroc/interviews-1 | /datastructures/linkedlist/python/algorithms/classic/odd-even-list.py | 956 | 4.15625 | 4 | class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
def odd_even(head):
if not head:
return None
odd = head
even_head = head.next
even = even_head
while even and even.next:
odd.next = even.next
odd = odd.next
e... |
bfa5b8c1a53e5ffe2ccb1859839da364ee0c03ca | vilvamoorthy/Python | /intTEST.py | 413 | 4.09375 | 4 | y=-56
print(abs(y))#it will print the INT as positive valu
print(6%5)#it will print the remaindercls
print(3**2)#same as below
print(pow(3,2))#2(second no.) will act as power of 3(first no.) output:9
print(str(y))#it will print INT as STR(convert INT to STR)
print(max(5,8))#it will print the max valu
print(min(... |
e24dde23cb3eb0d90474b5951441456ce48c74a5 | nishad10/prologParentAI | /graphic.py | 3,550 | 3.6875 | 4 | from pyswip import *
import easygui
import random
# Creating a positive and negative expression list that will be used at random based on input to make the robot human like.
posReaction = ['Good boy!','Wow','Nice!','Makes sense.','Cool']
negReaction = ['Really?','Its fine','Oh!','Well its in the past now.']
#defini... |
996883db8c67365fa646cf6e849bdab7d05e3502 | jimnel/simple-rnn | /modules/make_net.py | 939 | 3.875 | 4 | #!/usr/bin/env python3
import torch
import torch.nn as nn
class RNN(nn.Module):
"""
Class for a simple RNN with hidden state size hidden_size
The RNN is deep with a 32 layer for both the hidden state and the output
"""
def __init__(self, hidden_size):
super(RNN, self).__init__()
s... |
3785335be95fc301287121e74101a04557d89ce8 | jessicasml/programacao-orientada-a-objetos | /listas/lista-de-exercicio-02/Questao 6.py | 114 | 3.921875 | 4 | raio=float(input("digite o raio do seu circulo:"))
area=raio**2*3.14
print("A area do circulo é {}".format(area)) |
55b3cd4064f0422bde232be38c5dbd5409d31ea5 | jessicasml/programacao-orientada-a-objetos | /listas/lista-de-exercicio-02/Questao 7.py | 149 | 3.859375 | 4 | lado=float(input("digite o valor do lado do quadrado :"))
quadrado=lado**2
dobro=quadrado*2
print("o dobro da area do quadrado é {}".format(dobro))
|
22e4a7841ae57ad5092c3a91caa5b62396fa32f0 | DaveyCrockett/DataStructureImplementation | /Months.py | 302 | 3.71875 | 4 | class Months:
def __init__(self):
self.months_year = ('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December')
def pi_day(self):
for i in self.months_year:
if i == 'March':
print(i)
|
5f1fc47a45e750652b2da0761ceb9bc833ba4eae | dawsbot/soundvisualizer | /noiserecorder/histogram.py | 859 | 3.640625 | 4 | # histogram.py
#
# Draw histograms for frequency output
#
# Niklas Fejes 2014
# Imports
import sys
import numpy as np
# Draw a histogram
def hist(x,xmin,xmax,n,bar):
sys.stdout.write('\033[0;0f') # cursor to position 0,0
s = ''
for i in range(n):
for v in x:
s += (bar if (v-xmin >= (n... |
1bde60e77b7c95a7b3e56428fc0c868f4a8dd43f | jameso12/JustSomeSnippets | /intermediatePythonFollowAlong4.py | 2,946 | 3.71875 | 4 | # the rest...
'''
def foo(a, b, *args, **kwargs):
# * saves extra positional arguments as a tuple
# **saves extra positional arguments as a dictionary
# * forces keyword only arguments to its left
# *args counts for what is above ^^
print(a,b)
print(args)
print(kwargs)
for arg in args:... |
8ed73f205dfa1e8514d6b72345b227661485537e | faf4r/pynput | /连点器v2.py | 2,214 | 3.625 | 4 | import time
from pynput import mouse
from pynput.mouse import Button, Controller as Mouse_controller
ms = Mouse_controller()
# 可以直接用click代替press+release,方便一点
# mouse.click(Button.right)
# 这里暂时没用
# def listen():
# def on_move(x, y):
# print('Pointer moved to {0}'.format(
# (x, y)))
... |
17756b6cd7bad67ae8754a0543ecf75786e837e6 | ucsd-cse8a-w20/ucsd-cse8a-w20.github.io | /lectures/CSE8AW20-01-07-Lec1-Intro/input-print.py | 76 | 3.546875 | 4 | str1 = input()
str2 = input()
combined = str1 + ", " + str2
print(combined)
|
0286082761929abde1eff07e79e5fae683517d31 | antichloride/madn_simulation | /figure.py | 1,660 | 3.515625 | 4 | #!/usr/bin/env python3
class Figure:
def __init__(self, player, current_place):
self.current_place = current_place
self.player = player
self.current_place.players_figure = self
def updatePlace(self, new_place):
if new_place is None:
return 0
if new_place.pla... |
6ad76a71d7da7cde0e94b942dc4521767135a3a9 | takke2607/guess-the-number | /random.py | 518 | 4 | 4 | import random
def random_number():
choice = int(input("choose a random number:"))
rand = random.randint(1,10)
if choice == rand:
print "your guess was correct"
else:
print "oh oh..wrong answer...try again.."
print "you choose %d , but the correct answer was %d" %(choi... |
54bb7d0a2ddb26d4ba697f93b20ed876116ab2ff | sttagent/impractical-python-projects | /DecodingAmericanCivilWarCiphers/three-rail-fence-cipher.py | 2,038 | 3.625 | 4 | import math
from DecodingAmericanCivilWarCiphers.route_cipher_encoder import \
delete_punctuation
MESSAGE = """We will run the batteries at Vicksburg the night of April 16 and
proceed to Grand Gulf where we will reduce the forts. Be
prepared to cross the river on April 25 or 29. Admiral Po... |
9d8f8664bf301c539f5186e285606142589e8140 | clementi117/use-of-function | /DivideLettersAndDigits/python.py | 603 | 3.9375 | 4 | import random
import string
print('{0:25s} {1:13s} {2:13s} {3:10s}'.format('Given String', "Uppercases", "Lowercases", "Digits"))
for i in range(0, 5):
random_string = ""
for j in range(0, 20):
random_string += random.choice(string.ascii_letters + string.digits)
upperCases = ''.jo... |
da52c176eb59114d151cbb86f9ac682381d9ae35 | sanskarlather/100-days-of-code-with-python | /Day 21/scoreboard.py | 377 | 3.546875 | 4 | from turtle import Turtle
class Score(Turtle):
def __init__(self,xpos):
super().__init__()
self.score=0
self.penup()
self.color("white")
self.ht()
self.setpos(xpos,280)
self.inc_score()
def inc_score(self):
self.clear()
self.write(self.scor... |
e97459d61c89cfa43f78b01db8e58dcb648ba43b | sanskarlather/100-days-of-code-with-python | /Day 22/advanceg_pong_paddle.py | 489 | 3.71875 | 4 | from turtle import Turtle
class Paddle(Turtle):
def __init__(self,face,xpos,ypos):
super().__init__()
self.shape("square")
self.penup()
self.shapesize(1,5)
self.color("white")
self.seth(face)
self.setpos(xpos,ypos)
def up(self):
self.sety(self.ycor... |
accc6f577e1ca4f7d607d0dd8523b903e2e361e6 | sanskarlather/100-days-of-code-with-python | /Day 16/main.py | 1,248 | 3.796875 | 4 | from data import question_data
class Question:
def __init__(self, qu,a):
self.qu=qu
self.a=a
class QuestionBrain:
def __init__(self,question_number,questions,score):
self.question_number=0
self.questions=questions
self.score=0
def still_question(self):
... |
ca4bac603c2a0804dbee13abacf7e0385bc98833 | sanskarlather/100-days-of-code-with-python | /Day 4/day4(RPS).py | 1,121 | 4.09375 | 4 | #Rock Paper Scissors game
import random
rock = '''
_______
---' ____)
(_____)
(_____)
(____)
---.__(___)
'''
paper = '''
_______
---' ____)____
______)
_______)
_______)
---.__________)
'''
scissors = '''
_______
---' ____)____
______)
... |
0f815f742c5a76a7d008172fc65465347d78746c | sanskarlather/100-days-of-code-with-python | /Day 5/day5(average_height).py | 259 | 3.625 | 4 | #average height
student_heights = input("Input a list of student heights ").split()
for n in range(0, len(student_heights)):
student_heights[n] = int(student_heights[n])
sums=0
lens=0
for i in student_heights:
sums+=i
lens+=1
print(round(sums/lens)) |
c3f199eb4777a63fc07ed93c83df2358aaadb8be | sanskarlather/100-days-of-code-with-python | /Day 18/turtle_race.py | 767 | 3.78125 | 4 | from turtle import Turtle, Screen
import random
turt_lisy = []
for i in range(0,6):
turt_lisy.append(Turtle(shape="turtle"))
color = ["red","green","yellow","blue","brown","orange"]
flag = 1
scr = Screen()
scr.setup(width=500,height=400)
bid = scr.textinput("BID","Who do you think will win")
flag = 0
ind = 0
for i... |
fb8464205fce6683e3603b8aa5fde74d777daf87 | sanskarlather/100-days-of-code-with-python | /Extra Practise/det.py | 1,098 | 4.0625 | 4 | #Determinant Of a NxN Matrix
def det_three(a):
if len(a)==2:
return ((a[0][0]*a[1][1]-a[1][0]*a[0][1]))
b=[[[0 for i in range(0,len(a))] for j in range(0,len(a))]for i in range(0,len(a))]
c=[]
for i in range(0,len(a)):
for j in range(0,len(a)):
for k in range(0,len(a)... |
15798a231a5145697f92fbe5d69caba234bbaac8 | adarshmammen/TopCoderPractice | /SRM_148_div2_250.py | 294 | 3.5625 | 4 | class DivisorDigits:
def howMany(self, number):
num_list1 = map(int, str(number))
#num_list2 = [ele for ele in numlist1 if ele !=0]
count = 0
for ele in num_list1:
if ele != 0 and number%ele == 0:
count+=1
return count
test = DivisorDigits()
print test.howMany(12345) |
8c273b8a690d677021b0d0bbf61b6c26663d1870 | adarshmammen/TopCoderPractice | /misc/palindrome_hackerrank.py | 467 | 4.03125 | 4 | string = raw_input()
iter_string = list(string)
uniqs = list(set(iter_string))
count_list = []
for ele in uniqs:
ya = iter_string.count(ele)%2
print ya
if ya!= None:
count_list.append(ya)
found = False if sum(count_list)>1 else True
# Write the code ... |
551d5cdff2966c3795442719d0107a63b8d818ca | luismmontielg/project-euler | /euler004.py | 955 | 4.09375 | 4 | print """
Problem 4. Largest palindrome product
A palindromic number reads the same both ways. The largest palindrome
made from the product of two 2-digit numbers is 9009 = 91 99.
Find the largest palindrome made from the product of two 3-digit numbers.
"""
def generate_palindrome(num):
return int(str(num) + str... |
cb4fe0c2377a282863ea7b9e8bf8a9951daec648 | csiu/tokens | /python/relic/matplotlib_boxplot.py | 5,492 | 3.578125 | 4 | # Author: Celia
# Created: 20/11/13
# Example of using matplotlib to create boxplot:
# http://matplotlib.org/examples/pylab_examples/boxplot_demo2.html
import argparse
import sys
import os
import re
import pylab
import numpy
usage = """ %s [options] -i INFILE
Use matplotlib to create boxplot
""" % (__file__)
de... |
f14a09421f7530e0ff048a30ff3180c0cb1bc76e | dev-jaj/python-coder | /driving-eligibility-test.py | 416 | 4.09375 | 4 | print("************DRIVING ELIGIBILITY TEST************")
print("\t")
while (true):
age= float(input("enter your age:"))
if age>18 and age<81:
print("you are eligible to drive")
elif age==18:
print("Please come to our association to tell if you are physically eligible to drive")
elif age>8 and age<18:
... |
44606d5e66865d6e00c02af246c11be70805c40b | AlwaysFrank/Learning | /learning/ALGO/QuickSort.py | 840 | 4.0625 | 4 | #!/usr/bin/pythoon3
#-*-coding:UTF-8-*-
def quicksort(L):
qsort(L, 0, len(L) - 1)
return L
def qsort(L, first, last):
if first < last:
split = partition(L, first, last)
qsort(L, first, split - 1)
qsort(L, split + 1, last)
def partition(L, first, last):
#choose first element a... |
61be38cf3fbb729fc9fd40c15ad150b72c70efca | zhu00069/CRUD_on_DataArray_Python | /unit_test.py | 1,111 | 3.59375 | 4 | '''
Description: unit test for assignment3, test add function
Created on 2019-03-02
Last modified on 2019-03-02
@author:Bo Zhu, student Number:040684747
'''
#import unit test framework
import unittest
#import, readDataFromCsv, printCurrentArray functions from file crud_on_array.py
from crud_on_array import... |
6cb5c89761c6cff96c1ec4654883d7fcfab64609 | GretaThunbergUltras/botlib | /botlib/forklift.py | 1,840 | 3.515625 | 4 | from .motor import CalibratedMotor
class Forklift:
"""
The bots forklift.
"""
def __init__(self, bot):
self._bot = bot
self._rotate_motor = CalibratedMotor(CalibratedMotor._bp.PORT_C, calpow=70)
self._height_motor = CalibratedMotor(CalibratedMotor._bp.PORT_A, calpow=50)
de... |
4ead0ecb0484d266bb6d28487a537949353f7272 | tombrereton/sorting_algorithms | /sorting_algorithms.py | 8,026 | 4.0625 | 4 | import unittest
import random
"""
This is an implementation of common sorting algorithms.
The algorithms are based on the implementations found
on the geeksforgeeks website.
The algorithms are unit tested to ensure correctness.
"""
def selectionSort(a):
for i in range(len(a) - 1):
# find index of min el... |
ab74e09914845259d9e58f3afeff0e85997e1457 | mt589/randomcode | /list.py | 156 | 3.796875 | 4 | numbers = [538,36,81,6,70,4,2,10,14,32]
person = int(input("Pick a number"))
for counter in numbers:
if counter < person :
print (counter)
|
32fba3675722a9bb51ddda02bfb0b5d48fd76fed | JimVargas5/counting-characters | /counting.py | 1,182 | 3.890625 | 4 | #Jim Vargas counting
import string
def LetterTable(phrase):
compare = (string.ascii_uppercase + string.ascii_lowercase +
" " + string.digits + string.punctuation)
table = ""
for letter in range(len(compare)):
if phrase.count(compare[letter]) > 0:
table = ("'"+compare[letter]+"'") +... |
4ea3de79585ceb25277c15f43cbff6783b04ad9b | astikagupta/HW09 | /presidents.py | 599 | 4.0625 | 4 | #!/usr/bin/env python
# Exercise: Presidents
# Write a program to:
# (1) Load the data from presidents.txt into a dictionary.
# (2) Print the years the greatest and least number of presidents were alive.
# (between 1732 and 2015 (inclusive))
# Ex.
# 'least = 2015'
# 'most = 2015'
# Bonus: Confirm... |
ea478eba77011497ece126a3a7bc46ed7b4c09c6 | CarolYing/430-Coursework | /Monte_Carlo_simulation.py | 7,264 | 3.578125 | 4 | #YouTube: https://youtu.be/58L1M2aBbLk
#--------------------------prng class-----------------------
#open and read the file
with open('war-and-peace.txt') as infile:
content = infile.read()
bound = len(content)
#create a class
class WarAndPeacePseudoRandomNumberGenerator():
'''This class generates ... |
747afeda493340c139e3615a36c392394a43c0f4 | churximi/bookreview | /函数测试与查询/定义类.py | 496 | 4.09375 | 4 | # -*- coding:utf-8 -*-
"""
功能:类的定义
版本:2016年4月2日 15:53:30
"""
class People:
# 定义基本属性
name = ''
age = 0
# 定义私有属性
__weight = 0
# 定义构造方法
def __init__(self, n, a, w):
self.name = n
self.age = a
self.__weight = w
def speak(self):
print("%s is speaking: I a... |
dd33cc1d27b04dd79e94def2a7a778ce044d67a2 | churximi/bookreview | /函数测试与查询/count.py | 292 | 3.578125 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
功能:count()函数
时间:2016年4月18日 20:07:23
"""
import nltk
list1 = ["中文", "中文", "中", "文"]
print list1.count("中文")
print "+".join(list1[0:2])
print list1.index("中")
list1[3] = "修改"
print "+".join(list1)
|
8483e4ba34ff1dad273d6436779774fc3fd1ccf8 | churximi/bookreview | /函数测试与查询/dict.py | 303 | 3.875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
功能:字典用法
时间:2016年5月17日 22:31:57
"""
firstnodes = {"node1": [0, 1], "node2": [2, 3]}
item = "ROOT"
firstnodes[item] = [4, 5]
print firstnodes[item][1]
if item in firstnodes:
firstnodes[item].append(6)
print firstnodes[item]
|
c977bb810fb517ed7826d628be12a4e024595240 | churximi/bookreview | /函数测试与查询/ngram中文.py | 689 | 3.75 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
功能:测试NLTK的ngrams(),针对中文实验
时间:2016年4月25日 19:28:48
"""
import nltk
list1 = ["信息", "检索", "信息", "组织", "信息", "咨询", "信息", "检索", "信息"] # 测试列表
temp = nltk.ngrams(list1, 2) # 2-gram,也可以用nltk.bigrams
list2 = []
for item in temp:
list2.append("".join(item)) ... |
add9c26bf1add61b9fd2708e894b3604ad9c018c | churximi/bookreview | /函数测试与查询/re模块.py | 756 | 3.5625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
功能:学习re模块
时间:2016年6月1日 18:31:01
"""
import re
# re.match
text = u"这是一个测试句。这是第二个测试句。这是第三个测试句。"
a = re.match(u"这是", text)
print u"match " + a.group(0) if a else u"not match"
# re.search
b = re.search(u"一个", text)
print u"search " + b.group(0) if b else u"not search"
... |
d6571736b59ef7b210f190a0650bdf095649664a | kusuma-bharath/Python | /ex_sets.py | 170 | 4.125 | 4 | groceries = {'milk','beer','beer','cheese','chicken'}
print(groceries)
if 'milk' in groceries:
print("You already have milk")
else:
print("You need to get milk") |
a4814453cb1365a533faa752c23ea8b13a6a095f | kusuma-bharath/Python | /ex_continue.py | 144 | 3.703125 | 4 | numberTaken=[2,7,10,20,22]
print("Here are the numbers available")
for n in range(24):
if n in numberTaken:
continue
print(n)
|
19b98d7d1714bd4094e868c34a72dc01985d5e56 | nunulong/algorithms | /coding-challenges/kth-SSL.py | 904 | 3.65625 | 4 | class ListNode:
def __init__(self, val):
self.val = val
self.next = None
# iterate thru linked list
# def kthSSL(num, head):
# curr = head
# len = 1
# while curr.next is not None:
# curr = curr.next
# len = len + 1
# inx = len + 1 - num
# curr = head
# count... |
ca9f479826dbc1d90f044cdbdf3ecddd5103a80a | 4jeR/db-clinic-project | /python/db_management.py | 4,342 | 3.59375 | 4 | import tkinter
from tkinter import *
import tkinter.messagebox
import psycopg2
from guis import *
def connect():
try:
conn = psycopg2.connect(
database = "dfi2dif1n0rgd1",
user = "kfuhgkrrumgxsu",
password = "761ea554798535a9c858113362c9c3256421b4eab2f164814225c1e6add16... |
92247f678d72036d560323f40d128dbd75bf523c | JamesDoane/practical_python_practice | /rps.py | 690 | 3.96875 | 4 | import random
computer_choice = random.choice(['scissors', 'paper', 'rock'])
user_choice = input("Rock, paper, or scissors?\n").lower()
if computer_choice == user_choice:
print("TIE")
elif user_choice == 'rock' and computer_choice == 'scissors':
print("You win")
elif user_choice == 'paper' and computer_cho... |
80ddc11803cee9190684ad8ba87f9e0a383768de | The-EnspireTech/Health-Care-in-Nepal | /Hospital Management System/dataTesting.py | 306 | 3.984375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 30 07:53:25 2020
@author: niraj
"""
import sqlite3
conn = sqlite3.connect('Information.db')
c = conn.cursor()
user = "select * from PatientInfo"
c.execute(user)
result = c.fetchall()
for value in result:
print(value)
|
680400c5384964dbaf27dcce114549bfdd904917 | A01377230/Mision-04 | /Triangulos.py | 1,694 | 4.15625 | 4 | #Jesús Roberto Herrera Vieyra // A01377230
#Programa para clasificar triángulos
#Evalua si es equilátero
def esEquilatero(ladoA, ladoB, ladoC):
if ladoA==ladoB and ladoB==ladoC:
return "equilátero"
else:
return "not"
#Evalua si es isoceles (Tomando en cuanta que la definicion de
#triangulo is... |
c3deeb815c396bade393a9c2f9c7ddd528613f8a | rodolfoksveiga/hacker_rank | /the_minion_game.py | 348 | 3.53125 | 4 | def minion_game(string):
vowels = 'AEIOU'
stuart = 0
kevin = 0
for c, v in enumerate(string):
if v in vowels:
kevin += len(string) - c
else:
stuart += len(string) - c
if kevin > stuart:
print('Kevin {}'.format(kevin))
elif stuart > kevin:
print('Stuart {}'.format(stuart))
else:
print('Draw')
... |
2cab59abb3dfc3037da226a347cd20e5eed41295 | Totoro2205/for_my_shiny_students | /lesson_3/homework/hw_3_3.py | 328 | 4.03125 | 4 | """3. Реализовать функцию my_func(), которая принимает три позиционных аргумента, и возвращает
сумму наибольших двух аргументов."""
def sum_of_max(*args):
return sum(args) - min(args)
print(sum_of_max(0, 1, 2, 3, 4, 5, 6))
|
20240e48a07107b998b7854a551144eff59b111d | Totoro2205/for_my_shiny_students | /lesson_2/homework/hw_2_1.py | 612 | 4.28125 | 4 | """1. Создать список и заполнить его элементами различных типов данных. Реализовать скрипт проверки типа данных
каждого элемента. Использовать функцию type() для проверки типа. Элементы списка можно не запрашивать у пользователя,
а указать явно, в программе."""
my_list = [ValueError(), 1, 2, "string", None, False]
for... |
3e5f51ad0a33f4805733061e80acfb21b8709b4f | JunqiYangjqy/Learning-Notes | /SomePythonPractices/SomePythonTricks.py | 1,956 | 3.625 | 4 | #Some consise but might be useful Python tricks
class Tricks:
# 1. Check duplications
# Use Set()
def all_unique(lst:List[int]):
return len(lst)==len(set(lst))
# If True, no duplications
# 2. Check the memory usage
import sys
var = 10
print(sys.getsizeof(var))
# 3. Calculate Byte Size
... |
b11b2710784d5475f55541936bad1c91eb77b51b | Anewnoob/Leetcode | /longestPalindrome.py | 2,922 | 3.5625 | 4 | class Solution:
#暴力法
def longestPalindrome(self, s: str) -> str:
s_len = len(s)
if s_len < 2 : return s
#init
max_len = 1
max_subPalidrome = s[0]
for i in range(s_len-1):
for j in range(i+1,s_len):
if j-i+1 > max_len:
... |
68367aa265b464c31450eeadddc30406c9b21f6c | Anewnoob/Leetcode | /rotate_1.py | 548 | 4.03125 | 4 | 给定一个 n × n 的二维矩阵表示一个图像。
将图像顺时针旋转 90 度。
class Solution:
def rotate(self, matrix: List[List[int]]) -> None:
"""
Do not return anything, modify matrix in-place instead.
"""
if not matrix: return []
matrix_len = len(matrix)
for i in range(1,matrix_len):
for ... |
214bb88c93c257f894d51f4c235d23860091c7fe | Anewnoob/Leetcode | /kthToLast.py | 693 | 3.578125 | 4 | #实现一种算法,找出单向链表中倒数第 k 个节点。返回该节点的值。
#注意:本题相对原题稍作改动
#示例:
#输入: 1->2->3->4->5 和 k = 2
#输出: 4
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def kthToLast(self, head: ListNode, k: int) -> int:
if head is None:... |
a77549231d296036f0c9df083decb2fadeae65aa | Anewnoob/Leetcode | /nthSuperUglyNumber.py | 1,024 | 3.5625 | 4 | 编写一段程序来查找第 n 个超级丑数。
超级丑数是指其所有质因数都是长度为 k 的质数列表 primes 中的正整数。
class Solution:
def nthSuperUglyNumber(self, n: int, primes: List[int]) -> int:
"""DP"""
# dp = [0] * n
# pointer = [0] * len(primes)
# dp[0] = 1
# for i in range(1, n):
# dp[i] = min(x * dp[y] for x,... |
a2f14aba0d126c7f8c655d7489908ce3bfeb51a7 | Anewnoob/Leetcode | /respace.py | 1,027 | 3.984375 | 4 | #哦,不!你不小心把一个长篇文章中的空格、标点都删掉了,并且大写也弄成了小写。像句子"I reset the computer. It still didn’t boot!"已经变成了"iresetthecomputeritstilldidntboot"。在处理标点符号和大小写##之前,你得先把它断成词语。当然了,你有一本厚厚的词典dictionary,不过,有些词没在词典里。假设文章用sentence表示,设计一个算法,把文章断开,要求未识别的字符最少,返回未识别的字符数。
#注意:本题相对原题稍作改动,只需返回未识别的字符数
class Solution:
def respace(self, dictionary:... |
8f8178d19e3986939ac40577f4d8956177346c91 | Anewnoob/Leetcode | /copyRandomList.py | 1,631 | 3.6875 | 4 | #请实现 copyRandomList 函数,复制一个复杂链表。在复杂链表中,每个节点除了有一个 next 指针指向下一个节点,还有一个 random 指针指向链表中的任意节点或者 null
"""
# Definition for a Node.
class Node:
def __init__(self, x: int, next: 'Node' = None, random: 'Node' = None):
self.val = int(x)
self.next = next
self.random = random
"""
class Solution:
de... |
4b5a0ede1d8e3b73f5a9f60658413a462a208883 | Anewnoob/Leetcode | /addBinary.py | 1,413 | 3.625 | 4 | #给你两个二进制字符串,返回它们的和(用二进制表示)。
#输入为 非空 字符串且只包含数字 1 和 0。
class Solution:
def addBinary(self, a: str, b: str) -> str:
if a == '0': return b
if b == '0': return a
len_a = len(a)
len_b = len(b)
min_len = min(len_a,len_b)
flag = 0
i,j = len_a-1,len_b-1
... |
bce2f4bfba2977b84d7189b57013316a340fc28f | lilamullany/testing-apps | /contraband_detector/contraband_summary.py | 1,500 | 3.703125 | 4 | import time
"""
Tracks all occurrences of contraband detections. Stores tuples of
(detection, time, frame) in a list, contraband_detections, that
can be accessed to produce a log of contraband detections, the
time they occurred, and the video frame of the incident.
"""
class ContrabandSummary:
def __init__(self):
... |
44c1d2f1302055e75c071387567be8c32de8f646 | umapavani09/uma-Python | /string.py | 335 | 4.09375 | 4 | # Strings
" " "
---->Collection of character is called string or
---->Group of characters is called a String
---->in python string representation is '' or "" or " " " " " "
---->in python string is imutable
---->in python string is indexed value based
---->string supports slicing operator------------>':'
" " "
a=''
... |
b42b3c304f6e62850cd3d180c8e77d1002c76ee4 | PPPadventure/CODEKATA-PROBLEMS | /MIXED SETS.py | 5,558 | 4.25 | 4 |
# Q1
# Write a code to get the input in the given format and print the output in the given format.
#
# Input Description:
# A single line contains a string.
#
# Output Description:
# Print the characters in a string separated by comma.
#
# Sample Input :
# guvi
#
# Sample Output :
# g,u,v,i
c = input(... |
0ba3cf58fefa735a80c5ade905b0b0f5bcda69a3 | amasiukevich/InterpreterNew | /tests/utils/test_position.py | 1,723 | 3.515625 | 4 | from src.utils.position import Position
from src.exceptions.position_exception import PositionException
import unittest
class TestPosition(unittest.TestCase):
def test_position_creation(self):
pos = Position(line=3, column=10)
self.assertEqual(pos.line, 3, "Line doesn't match")
self.asser... |
699c165b346085c68acafcb724fb0844aa60cbdb | shen-huang/selfteaching-python-camp | /exercises/1901100040/1001S02E05_array.py | 306 | 4.09375 | 4 | a_list=[0,1,2,3,4,5,6,7,8,9]
a_list.reverse()
a_list=a_list[2:8]
a_list.reverse()
print(a_list)
for bin_element in a_list:
print (bin_element, bin(bin_element))
for oct_element in a_list:
print (oct_element, oct(oct_element))
for hex_element in a_list:
print (hex_element, hex(hex_element)) |
0a26ae6161e7270d9ed3a7958e9d0cb915e2ddf4 | shen-huang/selfteaching-python-camp | /exercises/1901050136/d07/mymodule/stats_word.py | 5,826 | 3.84375 | 4 | # this script is to write a function to call other functions
# 1 for english word
def stats_text_en(text):
text = text.strip().split()
words = [] # for store the text after processing
symbols = '、??:「」,。.!,“”'
for word in text:
for symbol in symbols:
word = word.replace(symbol,'') ... |
8adf345def689ca214d6950eb30bce00764a5fde | shen-huang/selfteaching-python-camp | /exercises/1901010060/1001S02E04_control_flow.py | 957 | 3.609375 | 4 | #使⽤ for...in 循环打印九九乘法表
'''for i in range(1,10):
for j in range(1,i+1): #内层循环
print("{}*{}={}".format(i,j,i*j),end=" ")
print(" ")
'''
#使用for循环打印九九乘法表并把偶数行去掉
'''for i in range(1,10):
for j in range(1,i+1):
if i %... |
453f59c8e4655d5e96e686a2142b2304b96e327d | shen-huang/selfteaching-python-camp | /exercises/1901100138/1001S02E05_array.py | 850 | 4 | 4 | # 1. 对列表[0,1,2,3,4,5,6,7,8,9]翻转
sample_list = [0,1,2,3,4,5,6,7,8,9]
reversed_list = sample_list[::-1]
print('列表翻转 ==>', reversed_list)
# 2. 翻转后的列表拼接成字符串
joined_str = ''.join([str(i) for i in reversed_list])
print('翻转后的数组拼接成字符串 ==>', joined_str)
# 3. 用字符串切片的方式取出第三到第八个字符
sliced_str = joined_str[2:8]
print('用字符串切片的方式取... |
bb1f41f123568284f55321d1ae3f49e16f388c4f | shen-huang/selfteaching-python-camp | /exercises/1901090061/1001S02E04_control_flow.py | 523 | 3.5625 | 4 | #用for in 循环打印九九乘法表
for i in range (1,10):
for j in range (1,i+1):
x = int(i)
y = int(j)
z = int(i*j)
if i > j:
print(f'{x}*{y}={z}',end='\t')
if i == j:
print(f'{x}*{y}={z}',end='\n')
#用while循环打印九九乘法表,并去除偶数行
a = 1
while int(a)<10:
if a%2==1:
... |
6bc4dfd92126d4f60a219fa2937b3184fb25aaf8 | shen-huang/selfteaching-python-camp | /exercises/1901100146/calculator.py | 797 | 4.09375 | 4 | operator=input('请输入运算符(+、-、*、/):')
first_number=input('请输入第一个数字:')
second_number=input('请输入第二个数字:')
a=int(first_number)
b=int(second_number)
print('operator:', operator, type(operator))
print('first-number', first_number, type(first_number), type(a))
print('second-number', second_number, type(second_number), type(b))... |
5ad0be792c68f9cae524c0acafb090f5493d36fa | shen-huang/selfteaching-python-camp | /exercises/1901010114/1001S02E06_stats_word.py | 1,886 | 3.859375 | 4 | #作业1. 封装统计英⽂文单词词频的函数
Text = open('D:\\dayfive\yinwen.txt')
s = Text.read()
#之前复制文档在代码的做法有偷懒的想法,如果碰到文档很长的话难道我要全文复制?,要创建文件然后在读取:
def stats_text_en(s): #定义一个函数stats_text_en
counts = dict() #新建一个空字典
words = s.split() #使用split方法把text字符串中的每个单词分割,且返回的是一个列表
for word in words: #使用一个for循环
if word in ... |
e9181ede1b689eb7e2952c5a677ece9147f9ba56 | shen-huang/selfteaching-python-camp | /exercises/1901100064/1001S02E05_string.py | 2,860 | 3.96875 | 4 | import string
text = '''The Zen of Python , by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough ... |
b8488caa2fd0abf6c9e72a5e21e7d2a873a41452 | shen-huang/selfteaching-python-camp | /19100104/imjingjingli/d5_exercise_stats_text.py | 1,788 | 3.96875 | 4 | import re
text = '''
The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
A... |
4ece03152367c55f9c2939d400a5482339ac331a | shen-huang/selfteaching-python-camp | /exercises/1901090014/1001S01E05_stats_text.py | 1,146 | 3.53125 | 4 | text='''
The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although prac... |
b376fbd1eb6d7fdf317e6b216be364d4cea99609 | shen-huang/selfteaching-python-camp | /19100303/hailinsu/d3_exercise_calculator.py | 549 | 3.84375 | 4 | print("Hi,l am hailinsu.Nice to meet you.")
print("请依次输入两个数字.")
input_number_var_first=int(input("请输入第一个数字:")
input_number_var_second=int(input("请输入第二个数字:")
add_var=input_number_var_first+input_number_var_second
minus_var=input_number_var_first-input_number_var_second
multiply_var=input_number_var_first*imput_num... |
09effdff5b98e442da455105953dcbb11e273e40 | shen-huang/selfteaching-python-camp | /exercises/1901100020/1001S02E03_calculator.py | 1,107 | 4.09375 | 4 | # 土法计算器--甲
print ("请系好安全带,我是你土法计算器甲大爷")
print ("请人类依次输入数据:")
# 用户输入
num1 = int(input("输入第一个数字: "))
num2 = int(input("输入第二个数字: "))
# 结果输出
print ((num1+num2),(num1-num2),(num1*num2),(num1/num2))
print ("上面四个数字依次为加减乘除的运算结果")
# 土法计算器--乙
# 用户输入选择
choice = input("输入你的选择(加/减/乘/除):")
# 用户输入数字
num1 = int(input("输入第一个数字: ")... |
4f26c642316bc2cd1316e30de4e3eec6951025de | shen-huang/selfteaching-python-camp | /exercises/1901010140/1001S02E04_control_flow.py | 1,398 | 3.859375 | 4 | #方案一:利用for...in 实现九九乘法表
for i in range(1,10):
for j in range(1,i+1):
print('%d*%d=%2d\t'%(j,i,i*j),end='')#%d指的是整型
print()
#方案二:利用for...in 实现九九乘法表
for i in range(1,10):
for j in range(1,10):
print(i,"*",j,"=",i*j,"\t",end='')#end=""表示不换行
if i == j:
print("")
... |
b72e82eba529d38972f0542630cdb889a49b681d | shen-huang/selfteaching-python-camp | /19100302/catynchyna/day12/mymodule_day12/stats_word.py | 7,059 | 3.59375 | 4 | # today's tasks used the same one parameter "text"
# (a variable should be assigned with strings including both en and cn)
text = '''
The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than ... |
7f53885e5ab9bc2412e8c47f1f085e796bacb0f6 | shen-huang/selfteaching-python-camp | /19100303/gogogomove/d5_exercise_string.py | 1,887 | 3.78125 | 4 | s = '''The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practi... |
1736901e1d0d68151e4ce9e86cd7501f88f909e9 | shen-huang/selfteaching-python-camp | /exercises/1901100108/1001S02E04_control_flow.py | 348 | 3.625 | 4 |
#for loop
for i in range(1,10):
for j in range(1,10):
if j <= i:
x = i * j
print(f"{i} * {j} = {x}",end=' ')
print()
#while loop
i = 1
while i < 10:
if i%2 !=0:
j = 1
while j <= i:
print(f"{i} * {j} = {i*j}", end=' ')
j = j + 1
... |
4ee11717f9da8f586ae5432e227dd40cc0da825b | shen-huang/selfteaching-python-camp | /exercises/1901100032/1001S02E04_control_flow.py | 874 | 3.921875 | 4 |
print('打印九九乘法表')
for x in range(1,10):
print("第%d行" % x, end='\t')
for y in range(1, x+1):
print(x, '*', y, '=', x * y, end='\t')
print()
print('\n打印跳过偶数行的九九乘法表')
x = 1
while x < 10:
if x % 2 == 0:
print()
else:
for y in range(1, x + 1):
print(x, '*', y, '... |
723a1d3166252207f819cc30743f027c95b361ff | shen-huang/selfteaching-python-camp | /exercises/1901100230/1001S02E03_calculator.py | 568 | 4.125 | 4 | print("###############################")
print("#####欢迎来到计算中心######")
print("###############################")
a = input("请输入第一个数字: ")
print("计算方式编号如下: ")
print("1:加法 ")
print("2:减法 ")
print("3:乘法 ")
print("4:除法 ")
method = input("请选择计算方式(1/2/3/4): ")
b = input("请输入第二个数字: ")
a = int(a)
b = int(b)
if method == "1":
... |
cbe8b396b43f71ad971636f7f551e53a1c462c4f | shen-huang/selfteaching-python-camp | /exercises/1901100058/1001S02E05_array.py | 1,031 | 3.796875 | 4 | # 数组操作,进制转换
Sample_list = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
# 1. 将数组 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] 翻转
reversed_list = sorted(Sample_list, reverse=True)
print('翻转结果', reversed_list)
#reversed_list = Sample_list[::-1]
# 2. 翻转后的数组拼接成字符串
combined_str = ''
for i in reversed_list:
combined_str += combined_str.join(str... |
1ecdd8cd6b35f88e75de79e7fb0e48120579c617 | shen-huang/selfteaching-python-camp | /exercises/1901010076/1001S02E02_hello_python/1001S02E04_control_flow.py | 1,378 | 3.828125 | 4 | #作者:邓超
#学号:1901010076
#内容:用for...in..语法打印九九乘法表
#用时:3小时左右
print('打印九九乘法表') #将range的数列储存进a的变量当中
for a in range(1,10): #还是将range这个数列储存在b的变量中(range里为什么是1,a+1,暂时不懂)
for b in range(1,a+1): #按照乘法表格式序打印出来,但此时打印出来的是连续的,没有回车换行。
print(a, '*', b, '=', a * b, sep='', end=' ')
print() ... |
27b37361d368e347f8c159b46440aaf5e4b460a6 | shen-huang/selfteaching-python-camp | /exercises/1901050092/1001S02E05_array.py | 571 | 3.578125 | 4 | sample_list=[0,1,2,3,4,5,6,7,8,9]
reversed_list=sample_list[::-1]
print('列表反转====',reversed_list)
joined_str=''.join([str(i) for i in reversed_list])
print('反转后转换成字符串===',joined_str)
sliced_str=joined_str[2:8]
print('切片后取出第三到第八个字符',sliced_str)
reversed_str=sliced_str[::-1]
print('字符串反转',reversed_str)
int_value=int(reve... |
27d42705f2f4578237cbed836dae0407a6c112c8 | shen-huang/selfteaching-python-camp | /exercises/1901090036/1001S02E06_stats_word.py | 1,961 | 3.609375 | 4 | #!/usr/bin/python
#-*-coding:UTF-8 -*-
#统计封装英文单词词频的函数,接受字符串,词频降序排列数组
import re #引入正则表达式,以便操作字串符,import放在最上方
def stats_text_en(text): #定义函数
x=text.replace('.','').replace('!','').replace(',','') #去掉标点符号
y=x.split() #拆分
text_set=set(y) #转换为set类型
counter={} #用于存放单词和出现的次数
for en in text_set: #从集... |
f070930584940932b1c012bb35326f9dd4bd5a07 | shen-huang/selfteaching-python-camp | /exercises/1901010109/1001S02E04_control_flow.py | 640 | 4.15625 | 4 | # 1、使⽤for...in循环打印九九乘法表
for m in range(1,10):
for n in range(1,m+1):
print(m,'×',n,'=',m*n,end='\t')
print('\n')
# 2、使⽤ while 循环打印九九乘法表并⽤条件判断把偶数⾏去除掉
m = 1
while m <= 9:
n = 1
if m % 2 == 1:# 奇数odd
while n<=m:
print(m,'×',n,'=',m*n,end='\t')
n += 1
print('... |
59b08d469e1f1d0b79200eafb315b63e3b285315 | shen-huang/selfteaching-python-camp | /19100205/ss412231878/d3_exercise_calculator.py | 1,331 | 4.09375 | 4 | #这是我第三天的作业,制作一个计算器,会带有加减乘除功能,可以输入小数
#这里定义输入的值的运算规则,默认加减乘除都会运算,但是因为选择不同,只会输出相应的结果,比如选“1”,这时加减乘除的结果都算出来了,但是只会输出add(x,y)里的加法结果。
def add(x,y):#这里计算x加y并返回一个值
return x + y
def sub(x,y):#这里计算x减y并返回一个值
return x - y
def mul(x,y):#这里计算x乘y并返回一个值
return x * y
def div(x,y):#这里计算x除y并返回一个值
return x / y
#这里是输入和反馈的代... |
9b0021a7be8407ff0b5cbd1c6469c311c4ce5c86 | shen-huang/selfteaching-python-camp | /exercises/1901050155/1001S02E04_control_flow.py | 354 | 3.703125 | 4 | #按照格式输出9*9乘法表:
for i in range(1,10):
for j in range(1,10):
if i>=j: #当i大于等于j的时候才输出
print(i,"*",j,"=",i*j,'\t',end='')
print('')
print('')
m=1
while (m<10):
n=1
while (n<10):
if m>=n:
print(m,"*",n,"=",m*n,'\t',end='')
n+=1
print('')
m+=2
|
72a2a2479fec8a33199458c20c9a6aef9fc72e6e | shen-huang/selfteaching-python-camp | /exercises/1901100079/1001S02E04_control_flow.py | 688 | 3.875 | 4 | for a in range(1,10):
for b in range(1,a+1):
print(b,"*",a,"=",a*b,end="\t")
print('')
print('''''')
i=1
while i<10:
if i%2==0:
print()
else:
for j in range(1,1+i):
print('{}*{}={}'.format(j,i,i*j),end='\t')
i+=1
print('''
''')
# 两种格式均可生成正确结果,但偶数行保留了
for a in ra... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.