{"id":111317,"date":"2023-08-02T02:43:58","date_gmt":"2023-08-02T02:43:58","guid":{"rendered":"https:\/\/learnexams.com\/blog\/?p=111317"},"modified":"2023-08-02T02:44:01","modified_gmt":"2023-08-02T02:44:01","slug":"wgu-c859-python-exam-2023-2024-questions-and-complete-elaborations","status":"publish","type":"post","link":"https:\/\/www.learnexams.com\/blog\/2023\/08\/02\/wgu-c859-python-exam-2023-2024-questions-and-complete-elaborations\/","title":{"rendered":"WGU C859 Python Exam 2023-2024"},"content":{"rendered":"\n<p>Minimum field width with strings &#8211; ANSWER &#8211; print(&#8216;Student name (%5s)&#8217; % &#8216;Bob&#8217;<br>the 5 specifies that there are a minimum of 5 characters and thus the print out would be<br>( Bob)<br>Conversion flags &#8211; ANSWER &#8211; alter the output of conversion specifiers<br>%08d adds leading zeros to the minimum width of 8 characters<br>precision components(Rounding) &#8211; ANSWER &#8211; Indicates how many digits to the right of<br>the decimal should be included<br>&#8216;%.1f&#8217; % 1.725 indicates a precision of 1 resulting in 1.7<br>.replace() &#8211; ANSWER &#8211; replace(old,new,count)<br>count replaces only the first occurrence<br>count can be left out<br>translation = translation.replace(&#8216;one&#8217;, &#8216;uno&#8217;)<br>.find(x) &#8211; ANSWER &#8211; Returns the position of the first occurrence of item x in the string<br>if my_str is &#8216;Boo Hoo!&#8217;<br>my_str.find(&#8216;!&#8217;) Returns 7<br>my-str.find(&#8216;Boo&#8217;) Returns 0<br>my_str.find(&#8216;oo&#8217;) returns 1<br>find(x, start) &#8211; ANSWER &#8211; Same as find(x) but begins the search at position start<br>find(x, start, end) &#8211; ANSWER &#8211; Same as find(x,start) but stops the search at position end<br>rfind(x) &#8211; ANSWER &#8211; Same as find but searches the string in reverse, returning the last<br>occurrence in the string<br>count(x) &#8211; ANSWER &#8211; Returns the number of times x occurs in the string<br>using in operator to check if a character or substring is contained in the string &#8211;<br>ANSWER &#8211; if &#8216;b&#8217; in my_string<br>Comparing Strings &#8211; ANSWER &#8211; may be compared using relational operators (&lt;&gt; &lt;=<br>etc..)<br>equality operators (==,!=)<br>1 \/ 2<br>membership operators (in,not in)<br>identity operators (is, is not)<br>my_str = &#8216;Hello&#8217;<br>my_str == &#8216;Hello&#8221; evaluates to True<br>relational comparison will compare the ASCII unicode values. if a string is shorter with<br>all the same characters then the shorter is considered less than<br>Do not use identity operators where you should be using an equality operator<br>comparisons are case sensitive<br>isalnum() &#8211; ANSWER &#8211; Returns True if all characters int he string are lowercase or<br>uppercase letters, or the numbers 0-9<br>isdigit() &#8211; ANSWER &#8211; Returns True if all characters are the numbers 0-9<br>islower() &#8211; ANSWER &#8211; Returns True if all characters are lowercase letters<br>isupper() &#8211; ANSWER &#8211; Returns True if all characters are uppercase letters<br>isspace() &#8211; ANSWER &#8211; Returns True if all characters are whitespace<br>startswith(x) &#8211; ANSWER &#8211; Returns True if the string starts with x<br>endswith(x) &#8211; ANSWER &#8211; Returns True if the string ends with x<br>capitalize() &#8211; ANSWER &#8211; Returns a copy of the string with the first character capitalized<br>and rest lowercased<br>lower() &#8211; ANSWER &#8211; Returns a copy of the string with all characters lowercased<br>upper() &#8211; ANSWER &#8211; Returns a copy of the string with all characters uppercased<br>strip() &#8211; ANSWER &#8211; Returns a copy of the string with leading and trailing whitespace<br>removed<br>can be used to turn a string literal into a list of items by using the whitespace character<br>as the default separator<br>if it was strip(\/) the default separator would be the \/ character. If the string contained a<br>double \/\/ then an empty list element would be created<br>title() &#8211; ANSWER &#8211; Returns a copy of the string with the first letters of words capitalized<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Minimum field width with strings &#8211; ANSWER &#8211; print(&#8216;Student name (%5s)&#8217; % &#8216;Bob&#8217;the 5 specifies that there are a minimum of 5 characters and thus the print out would be( Bob)Conversion flags &#8211; ANSWER &#8211; alter the output of conversion specifiers%08d adds leading zeros to the minimum width of 8 charactersprecision components(Rounding) &#8211; ANSWER &#8211; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[],"tags":[],"class_list":["post-111317","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/posts\/111317","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/comments?post=111317"}],"version-history":[{"count":0,"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/posts\/111317\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/media?parent=111317"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/categories?post=111317"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/tags?post=111317"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}