Save information in the file
Write a program thatStudent Name and NumberReceive users and in a file namedStudents.txtSave. Also, after each storage, display the entire information of this file at the output.
Write a program thatStudent Name and NumberReceive users and in a file namedStudents.txtSave. Also, after each storage, display the entire information of this file at the output.
name = input('name: ') | |
code = input('code: ') | |
f = open('students.txt', 'a') | |
f.write(name + '\n') | |
f.write(code + '\n') | |
f.close() | |
f = open('students.txt', 'r') | |
print(f.read()) | |
f.close() |
import os | |
def save_student_data(): | |
with open('student.txt','w') as file: | |
while 1: | |
name=input('enter student name(for end enter exit):') | |
if name.lower()=='exit': | |
break | |
student_id=input('enter student number:') | |
file.write(f'{name},{student_id}\n') | |
file.flush() | |
file_size=os.path.getsize('student.txt') | |
print(f'file size saved:{file_size}bite') | |
save_student_data() |
Submitting answers is currently unavailable.
Write a program that receives a number of input and from that number to zero countdown and prints in the output
Write a class that receives two numbers and the methods of subtraction, multiplication and division can be called. By calling each method, the necessary calculations are required and the result is returned in
Write a function that receives a text and returns the first 100 characters with "..." if the text is longer than 100 characters. Otherwise it will restore the whole text unchanged.
Write a program that gets the user's age from the input and calculates and prints the user's birthday
Write a program that receives students' scores and names and prints from the highest to the lowest score, respectively
Write a program that receives 2 users and calculates the Fibonacci series (between those two) and prints in the output
برای استفاده از این بخش باید وارد حساب کاربریت بشی
ورود/ثبت نام If you don’t understand the exercise or can’t solve it for any reason, that’s completely
normal—don’t worry 😊
Try checking out easier exercises and reviewing different answers
submitted by others. Gradually, you can move on to more challenging exercises. Also, your answer
might be correct even if it’s different from others.