3.26python作业

这篇博客展示了几个Python编程的练习,包括基于用户输入的人数判断和年龄判断的场景。通过`if`语句检查人数以决定是否接受,以及使用`while`循环不断询问用户年龄,并根据年龄给出不同票价信息。程序中包含了多种`while`循环的实现方式,以及如何退出循环的条件设定。
# 7-2


num = input("How many people do you have?")
num = int(num)
if (num >= 8):
    print("Sorry, there are no desk available.")
else:
    print("Welcome. This way please.")

# 7-5
while True:
    age = input("Please input your age:")
    age = int(age)
    if (age <= 3):
        print("Free ticket!")

    if (age <= 12):
        print("10 dollors")

    if (age > 12):
        print("15 dollars")


# 7-6-1
age = input("Please input your age:")
while age!= 'quit':
    age = int(age)
    if (age <= 3):
        print("Free ticket!")

    if (age <= 12):
        print("10 dollors")

    if (age > 12):
        print("15 dollars")
    age = input("Please input your age:")


# 7-6-2
active = True
while Active:
    age = input("Please input your age:")
    if(age == 'quit'):
        active = True
    else:
        age = int(age)
        if (age <= 3):
            print("Free ticket!")

        if (age <= 12):
            print("10 dollors")

        if (age > 12):
            print("15 dollars")

# 7-6-3
while True:
    age = input("Please input your age:")
    if(age == 'quit'):
        break;
    age = int(age)
    if (age <= 3):
        print("Free ticket!")

    if (age <= 12):
        print("10 dollors")

    if (age > 12):
        print("15 dollars")


# 7-7
while True:
    print(111)





(deepmd) wjj@wjj:~/下载/dpgen_example/run$ dpgen run param.json machine.json DeepModeling ------------ Version: 0.13.2 Path: /home/wjj/.local/lib/python3.12/site-packages/dpgen Dependency ------------ numpy 2.3.3 /home/wjj/anaconda3/envs/deepmd/lib/python3.12/site-packages/numpy dpdata 0.2.25 /home/wjj/anaconda3/envs/deepmd/lib/python3.12/site-packages/dpdata pymatgen unknown version or path monty 2025.3.3 /home/wjj/anaconda3/envs/deepmd/lib/python3.12/site-packages/monty ase 3.26.0 /home/wjj/.local/lib/python3.12/site-packages/ase paramiko 4.0.0 /home/wjj/.local/lib/python3.12/site-packages/paramiko custodian 2025.8.13 /home/wjj/.local/lib/python3.12/site-packages/custodian Reference ------------ Please cite: Yuzhi Zhang, Haidi Wang, Weijie Chen, Jinzhe Zeng, Linfeng Zhang, Han Wang, and Weinan E, DP-GEN: A concurrent learning platform for the generation of reliable deep learning based potential energy models, Computer Physics Communications, 2020, 107206. ------------ Description ------------ INFO:dpgen:start running INFO:dpgen:continue from iter 000 task 03 INFO:dpgen:=============================iter.000000============================== INFO:dpgen:-------------------------iter.000000 task 04-------------------------- 2025-10-13 10:54:16,721 - INFO : Find old submission; recover submission from json file;submission.submission_hash:c22c94250a2e8edeedca2388333dabd19cbf2f45; machine.context.remote_root:/home/ecust/lws/c22c94250a2e8edeedca2388333dabd19cbf2f45; submission.work_base:iter.000000/01.model_devi; 2025-10-13 10:54:16,736 - INFO : job: 8a607c787cb1d1b40001984d6cc3b2f10fc05d48 29066 finished 2025-10-13 10:54:16,753 - INFO : info:check_all_finished: False 2025-10-13 10:54:16,870 - INFO : job: d646becfdf5e3040b853fccde2c71122896d988f 111123 terminated; fail_cout is 10; resubmitting job 2025-10-13 10:54:16,884 - INFO : job:d646becfdf5e3040b853fccde2c71122896d988f re-submit after terminated; new job_id is 63282 2025-10-13 10:54:17,137 - INFO : job:d646becfdf5e3040b853fccde2c71122896d988f job_id:63282 after re-submitting; the state now is <JobStatus.running: 3> 2025-10-13 10:54:48,186 - INFO : job: d646becfdf5e3040b853fccde2c71122896d988f 63282 finished INFO:dpgen:-------------------------iter.000000 task 05-------------------------- INFO:dpgen:-------------------------iter.000000 task 06-------------------------- INFO:dpgen:system 000 candidate : 240 in 310 77.42 % INFO:dpgen:system 000 failed : 22 in 310 7.10 % INFO:dpgen:system 000 accurate : 48 in 310 15.48 % INFO:dpgen:system 000 accurate_ratio: 0.1548 thresholds: 1.0000 and 1.0000 eff. task min and max -1 20 number of fp tasks: 20 INFO:dpgen:-------------------------iter.000000 task 07-------------------------- 2025-10-13 10:54:49,753 - INFO : info:check_all_finished: False 2025-10-13 10:54:49,759 - INFO : job: 8990a877934816f287da1378d33e5bdd76594d8a submit; job_id is 63693 2025-10-13 10:54:50,776 - INFO : job: 8990a877934816f287da1378d33e5bdd76594d8a 63693 terminated; fail_cout is 1; resubmitting job 2025-10-13 10:54:50,778 - INFO : job:8990a877934816f287da1378d33e5bdd76594d8a re-submit after terminated; new job_id is 63999 2025-10-13 10:54:51,007 - INFO : job:8990a877934816f287da1378d33e5bdd76594d8a job_id:63999 after re-submitting; the state now is <JobStatus.running: 3> 2025-10-13 10:55:21,023 - INFO : job: 8990a877934816f287da1378d33e5bdd76594d8a 63999 terminated; fail_cout is 2; resubmitting job 2025-10-13 10:55:21,025 - INFO : job:8990a877934816f287da1378d33e5bdd76594d8a re-submit after terminated; new job_id is 64320 2025-10-13 10:55:21,255 - INFO : job:8990a877934816f287da1378d33e5bdd76594d8a job_id:64320 after re-submitting; the state now is <JobStatus.running: 3> 2025-10-13 10:55:51,271 - INFO : job: 8990a877934816f287da1378d33e5bdd76594d8a 64320 terminated; fail_cout is 3; resubmitting job Traceback (most recent call last): File "/home/wjj/.local/lib/python3.12/site-packages/dpdispatcher/submission.py", line 356, in handle_unexpected_submission_state job.handle_unexpected_job_state() File "/home/wjj/.local/lib/python3.12/site-packages/dpdispatcher/submission.py", line 855, in handle_unexpected_job_state raise RuntimeError(err_msg) RuntimeError: job:8990a877934816f287da1378d33e5bdd76594d8a 64320 failed 3 times. Possible remote error message: ==> /home/ecust/lws/908a36d8905077a9f8ff1d3d86d69c9db3c9cd0e/task.000.000003/fp.log <== [proxy:0:0@wjj] HYD_spawn (../../../../../src/pm/i_hydra/libhydra/spawn/intel/hydra_spawn.c:177): execvp error on file vasp_std (No such file or directory) [proxy:0:0@wjj] HYD_spawn (../../../../../src/pm/i_hydra/libhydra/spawn/intel/hydra_spawn.c:177): execvp error on file vasp_std (No such file or directory) [proxy:0:0@wjj] HYD_spawn (../../../../../src/pm/i_hydra/libhydra/spawn/intel/hydra_spawn.c:177): execvp error on file vasp_std (No such file or directory) [proxy:0:0@wjj] HYD_spawn (../../../../../src/pm/i_hydra/libhydra/spawn/intel/hydra_spawn.c:177): execvp error on file vasp_std (No such file or directory) The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/home/wjj/.local/bin/dpgen", line 7, in <module> sys.exit(main()) ^^^^^^ File "/home/wjj/.local/lib/python3.12/site-packages/dpgen/main.py", line 255, in main args.func(args) File "/home/wjj/.local/lib/python3.12/site-packages/dpgen/generator/run.py", line 5474, in gen_run run_iter(args.PARAM, args.MACHINE) File "/home/wjj/.local/lib/python3.12/site-packages/dpgen/generator/run.py", line 4826, in run_iter run_fp(ii, jdata, mdata) File "/home/wjj/.local/lib/python3.12/site-packages/dpgen/generator/run.py", line 4047, in run_fp run_fp_inner( File "/home/wjj/.local/lib/python3.12/site-packages/dpgen/generator/run.py", line 4026, in run_fp_inner submission.run_submission() File "/home/wjj/.local/lib/python3.12/site-packages/dpdispatcher/submission.py", line 260, in run_submission self.handle_unexpected_submission_state() File "/home/wjj/.local/lib/python3.12/site-packages/dpdispatcher/submission.py", line 360, in handle_unexpected_submission_state raise RuntimeError( RuntimeError: Meet errors will handle unexpected submission state. Debug information: remote_root==/home/ecust/lws/908a36d8905077a9f8ff1d3d86d69c9db3c9cd0e. Debug information: submission_hash==908a36d8905077a9f8ff1d3d86d69c9db3c9cd0e. Please check error messages above and in remote_root. The submission information is saved in /home/wjj/.dpdispatcher/submission/908a36d8905077a9f8ff1d3d86d69c9db3c9cd0e.json. For furthur actions, run the following command with proper flags: dpdisp submission 908a36d8905077a9f8ff1d3d86d69c9db3c9cd0e
最新发布
10-14
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值