Filename=open('StudentBio.txt','w')
Name=1
fathername=1
Nationality=1
religion=1
if Name==1 and fathername==0 and Nationality==1 and religion==1:
print('You are Eligible for Admission\nCongratualation')
else:
print('Tick All The Above boxes That You Have To fill')
def StudentBiography(Name,fathername,Nationality,religion):
Name=input('Enter Name Of student : ')
fathername=input('Enter Name Of father : ')
Nationality=input('Enter Nationality :')
religion=input('Enter Religion : ')
all_info=[Name,fathername,Nationality,religion]
return all_info
def Grading(Maths,Islamiat,English):
A=Maths+Islamiat+English
B=(A/300)*100
C=[Maths,Islamiat,English]
return (B,C)
for i in range(2):
a=StudentBiography(Name,fathername,Nationality,religion)
f=str(a)
Filename.write(f)
for j in range(2):
Maths = eval(input('Enter no : '))
Islamiat = eval(input('Enter no : '))
English = eval(input('Enter no : '))
b=Grading(Maths,Islamiat,English)
g=str(b)
Filename.write(g)
Filename.close()
please Help me I need Serious Help
答案 0 :(得分:-1)
据我了解,您想将学生信息写入文本文件。首先,我认为您应该阅读有关Python语法的更多信息,并开始编写脚本。例如,在Python中,变量和函数应以小写字母开头,并且您需要在=
符号和类似符号之间加空格。我会尽力帮助您。
def get_student_bio():
name = input('Enter Name Of student : ')
father_name = input('Enter Name Of father : ')
nationality = input('Enter Nationality :')
religion = input('Enter Religion : ')
return ' '.join([name, father_name, nationality, religion])
def get_student_grade():
math = input('Enter no : ')
islamiat = input('Enter no : ')
english = input('Enter no : ')
avg = str(sum(float(math) + float(islamiat) + float(english)) / 3)
return ' '.join([avg, math, islamiat, english])
fileobj = open('StudentBio.txt','w')
for i in range(2):
bio = get_student_bio()
grades = get_student_grades()
fileobj.write(bio + ' ' + grades + '\n')
fileobj.close()
我假设您正在尝试输入学生简历,然后逐一评分,并将其写在文本文件中。这是实现此目的的一种方法。我试图使其与您的操作方式保持相似,因此可能更容易理解。不过,我摆脱了最初的if
声明,因为我不确定您要达到的目标。无论如何,希望这是有用的。