Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi, I need help write this program in Python Write a program that reads a file of numbers of type int and writes all the

Hi, I need help write this program in Python

Write a program that reads a file of numbers of type int and writes all the numbers to another file, but without any duplicate numbers. Assume that the numbers in the input file are already ordered from smallest to largest. After the program is run, the new file will contain all the numbers in the original file, but no number will appear more than once in the file. The numbers in the output file should also be sorted from smallest to largest. Your program should obtain both file names from the user. The input files is a text-file with one number per line. In addition, everything written to the output file should also be written to the screen/monitor so that the user is aware of where the program is in processing.

Make sure to use exception handling around all user input and file processing.

Case 1: Use the input file:

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

2

2

2

2

2

2

2

2

2

2

2

2

2

2

2

2

2

2

2

3

3

3

3

3

3

3

3

3

3

3

3

3

3

3

3

3

3

3

3

3

3

3

3

3

4

4

4

4

4

4

4

4

4

4

4

4

4

4

4

4

4

4

4

4

4

5

5

5

5

5

5

5

5

5

5

5

5

5

5

5

5

5

5

6

6

6

6

6

6

6

6

6

6

6

6

6

6

6

6

6

6

6

6

6

6

6

6

7

7

7

7

7

7

7

7

7

7

7

7

7

7

7

7

7

7

7

7

7

7

7

7

7

7

7

7

7

7

8

8

8

8

8

8

8

8

8

8

8

8

8

8

8

8

8

9

9

9

9

9

9

9

9

9

9

9

9

9

9

9

9

9

9

9

9

9

9

9

10

10

10

10

10

10

10

10

10

10

10

10

10

10

10

10

10

10

10

10

10

10

10

10

11

11

11

11

11

11

11

11

11

12

12

12

12

12

12

12

12

12

12

12

12

12

12

12

12

12

12

12

12

12

12

12

12

12

13

13

13

13

13

13

13

13

13

13

13

13

13

13

13

13

13

13

13

13

13

13

13

13

13

14

14

14

14

14

14

14

14

14

14

14

14

14

14

14

14

14

14

15

15

15

15

15

15

15

15

15

15

15

15

15

15

15

15

15

15

15

15

15

15

15

15

15

15

15

15

15

15

16

16

16

16

16

16

16

16

16

16

16

16

16

16

16

16

16

16

16

16

16

17

17

17

17

17

17

17

17

17

17

17

17

17

17

17

17

17

17

17

17

17

17

17

17

17

17

17

17

18

18

18

18

18

18

18

18

18

18

18

18

18

18

18

18

18

18

19

19

19

19

19

19

19

19

19

19

19

19

19

19

19

19

19

19

19

19

19

19

19

20

20

20

20

20

20

20

20

20

20

20

20

20

20

20

20

20

20

20

21

21

21

21

21

21

21

21

21

21

21

21

21

21

21

21

21

21

21

21

21

21

21

21

21

21

21

21

21

21

21

21

22

22

22

22

22

22

22

22

22

22

22

22

22

22

22

22

22

22

22

23

23

23

23

23

23

23

23

23

23

23

23

23

23

23

23

23

23

23

23

23

23

24

24

24

24

24

24

24

24

24

24

24

24

24

24

24

24

24

24

24

24

24

24

25

25

25

25

25

25

25

25

25

25

25

25

25

25

25

25

25

25

25

26

26

26

26

26

26

26

26

26

26

26

26

26

26

26

26

26

26

26

26

26

26

26

26

27

27

27

27

27

27

27

27

27

27

27

27

27

27

27

27

27

27

27

27

27

28

28

28

28

28

28

28

28

28

28

28

28

28

28

28

28

28

28

28

28

28

29

29

29

29

29

29

29

29

29

29

29

29

29

29

29

29

29

30

30

30

30

30

30

30

30

30

30

30

30

30

30

30

30

30

30

30

30

30

30

31

31

31

31

31

31

31

31

31

31

31

31

31

31

31

31

31

31

31

31

31

32

32

32

32

32

32

32

32

32

32

32

32

32

32

32

32

32

32

32

32

32

32

32

32

32

32

33

33

33

33

33

33

33

33

33

33

33

33

33

33

33

33

33

33

33

33

33

33

33

33

33

33

33

33

33

33

34

34

34

34

34

34

34

34

34

34

34

34

34

34

35

35

35

35

35

35

35

35

35

35

35

35

35

35

35

35

35

35

35

35

35

35

35

35

35

35

36

36

36

36

36

36

36

36

36

36

36

36

36

36

36

36

36

36

36

37

37

37

37

37

37

37

37

37

37

37

37

37

37

37

37

37

37

37

37

37

37

37

37

37

37

37

38

38

38

38

38

38

38

38

38

38

38

38

38

38

38

38

38

38

38

38

38

39

39

39

39

39

39

39

39

39

39

39

39

39

39

39

39

39

39

39

39

40

40

40

40

40

40

40

40

40

40

40

40

40

40

40

40

40

40

40

40

40

40

40

40

40

40

41

41

41

41

41

41

41

41

41

41

41

41

41

41

41

41

41

41

41

41

41

41

41

42

42

42

42

42

42

42

42

42

42

42

42

42

42

42

42

42

42

42

42

43

43

43

43

43

43

43

43

43

43

43

43

43

43

43

43

43

43

43

43

43

43

43

44

44

44

44

44

44

44

44

44

44

44

44

44

44

44

44

44

44

44

44

44

44

44

44

44

44

45

45

45

45

45

45

45

45

45

45

45

45

45

45

45

45

45

45

45

45

45

45

45

45

45

45

45

46

46

46

46

46

46

46

46

46

46

46

46

46

46

47

47

47

47

47

47

47

47

47

47

47

47

47

47

47

47

47

47

47

47

47

47

47

47

47

47

47

47

47

47

47

47

47

47

47

50

50

50

50

50

50

50

50

50

50

50

50

50

50

50

51

51

51

51

51

51

51

51

51

51

51

51

51

51

51

51

51

51

51

51

51

51

51

51

51

52

52

52

52

52

52

52

52

52

52

52

52

52

52

52

52

52

52

52

52

52

52

52

52

52

52

52

53

53

53

53

53

53

53

53

53

53

53

53

53

53

53

53

53

53

53

53

53

53

53

54

54

54

54

54

54

54

54

54

54

54

54

54

54

54

54

54

54

55

55

55

55

55

55

55

55

55

55

55

55

55

55

55

55

55

55

55

55

56

56

56

56

56

56

56

56

56

56

56

56

56

56

56

56

56

57

57

57

57

57

57

57

57

57

57

57

57

57

57

57

57

57

57

57

57

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

58

59

59

59

59

59

59

59

59

59

59

59

59

59

59

59

59

59

60

60

60

60

60

60

60

60

60

60

60

60

60

60

60

60

60

60

60

60

60

60

60

60

60

60

60

60

60

61

61

61

61

61

61

61

61

61

61

61

61

61

61

61

61

61

61

61

61

61

61

61

61

61

61

62

62

62

62

62

62

62

62

62

62

62

62

62

62

62

62

62

63

63

63

63

63

63

63

63

63

63

63

63

63

63

63

63

63

63

64

64

64

64

64

64

64

64

64

64

64

64

64

64

64

64

64

64

64

64

64

64

64

64

64

64

64

64

64

64

65

65

65

65

65

65

65

65

65

65

65

65

65

65

65

65

65

65

65

65

65

65

65

65

65

65

65

65

65

65

65

65

65

65

65

66

66

66

66

66

66

66

66

66

66

66

66

66

66

66

66

66

66

66

66

66

67

67

67

67

67

67

67

67

67

67

67

67

67

67

67

67

67

67

67

68

68

68

68

68

68

68

68

68

68

68

68

68

68

68

68

68

68

68

68

68

68

68

68

68

68

68

69

69

69

69

69

69

69

69

69

69

69

69

69

69

69

69

69

69

69

69

70

70

70

70

70

70

70

70

70

70

70

70

70

70

70

70

70

70

70

70

70

70

70

70

70

71

71

71

71

71

71

71

71

71

71

71

71

71

71

71

71

71

71

71

71

71

71

71

71

71

71

71

72

72

72

72

72

72

72

72

72

72

72

72

72

72

72

72

72

72

72

72

72

72

72

72

72

72

72

72

73

73

73

73

73

73

73

73

73

73

73

73

73

73

73

73

73

73

73

73

73

73

76

76

76

76

76

76

76

76

76

76

76

76

76

76

76

76

76

76

77

77

77

77

77

77

77

77

77

77

77

77

77

77

77

77

77

77

77

77

77

77

77

77

77

77

78

78

78

78

78

78

78

78

78

78

78

78

78

78

78

78

78

78

78

78

78

78

78

78

78

78

78

78

78

78

79

79

79

79

79

79

79

79

79

79

79

79

79

79

79

79

79

79

79

79

79

80

80

80

80

80

80

80

80

80

80

80

80

80

80

80

80

80

80

80

80

80

80

80

80

80

80

80

80

81

81

81

81

81

81

81

81

81

81

81

81

81

81

81

81

81

81

81

81

81

81

81

81

81

81

81

81

81

81

81

82

82

82

82

82

82

82

82

82

82

82

82

82

82

82

82

82

82

82

82

82

82

82

82

82

83

83

83

83

83

83

83

83

83

83

83

83

83

83

83

83

83

83

83

83

84

84

84

84

84

84

84

84

84

84

84

84

84

84

84

84

84

84

84

84

84

84

84

84

84

85

85

85

85

85

85

85

85

85

85

85

85

85

85

85

85

85

85

85

85

85

85

85

86

86

86

86

86

86

86

86

86

86

86

86

86

86

86

86

86

86

86

86

87

87

87

87

87

87

87

87

87

87

87

87

87

87

87

87

87

87

88

88

88

88

88

88

88

88

88

88

88

88

88

88

88

88

88

88

88

88

89

89

89

89

89

89

89

89

89

89

89

89

89

89

89

89

89

89

89

89

89

89

89

89

89

89

89

89

89

89

89

90

90

90

90

90

90

90

90

90

90

90

90

90

90

90

90

90

90

90

90

90

90

90

90

91

91

91

91

91

91

91

91

91

91

91

91

91

91

91

91

91

91

91

91

91

91

91

91

91

92

92

92

92

92

92

92

92

92

92

92

92

92

92

92

92

92

92

92

92

93

93

93

93

93

93

93

93

93

93

93

93

93

93

93

93

93

93

93

93

93

93

93

93

93

93

93

93

93

93

93

94

94

94

94

94

94

94

94

94

94

94

94

94

94

94

94

94

94

94

94

94

94

95

95

95

95

95

95

95

95

95

95

95

95

95

95

95

95

95

95

95

95

95

95

95

96

96

96

96

96

96

96

96

96

96

96

96

96

96

96

96

96

96

96

96

96

96

96

96

96

96

96

96

96

96

96

97

97

97

97

97

97

97

97

97

97

97

97

97

97

97

97

97

97

97

97

97

97

97

98

98

98

98

98

98

98

98

98

98

98

98

98

98

98

98

98

98

98

98

98

98

98

99

99

99

99

99

99

99

99

99

99

99

99

99

99

99

99

99

99

99

99

99

99

99

99

100

100

100

100

100

100

100

100

100

100

100

100

100

Write your output to file, OutputNumbers.txt

Case 2: Use the input file:

63

213

266

346

417

450

633

761

871

872

927

1136

1159

1207

1230

1263

1266

1337

1373

1570

1818

1886

1950

2008

2008

2032

2089

2095

2148

2265

2391

2557

2735

2749

2786

2819

2966

3034

3037

3080

3137

3188

3232

3306

3463

3469

3493

3761

3825

3834

3880

3889

3961

4047

4109

4414

4468

4498

4568

4659

4687

4710

4752

4774

4798

5007

5028

5058

5322

5490

5570

5639

5659

5706

5810

5911

5928

5975

6001

6261

6383

6612

6734

6749

6929

7192

7228

7448

7518

7543

7571

7801

7828

7856

7876

8029

8097

8230

8462

8525

8562

8605

8633

8643

8701

8734

8745

9014

9018

9057

9063

9129

9186

9386

9389

9402

9434

9480

9543

9635

9713

9899

9926

9933

9987

10031

10033

10106

10328

10434

10582

10658

10818

10862

11038

11102

11143

11175

11223

11327

11511

11544

11583

11584

11696

11704

11742

11958

11981

12019

12122

12143

12196

12309

12321

12365

12510

12520

12526

12719

12994

13088

13204

13288

13376

13411

13515

13526

13549

13595

13694

13724

13825

13841

13908

13919

13927

13931

14082

14136

14196

14278

14293

14386

14470

14505

14583

14636

14638

14697

14857

15046

15049

15054

15337

15348

15380

15593

15843

15863

15982

15985

15994

16006

16073

16434

16605

16619

16666

16750

16774

16809

16929

17074

17166

17166

17273

17433

17889

17921

17944

18118

18126

18380

18420

18510

18675

18824

18872

18895

19078

19118

19247

19388

19429

19560

19596

19740

19908

19981

20054

20467

20517

20575

20587

20729

20840

21001

21123

21129

21248

21395

21453

21624

21710

21926

22148

22220

22329

22368

22391

22467

22483

22513

22559

22812

22882

22952

22958

23014

23037

23037

23043

23054

23143

23364

23413

23606

23627

23652

23689

23738

23770

23891

23957

24015

24081

24173

24364

24391

24737

24906

24923

24942

24962

25009

25045

25048

25049

25242

25249

25374

25407

25493

25515

25635

25798

25799

25834

25997

26113

26151

26223

26247

26278

26606

26643

26646

26651

26720

26795

26961

26983

27037

27076

27081

27128

27185

27284

27605

27627

27661

27787

27806

27869

27893

28005

28166

28277

28282

28311

28390

28644

28739

28853

29077

29085

29333

29375

29626

29915

30157

30450

30516

30577

30743

30867

31066

31088

31170

31231

31231

31292

31335

31405

31492

31567

31611

31656

31668

31689

31834

31855

31925

32010

32064

32110

32255

32314

32457

32501

32659

32693

32818

32949

33009

33057

33347

33353

33379

33584

33589

33609

33611

33616

33665

33704

33761

33813

33997

34117

34346

34349

34540

34553

34612

34668

34710

34740

34749

34808

35082

35183

35245

35426

35433

35434

35509

35578

35643

35763

35910

35919

36033

36058

36103

36130

36233

36265

36371

36421

36527

36562

36749

36858

37130

37139

37304

37450

37466

37668

37688

37699

37848

37861

38045

38137

38286

38296

38310

38498

38554

38601

38875

39038

39041

39159

39270

39290

39356

39440

39445

39487

39502

39503

39520

39581

39587

39674

39685

39790

39815

39946

39991

40032

40039

40051

40191

40327

40396

40633

40666

40720

40748

40865

40910

40954

40993

41031

41066

41093

41280

41397

41414

41427

41436

41454

41602

41666

41826

42041

42052

42074

42162

42214

42324

42529

42578

42716

42896

42942

43128

43178

43418

43465

43479

43522

43645

43731

43956

44056

44116

44160

44197

44368

44464

44527

44536

44653

44756

44777

44786

44822

44827

45075

45090

45195

45249

45472

45532

45533

45817

45849

45937

46274

46277

46413

46480

46632

46715

46803

46847

46851

46889

47048

47063

47072

47102

47298

47352

47387

47420

47477

47549

47550

47790

47853

47881

48033

48096

48430

48464

48469

48596

48627

48728

48774

48797

48971

49103

49346

49428

49521

49555

49571

49615

49810

49892

49911

50114

50207

50258

50282

Write your output to file, Output2.txt

Your prompts should be: Input filename request: Please enter the name of your input file: Output filename request: Please enter the name of your output file: First line of output: Unique Numbers in file InputNumbers.txt are: Last line of output (after unique numbers are printed out): There were 97 unique integers in the file InputNumbers.txt that contained a total of 2216 integers

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions