Python basic programming technique


gcse programming techniques
Jacob Slater
Flashcards by Jacob Slater, updated more than 1 year ago
Jacob Slater
Created by Jacob Slater over 4 years ago

Resource summary

Question Answer
Define a constant and define a variable? constant: A constant is a memory location used to store a value that cannot be changed whilst the program is running variable: A variable is a memory location used to store a value that can be changed whilst the program is running
name and give an example of all data types used in programming? string:"Hello" integer: "3" floating/real number: "3.5" boolean: "true" character: "K"
What is casting? casting is used to convert one data type into another. For example: int(string variable) this would convert a string into an integer.
state common arithmatic operators? + addition adds two or more values together - subtraction takes the second value from the first value *multiplication multiplies two or more values together /real division divides first value by second value //integer division used to find the quotient(integer number before the decimal point) after division %remainder used to find remainder(modulus) after division **exponential raises the value to the power of the exponential
what is the difference between modulus and quotient division? Modulus division finds the remainder of the sum and quotient division finds the whole number or integer of the sum.
What is a sequence and give an example? A sequence is a pre-determined order carried out into the next one. No action can be skipped in the sequence.Example: cat = input("Enter name of your cat") name = input("Enter you name") print("Your name is",name,"and your cats name is",cat,)
What is a selection and give an example? Selection is an algorithm to choose between two or more options. We use the if the else structure make decisions about which path to follow. Example: Passcode = input("Enter passcode") If passcode =="Go": print("Allow unrestricted access Else: print("Deny all access")
what is a iteration and give an example? Iteration is the process of repeating a set of instructions a fixed number of times or until a condition is met. The two types of loops are: count-controlled-for loops condition controlled-while loops Example: for x in range(1,6) while fruit =="bannanas":
define the term string concatenation? String concatenation is when you join strings together using + sign example: string1 = input("Enter favourite colour") string2 = "cat" newstring = string1+""+string2 print(newstring)
What does x.upper() do in python? x is now all upper case letters
what does x.lower() do in python? x is now all lower case letters
what does len(x) do in python? Calculates the number of characters in a string
what does x[index] do in python? extracts that character from the string starts at 0 example: x = "Hello" print(x[2]) it would print l
what does x[a:b] do in python? extracts string starting at position a and finish at position b. Example: x = "hello" print(x[0:4] it would print hell
what does x.substring(a,b) do in javascript? extracts a string starting at position a with a length of b. Example: x = "hello" print(x.substring(0,2)) this would print he
Show full summary Hide full summary


A level Computing Quiz
Zacchaeus Snape
Types and Components of Computer Systems
Jess Peason
Input Devices
Jess Peason
Output Devices
Jess Peason
Kwame Oteng-Adusei
Pack of playing cards answer
Karl Taylor
Code Challenge Flow Chart
Charlotte Hilton
Computing Hardware - CPU and Memory
Computer Systems
Computer science quiz
Ryan Barton
GCSE Computing - 4 - Representation of data in computer systems