Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8727599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:27:49+00:00 2026-06-13T08:27:49+00:00

I am teaching the A level syllabus by the Cambridge exam board. One typical

  • 0

I am teaching the A level syllabus by the Cambridge exam board. One typical question on the practical paper is this:

In a programming language of your choice, declare an array of ten integers and then initializes it.

I have this:

myArray = []        #create the array

for i in range(10): # initializes to 0
    myArray.append(0)

I believe this is what most people would do in Python? However, unlike Pascal etc it does not strictly answer the question as the lists in Python are essentially dynamic arrays with the added problem of not restricting the data type of each element. Can I declare a specific size array and type like in Pascal, instead of an empty dynamic list, without any type of loop and restricts the type of the array?

Something like (pseudo code):

myArray[10] : integer

This is a none commercial question but an educational one.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T08:27:51+00:00Added an answer on June 13, 2026 at 8:27 am

    You could use the array module

    a = array.array('i',(0 for _ in xrange(10)))
    

    Arrays require that all elements be the same type, as specified when it is created. They can still be appended to however

    If you were really determined, you could use the ctypes module to build a C array. But, that is probably not very pythonic as it forces you to do more low level stuff.

    import ctypes
    intArray10 = ctypes.c_int * 10
    myArray = intArray10(*(0 for _ in xrange(10)))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am teaching myself machine learning now. One simple question regarding information gain. How
I’m teaching an entry-level C++ programming class. We only use iostream in the class
In teaching a first language to someone with no programming background I am having
I am teaching myself C# and one of the current chapters challenges asks me
I'm teaching myself programming and today's challenge is to write a program that can
I've been teaching myself F# for a while now. I've read Programming F# by
I'm teaching myself iOS 5 programming through the Stamford University CS193P class, I just
I am teaching myself Objective-C and iOS programming with IOS Programming: The Big Nerd
I'm teaching a Python class on object-oriented programming and as I'm brushing up on
I've been teaching myself programming from scratch by creating a simple app in Objective

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.