- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在制作一个包含设计和所有内容的标记表,我已经完成了在字符串上使用格式设置的所有操作,一切都很好,但我在 3 个地方遇到了问题,下面是我的代码,在代码之后我还将给出结果,这样你就可以看到我在哪里遇到问题。问题出在分数和总计上。
from datetime import datetime
year=datetime.now().year
date=datetime.now().strftime("%d-%m-%Y")
while True:
while True:
Name=input("\nType your name:")
if len(Name)==0:
print('''"You made mistake while filling name section"''')
else:
break
while True:
F_Name=input("\nType father name:")
if len(F_Name)==0:
print('''"You made mistake while filling f.name section"''')
else:
break
while True:
School=input("\nType your school name:")
if len(School)==0:
print('''"You made mistake while filling school section"''')
else:
break
while True:
Group=input("\nType your group eg.Science,Arts:")
if len(Group)==0:
print('''"You made mistake while filling group section"''')
else:
break
while True:
Board=input("\nType name of your board:")
if len(Board)==0:
print('''"You made mistake while filling board section"''')
else:
break
while True:
try:
num1 = int(input('\nEnter number of total subjects:'))
except ValueError:
print('''\n"Please enter only number"''')
else:
break
l_Subjects=[]
l_T_Marks=[]
l_Marks=[]
S_numbers=["first","second","third","fourth","fifth","sixth","seventh","eighth","ninth","tenth","eleventh","twelth","thirteenth","fourteenth","fifteenth","sixteenth","eighteenth","nineteenth","twentieth"]
for i in range(num1):
print(f'''\n"For the {S_numbers.pop(0)} subject"\n''')
Subjects=input("Type subject name:")
l_Subjects.append(Subjects)
while True:
try:
T_Marks= int(input(f'Enter total marks for {Subjects}:'))
l_T_Marks.append(T_Marks)
while True:
try:
Marks = int(input('Enter obtained marks:'))
except ValueError:
print('''\n"Please enter only number"''')
if Marks>T_Marks:
print('''\n"Please insert correct marks"''')
else:
l_Marks.append(Marks)
break
except ValueError:
print('''\n"Please enter only number"''')
else:
break
print('''\n\n "Here is your Marksheet"\n\n''')
print("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
print(f"{'§': <80}§")
print(f"{'§': <80}§")
print(f"§ {Board.title(): <54}§")
print(f"{'§': <80}§")
print(f"{'§': <80}§")
print(f"§ Examination Annual {year: <51}§")
print(f"{'§': <80}§")
print(f"§ Name {Name.title(): <58}§")
print(f"{'§': <80}§")
print(f"§ F.Name {F_Name.title(): <58}§")
print(f"{'§': <80}§")
print(f"§ School/Private {School.title(): <58}§")
print(f"{'§': <80}§")
print(f"§ Group {Group.title(): <58}§")
print(f"{'§': <80}§")
print("§ _________________________________________________________________________ §")
print("§ | | §")
print("§ | Subjects | §")
print("§ |_________________________________________________________________________| §")
print("§ | Component | Marks | §")
print("§ |__________________________________|______________________________________| §")
l_T_Marks1=list(l_T_Marks)
l_Marks1=l_Marks.copy()
l_Subjects1=l_Subjects.copy()
for i in list(l_Marks):
print(f"§ | {l_Subjects.pop(0): <22}| {l_Marks.pop(0)}/{l_T_Marks.pop(0): <17}| §")
print(f"§ |__________________________________|______________________________________| §")
Sum_Marks=(sum(l_Marks1))
Sum_T_Marks=(sum(l_T_Marks1))
Percentage=(Sum_Marks/Sum_T_Marks)*100
if(Percentage>=80):
Grade='A+'
elif(Percentage>=70 and Percentage<80):
Grade='A'
elif(Percentage>=60 and Percentage<70):
Grade='B'
elif(Percentage>=50 and Percentage<60):
Grade='C'
elif(Percentage>=40 and Percentage<50):
Grade='D'
else:
Failed=('''"Sorry! You have failed the exam." §''')
Grade='F'
print(f"{'§': <80}§")
print(f"{'§': <80}§")
print(f"§ Grand Total {Sum_Marks} out of {Sum_T_Marks:<25}§")
print(f"{'§': <80}§")
print("§ _______ §")
print("§ | | §")
print(f"§ Grade | {Grade.title(): <4}| §")
print("§ |_______| §")
if Grade=='F':
print(f"{'§': <80}§")
print(f"§ {Failed: <5}")
print(f"{'§': <80}§")
print("§ Waseem Munir §")
print("§ _________________________ §")
print("§ Controller of Examination §")
print(f"{'§': <80}§")
print(f"§ Dated:{date: <72}§")
print(f"{'§': <80}§")
print(f"{'§': <80}§")
print("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
while True:
Repeat=input("\nDo you want to repeat?\n\nYes or No:")
Repeat=Repeat.lower()
if Repeat not in ["yes","y","no","n"]:
print('''"\nPlease select correct option"''')
else:
break
if Repeat in ["yes","y"]:
continue
else:
if Repeat in ["no","n"]:
print("\n-----Thank you for using-----")
input()
break
"Here is your Marksheet"
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
§ §
§ §
§ Bermingham Board §
§ §
§ §
§ Examination Annual 2019 §
§ §
§ Name John Michael §
§ §
§ F.Name Brad Michael §
§ §
§ School/Private Bermingham High School §
§ §
§ Group Science §
§ §
§ _________________________________________________________________________ §
§ | | §
§ | Subjects | §
§ |_________________________________________________________________________| §
§ | Component | Marks | §
§ |__________________________________|______________________________________| §
§ | Maths | 76/100 | §
§ |__________________________________|______________________________________| §
§ | English | 81/100 | §
§ |__________________________________|______________________________________| §
§ §
§ §
§ Grand Total 157 out of 200 §
§ §
§ _______ §
§ | | §
§ Grade | A | §
§ |_______| §
§ §
§ Waseem Munir §
§ _________________________ §
§ Controller of Examination §
§ §
§ Dated:04-07-2019 §
§ §
§ §
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Do you want to repeat?
Yes or No:
最佳答案
您必须在整数输出中遇到问题的所有 3 个位置使用字符,您需要更改 {Sum_T_Marks:<25} 中的总计 {Sum_Marks:>3 或 4 #(根据每个输出的需要)}§ ")。我已更正下面的代码。
from datetime import datetime
year=datetime.now().year
date=datetime.now().strftime("%d-%m-%Y")
while True:
while True:
Name=input("\nType your name:")
if len(Name)==0:
print('''"You made mistake while filling name section"''')
else:
break
while True:
F_Name=input("\nType father name:")
if len(F_Name)==0:
print('''"You made mistake while filling f.name section"''')
else:
break
while True:
School=input("\nType your school name:")
if len(School)==0:
print('''"You made mistake while filling school section"''')
else:
break
while True:
Group=input("\nType your group eg.Science,Arts:")
if len(Group)==0:
print('''"You made mistake while filling group section"''')
else:
break
while True:
Board=input("\nType name of your board:")
if len(Board)==0:
print('''"You made mistake while filling board section"''')
else:
break
while True:
try:
num1 = int(input('\nEnter number of total subjects:'))
except ValueError:
print('''\n"Please enter only number"''')
else:
break
l_Subjects=[]
l_T_Marks=[]
l_Marks=[]
S_numbers=["first","second","third","fourth","fifth","sixth","seventh","eighth","ninth","tenth","eleventh","twelth","thirteenth","fourteenth","fifteenth","sixteenth","eighteenth","nineteenth","twentieth"]
for i in range(num1):
print(f'''\n"For the {S_numbers.pop(0)} subject"\n''')
Subjects=input("Type subject name:")
l_Subjects.append(Subjects)
while True:
try:
T_Marks= int(input(f'Enter total marks for {Subjects}:'))
l_T_Marks.append(T_Marks)
while True:
try:
Marks = int(input('Enter obtained marks:'))
except ValueError:
print('''\n"Please enter only number"''')
if Marks>T_Marks:
print('''\n"Please insert correct marks"''')
else:
l_Marks.append(Marks)
break
except ValueError:
print('''\n"Please enter only number"''')
else:
break
print('''\n\n "Here is your Marksheet"\n\n''')
print("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
print(f"{'§': <80}§")
print(f"{'§': <80}§")
print(f"§ {Board.title(): <54}§")
print(f"{'§': <80}§")
print(f"{'§': <80}§")
print(f"§ Examination Annual {year: <51}§")
print(f"{'§': <80}§")
print(f"§ Name {Name.title(): <58}§")
print(f"{'§': <80}§")
print(f"§ F.Name {F_Name.title(): <58}§")
print(f"{'§': <80}§")
print(f"§ School/Private {School.title(): <58}§")
print(f"{'§': <80}§")
print(f"§ Group {Group.title(): <58}§")
print(f"{'§': <80}§")
print("§ _________________________________________________________________________ §")
print("§ | | §")
print("§ | Subjects | §")
print("§ |_________________________________________________________________________| §")
print("§ | Component | Marks | §")
print("§ |__________________________________|______________________________________| §")
l_T_Marks1=list(l_T_Marks)
l_Marks1=l_Marks.copy()
l_Subjects1=l_Subjects.copy()
for i in list(l_Marks):
print(f"§ | {l_Subjects.pop(0): <22}| {l_Marks.pop(0):>4}/{l_T_Marks.pop(0): <16}| §")
print(f"§ |__________________________________|______________________________________| §")
Sum_Marks=(sum(l_Marks1))
Sum_T_Marks=(sum(l_T_Marks1))
Percentage=(Sum_Marks/Sum_T_Marks)*100
if(Percentage>=80):
Grade='A+'
elif(Percentage>=70 and Percentage<80):
Grade='A'
elif(Percentage>=60 and Percentage<70):
Grade='B'
elif(Percentage>=50 and Percentage<60):
Grade='C'
elif(Percentage>=40 and Percentage<50):
Grade='D'
else:
Failed=('''"Sorry! You have failed the exam." §''')
Grade='F'
print(f"{'§': <80}§")
print(f"{'§': <80}§")
print(f"§ Grand Total {Sum_Marks:>4} out of {Sum_T_Marks:<23}§")
print(f"{'§': <80}§")
print("§ _______ §")
print("§ | | §")
print(f"§ Grade | {Grade.title(): <4}| §")
print("§ |_______| §")
if Grade=='F':
print(f"{'§': <80}§")
print(f"§ {Failed: <5}")
print(f"{'§': <80}§")
print("§ Waseem Munir §")
print("§ _________________________ §")
print("§ Controller of Examination §")
print(f"{'§': <80}§")
print(f"§ Dated:{date: <72}§")
print(f"{'§': <80}§")
print(f"{'§': <80}§")
print("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
while True:
Repeat=input("\nDo you want to repeat?\n\nYes or No:")
Repeat=Repeat.lower()
if Repeat not in ["yes","y","no","n"]:
print('''"\nPlease select correct option"''')
else:
break
if Repeat in ["yes","y"]:
continue
else:
if Repeat in ["no","n"]:
print("\n-----Thank you for using-----")
input()
break
关于python - 格式化整数输出时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56886771/
我对 c# 有点陌生,我在尝试围绕这个 if-then 语句尝试实现时遇到了一些麻烦。 这是我的目标:当用户将订单输入系统时,将为每个订单创建一个唯一的 orderID。但是,一些附加功能是用户可以选
我已经搜索了这个特定的错误,发现根本问题涉及循环计数错误并导致程序超出数组的界限。 但是,当我将每个数组降低到数组开始丢失输出数据的程度后,它继续抛出相同的错误。我对 C/C++ 仍然是新手,但任何对
我不明白为什么我运行这个小程序时屏幕上没有任何显示? while 循环甚至开始了吗? #include #include int main() { char word[20]; char
我接手了一个用 Perl 编写的项目,它有一些依赖项,例如 Template::Toolkit , Image::ExifTool , 和 GD仅举几例。目前,这些依赖项使用 --prefix 构建到
我想对一个字段进行累积总和,但只要遇到 0 就重置聚合值。 这是我想要的一个例子: data.frame(campaign = letters[1:4] , date=c("jan","
不久前,该项目的 gradle 构建运行良好,但现在一直失败并显示以下错误(带有 --info 标志的输出): Starting process 'Gradle Test Executor 1'. W
我是编程新手,想用 Java 制作一个掷骰子程序来执行。代码如下: import java.math.*; public class Dices { public static int dice1=0
这个问题已经有答案了: What is a StringIndexOutOfBoundsException? How can I fix it? (1 个回答) 已关闭 5 年前。 我对 Java 完
这个方法一直抛出标题中的异常,我找不到原因,我已经通过连接创建了其他表,并且所有引用的表都已创建。我正在使用嵌入式JavaDB . private void createEvidenceTable()
我刚开始上课,这是我第三次尝试上课。我遇到了一个 NameError,我真的不知道如何解决。看看我的程序,看看你能不能帮忙。 import random import math import pyga
好吧,这是我的困境,我向 JFrame 添加了三个面板。第一个(不可见)第二个(可见)和第三个(不可见)..我使用第一个面板作为菜单,当您选择一个选项时,第一个面板被制作(可见),然后第三个面板被制作
我的部分代码遇到问题。如果我选择选项 A,它会运行并给我正确的答案,但是,如果我选择选项 S 或 M,它不会给我任何结果,只会去到它应该去的地方。已经尝试将 if 更改为 else if,但它显示“预
我这里有一些代码,但我正在努力解决它,因为我似乎无法掌握这个文件指针的东西。我对使用文件还很陌生。我见过类似的其他问题,并且尝试了对其他人有效的解决方案,但由于某种原因它们对我不起作用。这是出现问题的
我们有一个很大的应用程序,我们已经将 TODO 规则添加到质量门中,如果发现 TODO 注释,它会给出错误。如果我们只是删除 TODO 注释(这很可怕),它会起作用,但添加 TODO 注释的整个目的就
我正在尝试编写一个名为 isVowel 的函数,它接受一个字符(即长度为 1 的字符串)并在它是元音、大写或小写时返回“true”。如果该字符不是元音字母,该函数应返回“false”。 这看起来应该可
我一直在努力完成我正在做的这个小项目,但由于某种原因它无法正常工作。 问题是当我第一次访问该页面并单击出现在主要部分中的第一个链接时,它会根据需要显示弹出框。现在,当我点击另一天,例如星期天并尝试点击
我正在尝试制作一个 WPF 应用程序。我的窗口内有一个数据网格。我制作了另一个窗口,将新数据添加到我的数据网格中。虽然它按照我想要的方式工作,但我不断遇到异常。我的 MySQL 代码: using S
我试图在我似乎无法使 NSUserDefaults 正常工作的程序中保存几个首选项。如果有人可以查看我的代码并查看是否有任何错误,我们将不胜感激 NSString *kGameIsPaused = @
设置 SymmetricDS版本是3.9.1(也试过3.9.0) 设置是从 postgres 9.5.3 到 postgres 9.5.3 Windows 10 pc(客户端节点)到 Windows
经过长时间的努力,我终于(差不多)完成了我的java菜单程序。但是,我无法让我的返回更改功能在我的代码末尾工作。它给出了非常奇数的数字。有什么想法吗? 代码: import java.io.*; im
我是一名优秀的程序员,十分优秀!