0% found this document useful (0 votes)
10 views7 pages

PDF 24

The document contains Python code snippets for various tasks, including data entry and file handling with pickle, as well as turtle graphics for drawing shapes. It demonstrates how to create, read, and append to text files and includes examples of drawing shapes like squares, circles, and faces using the turtle module. Additionally, it showcases the use of colors and filled shapes in turtle graphics.

Uploaded by

mitanshparmar201
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
10 views7 pages

PDF 24

The document contains Python code snippets for various tasks, including data entry and file handling with pickle, as well as turtle graphics for drawing shapes. It demonstrates how to create, read, and append to text files and includes examples of drawing shapes like squares, circles, and faces using the turtle module. Additionally, it showcases the use of colors and filled shapes in turtle graphics.

Uploaded by

mitanshparmar201
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 7
eS) u 1 oP 13 or oy ay ors 18 ag pis 21 22 Es cy Pi PL 27 28 29 30 cs EP] 33 Ee. import pickle Past ee Tee a ee! meee meee s BLS records = [] n= int(input("How many records do you want to enter? ")) for _ in range(n): rolino = int(input("Enter Roll Number: ")) name = input("Enter Name: ") eee or Cee ee ee UC LD) with open(filename, ‘wb') as file: estsCe Gra Eee ae) Pe eg eer et aera ea) Pe eet Mee ee ee CL ee def search_rollno(filename, search_roll): a with open(filename, ‘rb') as file: records = pickle.load(file) Seo RU te ed Pom a ee eed Pee USGL a) Peat print("Rollno not foun except FileNotFoundError: print("File not found.") ° Pa) filename = ‘students.dat‘ acre meee sett) Pree SORE Ue) tae eT ce ec search_rollno(filename, search_roll) zee Ce ed Ea Oem ete adept eas Ee eh with open("example.txt", "w") as file: file.write("Hello, this is the first line.\n") SSR Ee eke Ga ee ee la ee | UG Seagal a) # Step 2: Read from the file with open("example.txt", "r") as file: content = file.read() eta CU ae ese Pistia tc) # Step 3: Append to the file with open("example.txt", "a") as file: | CeCe Gg |e) ol el fleet Glbe- Me) st tute ei Ea) Seto Ted with open("example.txt", " Fae ekay print("\nReading file line-by-line:"} ate ee Um Se e-t | print(line.strip()) ey i Se ne) 12 a) ac ale) ais) ais 18 ai) 28 21 rd a re aie] 26 rs 28 ri) Bi) 25 ard ce) import turtle # Setup turtle t = turtle.Turtle() ets tt) # Draw Square t-penup() ee teal ee aD ceeerecele el for _ in range(4): eae Tle ele cae ese EA a oe ee aL cae tee Gs ee cee for _ in range(2): cea ese eee cae ae eB eee ale ese ce tse # Draw Circle ees) t.goto(20a, -50) peel t.circle(58) pal eee or] Woo Sy ooh Ln Be luo | a — Cee] vd 13 vey vy mn] l7 mk] 19 ris) 21 nr 23 a 25 ris) 27 ric] 29 i) Bi ard 33 35 36 ce 38 39 oy rd ote as a Esta a) ea t = turtle.Turtle(} t.speed(1) # Filled Square ei) t.goto(-200, @) pee suriy e) t.fillcolor("red"} pegs): oh ee for _ in range(4): ete Cie ene) t.left(99) t.end_fill(} # Filled Rectangle ee) beeen es aD cee ae t.fillcolor("green") t.begin_fill{) for _ in range(2): cede te eel B pan ae ceed a tla Less p Paes at 01:)) t.end_fil1() # Filled Circle eee) pees ee ee beets ae) t.fillcolor("blue"} beds): s hee t.circle(5@) t.end_fill() turtle.done() sly a ee a ee) as a) ae he at) a a] 19 28 21 rr 23 25 vii) rai vii) 29 eae ard 33 eh] 36 Fi 38 Bi ca ce) re) a import turtle Faecal |e el a screen = turtle.Screen() Pie ea ete Oe t = turtle.Turtle() ee # Draw face (yellow circle) cae Pee LD eo ce) t.fillcolor ("yellow") t.begin_fill() t.circle(1090) a # Draw left eye t.penup() t.goto(-35, 20) Peo ee) og ee eT a t.begin_fill() t.circle(18) a ee) # Draw right eye t.penup() t.goto(35, 28) eee ee) t.begin_fill() t.circle(10) oe oe) ae ey t.penup() t.goto(-48, -20@) peta terete gla t.width(5) cee ce) t.circle(5@, 124) care hero iam ae WO oo oun Be ut el cn") aP ai) aE 15. airy vs ai 19 rai) 21 era re] 25 import turtle import colorsys t = turtle. Turtle() cy turtle. bgcolor ("black") alee ee eB Ae ee radius = 200 Ai a] for i in range(7): cae el t.goto(@, -radius) ce te See el) t.pencolor(colorsys.hsv_to_rgb(hue, 1, 1)) t.circle(radius, 189) radius -= 2@ hue += 1/7 t.hideturtle(} cat meee el aes eee ei ee ee ee ee ee ee 2 en ee eee import turtle eee sereen = turtle.Sereen() Pew ecne are not aero say este cerste ec eects Pree sears) Bote) ees Meee tet east oo) fee eee (and SD see e Petes oC) Sate.) cere crtecy) Set tc) erectile) es Ce ee arr) draw_rectangle(“wnite", 38) I Middle Poe e shar ae Ma rd ernst ry chakra = turtle.Turtle() Ty Seo 1a) Se) ee) chakra.color ("blue") ee eer ies) Pe eter e ss) ere) Pee eds eee eee One) chakra. forward(35) Beers) Pe tescemot sta er res aee sea aces olympic .pensize(5) Con eed) Pe eter Rote gtr castrey positions = [(-128, -156), (@, 15), (128, -158), (-68, -288), (68, -298)] Ste gst eee es cena ra enor seasu See rOber esters cs olympic.penup() risers) toro ts) olympic.color(coler) olympic.cirele(sa) se Eeera Cras 15) Per ecras tay Ptostaoeetastts] naan) cases ate) 1

You might also like