python实验一、测试

实验一、测试

在这里插入图片描述

#circle
#请完成程序
import math

r = float(input())

c = 2*math.pi*r
a = math.pi*r**2

print("{:.2f} {:.2f}".format(c,a))

在这里插入图片描述

#sum
#请完成程序
a = int(input())
if 100 <= a <= 999:
    d1 = a // 100
    d2 = (a % 100) // 10
    d3 = a % 10
    total = d1 + d2 + d3
    print("{}".format(total))

在这里插入图片描述

#请完成程序
import math

input_str = input()
input_list = input_str.split(",")

n = int(input_list[0])
k = int(input_list[1])

c = math.factorial(n) / (math.factorial(n - k) * math.factorial(k))
print(int(c))

在这里插入图片描述

#请完成程序
input_str = input()

cleaned_str = input_str.replace(" ","").lower()

is_palindrome = cleaned_str == cleaned_str[::-1]

print(is_palindrome)

在这里插入图片描述

#请完成程序
input_str = input()

words = input_str.split()
words_count = len(words)

print("{}".format(words_count))

在这里插入图片描述

#请在此文件中完成程序编写
n = int(input())

odd_numbers = [str(x) for x in range(1, n + 1) if x % 2 != 0]
result_str = " ".join(odd_numbers)

print(result_str)

在这里插入图片描述

#编写凯撒密码加密程序
input_str = input()
encrypted_str = ""
offset = 3
for char in input_str:
    ascii_value = ord(char)
    if char.isupper():
        encrypted_char = chr(((ascii_value - ord('A') + offset) % 26) + ord('A'))
    else:
        encrypted_char = chr(((ascii_value - ord('a') + offset) % 26) + ord('a'))
    encrypted_str += encrypted_char
print("{}".format(encrypted_str))
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

-Z_Nuyoah

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值