Created
October 1, 2021 04:53
-
-
Save smith0022/6a9881e0af980e620f9175c73de0df90 to your computer and use it in GitHub Desktop.
an program file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Write a program that rotates the elements of a list so that the element at | |
the first index moves to the second index, the element in the second | |
index moves to the third index, etc., and the element at the last moves to | |
the first index.""" | |
"question 9" | |
# def lower_case(): | |
# ob = open("/Users/mahantsmith/Library/Application Support/JetBrains/PyCharmCE2020.3/scratches/file14fun.txt") | |
# fb = open("lower_file14fun.txt","w") | |
# j = ob.readlines() | |
# for x in j: | |
# if x[0].islower(): | |
# fb.write(x) | |
# ob.close() | |
# fb.close() | |
# lower_case() | |
"question 10" | |
# def fun1(): | |
# ob = open("/Users/mahantsmith/Library/Application Support/JetBrains/PyCharmCE2020.3/scratches/file14fun.txt") | |
# print(max(ob.readlines(),key=len)) | |
# fun1() | |
"question 11" | |
# ob = open("/Users/mahantsmith/Library/Application Support/JetBrains/PyCharmCE2020.3/scratches/file14fun.txt") | |
# n = ob.readlines() | |
# for x in n: | |
# if x[0] == "k" or x[0] == "K": | |
# print(x) | |
"question 12" | |
# ob = open("/Users/mahantsmith/Library/Application Support/JetBrains/PyCharmCE2020.3/scratches/file14fun.txt") | |
# n = ob.readlines() | |
# for x in n: | |
# if len(x)>20: | |
# print(x) | |
"question 13" | |
# import random | |
# ob = open("/Users/mahantsmith/Library/Application Support/JetBrains/PyCharmCE2020.3/scratches/file14fun.txt") | |
# n = ob.readlines() | |
# print(random.choice(n)) | |
"question 14" | |
import pickle | |
import os | |
def writing(): | |
ob = open("library.dat","w") | |
while True: | |
book_no = int(input("enter the book number :")) | |
book_name = input("enter the book name :") | |
author_name = int(input("enter the author name :")) | |
pickle.dump([book_no,book_name,author_name],ob) | |
k = input("do you want to continue[y/n] :") | |
if k == "n" or k == "N": | |
break | |
ob.close() | |
def reading(): | |
ob = open("library.dat") | |
"question 15" | |
# import csv | |
# import os | |
# | |
# | |
# def writing(): | |
# ob = open("student.csv", "w", newline="") | |
# csv_w = csv.writer(ob) | |
# l=[] | |
# while True: | |
# roll_no = int(input("Enter roll no:")) | |
# name = input("Enter name:") | |
# mark = int(input("Enter mark:")) | |
# stream = input("Enter stream:") | |
# l.append([roll_no,name,mark,stream]) | |
# k = input("want ot continue") | |
# if k == "n": | |
# break | |
# for x in l: | |
# csv_w.writerow(x) | |
# ob.close() | |
# | |
# | |
# def reading(): | |
# ob = open("student.csv", "r") | |
# csv_r = csv.reader(ob) | |
# for i in csv_r: | |
# print(i) | |
# | |
# | |
# def searching(): | |
# ob = open("student.csv", "r") | |
# csv_r = csv.reader(ob) | |
# name = input("enter the name to search:") | |
# found = 0 | |
# for i in csv_r: | |
# if i[0] == name: | |
# found = 1 | |
# print(i) | |
# if found == 0: | |
# print("name not found") | |
# | |
# | |
# def update(): | |
# obs = open("dubstudent.csv", "w", newline="") | |
# csv_ws = csv.writer(obs) | |
# ob = open("student.csv", "r") | |
# csv_r = csv.reader(ob) | |
# name = input("enter the name to update") | |
# l = [] | |
# for i in csv_r: | |
# if i[0] == name: | |
# mark = input("enter the new mark") | |
# l.append([i[0], mark]) | |
# else: | |
# l.append(i) | |
# for x in l: | |
# csv_ws.writerow(x) | |
# obs.close() | |
# ob.close() | |
# os.remove("student.csv") | |
# os.rename("dubstudent.csv","student.csv") | |
# | |
# def delete(): | |
# obs = open("dubstudent.csv", "w", newline="") | |
# csv_ws = csv.writer(obs) | |
# ob = open("student.csv", "r") | |
# csv_r = csv.reader(ob) | |
# name = input("enter the name to update") | |
# l = [] | |
# for i in csv_r: | |
# if i[0] == name: | |
# pass | |
# else: | |
# l.append(i) | |
# for x in l: | |
# csv_ws.writerow(x) | |
# obs.close() | |
# ob.close() | |
# os.remove("student.csv") | |
# os.rename("dubstudent.csv", "student.csv") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment