#!/usr/bin/env python3 # -*- coding: utf-8 -*- __author__ = 'Fan Lijun' import math for i in range(1000, 10000): n, m = str(math.sqrt(i)).split('.') ' and i//1000 == int(str(i)[1]) and i % 10 == int(str(i)[-2]): print(i)
#coding=utf-8 def init_set(): r10=range(10) return [(i, j, k, l) for i in r10 for j in r10 for k in r10 for l in r10 if (i != j and i != k and i != l and j != k and j != l and k != l) ] #对给定的两组数,计算xAyB.不知道能不能更快些 def get_match_ab(target, source): la,
# coding=utf-8# 猜数# 记录猜数的过程import randomcom_result=[] #存放电脑结果,数组com_count=0 #存放电脑猜测次数ran=random.randint(0,100) #随机生成数字print('Start Guessing 开始猜测')up=100 #设置上限和下限down=0print('Human provide random number is: ',ran) #人随机提供一个数guessing=0 #为循环初始化while (gu
非常简单的GUI版猜数字游戏,后面有时间好好研究下 # -*- coding: utf-8 -*-"""Created on Mon Jan 28 16:30:17 2019 @author: pelu""" import tkinterimport random number = random.randint(1, 100) def check_number(): guess_number = int(txt_guess.get()) if g
设定一个理想数字比如:66,让用户输入数字,如果比66⼤,则显示猜测的结果⼤了:如果比66⼩,则显示猜测的结果小了;只有等于66,显示猜测结果 第一种方式(最简单的方式实现) n = 66 # 理想数字 num = int(input('请输入一个数:')) # input()的返回值是字符串,所以需要使用int()转换下类型 if num > n: print('很抱歉,你猜错了!') elif num < n: print('很抱歉,你猜错了!') else: # 这个分支中else表示
代码运行效果如下: 注意: 1.必须要在python3环境想使用 2.QQ:3084276329(一起交流学习) 3.还请大家评论 Guess the word game代码如下: #! /usr/bin/env python # -*- coding: utf- -*- # Guess the word game # 博客:https://www.cnblogs.com/muxii # 那个木兮啊 import tkinter import threading import time from
#猜数字 import random num_rd=random.randint(0,100) count=1 while 1<=count<=10: num_ip=input('请输入0---100之间的整数:') if num_ip.isdigit(): num=int(num_ip) if num==num_rd: print('用了'+str(count)+'次猜对了') break elif (num<0 or num >100): print('数字超出范围了,重新输入
import random//引用随机数rand=random.randint(0,99)t=0while 1: //用t来记录使用次数 t+=1 //自行输入一个随机数 aNumber=int(input("put a number:")) if rand<aNumber: print("more") elif rand>aNumber: print("less") else : breakprint("you are r