100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Exam (elaborations)

PYTHON PROGRAMMING CHEATSHEET

Rating
-
Sold
-
Pages
4
Grade
A+
Uploaded on
04-08-2024
Written in
2024/2025

a handy reference guide that summarizes essential Python programming concepts, syntax, and functions in a concise format. It’s designed to provide quick access to commonly used information and can be a valuable tool for both beginners and experienced programmers

Show more Read less
Institution
Course








Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Course

Document information

Uploaded on
August 4, 2024
Number of pages
4
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Content preview

Python Cheat Sheet
/


Functions Vocabulary (cont) Area of a triangle (cont)

print() displays inform​ation on value the number or string can be store in height = float(​inp​ut(​'Enter the
the screen valuable height of the triangle: '))
input() receives inform​ation syntax make impossible to the phase print ('The area of the triangle
from the user error is', areaof​tri​ang​le(​base, height))
int() converts a value to an
integer Code
Python Palindrome
float() change number to be mystring = "hello"
while True:
decimal number print (mystring) ​ ​ ​ def ispali​ndr​ome​(word):
str() a list of characters firstname = input ("What is your ​ ​ ​ ​ ​ ​ ​ ​rev​erse= "​"
len() The length of the string first name? ") ​ ​ ​ ​ ​ ​ ​ ​myr​esult= "​"
" " " .... " " " comment (many lines) lastname = input(​"What is your last ​ ​ ​ ​ ​ ​ ​ for letter in word:
name? ")
# commen​t(one line) ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​rev​erse= letter+
fullname = firstname + " " +
import random + pick random item in the reverse
lastname
random.ch​oice() list ​ ​ ​ ​ ​ ​ ​ if word == reverse:
print (fullname) ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ r
​ eturn True
Vocabulary letter​number = int(in​put​("What is
​ ​ ​ ​ ​ ​ ​ e
​ lse:
letter number? ")) ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ r
​ eturn False
variable holds a value and can be changed
if letter​number > len(fu​lln​ame):
​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​rev​erse= "​"
string a list of characters such as number,
​ ​ ​ ​ ​ ​print ("in​valid letter ​ ​ ​ ​word= input(​"P
​ lease enter a
letter, symbols
number, try again! ")
word: ")
input receives inform​ation from the user
else: ​ ​ ​ if word == "​qui​t":
float number with a decimal ​ ​ ​ ​ ​ l
​ etter = ​ ​ ​ ​ ​ ​ ​ b
​ reak
number
(fulln​ame​[le​tte​rnu​mber] )
​ ​ ​ ​myr​esult= ispali​ndr​ome​(word)
syntax structure of language or grammar ​ ​ ​ ​ ​ p
​ rint (letter) ​ ​ ​ ​pri​nt(​"This word has",
integer whole number or counting number ​ ​ ​ ​ ​ ​num​ber​letter =
len(wo​rd)​,"le​tte​rs")
print displays inform​ation on the screen int(in​put​("How many times to print ​ ​ ​ if myresult== True:
letter ? ")) ​ ​ ​ ​ ​ ​ ​ ​pri​nt(​Tru​e,'​,',​wor​d+s​tr(​"
​ ​ ​ ​ ​ if number​letter > 100: is a palind​rom​e"))
​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ p
​ rint ("too many
​ ​ ​ e
​ lse:
letter too print! ") ​ ​ ​ ​ ​ ​ ​ ​pri​nt(​Fal​se,​','​,wo​rd+​str​("
​ ​ ​ ​ ​ e
​ lse:
is not a palind​rom​e"))
​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ p
​ rint (letter *
# Print: Please enter a word:
number​letter)
kayak
This word has 5 letters
Area of a triangle
True , kayak is a palindrome
def areaoftriangle(base, height): Please enter a word: mint
​ ​ ​return base height 1/2 This word has 4 letters
base = float(​inp​ut(​'Enter the base False , mint is not a palindrome

of the triangle: '))



By mint.sirikorn Published 10th February, 2016. Sponsored by Readability-Score.com
Last updated 21st March, 2016. Measure your website readability!
Page 1 of 4. https://readability-score.com
$8.39
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached

Get to know the seller
Seller avatar
kimblegavane1

Get to know the seller

Seller avatar
kimblegavane1 (self)
Follow You need to be logged in order to follow users or courses
Sold
0
Member since
1 year
Number of followers
0
Documents
5
Last sold
-
STUDY CHEATS AND SOLUTIONS 99

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions